/* ═══════════════════════════════════════════════════════════════════════════
   RAISE THE BLACK — styles
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #000000;
  --bg-2: #0a0908;
  --ink: #e8dfc9;
  --ink-2: #c9bfa6;
  --ink-mute: #847d6b;
  --ink-dim: #5a5448;
  --rule: rgba(232, 223, 201, 0.18);
  --rule-soft: rgba(232, 223, 201, 0.08);
  --paper: #000000;
  --serif: "EB Garamond", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --display: "Cinzel", "Trajan Pro", "EB Garamond", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

.theme-bone {
  --bg: #f1ebda;
  --bg-2: #ebe4d0;
  --ink: #161310;
  --ink-2: #2a251e;
  --ink-mute: #5e574a;
  --ink-dim: #8e8674;
  --rule: rgba(22, 19, 16, 0.20);
  --rule-soft: rgba(22, 19, 16, 0.08);
  --paper: #f1ebda;
}
.theme-sepia {
  --bg: #211a13;
  --bg-2: #2a2118;
  --ink: #e9d6b4;
  --ink-2: #cdb78f;
  --ink-mute: #957e5b;
  --ink-dim: #6e5a3d;
  --rule: rgba(233, 214, 180, 0.18);
  --rule-soft: rgba(233, 214, 180, 0.08);
  --paper: #211a13;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button[disabled] { cursor: default; }

.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

.bg-fx {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(232,223,201,0.04), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(232,223,201,0.03), transparent 70%);
  mix-blend-mode: screen;
  z-index: 2; /* above video, below UI */
}

/* Local-hosted background video. Plays muted/looped behind the emblem. */
.bg-video-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
  background: #000;
}
.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  opacity: 0.55;
  filter: brightness(0.75) saturate(0.85) blur(0.5px);
}
/* Vignette + bottom darken so the emblem and labels read cleanly over the water. */
.bg-video-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, transparent 0%, rgba(10,9,8,0.55) 70%, rgba(10,9,8,0.85) 100%),
    linear-gradient(to bottom, rgba(10,9,8,0.20) 0%, rgba(10,9,8,0) 30%, rgba(10,9,8,0) 70%, rgba(10,9,8,0.45) 100%);
}
.theme-bone .bg-video, .theme-sepia .bg-video { opacity: 0.30; filter: brightness(0.85) saturate(0.7) blur(0.5px); }
.theme-bone .bg-fx, .theme-sepia .bg-fx { mix-blend-mode: normal; opacity: 0.7; }

