/* ==========================================================================
   CORPORATE PROFILE FLIPBOOK
   Base structural rules (the .stf__* classes) are St. PageFlip's own —
   required for its positioning model, reproduced here rather than shipped
   as a separate file since they're a handful of lines. Everything else is
   this theme's own look, built to match the reference: a soft grey stage,
   white pages with a spine crease, round arrow buttons outside the book,
   and a dark pill toolbar underneath.
   ========================================================================== */

/* ---------------- St. PageFlip base (MIT, github.com/Nodlik/StPageFlip) ---------------- */

.stf__parent { position: relative; display: block; box-sizing: border-box; transform: translateZ(0); touch-action: pan-y; }
.stf__wrapper { position: relative; width: 100%; box-sizing: border-box; }
.stf__parent canvas { position: absolute; width: 100%; height: 100%; left: 0; top: 0; }
.stf__block { position: absolute; width: 100%; height: 100%; box-sizing: border-box; perspective: 2000px; }
.stf__item { display: none; position: absolute; transform-style: preserve-3d; }
.stf__outerShadow,
.stf__innerShadow,
.stf__hardShadow,
.stf__hardInnerShadow { position: absolute; left: 0; top: 0; }

/* ---------------- fallback card (no JS / load failure) ---------------- */

.kb-fallback {
	position: relative;
	display: block;
	max-width: 980px;
	margin: 40px auto 0;
	border-radius: 14px;
	overflow: hidden;
	border: 1px solid var(--rb-line);
	box-shadow: 0 18px 44px -24px rgba(10, 22, 40, .3);
	text-decoration: none;
	background: var(--rb-alt);
}

.kb-fallback img { display: block; width: 100%; height: auto; }

.kb-fallback__body { display: flex; flex-direction: column; gap: 4px; padding: 18px 44px 18px 18px; }
.kb-fallback__t { font-family: var(--font-display); font-size: 1rem; font-weight: 800; color: var(--rb-ink); }
.kb-fallback__s { font-size: .84rem; color: var(--rb-ink-2); }
.kb-fallback__icon { position: absolute; top: 18px; right: 18px; color: var(--color-primary); }

/* Once the viewer is live, the fallback is hidden via the [hidden] attribute
   set in flipbook.js — no extra CSS needed for that swap. */

/* ---------------- viewer shell ---------------- */

.kb-viewer { max-width: 1200px; margin: 40px auto 0; }

/* Sub-headings when more than one flipbook shares a section — the first
   instance's own top margin (from .rb-goc-poster__figure or .rb-lead above
   it) is enough; the second one needs its own separation from the first
   flipbook's toolbar sitting right above it. */
.kb-flipbook__title {
	margin: 48px 0 8px;
	font-family: var(--font-display);
	font-size: 1.3rem;
	font-weight: 800;
	color: var(--rb-ink);
	text-align: center;
}

.kb-flipbook__title:first-child { margin-top: 0; }

.kb-flipbook__lead {
	margin: 0 auto 20px;
	max-width: 56ch;
	font-size: .92rem;
	color: var(--rb-ink-2);
	text-align: center;
}

/* DearFlip's own wrapper. It was given height="100%" in the shortcode
   (inc/pdf-flipbook.php), which only means something if this element —
   its direct parent — actually has a height for that to be 100% of;
   without one it resolves to nothing and DearFlip falls back to
   whatever internal default it has, which is where a fixed pixel height
   (like the 700px this replaced) tends to come from and stop adapting
   to the viewport.

   clamp() ties it to viewport height instead of a fixed number: short on
   a phone in portrait, taller on desktop, capped so it never gets
   absurdly tall on a large monitor. No overflow:hidden — DearFlip's own
   toolbar/fullscreen controls are its to size, not this wrapper's to
   clip. */
.kb-dflip {
	max-width: 1200px;
	height: clamp(420px, 72vh, 760px);
	margin: 0 auto 40px;
}

.kb-dflip iframe,
.kb-dflip canvas { max-width: 100%; }

@media (max-width: 480px) {
	/* Phones in portrait have the least vertical room of any target this
	   clamp() covers — floor it a bit lower so the toolbar and page both
	   still fit above the fold instead of the book alone claiming most
	   of the screen. */
	.kb-dflip { height: clamp(360px, 62vh, 560px); }
}


