/* SDN Flip Books. Colours fall back to the site's palette when the theme has one. */
:root {
	--sdnfb-ink: var(--wp--preset--color--navy, #12284c);
	--sdnfb-accent: var(--wp--preset--color--brand-blue, #1f6fb2);
	--sdnfb-muted: #5b6577;
	--sdnfb-line: #dde3ea;
	--sdnfb-bg: #f6f8fb;
	--sdnfb-reader-bg: #e9edf2;
}

/* ---- Library page ---- */
.sdnfb-main--library {
	box-sizing: border-box;
	padding: 60px 1.5rem;
}
.sdnfb-main--library .sdnfb-head__title {
	margin: 0 0 clamp(12px, 2vw, 20px);
	font-size: clamp(1.9rem, 4vw, 2.9rem);
	line-height: 1.15;
	color: var(--sdnfb-ink);
}
.sdnfb-content > *:first-child {
	margin-top: 0;
}
.sdnfb-library .sdnfb-content > p {
	color: var(--sdnfb-muted);
	font-size: 1.075rem;
	line-height: 1.6;
}

/* ---- Book grid ---- */
.sdnfb-grid {
	display: grid;
	grid-template-columns: repeat(var(--sdnfb-cols, 3), minmax(0, 1fr));
	gap: clamp(20px, 3vw, 36px) clamp(16px, 2.4vw, 28px);
	margin: clamp(28px, 4vw, 44px) 0 0;
	padding: 0;
	list-style: none;
}
.sdnfb-card {
	margin: 0;
	min-width: 0;
}
.sdnfb-card__link {
	display: flex;
	flex-direction: column;
	gap: 12px;
	color: inherit;
	text-decoration: none;
}
.sdnfb-card__cover {
	position: relative;
	display: block;
	aspect-ratio: 210 / 297;
	overflow: hidden;
	border-radius: 4px 8px 8px 4px;
	background: #fff;
	box-shadow: 0 1px 2px rgba(18, 40, 76, 0.08), 0 8px 24px -8px rgba(18, 40, 76, 0.25);
	transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.25s ease;
}
.sdnfb-card__cover::before { /* spine */
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: 6px;
	background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0));
	z-index: 1;
}
.sdnfb-card__cover img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.sdnfb-card__cover.is-plain {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 18px;
	box-sizing: border-box;
	background: linear-gradient(160deg, var(--sdnfb-accent), var(--sdnfb-ink));
}
.sdnfb-card__plain-title {
	color: #fff;
	font-weight: 700;
	font-size: 1.05rem;
	line-height: 1.3;
	text-align: center;
}
.sdnfb-card__title {
	font-weight: 600;
	font-size: 1rem;
	line-height: 1.35;
	color: var(--sdnfb-ink);
}
@media (hover: hover) {
	.sdnfb-card__link:hover .sdnfb-card__cover {
		transform: translateY(-4px);
		box-shadow: 0 2px 4px rgba(18, 40, 76, 0.08), 0 16px 32px -10px rgba(18, 40, 76, 0.35);
	}
	.sdnfb-card__link:hover .sdnfb-card__title {
		color: var(--sdnfb-accent);
	}
}
.sdnfb-card__link:focus-visible {
	outline: none;
}
.sdnfb-card__link:focus-visible .sdnfb-card__cover {
	outline: 3px solid var(--sdnfb-accent);
	outline-offset: 3px;
}
@media (max-width: 1024px) {
	.sdnfb-grid {
		grid-template-columns: repeat(min(var(--sdnfb-cols, 3), 3), minmax(0, 1fr));
	}
}
@media (max-width: 600px) {
	.sdnfb-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
	.sdnfb-card__title {
		font-size: 0.9rem;
	}
}

/* ---- Reading page ---- */
.sdnfb-bar {
	position: sticky;
	top: 0;
	z-index: 60; /* above the book, also when zoomed in */
	display: flex;
	align-items: center;
	gap: 16px;
	box-sizing: border-box;
	margin: 0 -1.5rem;
	padding: 10px 1.5rem; /* 10px above and below: header → bar → book */
	background: #fff;
}
.admin-bar .sdnfb-bar {
	top: var(--wp-admin--admin-bar--height, 32px);
}
@media (max-width: 600px) {
	.admin-bar .sdnfb-bar {
		top: 0; /* the admin bar scrolls away on phones */
	}
}
.sdnfb-bar__back {
	flex: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px;
	border-radius: 6px;
	color: var(--sdnfb-accent);
	font-weight: 600;
	font-size: 0.95rem;
	text-decoration: none;
	background: var(--sdnfb-bg);
}
.sdnfb-bar__back:hover {
	background: var(--sdnfb-line);
}
.sdnfb-bar__title {
	flex: 1;
	min-width: 0;
	margin: 0;
	font-size: clamp(1rem, 2vw, 1.25rem);
	line-height: 1.3;
	color: var(--sdnfb-ink);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
@media (max-width: 600px) {
	.sdnfb-bar__back {
		font-size: 0;
		padding: 8px 10px;
	}
	.sdnfb-bar__back span {
		font-size: 1.1rem;
	}
}
.sdnfb-main--book {
	box-sizing: border-box;
	margin: 0;
	/* Same side padding as the theme's sections (1.5rem); bottom matches their 60px rhythm. */
	padding: 0 1.5rem 60px;
}
.sdnfb-reader {
	width: 100%;
	overflow: hidden;
	border-radius: 10px;
	background: var(--sdnfb-reader-bg);
}
.sdnfb-reader__book {
	width: 100%;
}
.sdnfb-reader__intro {
	margin: 0 0 16px;
	color: var(--sdnfb-muted);
}

/* Floating chat/WhatsApp widgets: their empty wrapper (sized by the closed chat box) sits over
   the reader's arrows and swallows clicks. Let clicks through the wrapper, keep its children
   (button, open box) clickable. */
.sdnfb-book .sdn-wa {
	pointer-events: none;
}
.sdnfb-book .sdn-wa > * {
	pointer-events: auto;
}

/* Phones and tablets: tighter spacing, in step with the theme's sections. */
@media (max-width: 781px) {
	.sdnfb-main--book {
		padding-bottom: 40px;
	}
	.sdnfb-main--library {
		padding-top: 40px;
		padding-bottom: 40px;
	}
}

/* Arrows follow the screen (viewer.js sets their top); glide instead of jumping. */
.sdnfb-reader .df-ui-nav {
	transition: top 0.12s linear;
}
@media (prefers-reduced-motion: reduce) {
	.sdnfb-reader .df-ui-nav {
		transition: none;
	}
}