/* View transition (kept subtle to avoid paused-iframe issues) */
.view-fade {
  position: absolute;
  inset: 0;
  opacity: 1;
  animation: fadeIn 0.5s ease both;
}
@keyframes fadeIn {
  0%   { opacity: 0.001; }
  100% { opacity: 1; }
}

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--rule-soft);
  z-index: 5;
}
.home-btn {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-mute);
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}
.home-btn:hover { color: var(--ink); background: var(--rule-soft); }
.home-glyph { display: inline-flex; transition: transform 0.6s cubic-bezier(.2,.7,.2,1); }
.home-btn:hover .home-glyph { transform: rotate(30deg); }
.topbar-crumbs {
  justify-self: center;
  display: flex;
  gap: 10px;
  align-items: center;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.crumb-sep { color: var(--ink-dim); }
.topbar-title {
  justify-self: end;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ── Splash screen ──────────────────────────────────────────────────────── */
/* First-load gate. The flower is shown with a dark radial vignette over its
   center (masking the skull); the prompt 'Enter, Those Who Dare?' sits in
   that dimmed center. Clicking anywhere dismisses + counts as the user
   gesture needed to unmute background audio. */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg, #0a0908);
  cursor: pointer;
}
.splash:focus-visible { outline: none; }

/* Leaving transition (click): petals + text ignite crimson for ~650ms, then
   the whole overlay dissolves over 1050ms, revealing the page below.
   Total ~1700ms (matches the JS timeout in index.html). */
.splash.is-leaving {
  animation: splashFadeOut 1050ms ease-in 650ms forwards;
  pointer-events: none;
  cursor: default;
}
.splash.is-leaving .splash-flower {
  /* Deep crimson — darker and less orange than blood red. */
  filter: brightness(0.42) sepia(1) saturate(6) hue-rotate(-25deg);
  transition: filter 700ms ease-in;
}
.splash.is-leaving .splash-text {
  color: #7a0f1a;
  text-shadow: 0 0 28px rgba(122, 15, 26, 0.55), 0 0 12px rgba(0, 0, 0, 0.9);
  animation: none;
  opacity: 1;
  transition: color 620ms ease-in, text-shadow 620ms ease-in;
}
@keyframes splashFadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Splash reuses .flower-stage and .flower-wrap so its flower sits at the
   exact same screen position as the home flower (no jump on click). The
   splash-* classes only add mask + overlay text. */
.splash .flower-stage { position: absolute; inset: 0; }
.splash-flower-wrap {
  position: relative;
  /* Slow ceremonial fade-in on first page load. The dark background is
     already painted on the first frame (no flash); only the petals and
     prompt rise into view. Suppressed once leaving so the crimson
     ignition isn't competing with a fade-in. */
  animation: splashRiseIn 1800ms ease-out both;
}
.splash.is-leaving .splash-flower-wrap { animation: none; }
@keyframes splashRiseIn {
  0%   { opacity: 0; }
  35%  { opacity: 0; }   /* hold black briefly */
  100% { opacity: 1; }
}
.splash-flower {
  /* Mask out the inner circle (skull region) so only the petal ring is
     visible. Sized to fully swallow the skull's jaw. */
  -webkit-mask-image: radial-gradient(
    circle at 50% 50%,
    transparent 0%,
    transparent 33%,
    black 38%,
    black 100%
  );
          mask-image: radial-gradient(
    circle at 50% 50%,
    transparent 0%,
    transparent 33%,
    black 38%,
    black 100%
  );
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
}
.splash-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.04em;
  /* IM Fell English: distressed antique serif from a 17th-century type
     specimen. Renders with irregular ink-bleed edges that match the
     chalky petals far better than EB Garamond's clean lines. */
  font-family: "IM Fell English", "EB Garamond", Georgia, serif;
  font-style: italic;
  font-size: clamp(26px, 5vh, 52px);
  line-height: 1.0;
  color: rgba(232, 223, 201, 0.92);
  letter-spacing: 0.01em;
  text-align: center;
  text-shadow: 0 0 28px rgba(0, 0, 0, 0.95);
  animation: splashPulse 2.6s ease-in-out infinite;
  pointer-events: none;
}
.splash-text span { display: block; }
@keyframes splashPulse {
  0%, 100% { opacity: 0.78; }
  50%      { opacity: 1.00; }
}
@media (max-width: 720px) {
  .splash-text { font-size: clamp(18px, 4.4vh, 28px); }
}

/* ── Flower stage ───────────────────────────────────────────────────────── */
/* Flexbox column. Flower + wordmark sit as one vertically-centered unit.
   align-items: center guarantees every child shares the viewport's
   horizontal centerline. */
.flower-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 28px;
}
/* Flower wrap: allow labels to escape the box on hover.
   No solid bg — the PNG's black pixels are knocked out via screen blend so the
   background video shows through cleanly. */
.flower-wrap {
  position: relative;
  width: min(56vh, 70vw, 560px);
  aspect-ratio: 1 / 1;
  overflow: visible;
  background: transparent;
  transform: none; /* defensive: kill any cached translateX */
  margin: 0;
}
.flower-art {
  width: 100%; height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 10px 60px rgba(232,223,201,0.06));
  /* PNGs are alpha-keyed (luminance-as-alpha) so they sit cleanly over the video. */
}
/* Tints use the bone PNG as a CSS mask, then fill with a solid colour. This
   guarantees the red/ember petal art is pixel-aligned with the bone art —
   no second hand-drawn PNG required, no ghost offset. The clip-path narrows
   the painted region to a single petal. */
.flower-tint {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-mask: url("logo.png") center / 100% 100% no-repeat;
          mask: url("logo.png") center / 100% 100% no-repeat;
}
.flower-tint-red   { background: #c8261c; opacity: 1; }
.flower-tint-ember { background: #d8842a; opacity: 0.85; }

.theme-bone .flower-art.base-logo {
  filter: invert(1) hue-rotate(180deg) drop-shadow(0 10px 60px rgba(0,0,0,0.10));
}
.theme-bone .flower-tint { filter: invert(1) hue-rotate(180deg); }

.flower-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}

/* "Sailing Soon" banner — shown above the flower while petals are locked
   for public visitors. Suppressed for admin (RTB_ADMIN gate in JSX). */
.flower-coming-soon {
  position: absolute;
  top: 4%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-size: clamp(22px, 3.4vh, 36px);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #b03a3a;
  text-shadow: 0 0 24px rgba(176, 58, 58, 0.45);
  white-space: nowrap;
  z-index: 5;
  pointer-events: none;
}

/* Hover title — single label that lives ABOVE the flower, fades in when a petal is hovered */
.flower-hover-title {
  position: absolute;
  top: 5%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(.2,.7,.2,1);
  z-index: 4;
  white-space: nowrap;
}
.flower-hover-title.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.fht-primary {
  font-family: var(--display);
  font-size: clamp(14px, 1.8vh, 18px);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink);
  text-indent: 0.42em;
  text-shadow: 0 0 28px rgba(232,223,201,0.45);
}
.fht-secondary {
  margin-top: 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(14px, 1.7vh, 17px);
  color: var(--ink-2);
}