.kb-status {
	margin: 0 0 18px;
	text-align: center;
	font-size: .92rem;
	font-weight: 600;
	color: var(--rb-ink-2);
}

/* The grey stage the book sits on, exactly like a scanner bed — this is
   the backdrop behind the white pages. */
.kb-stagewrap {
	--kb-zoom: 1;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: clamp(20px, 4vw, 44px) 10px;
	border-radius: 20px;
	background: linear-gradient(180deg, #c7cdd6, #aab1bd);
	box-shadow: inset 0 2px 10px rgba(0, 0, 0, .18);
}

/*
 * A 550:733 fallback ratio until flipbook.js reads the PDF's actual page
 * dimensions and overrides this inline (it always does, for any document
 * that opens successfully — see the pageRatio comment in flipbook.js).
 * This value only matters for the brief moment before that JS runs, or
 * if a document fails to open in a way that still shows the stage.
 * 860px reads as a genuine full page on desktop rather than a small
 * preview, while width:100% keeps it correctly scaled down on any
 * narrower screen.
 */
.kb-stage {
	position: relative;
	width: 100%;
	max-width: 860px;
	aspect-ratio: 550 / 733;
	transform: scale(var(--kb-zoom));
	transform-origin: center;
	transition: transform .25s ease;
}

.kb-stagewrap.is-zoomed { overflow: auto; }

/* Each page — plain white paper, filled in by an <img> once rendered. */
.kb-page {
	background: #fff;
	box-shadow: 0 0 0 1px rgba(15, 23, 42, .06);
}

.kb-page img { display: block; width: 100%; height: 100%; object-fit: cover; background: #fff; }

/* Loading shimmer shown on a page until its render lands. */
.kb-page__shimmer {
	position: absolute;
	inset: 0;
	background: linear-gradient(100deg, #f1f3f6 30%, #fafbfc 45%, #f1f3f6 60%);
	background-size: 200% 100%;
	animation: kbShimmer 1.4s ease-in-out infinite;
}

@keyframes kbShimmer {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* Round arrow buttons, outside the book on each side. */
.kb-arrow {
	flex: none;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 0;
	background: rgba(255, 255, 255, .92);
	color: var(--rb-ink);
	box-shadow: 0 6px 18px rgba(10, 22, 40, .18);
	cursor: pointer;
	transition: transform .15s ease, background .15s ease;
}

.kb-arrow:hover { background: #fff; transform: scale(1.06); }
.kb-arrow:active { transform: scale(.96); }

/* ---------------- toolbar ---------------- */

.kb-toolbar {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: max-content;
	margin: 18px auto 0;
	padding: 8px 10px;
	border-radius: 999px;
	background: #2b3542;
	box-shadow: 0 10px 26px rgba(10, 22, 40, .28);
}

.kb-tbtn {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 0;
	background: transparent;
	color: #cbd3de;
	cursor: pointer;
	text-decoration: none;
	transition: background .15s ease, color .15s ease;
}

.kb-tbtn:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.kb-tcount {
	padding: 0 10px;
	font-family: var(--goc-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
	font-size: .8rem;
	font-weight: 600;
	color: #e8ecf1;
	white-space: nowrap;
}

.kb-tdiv { width: 1px; height: 20px; margin: 0 4px; background: rgba(255, 255, 255, .16); }

/* ---------------- responsive ----------------
   The stage is always the single-page portrait ratio now (set above,
   unconditionally), so nothing here needs to switch ratio by breakpoint
   any more — these rules just tune spacing and chrome for smaller
   screens. */

@media (max-width: 760px) {
	.kb-stagewrap { padding: 12px 6px; gap: 6px; }
	.kb-stage { max-width: 100%; }
	.kb-arrow { width: 36px; height: 36px; }
	.kb-arrow svg { width: 16px; height: 16px; }
	.kb-toolbar { flex-wrap: wrap; max-width: 96%; }
	.kb-viewer { margin-top: 24px; }
}

@media (max-width: 480px) {
	.kb-arrow { display: none; } /* swipe still works — St.PageFlip handles touch natively */
	.kb-stagewrap { padding: 8px 2px; border-radius: 14px; }
}
