.pdf-flipbook-wrapper {
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	font-family: inherit;
	box-sizing: border-box;
	/* Create an isolated stacking context so multiple instances don't bleed into each other. */
	isolation: isolate;
	position: relative;
}

.pdf-flipbook-wrapper *,
.pdf-flipbook-wrapper *::before,
.pdf-flipbook-wrapper *::after {
	box-sizing: border-box;
}

.pdf-flipbook-stage {
	position: relative;
	width: 100%;
	background: #1a1a1a;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	min-height: 320px;
}

.pdf-flipbook-book {
	margin: 0 auto;
	max-width: 100%;
}

.pdf-flipbook-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-size: 14px;
	letter-spacing: 0.02em;
	pointer-events: none;
	transition: opacity 0.25s ease;
}

.pdf-flipbook-wrapper.is-ready .pdf-flipbook-loading {
	opacity: 0;
}

.pdf-flipbook-controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 10px 12px;
	background: #2a2a2a;
	color: #fff;
}

.pdf-flipbook-btn {
	background: transparent;
	color: inherit;
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 4px;
	padding: 6px 12px;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.pdf-flipbook-btn:hover,
.pdf-flipbook-btn:focus-visible {
	background: rgba(255, 255, 255, 0.1);
	border-color: rgba(255, 255, 255, 0.5);
	outline: none;
}

.pdf-flipbook-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.pdf-flipbook-counter {
	font-variant-numeric: tabular-nums;
	font-size: 13px;
	min-width: 70px;
	text-align: center;
}

/* Fullscreen */
.pdf-flipbook-wrapper:fullscreen {
	width: 100vw;
	height: 100vh;
	background: #000;
	display: flex;
	flex-direction: column;
}

.pdf-flipbook-wrapper:fullscreen .pdf-flipbook-stage {
	flex: 1 1 auto;
}

.pdf-flipbook-wrapper:-webkit-full-screen {
	width: 100vw;
	height: 100vh;
	background: #000;
}

/* Pseudo-fullscreen fallback (iOS Safari & anywhere requestFullscreen is unavailable). */
.pdf-flipbook-wrapper.is-pseudo-fullscreen {
	position: fixed;
	inset: 0;
	/* Above any theme chrome (admin bar, sticky headers, hamburger menus). */
	z-index: 2147483646;
	width: 100vw;
	height: 100vh;
	background: #000;
	display: flex;
	flex-direction: column;
	margin: 0;
	max-width: none;
}

.pdf-flipbook-wrapper.is-pseudo-fullscreen .pdf-flipbook-stage {
	flex: 1 1 auto;
	min-height: 0;
}

body.pdf-flipbook-pseudo-fs-active {
	overflow: hidden;
}

/* Close (X) button — only visible while in any fullscreen mode. */
.pdf-flipbook-close {
	position: absolute;
	top: 12px;
	right: 12px;
	/* Above pseudo-fullscreen wrapper contents and any theme overlay. */
	z-index: 2147483647;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: none;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.15s ease;
}

.pdf-flipbook-close:hover,
.pdf-flipbook-close:focus-visible {
	background: rgba(0, 0, 0, 0.8);
	outline: none;
}

.pdf-flipbook-wrapper:fullscreen .pdf-flipbook-close,
.pdf-flipbook-wrapper:-webkit-full-screen .pdf-flipbook-close,
.pdf-flipbook-wrapper.is-fullscreen .pdf-flipbook-close,
.pdf-flipbook-wrapper.is-pseudo-fullscreen .pdf-flipbook-close {
	display: flex;
}

/* Page wrappers we hand to StPageFlip via loadFromHTML. */
.pdf-flipbook-page {
	background: #fff;
	overflow: hidden;
	position: relative;
}

.pdf-flipbook-page > canvas,
.pdf-flipbook-page > img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* Clickable link annotation overlay. */
.pdf-flipbook-link-layer {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 2;
}

.pdf-flipbook-link {
	position: absolute;
	display: block;
	pointer-events: auto;
	cursor: pointer;
	/* Invisible by default; uncomment background for debugging hit areas. */
	/* background: rgba(255, 255, 0, 0.2); */
}

/*
 * Cover / back-cover handling.
 * Only translate the visible page when StPageFlip is actually in landscape
 * (2-page spread) mode, regardless of viewport width — small containers
 * may switch to portrait/single-page mode at desktop widths too.
 */
.pdf-flipbook-wrapper.is-landscape.is-cover .pdf-flipbook-book > * {
	transform: translateX(-25%);
	transition: transform 0.4s ease;
}

.pdf-flipbook-wrapper.is-landscape.is-back-cover .pdf-flipbook-book > * {
	transform: translateX(25%);
	transition: transform 0.4s ease;
}

.pdf-flipbook-wrapper.is-landscape:not(.is-cover):not(.is-back-cover) .pdf-flipbook-book > * {
	transform: none;
	transition: transform 0.4s ease;
}

/* Kill the cast/box shadow on the visible single page when on cover/back. */
.pdf-flipbook-wrapper.is-cover .pdf-flipbook-page,
.pdf-flipbook-wrapper.is-back-cover .pdf-flipbook-page {
	box-shadow: none !important;
}

.pdf-flipbook-wrapper.is-cover .stf__item,
.pdf-flipbook-wrapper.is-back-cover .stf__item {
	box-shadow: none !important;
}

.pdf-flipbook-wrapper.is-cover .stf__outerShadow,
.pdf-flipbook-wrapper.is-cover .stf__innerShadow,
.pdf-flipbook-wrapper.is-back-cover .stf__outerShadow,
.pdf-flipbook-wrapper.is-back-cover .stf__innerShadow {
	display: none !important;
}

/*
 * Mobile fullscreen: force single-page layout regardless of orientation.
 * StPageFlip picks portrait vs landscape based on the book element's aspect
 * ratio. Constraining the book element to a portrait aspect on mobile
 * fullscreen keeps it in single-page mode even when the phone rotates.
 *
 * Trigger on either narrow viewport OR portrait orientation — newer phones
 * (iPhone 17 Pro Max, etc.) can report >768px CSS width but are still in
 * portrait and need single-page mode.
 */
@media (max-width: 768px), (orientation: portrait) and (max-width: 1024px) {
	.pdf-flipbook-wrapper.is-pseudo-fullscreen .pdf-flipbook-stage,
	.pdf-flipbook-wrapper.is-fullscreen .pdf-flipbook-stage,
	.pdf-flipbook-wrapper:fullscreen .pdf-flipbook-stage {
		align-items: center;
		justify-content: center;
	}

	.pdf-flipbook-wrapper.is-pseudo-fullscreen .pdf-flipbook-book,
	.pdf-flipbook-wrapper.is-fullscreen .pdf-flipbook-book,
	.pdf-flipbook-wrapper:fullscreen .pdf-flipbook-book {
		aspect-ratio: 500 / 650;
		height: 100%;
		width: auto;
		max-width: 100%;
		max-height: 100%;
	}
}
