/* ===== E-reader for "The Prerogative" preview ===== */

/* Strip the default window-body padding when it hosts the reader */
.window-body:has(.ereader) {
	padding: 0;
	overflow: hidden;
}

.ereader {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	font-family: "Iowan Old Style", "Palatino Linotype", "Palatino", "Book Antiqua", Georgia, serif;
	background:
		radial-gradient(120% 80% at 50% -10%, #2a2018 0%, #1a130d 55%, #120c08 100%);
	color: #2b2218;
	user-select: none;
	overflow: hidden;
}

/* ---- Top bar ---- */
.ereader-bar {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.5rem 0.9rem;
	background: rgba(0, 0, 0, 0.25);
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
	color: #cdbfa6;
	font-family: "Atkinson", system-ui, sans-serif;
	font-size: 0.78rem;
	letter-spacing: 0.02em;
}

.ereader-bar .er-title {
	font-weight: 700;
	color: #e8dcc4;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ereader-bar .er-chapter {
	flex: 1;
	text-align: center;
	color: #b6a888;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ereader-bar .er-preview-tag {
	flex-shrink: 0;
	padding: 0.12rem 0.5rem;
	border: 1px solid rgba(205, 191, 166, 0.35);
	border-radius: 999px;
	font-size: 0.66rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #cdbfa6;
}

/* ---- Stage (where the book sits) ---- */
.ereader-stage {
	position: relative;
	flex: 1;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 22px;
	perspective: 2400px;
	perspective-origin: 50% 45%;
}

.ereader-book {
	position: relative;
	display: flex;
	transform-style: preserve-3d;
	filter: drop-shadow(0 22px 40px rgba(0, 0, 0, 0.55));
}

.ereader-measure {
	position: absolute;
	left: -99999px;
	top: 0;
	visibility: hidden;
	pointer-events: none;
}

/* ---- A page surface ---- */
.er-page {
	position: relative;
	box-sizing: border-box;
	background:
		linear-gradient(180deg, #fbf6ea 0%, #f6efdd 100%);
	overflow: hidden;
}

/* subtle aged-paper vignette + fibers */
.er-page::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background:
		radial-gradient(140% 120% at 50% 0%, rgba(255,255,255,0.35), transparent 40%),
		radial-gradient(100% 100% at 50% 120%, rgba(120, 96, 60, 0.10), transparent 55%);
	mix-blend-mode: multiply;
}

/* spine shading: left page darkens toward its right edge, right page toward its left */
.er-page.left  { box-shadow: inset -18px 0 26px -18px rgba(60, 44, 24, 0.55); border-radius: 4px 2px 2px 4px; }
.er-page.right { box-shadow: inset  18px 0 26px -18px rgba(60, 44, 24, 0.55); border-radius: 2px 4px 4px 2px; }
.er-page.single { border-radius: 4px; box-shadow: inset 0 0 30px -18px rgba(60,44,24,0.5); }

.er-page-inner {
	position: relative;
	z-index: 1;
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
}

.er-content {
	flex: 1;
	min-height: 0;
	overflow: hidden;
	font-size: var(--er-font, 17px);
	line-height: 1.62;
	color: #2b2218;
	text-align: justify;
	hyphens: auto;
}

.er-content p {
	margin: 0 0 0.85em 0;
	text-indent: 1.25em;
}
/* first paragraph of a section / after a break: no indent */
.er-content p.er-first,
.er-content .er-h + p,
.er-content .er-break + p {
	text-indent: 0;
}
.er-content em { font-style: italic; }

.er-content .er-h {
	text-align: center;
	font-variant: small-caps;
	letter-spacing: 0.06em;
	font-weight: 600;
	font-size: 1.45em;
	margin: 0.2em 0 1.4em 0;
	color: #4a3a24;
}
.er-content .er-h .er-h-rule {
	display: block;
	width: 46px;
	height: 1px;
	margin: 0.7em auto 0;
	background: #b9a06f;
}

.er-content .er-break {
	text-align: center;
	margin: 1.3em 0;
	color: #9c7f4f;
	font-size: 1.1em;
	letter-spacing: 0.5em;
	text-indent: 0;
}

.er-page-num {
	flex-shrink: 0;
	text-align: center;
	font-size: 0.72rem;
	color: #9a875f;
	font-variant-numeric: oldstyle-nums;
	padding-top: 6px;
}

/* ---- Plate (special) pages ---- */
.er-content.er-plate {
	display: flex;
	flex-direction: column;
	justify-content: center;
	text-align: center;
	overflow: hidden;
}
.er-plate.halftitle .pl-title,
.er-plate.titlepage .pl-title {
	font-size: 2.1em;
	letter-spacing: 0.04em;
	font-variant: small-caps;
	color: #3a2c18;
	margin-bottom: 0.4em;
}
.er-plate.titlepage .pl-sub {
	font-style: italic;
	font-size: 1.05em;
	color: #6a583c;
	margin-bottom: 2.2em;
}
.er-plate.titlepage .pl-by { font-style: italic; color: #80704f; margin-bottom: 0.3em; font-size: 0.85em; }
.er-plate.titlepage .pl-author {
	font-size: 1.25em;
	font-variant: small-caps;
	letter-spacing: 0.08em;
	color: #3a2c18;
}
.er-plate.copyright {
	justify-content: flex-start;
	text-align: center;
	font-size: 0.74em;
	line-height: 1.7;
	color: #5a4c34;
	padding-top: 8%;
}
.er-plate.copyright .cw-title {
	font-variant: small-caps;
	font-size: 1.5em;
	letter-spacing: 0.04em;
	color: #3a2c18;
	margin-bottom: 1.4em;
}
.er-plate.copyright .cw { margin-bottom: 0.7em; }
.er-plate.epigraph { padding: 0 8%; }
.er-plate.epigraph .pl-quote {
	font-style: italic;
	font-size: 1.12em;
	line-height: 1.7;
	color: #3a2c18;
	margin-bottom: 1.4em;
}
.er-plate.epigraph .pl-attr { font-size: 0.85em; color: #6a583c; }

.er-plate.cover {
	justify-content: center;
	background:
		linear-gradient(160deg, #3a2a4d 0%, #241a36 55%, #15101f 100%);
	color: #ece3d0;
	border-radius: inherit;
}
.er-plate.cover .cv-title {
	font-size: 2.4em;
	font-variant: small-caps;
	letter-spacing: 0.05em;
	line-height: 1.1;
	margin-bottom: 0.5em;
	color: #f3ead4;
}
.er-plate.cover .cv-rule { width: 60px; height: 2px; background: #b89a5e; margin: 0 auto 1.1em; }
.er-plate.cover .cv-sub { font-style: italic; color: #c9bb9c; margin-bottom: 3em; font-size: 0.95em; }
.er-plate.cover .cv-author { font-size: 1.05em; letter-spacing: 0.12em; font-variant: small-caps; color: #e6dcc4; }

/* ---- Flipping leaf ---- */
.er-flip {
	position: absolute;
	top: 0;
	z-index: 50;
	transform-style: preserve-3d;
	will-change: transform;
}
.er-flip.animate { transition: transform 0.72s cubic-bezier(0.42, 0.05, 0.32, 1); }

.er-flip .er-face {
	position: absolute;
	inset: 0;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	overflow: hidden;
}
.er-flip .er-face.back { transform: rotateY(180deg); }

/* moving shadow gutter that sweeps as the page turns */
.er-flip .er-face::before {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: linear-gradient(90deg, rgba(0,0,0,0.28), rgba(0,0,0,0) 22%);
	opacity: 0;
	transition: opacity 0.72s ease;
}
.er-flip.animate.fwd .er-face.front::before,
.er-flip.animate.bwd .er-face.front::before { opacity: 0.5; }

/* ---- Click navigation zones ---- */
.er-nav-zone {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 42%;
	z-index: 40;
	cursor: pointer;
}
.er-nav-zone.prev { left: 0; }
.er-nav-zone.next { right: 0; }

/* ---- Bottom controls ---- */
.ereader-controls {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.55rem 0.9rem;
	background: rgba(0, 0, 0, 0.3);
	border-top: 1px solid rgba(255, 255, 255, 0.06);
	font-family: "Atkinson", system-ui, sans-serif;
}

.er-btn {
	flex-shrink: 0;
	width: 34px;
	height: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: rgba(205, 191, 166, 0.12);
	border: 1px solid rgba(205, 191, 166, 0.25);
	color: #e2d6bd;
	border-radius: 6px;
	cursor: pointer;
	font-size: 1rem;
	line-height: 1;
	transition: background 0.15s ease, opacity 0.15s ease;
}
.er-btn:hover { background: rgba(205, 191, 166, 0.25); }
.er-btn:disabled { opacity: 0.3; cursor: default; }

.er-progress {
	flex: 1;
	appearance: none;
	-webkit-appearance: none;
	height: 4px;
	border-radius: 4px;
	background: rgba(205, 191, 166, 0.22);
	cursor: pointer;
	outline: none;
}
.er-progress::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #d8c39a;
	border: 1px solid #8a734a;
	cursor: pointer;
}
.er-progress::-moz-range-thumb {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #d8c39a;
	border: 1px solid #8a734a;
	cursor: pointer;
}

.er-counter {
	flex-shrink: 0;
	font-size: 0.74rem;
	color: #b6a888;
	min-width: 78px;
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.ereader-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #b6a888;
	font-family: "Atkinson", system-ui, sans-serif;
	font-size: 0.9rem;
}