/* Hit-zone overlay sits on top of everything */
.flower-svg.flower-hits {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* Petal Zone Editor */
/* ─────────────────────────────────────────────────────────────────────────── */
.flower-wrap.is-editing { outline: 1px dashed rgba(120,220,120,0.4); }
.petal-editor-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 30;
  cursor: default;
}
.pe-zone { transition: opacity 0.2s; }
.pe-zone .pe-ellipse {
  fill: rgba(120, 220, 120, 0.22);
  stroke: rgba(160, 240, 160, 0.8);
  stroke-width: 3;
  cursor: move;
  transition: fill 0.2s, stroke 0.2s;
}
.pe-zone.is-sel .pe-ellipse {
  fill: rgba(255, 230, 100, 0.30);
  stroke: rgba(255, 240, 130, 1);
  stroke-width: 4;
}
.pe-zone .pe-axis {
  stroke: rgba(255, 240, 130, 0.6);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  pointer-events: none;
}
.pe-zone .pe-handle {
  fill: #fff;
  stroke: #111;
  stroke-width: 2;
  cursor: grab;
}
.pe-zone .pe-handle-center {
  fill: rgba(80, 200, 80, 1);
  stroke: #0a3a0a;
}
.pe-zone .pe-handle-tip {
  fill: rgba(255, 200, 50, 1);
  stroke: #4a2f00;
}
.pe-zone .pe-handle-side {
  fill: rgba(120, 180, 255, 1);
  stroke: #0a1f4a;
}
.pe-zone-num {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 28px;
  font-weight: 700;
  fill: #fff;
  paint-order: stroke;
  stroke: rgba(0,0,0,0.75);
  stroke-width: 5;
  pointer-events: none;
  user-select: none;
}

