/* PDF Flipbook — styles */

/* ── Wrapper ──────────────────────────────────────────────────────────── */
.pdf-flipbook-wrapper {
	position: relative;
	width: 100%;
	max-width: 1400px;
	margin: 0 auto 24px;
	background: #1a1a2e;
	border-radius: 6px;
	overflow: hidden;
	box-shadow: 0 4px 24px rgba( 0, 0, 0, 0.4 );
}

.pdf-flipbook-wrapper:focus {
	outline: none;
}

.pdf-flipbook-wrapper:focus-visible {
	outline: 2px solid #6c8ebf;
	outline-offset: 3px;
}

/* ── Hidden-state guard ───────────────────────────────────────────────── */
/* Author `display` declarations outrank the UA stylesheet's `[hidden]` rule,
   so any element we show/hide via the `hidden` attribute has to restate it —
   otherwise `el.hidden = true` has no effect. */
.pdf-flipbook-loading[hidden],
.pdf-flipbook-controls[hidden],
.pdf-flipbook-zoom[hidden],
.pdf-flipbook-zoom-spinner[hidden] {
	display: none;
}

/* ── Loading indicator ────────────────────────────────────────────────── */
.pdf-flipbook-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 320px;
	gap: 16px;
	color: #c8cdd8;
	font-size: 14px;
	padding: 24px;
}

@media ( min-width: 600px ) {
	.pdf-flipbook-loading {
		min-height: 420px;
	}
}

.pdf-flipbook-spinner {
	display: block;
	width: 48px;
	height: 48px;
	border: 4px solid rgba( 255, 255, 255, 0.12 );
	border-top-color: #6c8ebf;
	border-radius: 50%;
	animation: pdf-flipbook-spin 0.75s linear infinite;
	flex-shrink: 0;
}

@keyframes pdf-flipbook-spin {
	to {
		transform: rotate( 360deg );
	}
}

/* ── Progress bar ─────────────────────────────────────────────────────── */
.pdf-flipbook-progress {
	width: 200px;
	max-width: 80%;
	height: 4px;
	appearance: none;
	-webkit-appearance: none;
	border: none;
	border-radius: 2px;
	background: rgba( 255, 255, 255, 0.12 );
	overflow: hidden;
}

.pdf-flipbook-progress::-webkit-progress-bar {
	background: rgba( 255, 255, 255, 0.12 );
	border-radius: 2px;
}

.pdf-flipbook-progress::-webkit-progress-value {
	background: #6c8ebf;
	border-radius: 2px;
	transition: width 0.2s ease;
}

.pdf-flipbook-progress::-moz-progress-bar {
	background: #6c8ebf;
	border-radius: 2px;
}

@media ( prefers-reduced-motion: reduce ) {
	.pdf-flipbook-spinner {
		animation: none;
		border-top-color: #6c8ebf;
		opacity: 0.6;
	}

	.pdf-flipbook-progress::-webkit-progress-value {
		transition: none;
	}
}

/* ── Stage ────────────────────────────────────────────────────────────── */
.pdf-flipbook-stage {
	width: 100%;
	position: relative;
}

/* ── Controls — floating pill, pinned to the bottom-centre of the book ── */
.pdf-flipbook-controls,
.pdf-flipbook-zoom-controls {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX( -50% );
	z-index: 10;

	display: inline-flex;
	align-items: center;
	gap: 2px;

	padding: 5px 8px;
	background: rgba( 8, 8, 20, 0.72 );
	backdrop-filter: blur( 12px );
	-webkit-backdrop-filter: blur( 12px );
	border: 1px solid rgba( 255, 255, 255, 0.1 );
	border-radius: 999px;
	box-shadow:
		0 2px 8px rgba( 0, 0, 0, 0.45 ),
		inset 0 1px 0 rgba( 255, 255, 255, 0.06 );

	white-space: nowrap;
}

/* ── Prev / Next buttons ──────────────────────────────────────────────── */
.pdf-flipbook-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: 50%;
	color: rgba( 255, 255, 255, 0.85 );
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s, color 0.15s;
	/* Minimum 44×44 px touch target (WCAG 2.5.5) */
	min-width: 44px;
	min-height: 44px;
}

.pdf-flipbook-btn:hover {
	background: rgba( 255, 255, 255, 0.12 );
	color: #fff;
}

.pdf-flipbook-btn:active {
	background: rgba( 255, 255, 255, 0.2 );
}

.pdf-flipbook-btn:focus-visible {
	outline: 2px solid #6c8ebf;
	outline-offset: 2px;
}

.pdf-flipbook-btn[disabled] {
	opacity: 0.35;
	cursor: default;
}

.pdf-flipbook-btn[disabled]:hover {
	background: transparent;
	color: rgba( 255, 255, 255, 0.85 );
}

