/**
 * CW PDF Booklet - frontend styles.
 * Everything is scoped under .cwb / .cwb-modal to stay out of theme specificity fights.
 */

.cwb,
.cwb-modal {
	--cwb-bg: #1c1f24;
	--cwb-ui: #ffffff;
	--cwb-ui-dim: rgba(255, 255, 255, 0.62);
	--cwb-ui-bg: rgba(255, 255, 255, 0.08);
	--cwb-ui-bg-hover: rgba(255, 255, 255, 0.18);
	--cwb-radius: 6px;
	--cwb-cover-width: 340px;
	box-sizing: border-box;
}

.cwb *,
.cwb-modal * {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------ Cover */

.cwb--cover {
	display: block;
	max-width: var(--cwb-cover-width);
	margin: 0 auto;
}

.cwb .cwb-cover {
	display: block;
	width: 100%;
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	cursor: pointer;
	position: relative;
	text-align: center;
	-webkit-appearance: none;
	appearance: none;
}

.cwb .cwb-cover__frame {
	display: block;
	position: relative;
	border-radius: 2px 4px 4px 2px;
	overflow: visible;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.12);
	transition: transform 0.28s ease, box-shadow 0.28s ease;
	transform-origin: left center;
	background: #fff;
}

.cwb .cwb-cover:hover .cwb-cover__frame,
.cwb .cwb-cover:focus-visible .cwb-cover__frame {
	transform: perspective(1400px) rotateY(-7deg);
	box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.16);
}

.cwb .cwb-cover__image {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 2px 4px 4px 2px;
}