/* Toolbar */
.pe-toolbar {
  position: fixed;
  z-index: 200;
  background: rgba(20, 20, 18, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #e8dfc9;
  border: 1px solid rgba(232,223,201,0.2);
  border-radius: 8px;
  padding: 10px 12px;
  width: 220px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  user-select: none;
  transition: width 0.18s ease;
}
.pe-toolbar.is-collapsed { width: 200px; }
.pe-toolbar-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--display, serif);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #e8dfc9;
  margin-bottom: 10px;
  cursor: grab;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(232,223,201,0.08);
}
.pe-toolbar-title:active { cursor: grabbing; }
.pe-min {
  background: transparent;
  border: none;
  color: rgba(232,223,201,0.6);
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.pe-min:hover { color: #e8dfc9; }
.pe-toolbar.is-collapsed .pe-toolbar-title { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.pe-toolbar-title .pe-count {
  color: rgba(232,223,201,0.5);
  margin-left: 6px;
  font-size: 10px;
}
.pe-toolbar-row { display: flex; gap: 6px; margin-bottom: 8px; }
.pe-toolbar-row button {
  flex: 1;
  background: rgba(232,223,201,0.08);
  border: 1px solid rgba(232,223,201,0.2);
  color: #e8dfc9;
  padding: 6px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.pe-toolbar-row button:hover { background: rgba(232,223,201,0.15); border-color: rgba(232,223,201,0.4); }
.pe-toolbar-row button:disabled { opacity: 0.4; cursor: default; }
.pe-zone-info {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(232,223,201,0.1);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pe-info-line {
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
  color: rgba(232,223,201,0.85);
}
.pe-info-line span:first-child { color: rgba(232,223,201,0.45); }
.pe-info-line b { color: #ffe082; font-weight: 600; }
.pe-hints {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(232,223,201,0.1);
  color: rgba(232,223,201,0.45);
  font-size: 10px;
  line-height: 1.55;
}
.pe-hints kbd { font-family: inherit; }

.wordmark-edit-hint { color: rgba(232,223,201,0.4); }
.wordmark-edit-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  border: 1px solid rgba(232,223,201,0.25);
  border-radius: 3px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 9px;
  color: rgba(232,223,201,0.7);
}

/* Each petal hit zone */
.petal { cursor: pointer; }

/* (dim-on-hover filter chain removed — it triggered :has() layout recalcs and
   re-rasterized the bone PNG every hover, causing perceptible lag.) */

/* HTML labels positioned around the flower */
.petal-label-html {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(.2,.7,.2,1);
  white-space: nowrap;
  z-index: 5;
}
.petal-label-html.is-hover { opacity: 1; }
.petal-label-html.align-left  { text-align: left;   transform: translate(0, -50%) translateX(14px); }
.petal-label-html.align-right { text-align: right;  transform: translate(-100%, -50%) translateX(-14px); }
.petal-label-html.align-center { text-align: center; transform: translate(-50%, -50%); }
.petal-label-html.align-center.is-hover { transform: translate(-50%, calc(-50% + 0px)); }
.petal-label-html .petal-label-1 {
  font-family: var(--display);
  font-size: clamp(11px, 1.4vh, 14px);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink);
  text-indent: 0.32em;
  text-shadow: 0 0 24px rgba(232,223,201,0.4);
}
.petal-label-html .petal-label-2 {
  margin-top: 4px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(12px, 1.5vh, 15px);
  color: var(--ink-2);
}

/* (old SVG text labels removed — labels are now positioned as HTML around the flower) */

/* Wordmark beneath flower.
   Initial state: all text is crimson. Once body.rtb-entered is set
   (immediately for admin, after splash dismiss for visitors), the text
   fades over 2.4s to its normal cream/white tones. */
.wordmark { text-align: center; padding: 0; }
.wordmark-title {
  font-family: var(--display);
  font-size: clamp(34px, 5vh, 56px);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: #7a0f1a;
  white-space: nowrap;
  line-height: 1.2;
  margin-bottom: 6px;
  transition: color 2400ms ease-out;
}
.wordmark-sub {
  margin-top: 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(24px, 3.2vh, 30px);
  color: #7a0f1a;
  letter-spacing: 0.04em;
  transition: color 2400ms ease-out;
}
.wordmark-byline {
  margin-top: 2px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(11px, 1.5vh, 14px);
  color: #7a0f1a;
  letter-spacing: 0.04em;
  opacity: 0.85;
  transition: color 2400ms ease-out;
}
.wordmark-hint {
  margin-top: 18px;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #7a0f1a;
  transition: color 2400ms ease-out;
}
body.rtb-entered .wordmark-title  { color: var(--ink); }
body.rtb-entered .wordmark-sub    { color: var(--ink-2); }
body.rtb-entered .wordmark-byline { color: var(--ink-2); }
body.rtb-entered .wordmark-hint   { color: var(--ink-dim); }

/* ── Page (act / extra / read) ─────────────────────────────────────────── */
.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
}

.act-view, .extra-view {
  overflow: hidden;
}
.act-inner {
  flex: 1;
  overflow-y: auto;
  padding: 60px 32px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.extra-inner { padding-top: 50px; }

.act-head {
  text-align: center;
  margin-bottom: 56px;
  max-width: 720px;
}
.act-roman {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 18px;
}
.act-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(34px, 5.4vh, 56px);
  letter-spacing: 0.12em;
  margin: 0 0 22px;
  text-transform: uppercase;
  text-indent: 0.12em;
}
.act-epigraph {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(15px, 1.9vh, 18px);
  color: var(--ink-2);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.55;
  text-wrap: pretty;
}

/* Chapter rows */
.chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 720px;
  border-top: 1px solid var(--rule-soft);
}
.chapter-row {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 24px;
  align-items: baseline;
  padding: 24px 4px;
  text-align: left;
  border-bottom: 1px solid var(--rule-soft);
  transition: background 0.3s ease, padding-left 0.4s ease;
}
.chapter-row:not([disabled]):hover {
  background: linear-gradient(to right, var(--rule-soft), transparent 70%);
  padding-left: 16px;
}
.chapter-row[disabled] { cursor: default; opacity: 0.65; }
.chapter-num {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
}
.chapter-title {
  font-family: var(--display);
  font-size: clamp(18px, 2.4vh, 22px);
  letter-spacing: 0.04em;
  color: var(--ink);
}
.chapter-teaser {
  margin-top: 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-2);
  max-width: 56ch;
  line-height: 1.55;
  text-wrap: pretty;
}
.chapter-teaser-faint { color: var(--ink-mute); font-style: normal; letter-spacing: 0.18em; text-transform: uppercase; font-size: 10px; }
.chapter-meta {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.chapter-row.is-read .chapter-meta { color: oklch(0.78 0.06 70); }

/* ── Reading view ─────────────────────────────────────────────────────── */
.read-view { background: var(--bg); }
.read-progress {
  height: 1px;
  background: var(--rule-soft);
  position: relative;
}
.read-progress-bar {
  position: absolute; inset: 0 auto 0 0;
  background: var(--ink-2);
  transition: width 0.1s linear;
}
.read-scroll {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.read-article {
  margin: 0 auto;
  padding: 80px 32px 120px;
  font-family: var(--serif);
  line-height: 1.78;
  color: var(--ink);
}
.read-head {
  text-align: center;
  margin-bottom: 48px;
}
.read-act {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.read-chnum {
  margin-top: 24px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.read-chtitle {
  margin: 14px 0 24px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(32px, 5vh, 48px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-indent: 0.08em;
}
.read-epigraph {
  margin: 18px auto 0;
  max-width: 38ch;
  font-style: italic;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.55;
  text-wrap: pretty;
}
.read-rule { display: flex; justify-content: center; padding: 28px 0; }
.read-rule span {
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ink-mute);
  box-shadow:
    -16px 0 0 var(--ink-mute),
     16px 0 0 var(--ink-mute);
}
.read-article p { margin: 0 0 1.2em; text-wrap: pretty; }
.read-article p.first-para::first-letter {
  font-family: var(--display);
  float: left;
  font-size: 4.2em;
  line-height: 0.88;
  padding: 0.08em 0.12em 0 0;
  color: var(--ink);
  font-weight: 500;
}

.read-foot { margin-top: 40px; }
.read-end-glyph {
  text-align: center;
  font-size: 22px;
  letter-spacing: 0.5em;
  color: var(--ink-dim);
  margin: 32px 0 12px;
  text-indent: 0.5em;
}
.read-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 16px;
}
.read-nav-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  border: 1px solid var(--rule-soft);
  border-radius: 4px;
  text-align: left;
  transition: background 0.3s, border-color 0.3s, transform 0.3s;
}
.read-nav-btn:hover { border-color: var(--rule); background: var(--rule-soft); transform: translateY(-2px); }
.read-nav-btn.align-r { justify-content: flex-end; text-align: right; grid-column: 2; }
.read-nav-arrow { font-family: var(--display); font-size: 22px; color: var(--ink-mute); }
.read-nav-label { display: flex; flex-direction: column; gap: 4px; }
.read-nav-small {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.read-nav-title { font-family: var(--display); font-size: 14px; letter-spacing: 0.04em; color: var(--ink); }

/* ── Annotations (inline tokens) ──────────────────────────────────────── */
.ann {
  display: inline;
  position: relative;
  color: inherit;
  font: inherit;
  padding: 0 0.04em;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-decoration: underline dotted color-mix(in oklch, var(--ann-color) 75%, transparent);
  text-underline-offset: 4px;
  text-decoration-thickness: from-font;
  transition: background 0.25s, color 0.25s, text-decoration-color 0.25s;
  border-radius: 2px;
}
.ann:hover {
  background: color-mix(in oklch, var(--ann-color) 16%, transparent);
  color: color-mix(in oklch, var(--ann-color) 30%, var(--ink) 70%);
  text-decoration-color: var(--ann-color);
}
.ann.ann-active {
  background: color-mix(in oklch, var(--ann-color) 22%, transparent);
  color: color-mix(in oklch, var(--ann-color) 55%, var(--ink) 45%);
  text-decoration: underline solid var(--ann-color);
  text-decoration-thickness: 1.5px;
}
.ann.ann-bare { text-decoration: none; }
.ann.ann-bare:hover { text-decoration: underline dotted color-mix(in oklch, var(--ann-color) 75%, transparent); }

/* Different underline styles per type for accessibility */
.ann-person { text-decoration-style: dotted; }
.ann-place  { text-decoration-style: dashed; }
.ann-thing  { text-decoration-style: dotted; }
.ann-lore   { text-decoration-style: wavy; }

/* ── Annotation card (slide-in panel) ─────────────────────────────────── */
.ann-scrim {
  position: fixed; inset: 0;
  background: rgba(8, 7, 6, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 40;
}
.ann-scrim.is-open { opacity: 1; pointer-events: auto; }
.theme-bone .ann-scrim { background: rgba(20, 16, 12, 0.18); }

.ann-card {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--bg-2);
  border-left: 1px solid var(--rule);
  transform: translateX(110%);
  transition: transform 0.55s cubic-bezier(.2,.7,.2,1);
  z-index: 50;
  overflow-y: auto;
  box-shadow: -30px 0 60px rgba(0,0,0,0.45);
}
.ann-card.is-open { transform: translateX(0); }
.theme-bone .ann-card { box-shadow: -30px 0 60px rgba(0,0,0,0.18); }

.ann-card-inner { padding: 28px 28px 40px; }
.ann-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.ann-card-type {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ann-color);
}
.ann-card-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ann-color);
  box-shadow: 0 0 12px var(--ann-color);
}
.ann-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  font-family: var(--display);
  font-size: 20px;
  color: var(--ink-mute);
  transition: background 0.2s, color 0.2s;
}
.ann-close:hover { background: var(--rule-soft); color: var(--ink); }

