/* =========================================================
  Spoils of War Interactive Tome Website
  Static HTML/CSS/JS — Netlify ready
========================================================= */

:root {
  --font-heading: "Cinzel", Georgia, serif;
  --font-body: "Crimson Text", Georgia, serif;

  /* Light mode palette preserved from the previous site */
  --site-bg: #e9dfcf;
  --site-bg-2: #d8ccb8;
  --page-bg: #f6efe3;
  --page-edge: #efe4d2;
  --text: #2f281f;
  --muted: #6e6253;
  --accent: #7b5c3e;
  --rule: rgba(70, 52, 35, 0.14);
  --shadow: 0 18px 40px rgba(39, 28, 18, 0.18);
  --paper-opacity: 0.09;
  --button-bg: rgba(255,255,255,0.55);
  --button-border: rgba(60, 45, 30, 0.14);
  --selection-bg: rgba(123, 92, 62, 0.18);

  /* Book-cover accents */
  --leather-1: #1e0e0a;
  --leather-2: #3a1a13;
  --leather-3: #4a2a1d;
  --gold: #c6a461;
  --gold-muted: #8d7141;
  --moon: #efe3d1;

  --reader-font-size: 1.18rem;
  --transition: 240ms ease;
}

html[data-theme="dark"] {
  --site-bg: #100f10;
  --site-bg-2: #1c1816;
  --page-bg: #1f1a17;
  --page-edge: #2b241f;
  --text: #efe3d1;
  --muted: #b7a894;
  --accent: #d2b48c;
  --rule: rgba(255, 239, 219, 0.12);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --paper-opacity: 0.03;
  --button-bg: rgba(255,255,255,0.04);
  --button-border: rgba(255,255,255,0.08);
  --selection-bg: rgba(210, 180, 140, 0.22);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 50% 8%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 32%),
    linear-gradient(135deg, var(--site-bg), var(--site-bg-2) 58%, var(--site-bg));
  color: var(--text);
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

::selection {
  background: var(--selection-bg);
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
}

button {
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--gold);
  color: #120906;
  border-radius: 999px;
}

.skip-link:focus {
  left: 1rem;
}

.site-shell {
  min-height: 100vh;
  position: relative;
}

/* Ambient dust / shimmer */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.ambient span {
  position: absolute;
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background: rgba(244, 224, 168, 0.24);
  box-shadow: 0 0 0.8rem rgba(244, 224, 168, 0.22);
  animation: drift 14s linear infinite;
}

.ambient span:nth-child(1) { left: 8%; animation-delay: -2s; animation-duration: 18s; }
.ambient span:nth-child(2) { left: 22%; animation-delay: -10s; animation-duration: 16s; }
.ambient span:nth-child(3) { left: 48%; animation-delay: -4s; animation-duration: 19s; }
.ambient span:nth-child(4) { left: 73%; animation-delay: -7s; animation-duration: 15s; }
.ambient span:nth-child(5) { left: 91%; animation-delay: -12s; animation-duration: 21s; }

@keyframes drift {
  0% { transform: translateY(105vh) translateX(0); opacity: 0; }
  12% { opacity: 0.42; }
  85% { opacity: 0.3; }
  100% { transform: translateY(-12vh) translateX(42px); opacity: 0; }
}

/* =========================================================
  Closed Book Cover
========================================================= */
.cover-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
  position: relative;
  z-index: 1;
}

.book-cover {
  width: min(1050px, 100%);
  min-height: min(820px, calc(100vh - 2rem));
  position: relative;
  overflow: hidden;
  border-radius: clamp(1.25rem, 3vw, 2.25rem);
  border: 1px solid rgba(198, 164, 97, 0.26);
  box-shadow:
    0 2.2rem 4.4rem rgba(0, 0, 0, 0.58),
    inset 0 0 0 0.35rem rgba(0, 0, 0, 0.18),
    inset 0 0 4.5rem rgba(0, 0, 0, 0.58);
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 231, 183, 0.045), transparent 15%),
    radial-gradient(circle at 74% 26%, rgba(255, 255, 255, 0.03), transparent 13%),
    radial-gradient(circle at 64% 76%, rgba(0, 0, 0, 0.14), transparent 20%),
    radial-gradient(circle at 28% 82%, rgba(255, 212, 120, 0.035), transparent 18%),
    linear-gradient(100deg, rgba(0, 0, 0, 0.34) 0 8.5%, transparent 8.5% 100%),
    linear-gradient(135deg, #1e0e0a, #3a1a13 50%, #54311f);
}

