/**
 * 42GF Library — flipbook reader.
 *
 * Colours are taken from the theme's custom properties where they exist, with
 * literal fallbacks so the reader still looks right under any other theme.
 */

.gf-fb {
	--fb-stage: var(--forest, #0E3B2F);
	--fb-stage-2: var(--forest-3, #0A2B22);
	--fb-ink: #EAF4EE;
	--fb-muted: #93B7A6;
	--fb-accent: var(--accent, #3F9377);
	--fb-line: rgba(255, 255, 255, .16);

	display: block;
	margin: 0 0 32px;
	border-radius: var(--r, 8px);
	overflow: hidden;
	background: var(--fb-stage);
	box-shadow: 0 2px 4px rgba(14, 59, 47, .06), 0 18px 40px -18px rgba(14, 59, 47, .3);
}

/* ------------------------------------------------------------------ stage */

.gf-fb__stage {
	position: relative;
	display: grid;
	place-items: center;
	min-height: 380px;
	padding: 32px 20px;
	background:
		radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .06), transparent 60%),
		linear-gradient(160deg, var(--fb-stage), var(--fb-stage-2));
}

.gf-fb__book {
	width: 100%;
	max-width: 1000px;
	margin: 0 auto;
	touch-action: pan-y;
}

/* StPageFlip positions these itself; we only style the paper. */
.gf-fb__page {
	background: #fff;
	overflow: hidden;
	box-shadow: 0 0 1px rgba(0, 0, 0, .25);
}

.gf-fb__canvas {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: #fff;
}

/* Before the book mounts, the raw page divs would stack down the page. */
.gf-fb:not(.is-ready) .gf-fb__page {
	display: none;
}

.gf-fb__status {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	max-width: 34ch;
	text-align: center;
	color: var(--fb-muted);
	font-size: 14px;
	line-height: 1.6;
	margin: 0;
	padding: 0 16px;
}

.gf-fb__status.is-error {
	color: #F4C9C2;
}

.gf-fb__status[hidden] {
	display: none;
}

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

.gf-fb__bar {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	padding: 12px 16px;
	background: var(--fb-stage-2);
	border-top: 1px solid var(--fb-line);
}

.gf-fb__bar button,
.gf-fb__bar .gf-fb__dl {
	appearance: none;
	border: 1px solid var(--fb-line);
	background: rgba(255, 255, 255, .07);
	color: var(--fb-ink);
	font: inherit;
	font-size: 13px;
	line-height: 1;
	padding: 9px 14px;
	border-radius: 999px;
	cursor: pointer;
	text-decoration: none;
	transition: background .16s ease, border-color .16s ease, color .16s ease;
}

.gf-fb__bar button:hover,
.gf-fb__bar .gf-fb__dl:hover {
	background: var(--fb-accent);
	border-color: var(--fb-accent);
	color: #fff;
	text-decoration: none;
}

.gf-fb__bar button:focus-visible,
.gf-fb__bar .gf-fb__dl:focus-visible,
.gf-fb:focus-visible {
	outline: 2px solid var(--fb-accent);
	outline-offset: 2px;
}

.gf-fb__nav {
	font-variant-numeric: tabular-nums;
	min-width: 3.2em;
	text-align: center;
}

.gf-fb__count {
	color: var(--fb-muted);
	font-size: 12.5px;
	font-variant-numeric: tabular-nums;
	min-width: 11ch;
	text-align: center;
}

.gf-fb__spacer {
	flex: 1;
}

.gf-fb__hint {
	color: var(--fb-muted);
	font-size: 12px;
	margin: 0;
}

@media (max-width: 620px) {
	.gf-fb__stage {
		padding: 20px 12px;
		min-height: 300px;
	}

	.gf-fb__hint {
		display: none;
	}

	.gf-fb__bar {
		gap: 8px;
		padding: 10px 12px;
	}

	.gf-fb__bar button,
	.gf-fb__bar .gf-fb__dl {
		padding: 8px 12px;
		font-size: 12.5px;
	}

	.gf-fb__count {
		min-width: 0;
		flex: 1;
	}
}

/* ------------------------------------------------------------- fullscreen */

.gf-fb.is-full {
	display: flex;
	flex-direction: column;
	border-radius: 0;
	height: 100%;
}

.gf-fb.is-full .gf-fb__stage {
	flex: 1;
	min-height: 0;
}

.gf-fb.is-full .gf-fb__book {
	max-width: min(1400px, 92vw);
}

@media (prefers-reduced-motion: reduce) {
	.gf-fb__bar button,
	.gf-fb__bar .gf-fb__dl {
		transition: none;
	}
}