.ann-card-name {
  font-family: var(--display);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
  color: var(--ink);
  text-wrap: balance;
}
.ann-card-role {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-mute);
  font-size: 14px;
}
.ann-rule { padding: 18px 0; }
.ann-rule span {
  display: block;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--rule), transparent);
}
.ann-card-summary {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  margin: 0 0 18px;
  text-wrap: pretty;
}
.ann-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; }
.ann-tag {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  border: 1px solid var(--rule);
  padding: 4px 10px;
  border-radius: 999px;
}
.ann-card-meta { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-top: 1px solid var(--rule-soft); border-bottom: 1px solid var(--rule-soft); margin-bottom: 22px; }
.ann-meta-row { display: flex; justify-content: space-between; align-items: baseline; }
.ann-meta-label {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.ann-meta-val {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-2);
  font-size: 14px;
}
.ann-see { margin-bottom: 24px; }
.ann-see-label {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 10px;
}
.ann-see-list { display: flex; flex-direction: column; gap: 6px; }
.ann-see-btn {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 12px;
  border: 1px solid var(--rule-soft);
  border-radius: 4px;
  text-align: left;
  transition: background 0.25s, border-color 0.25s, transform 0.25s;
  position: relative;
}
.ann-see-btn::before {
  content: "";
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 2px; height: 60%;
  background: var(--ann-color);
  opacity: 0.6;
}
.ann-see-btn:hover { background: var(--rule-soft); border-color: var(--rule); transform: translateX(4px); }
.ann-see-name { font-family: var(--display); font-size: 13px; letter-spacing: 0.04em; color: var(--ink); }
.ann-see-type { font-family: var(--display); font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-mute); }
.ann-card-foot {
  margin-top: 8px;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-align: center;
}

