/* GCHS Annual Reports — flipbook modal styles. */

.gchs-flipbook-modal[hidden] {
	display: none;
}

.gchs-flipbook-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: grid;
	grid-template-rows: auto 1fr auto;
	background: rgba(15, 15, 15, 0.92);
	color: #fff;
	padding: env(safe-area-inset-top, 1rem) 1rem env(safe-area-inset-bottom, 1rem);
	gap: 0.75rem;
}

.gchs-flipbook-modal__close {
	position: absolute;
	top: 0.75rem;
	right: 1rem;
	width: 2.5rem;
	height: 2.5rem;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color 120ms ease;
}

.gchs-flipbook-modal__close:hover,
.gchs-flipbook-modal__close:focus-visible {
	background: rgba(255, 255, 255, 0.22);
}

.gchs-flipbook-modal__title {
	margin: 0.25rem 3rem 0 1rem;
	font-size: 1.05rem;
	font-weight: 500;
	opacity: 0.9;
}

.gchs-flipbook-modal__viewport {
	position: relative;
	overflow: hidden;
	display: flex;
	/* Cap the viewport width so StPageFlip's parent doesn't span the
	 * whole browser. Without this, the parent ends up wider than the
	 * two-page book content and the leaves don't meet at the spine
	 * (visible gap between left/right pages). TAMUK's modal has the
	 * same constraint via `max-width: 1200px` on its container. */
	max-width: 1200px;
	margin-left: auto;
	margin-right: auto;
	width: 100%;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

.gchs-flipbook-modal__viewport > * {
	max-width: 100%;
	max-height: 100%;
}

/* StPageFlip — two-layer setup that mirrors TAMUK's working flipbook.
 *
 *   .gchs-flipbook-modal__book   ← flex container, centers the book
 *   .gchs-flipbook-modal__pages  ← StPageFlip mounts here; only
 *                                  max-width/max-height constraints
 *                                  so the library can size itself.
 *
 * Mounting StPageFlip directly on the flex container fights its
 * internal layout math and causes the cover-flip drift. */
.gchs-flipbook-modal__book {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Matches TAMUK exactly: just max-width/max-height constraints, no
 * background. The minor sub-pixel spine gap is acceptable — same as
 * what TAMUK's site shows. Adding gradient masking introduced its
 * own artifacts during state transitions. */
.gchs-flipbook-modal__pages {
	max-width: 100%;
	max-height: 100%;
}

.gchs-flipbook-modal__leaf {
	background: #fff;
}

.gchs-flipbook-modal__leaf img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.gchs-flipbook-modal__loading {
	color: rgba(255, 255, 255, 0.85);
	font-size: 0.95rem;
	padding: 1rem 1.25rem;
	background: rgba(255, 255, 255, 0.08);
	border-radius: 8px;
}

/* Mobile scroll-snap fallback container. */
.gchs-flipbook-modal__scroll {
	width: 100%;
	height: 100%;
	overflow-y: auto;
	scroll-snap-type: y mandatory;
	-webkit-overflow-scrolling: touch;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
}

.gchs-flipbook-modal__scroll canvas {
	scroll-snap-align: center;
	max-width: 100%;
	height: auto;
	background: #fff;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.gchs-flipbook-modal__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	padding: 0.5rem 0;
}

.gchs-flipbook-modal__controls button,
.gchs-flipbook-modal__download {
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	border: 0;
	padding: 0.55rem 1rem;
	border-radius: 999px;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 120ms ease;
}

.gchs-flipbook-modal__controls button:hover:not(:disabled),
.gchs-flipbook-modal__controls button:focus-visible,
.gchs-flipbook-modal__download:hover,
.gchs-flipbook-modal__download:focus-visible {
	background: rgba(255, 255, 255, 0.22);
}

.gchs-flipbook-modal__controls button:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.gchs-flipbook-modal__page {
	font-size: 0.85rem;
	opacity: 0.85;
	min-width: 6rem;
	text-align: center;
}

.gchs-flipbook-modal__error {
	position: absolute;
	inset: 50% 1rem auto 1rem;
	transform: translateY(-50%);
	background: rgba(255, 255, 255, 0.08);
	padding: 1rem 1.25rem;
	border-radius: 8px;
	text-align: center;
	font-size: 0.95rem;
}

.gchs-flipbook-modal__error a {
	color: #fff;
	text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
	.gchs-flipbook-modal,
	.gchs-flipbook-modal * {
		transition: none !important;
		animation: none !important;
	}
}

/* ── PDF Lightbox (used by 990s viewer) ─────────────────────────── */

.gchs-pdf-lightbox[hidden] {
	display: none;
}

.gchs-pdf-lightbox {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: clamp(0.5rem, 2vw, 1.5rem);
}

.gchs-pdf-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.72);
	cursor: pointer;
}

.gchs-pdf-lightbox__dialog {
	position: relative;
	width: min(100%, 1000px);
	height: min(100%, 90vh);
	background: #fff;
	border-radius: 10px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.gchs-pdf-lightbox__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.75rem 1rem;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	background: #fafafa;
}

.gchs-pdf-lightbox__title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 600;
	color: #1a1a1a;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.gchs-pdf-lightbox__header-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-shrink: 0;
}

.gchs-pdf-lightbox__download {
	display: inline-flex;
	align-items: center;
	padding: 0.5rem 1rem;
	font-size: 0.9rem;
	font-weight: 600;
	border-radius: 999px;
	text-decoration: none;
	background: var(--wp--preset--color--primary, #c0392b);
	color: #fff;
	transition: opacity 120ms ease;
}

.gchs-pdf-lightbox__download:hover,
.gchs-pdf-lightbox__download:focus-visible {
	opacity: 0.88;
}

.gchs-pdf-lightbox__close {
	width: 36px;
	height: 36px;
	border: 0;
	background: transparent;
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
	color: #555;
	border-radius: 999px;
	transition: background-color 120ms ease, color 120ms ease;
}

.gchs-pdf-lightbox__close:hover,
.gchs-pdf-lightbox__close:focus-visible {
	background: rgba(0, 0, 0, 0.06);
	color: #000;
}

.gchs-pdf-lightbox__iframe {
	flex: 1;
	width: 100%;
	border: 0;
	background: #f5f5f5;
}

@media (max-width: 600px) {
	.gchs-pdf-lightbox {
		padding: 0;
	}
	.gchs-pdf-lightbox__dialog {
		width: 100%;
		height: 100%;
		border-radius: 0;
	}
}