@media ( prefers-reduced-motion: reduce ) {
	.pdf-flipbook-btn {
		transition: none;
	}
}

/* ── Icons ────────────────────────────────────────────────────────────── */
.pdf-flipbook-icon {
	display: block;
	/* Keep the button itself the event target, never the SVG. */
	pointer-events: none;
}

/* ── Divider between control groups ───────────────────────────────────── */
.pdf-flipbook-controls-divider {
	width: 1px;
	height: 20px;
	margin: 0 4px;
	background: rgba( 255, 255, 255, 0.14 );
	flex-shrink: 0;
}

/* ── Page counter ─────────────────────────────────────────────────────── */
.pdf-flipbook-page-info {
	padding: 0 12px;
	margin: 0 2px;
	border-left: 1px solid rgba( 255, 255, 255, 0.14 );
	border-right: 1px solid rgba( 255, 255, 255, 0.14 );
	min-width: 56px;
	text-align: center;
	color: rgba( 255, 255, 255, 0.75 );
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.05em;
	line-height: 34px;
	user-select: none;
}

/* ── Zoom overlay ─────────────────────────────────────────────────────── */
/* Covers the book within the wrapper (z-index 20 puts it above the book's own
   control pill at z-index 10) so StPageFlip never sees pointer events while
   the overlay is open. */
.pdf-flipbook-zoom {
	position: absolute;
	inset: 0;
	z-index: 20;
	background: #12121f;
}

.pdf-flipbook-zoom:focus {
	outline: none;
}

.pdf-flipbook-zoom:focus-visible {
	outline: 2px solid #6c8ebf;
	outline-offset: -4px;
}

/* ── Zoom viewport — clips the page and captures pan/pinch gestures ────── */
.pdf-flipbook-zoom-viewport {
	position: absolute;
	inset: 0;
	overflow: hidden;
	cursor: grab;
	/* Suppress native scroll/pinch so the front end owns every gesture. */
	touch-action: none;
	overscroll-behavior: contain;
}

.pdf-flipbook-zoom-viewport.is-panning {
	cursor: grabbing;
}

/* ── Zoom canvas — positioned and scaled entirely from JS ─────────────── */
.pdf-flipbook-zoom-canvas {
	position: absolute;
	top: 0;
	left: 0;
	display: block;
	transform-origin: 0 0;
	will-change: transform;
	/* Themes commonly set `canvas, img { max-width: 100% }`, which would fight
	   the transform-based sizing. Our class selector outranks those. */
	max-width: none;
	max-height: none;
}

/* ── Zoom spinner — shown while a page re-renders at a new scale ──────── */
.pdf-flipbook-zoom-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba( 255, 255, 255, 0.12 );
	border-top-color: #6c8ebf;
	border-radius: 50%;
	animation: pdf-flipbook-spin 0.75s linear infinite;
	pointer-events: none;
}

/* ── Zoom level readout — doubles as the reset button ─────────────────── */
.pdf-flipbook-zoom-level {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 44px;
	min-width: 60px;
	padding: 0 8px;
	background: transparent;
	border: none;
	border-radius: 999px;
	color: rgba( 255, 255, 255, 0.75 );
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.05em;
	cursor: pointer;
	flex-shrink: 0;
	user-select: none;
	transition: background 0.15s, color 0.15s;
}

.pdf-flipbook-zoom-level:hover {
	background: rgba( 255, 255, 255, 0.12 );
	color: #fff;
}

.pdf-flipbook-zoom-level:focus-visible {
	outline: 2px solid #6c8ebf;
	outline-offset: 2px;
}

/* Keep every touch target at 44 px on narrow screens; claw back the width
   from the readout and the dividers instead. */
@media ( max-width: 420px ) {
	.pdf-flipbook-zoom-controls {
		padding: 5px 4px;
	}

	.pdf-flipbook-zoom-controls .pdf-flipbook-controls-divider {
		margin: 0 1px;
	}

	.pdf-flipbook-zoom-level {
		min-width: 44px;
		padding: 0 2px;
		letter-spacing: 0;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.pdf-flipbook-zoom-spinner {
		animation: none;
		opacity: 0.6;
	}

	.pdf-flipbook-zoom-level {
		transition: none;
	}
}

/* ── Error state ──────────────────────────────────────────────────────── */
.pdf-flipbook-error {
	padding: 24px;
	text-align: center;
	color: #ff7675;
	font-size: 14px;
}

/* ── No-JS fallback ───────────────────────────────────────────────────── */
.pdf-flipbook-noscript {
	padding: 16px;
	text-align: center;
	font-size: 14px;
}

.pdf-flipbook-noscript a {
	color: #6c8ebf;
	text-decoration: underline;
}