/* ── Extras: cards, songs, marginalia, map ────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 880px;
}
.entry-card {
  text-align: left;
  border: 1px solid var(--rule-soft);
  padding: 18px 20px;
  border-radius: 4px;
  position: relative;
  transition: background 0.25s, border-color 0.25s, transform 0.25s;
}
.entry-card::before {
  content: "";
  position: absolute; left: 0; top: 18px; bottom: 18px;
  width: 2px;
  background: var(--ann-color);
  opacity: 0.7;
}
.entry-card:hover { background: var(--rule-soft); border-color: var(--rule); transform: translateY(-2px); }
.entry-type {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ann-color);
  margin-bottom: 8px;
}
.entry-name {
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.05em;
  color: var(--ink);
  margin-bottom: 2px;
}
.entry-role {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-mute);
}
.entry-summary {
  margin-top: 12px;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  text-wrap: pretty;
}
.entry-card.is-large { padding: 20px 24px; }

/* Songs */
.songs {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}
.song { text-align: center; }
.song-title {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 16px;
}
.song-lines {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  line-height: 1.9;
  color: var(--ink);
}

/* Marginalia */
.margin-notes {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
}
.margin-notes li { display: grid; grid-template-columns: 28px 1fr; gap: 8px; color: var(--ink-2); }
.margin-num { font-family: var(--display); font-size: 11px; letter-spacing: 0.18em; color: var(--ink-mute); padding-top: 3px; }

/* Colophon */
.prose {
  width: 100%;
  max-width: 640px;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.75;
  color: var(--ink);
}
.prose p { margin: 0 0 1.1em; text-wrap: pretty; }
.colophon { text-align: center; }
.colophon-mark { font-size: 24px; letter-spacing: 0.5em; color: var(--ink-dim); margin-top: 28px; }

/* Map */
.map-wrap { width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 36px; align-items: center; }
.marrow-map { width: 100%; padding: 12px; border: 1px solid var(--rule-soft); border-radius: 4px; background: var(--bg-2); }
.map-svg { width: 100%; height: auto; display: block; }
.port-label {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  fill: var(--ink);
}
.port-mark.is-muted .port-label { fill: var(--ink-mute); font-style: italic; }
.port-mark { transition: filter 0.2s; }
.port-mark:hover:not(.is-muted) { filter: drop-shadow(0 0 8px var(--ink)); }
.map-sea-label {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.42em;
  fill: var(--ink-mute);
}
.map-cmp { font-family: var(--display); font-size: 9px; letter-spacing: 0.1em; fill: var(--ink-mute); }