/* Faux page stack along the outer edge. */
.cwb .cwb-cover__edge {
	position: absolute;
	top: 3px;
	bottom: 3px;
	right: -5px;
	width: 5px;
	border-radius: 0 3px 3px 0;
	background: linear-gradient(90deg, #d8d8d4 0%, #f2f2ee 45%, #cfcfca 100%);
	pointer-events: none;
}

.cwb .cwb-cover__auto {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 240px;
	width: 100%;
	background: #f3f3f1;
	border-radius: 2px 4px 4px 2px;
}

.cwb .cwb-cover__label {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	margin-top: 14px;
	padding: 0.6em 1.2em;
	border-radius: 999px;
	background: var(--cwb-bg);
	color: #fff;
	font-size: 0.95rem;
	line-height: 1.2;
	font-weight: 600;
	transition: opacity 0.2s ease;
}

.cwb .cwb-cover:hover .cwb-cover__label {
	opacity: 0.86;
}

.cwb-notice {
	padding: 12px 16px;
	border-left: 4px solid #d63638;
	background: #fcf0f1;
	font-size: 0.9rem;
}

/* ----------------------------------------------------------------- Viewer */

.cwb--inline {
	display: block;
	width: 100%;
}

.cwb-boot {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 320px;
	background: var(--cwb-bg);
	border-radius: 8px;
}

.cwb-viewer {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	background: var(--cwb-bg);
	color: var(--cwb-ui);
	overflow: hidden;
	font-family: inherit;
}

.cwb-viewer--inline {
	border-radius: 8px;
}

.cwb-viewer--modal {
	height: 100%;
	border-radius: 0;
}

.cwb-stage-wrap {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
}

.cwb-viewport {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	overflow: hidden;
	perspective: 2800px;
	perspective-origin: 50% 50%;
	touch-action: pan-y;
	user-select: none;
	-webkit-user-select: none;
	cursor: pointer;
}

.cwb-viewport.is-zoomed {
	cursor: grab;
	touch-action: none;
}

.cwb-stage {
	position: relative;
	transform-style: preserve-3d;
	transition: transform 0.55s cubic-bezier(0.32, 0.06, 0.24, 1);
	will-change: transform;
}

.cwb-stage.cwb-no-anim,
.cwb-stage.cwb-no-anim .cwb-leaf {
	transition: none !important;
}

.cwb-book {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
}

.cwb-viewer.is-single .cwb-book {
	display: none;
}

.cwb-single {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: none;
}

.cwb-viewer.is-single .cwb-single {
	display: block;
}

/* -------------------------------------------------------------- The leaves */

.cwb-leaf {
	position: absolute;
	top: 0;
	left: 50%;
	width: 50%;
	height: 100%;
	transform-origin: left center;
	transform-style: preserve-3d;
	transition: transform 0.78s cubic-bezier(0.34, 0.05, 0.28, 1);
}

.cwb-leaf.is-flipped {
	transform: rotateY(-180deg);
}

/*
 * Only the two visible leaves cast a shadow. Putting it on every leaf stacks
 * one shadow per page at the spine, which is what turns the gutter into a hard
 * black band. The offset is positive (outward from the spine) and the flipped
 * leaf mirrors it automatically through its own rotation.
 */
.cwb-leaf.is-top {
	box-shadow: 7px 12px 30px rgba(0, 0, 0, 0.3), 2px 2px 6px rgba(0, 0, 0, 0.16);
}

.cwb-leaf.is-flipping {
	will-change: transform;
}

.cwb-face {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background: #ffffff;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}

.cwb-face--back {
	transform: rotateY(180deg);
}

.cwb-page {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #ffffff;
}

.cwb-page.is-blank {
	background: #f4f4f2;
}

.cwb-canvas {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* Gutter shading towards the spine. */
.cwb-shade {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	background: linear-gradient(
		90deg,
		rgba(0, 0, 0, 0.2) 0%,
		rgba(0, 0, 0, 0.1) 2%,
		rgba(0, 0, 0, 0.045) 6%,
		rgba(0, 0, 0, 0.015) 12%,
		rgba(0, 0, 0, 0) 20%
	);
}

/* --------------------------------------------------------------- Arrows */

.cwb-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.42);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.2s ease, background 0.2s ease;
	z-index: 5;
}

.cwb-stage-wrap:hover .cwb-arrow,
.cwb-arrow:focus-visible {
	opacity: 1;
}

.cwb-arrow:hover {
	background: rgba(0, 0, 0, 0.68);
}

.cwb-arrow[disabled] {
	opacity: 0 !important;
	pointer-events: none;
}

.cwb-arrow--prev {
	left: 10px;
}

.cwb-arrow--next {
	right: 10px;
}

.cwb-arrow svg {
	width: 20px;
	height: 20px;
}

/* -------------------------------------------------------------- Toolbar */

.cwb-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	flex: 0 0 auto;
	padding: 8px 10px;
	background: rgba(0, 0, 0, 0.28);
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.cwb-toolbar__group {
	display: flex;
	align-items: center;
	gap: 4px;
}

.cwb-viewer .cwb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 34px;
	height: 34px;
	padding: 0 8px;
	border: 0;
	border-radius: var(--cwb-radius);
	background: transparent;
	color: var(--cwb-ui);
	font-size: 0.78rem;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.cwb-viewer .cwb-btn:hover {
	background: var(--cwb-ui-bg-hover);
}

.cwb-viewer .cwb-btn[disabled] {
	opacity: 0.3;
	cursor: default;
}

.cwb-viewer .cwb-btn[disabled]:hover {
	background: transparent;
}

.cwb-viewer .cwb-btn svg {
	width: 18px;
	height: 18px;
}

.cwb-pager {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	margin: 0 4px;
	color: var(--cwb-ui-dim);
	font-size: 0.82rem;
}

.cwb-viewer .cwb-pager__input {
	width: 62px;
	height: 30px;
	padding: 0 6px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: var(--cwb-radius);
	background: var(--cwb-ui-bg);
	color: var(--cwb-ui);
	font-size: 0.82rem;
	text-align: center;
	box-shadow: none;
}

.cwb-viewer .cwb-pager__input:focus {
	outline: 2px solid rgba(255, 255, 255, 0.4);
	outline-offset: 1px;
}

/* --------------------------------------------------------------- Status */

.cwb-status {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	color: var(--cwb-ui-dim);
	font-size: 0.9rem;
	background: var(--cwb-bg);
	z-index: 6;
}

.cwb-status.is-hidden {
	display: none;
}

.cwb-status.is-error .cwb-spinner {
	display: none;
}

.cwb-spinner {
	display: block;
	width: 30px;
	height: 30px;
	border: 2px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: cwb-spin 0.9s linear infinite;
}

.cwb-cover__auto .cwb-spinner {
	border-color: rgba(0, 0, 0, 0.15);
	border-top-color: rgba(0, 0, 0, 0.5);
}

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

/* ---------------------------------------------------------------- Modal */

.cwb-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	height: 100dvh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	background: rgba(10, 12, 15, 0.86);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	z-index: 999999;
	opacity: 0;
	transition: opacity 0.22s ease;
}

.cwb-modal.is-open {
	opacity: 1;
}

.cwb-modal__inner {
	position: relative;
	width: 100%;
	height: 100%;
	background: var(--cwb-bg);
}

body.cwb-modal-open {
	overflow: hidden;
}

/* ----------------------------------------------------------- Responsive */

@media (max-width: 782px) {
	.cwb-arrow {
		display: none;
	}

	.cwb-toolbar {
		flex-wrap: wrap;
		justify-content: center;
		padding: 6px;
	}

	.cwb-viewer .cwb-btn {
		min-width: 38px;
		height: 38px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cwb-leaf,
	.cwb-stage,
	.cwb .cwb-cover__frame {
		transition: none !important;
	}
}