.book-cover::before,
.book-cover::after {
  content: "";
  position: absolute;
  inset: 1.1rem;
  border: 1px solid rgba(198, 164, 97, 0.22);
  border-radius: 1.5rem;
  pointer-events: none;
}

.book-cover::after {
  inset: 2rem;
  border-style: double;
  opacity: 0.5;
}

.cover-spine {
  display: none;
}

.cover-glow {
  position: absolute;
  width: 25rem;
  height: 25rem;
  left: 50%;
  top: 32%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(198, 164, 97, 0.18), transparent 65%);
  filter: blur(1px);
  animation: pulseGlow 4s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.22; transform: translate(-50%, -50%) scale(0.98); }
  50% { opacity: 0.38; transform: translate(-50%, -50%) scale(1.02); }
}

.cover-metal.corner {
  position: absolute;
  width: clamp(3rem, 8vw, 5rem);
  height: clamp(3rem, 8vw, 5rem);
  border: 1px solid rgba(198, 164, 97, 0.32);
  background: linear-gradient(135deg, rgba(198, 164, 97, 0.12), rgba(0, 0, 0, 0.16));
  z-index: 2;
}

.top-left { top: 1.4rem; left: 1.4rem; border-right: 0; border-bottom: 0; border-radius: 1rem 0 0 0; }
.top-right { top: 1.4rem; right: 1.4rem; border-left: 0; border-bottom: 0; border-radius: 0 1rem 0 0; }
.bottom-left { bottom: 1.4rem; left: 1.4rem; border-right: 0; border-top: 0; border-radius: 0 0 0 1rem; }
.bottom-right { bottom: 1.4rem; right: 1.4rem; border-left: 0; border-top: 0; border-radius: 0 0 1rem 0; }

.cover-content {
  position: relative;
  z-index: 3;
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(5.5rem, 12vw, 8rem) clamp(1.5rem, 5vw, 4rem) 2rem;
  text-align: center;
}

.eyebrow,
.small-label,
.chapter-number {
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--gold);
}

h1,
h2 {
  font-family: var(--font-heading);
  line-height: 1.05;
  margin: 0;
}

h1 {
  font-size: clamp(3.5rem, 10vw, 7rem);
  color: #e7d0a2;
  text-shadow:
    0 0.07em 0 rgba(0, 0, 0, 0.78),
    0 0 1.1rem rgba(198, 164, 97, 0.14);
}

.author-mark {
  font-family: var(--font-heading);
  color: #d9c18d;
  letter-spacing: 0.14em;
  margin-top: 0.4rem;
}

.cover-tagline {
  max-width: 610px;
  margin: 1.5rem auto 0;
  color: rgba(246, 230, 190, 0.88);
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  line-height: 1.45;
}

.cover-actions,
.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.85rem;
  margin-top: 2rem;
}

.btn,
.menu-btn {
  cursor: pointer;
  border-radius: 999px;
  padding: 0.85rem 1.25rem;
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  letter-spacing: 0.06em;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition), background var(--transition);
}

.btn:hover,
.menu-btn:hover {
  transform: translateY(-2px);
}

.btn:focus-visible,
.menu-btn:focus-visible,
.bookmark-toggle:focus-visible {
  outline: 3px solid rgba(255, 224, 142, 0.85);
  outline-offset: 3px;
}

.btn-primary {
  background: linear-gradient(135deg, #e7c981, var(--gold));
  color: #170a05;
  box-shadow: 0 0.8rem 1.4rem rgba(0, 0, 0, 0.32), inset 0 1px rgba(255, 255, 255, 0.42);
}

.btn-secondary,
.btn-ghost,
.page-btn,
.menu-btn {
  background: rgba(34, 16, 10, 0.72);
  color: #f2ddb0;
  border: 1px solid rgba(198, 164, 97, 0.42);
  box-shadow: inset 0 0 1rem rgba(0, 0, 0, 0.28);
}

.latest-panel {
  position: relative;
  z-index: 3;
  width: min(680px, calc(100% - 2rem));
  margin: 0 auto 1.4rem;
  padding: 1.15rem 1.25rem;
  border-radius: 1rem;
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.34), transparent 16%),
    radial-gradient(circle at 82% 22%, rgba(141, 93, 45, 0.08), transparent 18%),
    radial-gradient(circle at 22% 82%, rgba(104, 66, 29, 0.07), transparent 16%),
    linear-gradient(rgba(255, 245, 210, 0.9), rgba(217, 190, 130, 0.9));
  color: var(--text);
  border: 1px solid rgba(77, 44, 18, 0.36);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.34), inset 0 0 2rem rgba(99, 55, 20, 0.12);
  transform: rotate(-0.5deg);
}