/* Scrollbars */
.read-scroll::-webkit-scrollbar,
.act-inner::-webkit-scrollbar { width: 8px; }
.read-scroll::-webkit-scrollbar-thumb,
.act-inner::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
.read-scroll::-webkit-scrollbar-track,
.act-inner::-webkit-scrollbar-track { background: transparent; }

/* Mobile / narrow */
@media (max-width: 720px) {
  .topbar { padding: 14px 18px; }
  .topbar-title { display: none; }
  .read-article { padding: 60px 22px 100px; }
  .act-inner { padding: 40px 22px 60px; }
  .read-nav { grid-template-columns: 1fr; }
  .read-nav-btn.align-r { grid-column: 1; justify-content: flex-end; }
  .ann-card { width: 100vw; }
  .petal-label-1 { font-size: 48px; }
  .petal-label-2 { font-size: 36px; }
}

/* Custom extras: code, doctrine, ops, gear */
.code-wrap, .ops-wrap { display: flex; flex-direction: column; gap: 28px; }
.code-rules { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 14px; }
.code-rule { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 18px; padding: 14px 18px; border: 1px solid rgba(232,223,201,0.14); background: rgba(232,223,201,0.025); }
.code-rule-n { font-family: 'Cinzel', serif; font-size: 13px; letter-spacing: 0.18em; color: rgba(232,223,201,0.45); }
.code-rule-text { font-family: 'EB Garamond', serif; font-size: 18px; color: var(--ink); font-style: italic; }
.ops-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1px; background: rgba(232,223,201,0.10); border: 1px solid rgba(232,223,201,0.10); }
.ops-row { display: grid; grid-template-columns: 90px 1.2fr 2fr; align-items: baseline; gap: 18px; padding: 14px 18px; background: var(--bg); }
.ops-code { font-family: 'Cinzel', serif; font-size: 12px; letter-spacing: 0.20em; color: rgba(232,223,201,0.55); }
.ops-name { font-family: 'EB Garamond', serif; font-size: 17px; color: var(--ink); font-weight: 500; }
.ops-note { font-family: 'EB Garamond', serif; font-size: 15px; color: rgba(232,223,201,0.65); font-style: italic; }
@media (max-width: 720px) { .ops-row { grid-template-columns: 1fr; gap: 4px; padding: 12px 14px; } }




/* Background audio control — floating pill at bottom-right.
   Slim slider + speaker icon. Starts muted (browser autoplay policy);
   user can click the icon to toggle, or drag the slider above zero.
   The slider's filled portion is driven by --bg-audio-fill (set in JS). */
#bg-audio {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  background: transparent;
  border: none;
  opacity: 0.7;
  transition: opacity 200ms ease;
}
#bg-audio:hover, #bg-audio:focus-within { opacity: 1; }

#bg-audio-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(232, 223, 201, 0.18);
  color: rgba(232, 223, 201, 0.85);
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}
#bg-audio-toggle:hover {
  background: rgba(232, 223, 201, 0.08);
  color: rgba(232, 223, 201, 1);
  transform: scale(1.06);
}

/* Subtly pulse while muted to hint at "click for sound."
   Stops as soon as the user unmutes. */
#bg-audio.is-muted #bg-audio-toggle {
  animation: bgAudioPulse 2.6s ease-in-out infinite;
}
@keyframes bgAudioPulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(232, 223, 201, 0.0); }
  50%      { box-shadow: 0 0 0 5px rgba(232, 223, 201, 0.08); }
}

/* Range input — custom-styled across browsers. The track shows a filled
   portion via --bg-audio-fill (a percentage), so it reads as a level. */
#bg-audio-volume {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 4px;
  background: linear-gradient(
    to right,
    rgba(232, 223, 201, 0.85)   0%,
    rgba(232, 223, 201, 0.85)   var(--bg-audio-fill, 15%),
    rgba(232, 223, 201, 0.16)   var(--bg-audio-fill, 15%),
    rgba(232, 223, 201, 0.16)   100%
  );
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 0;
}
#bg-audio-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(232, 223, 201, 0.95);
  border: none;
  cursor: pointer;
  transition: transform 140ms ease;
}
#bg-audio-volume::-webkit-slider-thumb:hover { transform: scale(1.15); }
#bg-audio-volume::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(232, 223, 201, 0.95);
  border: none;
  cursor: pointer;
}
#bg-audio-volume:focus-visible {
  box-shadow: 0 0 0 2px rgba(232, 223, 201, 0.25);
  border-radius: 2px;
}

@media (max-width: 720px) {
  #bg-audio { bottom: 12px; right: 12px; padding: 5px 7px 5px 11px; gap: 8px; }
  #bg-audio-volume   { width: 76px; }
  #bg-audio-toggle   { width: 30px; height: 30px; font-size: 14px; }
}

/* Music credit — sits just above the audio pill. Stacked: song over artist.
   Subtle but readable — italic serif, bone color, brightens on hover. */
#bg-audio-credit {
  position: fixed;
  bottom: 62px;
  right: 18px;
  font-family: var(--serif);
  font-style: italic;
  text-align: right;
  text-decoration: none;
  color: rgba(232, 223, 201, 0.55);
  line-height: 1.25;
  z-index: 30;
  transition: color 200ms ease;
  pointer-events: auto;
}
#bg-audio-credit:hover { color: rgba(232, 223, 201, 0.92); }
#bg-audio-credit .bgc-song {
  font-size: 14px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
#bg-audio-credit .bgc-artist {
  font-size: 12px;
  letter-spacing: 0.04em;
  opacity: 0.78;
  margin-top: 2px;
}
@media (max-width: 720px) {
  /* On phones, collapse the credit to a single tiny line — just the artist —
     so it doesn't collide with the wordmark hint. The song title is hidden
     on this size only; full credit is still on tablet/desktop. */
  #bg-audio-credit {
    bottom: 50px;
    right: 14px;
    line-height: 1;
  }
  #bg-audio-credit .bgc-song { display: none; }
  #bg-audio-credit .bgc-artist {
    font-size: 11px;
    letter-spacing: 0.03em;
    margin-top: 0;
    white-space: nowrap;
    opacity: 0.85;
  }
}

/* ── Mobile wordmark + banner sizing ─────────────────────────────────────
   On phones, the title was overflowing (nowrap + big font + wide letter-
   spacing) and the rest of the stack was too tall. Scale everything down. */
@media (max-width: 720px) {
  .wordmark-title {
    font-size: clamp(18px, 7vw, 30px);
    letter-spacing: 0.28em;
    margin-bottom: 4px;
  }
  .wordmark-sub {
    font-size: clamp(14px, 4.2vw, 20px);
    margin-top: 6px;
  }
  .wordmark-byline {
    font-size: clamp(11px, 3.2vw, 14px);
  }
  .wordmark-hint {
    font-size: 9px;
    letter-spacing: 0.22em;
    margin-top: 12px;
  }
  .flower-coming-soon {
    font-size: clamp(16px, 5vw, 26px);
    letter-spacing: 0.24em;
  }
  .flower-stage {
    gap: 18px;
    padding: 20px 16px;
  }
  .flower-wrap {
    width: min(56vw, 50vh, 340px);
  }
}

/* ── Scene break ornament between paragraphs in the reader. The reader
   inserts these wherever a `"---"` sentinel appears in chapter.paragraphs. */
.scene-break {
  text-align: center;
  margin: 1.6em 0;
  letter-spacing: 0.6em;
  color: rgba(232, 223, 201, 0.30);
  font-size: 0.7em;
  user-select: none;
}

/* ── Act-header section divider in the chapter list. Drafted acts are bold
   and high-contrast; "to come" acts are dimmer and italicized. */
.chapter-section { list-style: none; padding: 0; margin: 28px 0 8px 0; }
.chapter-section:first-child { margin-top: 0; }
.chapter-section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 6px 0 8px 0;
  border-bottom: 1px solid rgba(232, 223, 201, 0.18);
  font-family: 'Cinzel', serif;
}
.chapter-section-num {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(232, 223, 201, 0.55);
}
.chapter-section-title {
  font-family: 'EB Garamond', serif;
  font-size: 19px;
  font-style: italic;
  color: var(--ink, #e8dfc9);
  flex: 1;
}
.chapter-section-status {
  font-family: 'EB Garamond', serif;
  font-size: 12px;
  letter-spacing: 0.10em;
  font-style: italic;
  color: rgba(232, 223, 201, 0.40);
}
.chapter-section-head.is-pending .chapter-section-title { color: rgba(232, 223, 201, 0.50); }
.chapter-section-head.is-pending { border-bottom-color: rgba(232, 223, 201, 0.08); }
.chapter-section-teaser {
  font-family: 'EB Garamond', serif;
  font-size: 14px;
  line-height: 1.55;
  color: rgba(232, 223, 201, 0.55);
  margin: 8px 0 4px 0;
  padding: 0 4px;
}