.latest-panel h2 {
  font-size: 1.2rem;
  color: #4b2d17;
  margin-bottom: 0.5rem;
}

.latest-panel ul {
  margin: 0;
  padding-left: 1.15rem;
  line-height: 1.35;
}

.latest-panel,
.latest-panel li,
.latest-panel strong {
  color: #302014;
}

.latest-panel li::marker {
  color: #4b2d17;
}

.cover-footer {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 0 1rem 2rem;
  color: rgba(246, 230, 190, 0.78);
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: #f2ddb0;
  text-underline-offset: 0.25rem;
}

/* Immersive newsletter signup */
.newsletter-panel {
  width: min(620px, calc(100% - 2rem));
  margin: 1rem auto 1.15rem;
  padding: 1.1rem;
  border-radius: 1rem;
  border: 1px solid rgba(198, 164, 97, 0.28);
  background:
    radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.08), transparent 22%),
    radial-gradient(circle at 84% 76%, rgba(198, 164, 97, 0.1), transparent 24%),
    rgba(20, 10, 7, 0.5);
  box-shadow: inset 0 0 1.4rem rgba(0, 0, 0, 0.24);
}

.newsletter-panel h2 {
  margin: 0.15rem 0 0.35rem;
  font-size: clamp(1.3rem, 3vw, 1.85rem);
  color: #e7d0a2;
}

.newsletter-panel p {
  margin: 0.35rem auto 0.9rem;
  max-width: 44rem;
  color: rgba(246, 230, 190, 0.82);
}

.newsletter-form {
  display: grid;
  gap: 0.8rem;
}

.newsletter-fields {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 0.75rem;
}

.newsletter-form label {
  display: grid;
  gap: 0.3rem;
  text-align: left;
  color: rgba(246, 230, 190, 0.86);
}

.newsletter-form label span {
  font-family: var(--font-heading);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.newsletter-form input {
  width: 100%;
  border: 1px solid rgba(198, 164, 97, 0.32);
  border-radius: 999px;
  padding: 0.78rem 0.95rem;
  font: inherit;
  color: #f7ead0;
  background: rgba(0, 0, 0, 0.26);
  box-shadow: inset 0 0 0.8rem rgba(0, 0, 0, 0.24);
}

.newsletter-form input::placeholder {
  color: rgba(246, 230, 190, 0.45);
}

.newsletter-form input:focus-visible {
  outline: 3px solid rgba(255, 224, 142, 0.72);
  outline-offset: 2px;
}

.newsletter-form .btn {
  justify-self: center;
}

.newsletter-message {
  min-height: 1.4rem;
  margin: 0;
  font-style: italic;
}

.newsletter-message.is-success {
  color: #f1d892;
}

.newsletter-message.is-error {
  color: #ffb7a6;
}

.scribe-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

html:not([data-theme="dark"]) .newsletter-panel {
  background:
    radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.24), transparent 22%),
    radial-gradient(circle at 84% 76%, rgba(123, 92, 62, 0.09), transparent 24%),
    rgba(255, 245, 210, 0.78);
  border-color: rgba(77, 44, 18, 0.28);
}

html:not([data-theme="dark"]) .newsletter-panel h2,
html:not([data-theme="dark"]) .newsletter-panel p,
html:not([data-theme="dark"]) .newsletter-form label {
  color: #302014;
}

html:not([data-theme="dark"]) .newsletter-form input {
  color: #302014;
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(60, 45, 30, 0.22);
}

html:not([data-theme="dark"]) .newsletter-form input::placeholder {
  color: rgba(48, 32, 20, 0.48);
}

html:not([data-theme="dark"]) .newsletter-message.is-success {
  color: #4b2d17;
}

html:not([data-theme="dark"]) .newsletter-message.is-error {
  color: #742d22;
}


/* Subtle open/close state transitions */
.cover-view,
.reader-view {
  transition: opacity 520ms ease, transform 520ms ease, filter 520ms ease;
}

.cover-view.is-fading-out {
  opacity: 0;
  transform: scale(0.985);
  filter: blur(4px);
  pointer-events: none;
}

.reader-view.is-preparing {
  opacity: 0;
  transform: translateY(12px) scale(0.99);
  filter: blur(4px);
}

.reader-view.is-visible {
  opacity: 1;
  /* Keep this as none so fixed-position controls stay attached to the viewport while reading. */
  transform: none;
  filter: none;
}

.cover-view.is-returning {
  animation: coverReturn 520ms ease both;
}

@keyframes coverReturn {
  from { opacity: 0; transform: scale(0.985); filter: blur(4px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* More restrained front-cover details */
.cover-metal {
  opacity: 0.28;
  filter: saturate(0.7);
}

.cover-glow {
  opacity: 0.32;
}

.cover-content .eyebrow,
.author-mark {
  opacity: 0.82;
}

/* =========================================================
  Reader View
========================================================= */
.reader-view {
  min-height: 100vh;
  padding: clamp(1rem, 3vw, 2rem);
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
}

.reader-view.is-opening .open-book,
.reader-view.is-turning .chapter-page {
  animation: pageAppear 440ms ease both;
}

@keyframes pageAppear {
  from { opacity: 0; transform: translateY(16px) scale(0.99); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.open-book {
  width: min(1180px, 100%);
  min-height: min(760px, calc(100vh - 4rem));
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
  gap: 0;
  filter: drop-shadow(0 2rem 3rem rgba(0, 0, 0, 0.42));
}

.page {
  position: relative;
  padding: clamp(1.25rem, 4vw, 3rem);
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, var(--paper-opacity)), transparent 22%),
    radial-gradient(circle at 78% 22%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 18%),
    radial-gradient(circle at 24% 74%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 16%),
    radial-gradient(circle at 84% 78%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 22%),
    linear-gradient(135deg, var(--page-bg), var(--page-edge));
  color: var(--text);
  border: 1px solid var(--rule);
  box-shadow: inset 0 0 3rem color-mix(in srgb, var(--accent) 14%, transparent);
}


.page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.42;
  background:
    radial-gradient(circle at 12% 20%, rgba(255, 255, 255, 0.2), transparent 10%),
    radial-gradient(circle at 30% 72%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 14%),
    radial-gradient(circle at 66% 26%, rgba(255, 255, 255, 0.12), transparent 12%),
    radial-gradient(circle at 84% 66%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 16%),
    radial-gradient(circle at 54% 90%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 12%);
  mix-blend-mode: multiply;
}

.page-left {
  border-radius: 1.25rem 0 0 1.25rem;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.page-left::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 2.4rem;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.16));
  pointer-events: none;
}

.page-right {
  border-radius: 0 1.25rem 1.25rem 0;
  border-left: 0;
}

.page-right::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2.2rem;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.16), transparent);
  pointer-events: none;
}

.marginalia {
  max-width: 15rem;
  font-style: italic;
  color: var(--muted);
  transform: rotate(-2deg);
}

.chapter-index-card {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0;
}

.chapter-index-card p {
  margin: 0.25rem 0;
}

.btn-ghost {
  align-self: flex-start;
  color: var(--text);
  background: var(--button-bg);
  border-color: var(--button-border);
}

.chapter-page {
  display: flex;
  flex-direction: column;
}

.chapter-page h2 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: var(--text);
  margin-bottom: 1.25rem;
}

.chapter-body {
  font-size: var(--reader-font-size);
  line-height: 1.72;
  max-width: 72ch;
}

.chapter-body p {
  margin: 0 0 1.1rem;
}

.chapter-body p:first-of-type::first-letter {
  font-family: var(--font-heading);
  font-size: 3.2em;
  float: left;
  line-height: 0.85;
  padding-right: 0.1em;
  color: var(--accent);
}

.chapter-nav {
  margin-top: auto;
  padding-top: 1.6rem;
  justify-content: space-between;
}

.page-btn {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, #2f281f), color-mix(in srgb, var(--accent) 52%, #100f10));
  color: var(--page-bg);
}

.chapter-nav .page-btn {
  flex: 0 1 13.5rem;
  width: auto;
  max-width: 13.5rem;
  min-width: 0;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: normal;
  overflow-wrap: break-word;
}

/* Worn disabled style for the final unavailable chapter button */
.worn-disabled,
.worn-disabled:hover,
.menu-btn:disabled,
.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.35) sepia(0.18);
  box-shadow:
    inset 0 0 0.9rem rgba(0, 0, 0, 0.42),
    0 0.2rem 0.3rem rgba(0, 0, 0, 0.12);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 3px, transparent 3px 7px),
    linear-gradient(135deg, #5b4730, #2d2319);
  color: rgba(241, 223, 184, 0.75);
}

html[data-theme="dark"] .page::before {
  opacity: 0.28;
  mix-blend-mode: screen;
}

/* =========================================================
  Book Menu / Bookmark
========================================================= */
.bookmark-toggle {
  position: fixed;
  top: 0;
  right: clamp(1rem, 4vw, 3rem);
  z-index: 1000;
  padding: 1.2rem 0.8rem 1.6rem;
  min-width: 4.6rem;
  color: #fff4c9;
  background: linear-gradient(180deg, #8d1f1f, #551111);
  border-radius: 0 0 0.4rem 0.4rem;
  box-shadow: 0 0.8rem 1rem rgba(0, 0, 0, 0.32);
  cursor: pointer;
  font-family: var(--font-heading);
  letter-spacing: 0.08em;
}

.bookmark-toggle::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1.1rem;
  margin: auto;
  width: 0;
  height: 0;
  border-left: 2.3rem solid transparent;
  border-right: 2.3rem solid transparent;
  border-top: 1.15rem solid #551111;
}

.book-menu {
  position: fixed;
  top: 5.4rem;
  right: clamp(1rem, 4vw, 3rem);
  z-index: 999;
  width: min(360px, calc(100vw - 2rem));
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(198, 164, 97, 0.42);
  background: rgba(24, 12, 8, 0.94);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.42);
  transform: translateY(-12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  max-height: calc(100vh - 6.5rem);
  overflow-y: auto;
}

.book-menu.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.menu-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.menu-btn {
  flex: 1 1 auto;
  padding: 0.72rem 0.85rem;
}

.menu-btn.danger {
  border-color: rgba(203, 82, 63, 0.55);
}

/* Light theme adjustments */
html:not([data-theme="dark"]) .btn-secondary,
html:not([data-theme="dark"]) .menu-btn,
html:not([data-theme="dark"]) .book-menu {
  background: rgba(72, 41, 20, 0.9);
  color: #fff1c2;
}

html:not([data-theme="dark"]) .bookmark-toggle {
  background: linear-gradient(180deg, #a03a2a, #682016);
}

html:not([data-theme="dark"]) .bookmark-toggle::after {
  border-top-color: #682016;
}

html:not([data-theme="dark"]) .ambient span {
  background: rgba(95, 58, 26, 0.24);
  box-shadow: 0 0 1rem rgba(95, 58, 26, 0.18);
}

body.mode-flicker::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: rgba(255, 238, 179, 0.2);
  animation: flicker 340ms ease both;
}

@keyframes flicker {
  0% { opacity: 0; }
  20% { opacity: 0.85; }
  45% { opacity: 0.18; }
  68% { opacity: 0.48; }
  100% { opacity: 0; }
}

/* =========================================================
  Responsive
========================================================= */
@media (max-width: 820px) {
  .cover-view {
    padding: 0.8rem;
  }

  .book-cover {
    min-height: auto;
  }

  .cover-content {
    padding-top: 4.8rem;
  }

  .latest-panel {
    width: calc(100% - 1.5rem);
    transform: none;
  }

  .open-book {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .page-left {
    border-radius: 1.25rem 1.25rem 0 0;
    min-height: auto;
    gap: 1rem;
  }

  .page-left::after {
    display: none;
  }

  .page-right {
    border-radius: 0 0 1.25rem 1.25rem;
    border-left: 1px solid var(--rule);
    border-top: 0;
  }

  .page-right::before {
    display: none;
  }

  .chapter-nav {
    justify-content: center;
    gap: 0.75rem;
  }

  .chapter-nav .page-btn {
    flex: 0 1 13.5rem;
  }

  .bookmark-toggle {
    right: 1rem;
    min-width: 4.2rem;
    font-size: 0.78rem;
  }
  .book-menu {
    right: 1rem;
    max-height: calc(100vh - 5.5rem);
    overflow-y: auto;
  }

}

@media (max-width: 520px) {
  .newsletter-fields {
    grid-template-columns: 1fr;
  }

  .newsletter-panel {
    width: calc(100% - 1rem);
    padding: 0.95rem;
  }

  .cover-actions,
  .chapter-nav,
  .footer-links {
    flex-direction: column;
  }

  .cover-actions .btn,
  .book-menu .menu-btn,
  .btn-ghost {
    width: 100%;
    text-align: center;
  }

  .chapter-nav {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .chapter-nav .page-btn {
    width: min(100%, 17rem);
    max-width: 17rem;
    flex: none;
    padding-inline: 0.9rem;
    font-size: clamp(0.76rem, 3.4vw, 0.88rem);
  }

  .cover-content {
    padding-inline: 1rem;
  }

  h1 {
    font-size: clamp(3rem, 18vw, 4.4rem);
  }

  .chapter-body {
    line-height: 1.66;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
