/* ============================================================
   The Ledger — dark evidence scrollytelling.
   Ink-purple ground, gold accounting accents, Ubuntu Mono numerals.
   ============================================================ */

:root {
  --purple-900: #2E1A34;
  --purple-800: #472850;
  --purple-700: #5E3568;
  --purple: #7A4686;
  --purple-300: #B08CB8;
  --purple-200: #D3BFD8;
  --purple-100: #EFE7F1;
  --gold-800: #86642F;
  --gold-700: #A87E3F;
  --gold: #C69A58;
  --gold-300: #DDC194;
  --gold-200: #ECD9BC;
  --teal: #478D9A;
  --teal-bright: #6FB3BF;
  --mauve: #9A6B7E;
  --mauve-light: #C9A9B5;
  --plum: #593640;
  --ink: #201826;
  --ink-deep: #17111C;
  --paper-line: rgba(198, 154, 88, .12);
  --text: #EFE7F1;
  --text-dim: #B8AEC0;

  --font-display: "Ubuntu", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Ubuntu Mono", Consolas, monospace;
  --font-body: "Mulish", system-ui, sans-serif;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold-800); color: #fff; }

h1, h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.015em; }

/* ---------- topbar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(20px, 4vw, 44px);
  background: linear-gradient(180deg, rgba(23,17,28,.92), rgba(23,17,28,0));
  pointer-events: none;
}
.topbar a { pointer-events: auto; }
.topbar-brand img { height: 26px; width: auto; display: block; }
.topbar-right { display: flex; align-items: center; gap: 20px; pointer-events: auto; }
.topbar-tag {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--gold-300); opacity: .85;
  transition: opacity .4s;
}
.topbar.past-cover .topbar-tag { opacity: 0; }
.topbar-guide {
  font-size: 13px; font-weight: 700; color: var(--gold);
  text-decoration: none; border: 1px solid rgba(198,154,88,.4);
  padding: 7px 14px; border-radius: 6px;
  transition: background .25s, color .25s;
}
.topbar-guide:hover { background: var(--gold); color: var(--ink); }

/* ---------- chapter rail ---------- */
.chapter-rail {
  position: fixed; right: clamp(10px, 2vw, 28px); top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px;
  z-index: 80;
}
.chapter-rail a {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-dim); text-decoration: none;
  width: 34px; height: 30px;
  display: flex; align-items: center; justify-content: flex-end;
  position: relative; padding-right: 12px;
  transition: color .3s;
}
.chapter-rail a::before {
  content: ""; position: absolute; right: 0; top: 50%;
  width: 6px; height: 1.5px; background: currentColor;
  transition: width .3s var(--ease-out);
}
.chapter-rail a.active { color: var(--gold); }
.chapter-rail a.active::before { width: 10px; }
@media (max-width: 900px) { .chapter-rail { display: none; } }

/* ---------- cover ---------- */
.cover {
  min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(122,70,134,.28), transparent 60%),
    var(--ink-deep);
}
.cover-rules {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(180deg, transparent 0 47px, var(--paper-line) 47px 48px);
  mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 75%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 75%, transparent 100%);
}
.cover-inner { position: relative; text-align: center; padding: 100px 24px 60px; max-width: 760px; }
.cover-kicker {
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--purple-300); margin-bottom: 36px;
}
.cover-title {
  font-size: clamp(60px, 11.5vw, 124px);
  line-height: .94; margin: 0 0 30px; color: var(--text);
  white-space: nowrap;
}
@media (max-width: 500px) { .cover-title { white-space: normal; } }
.cover-title br { display: none; }
@media (max-width: 500px) { .cover-title br { display: block; } .cover-title { letter-spacing: -.01em; } }
.cover-rule {
  width: 84px; height: 3px; margin: 0 auto 30px;
  background: linear-gradient(90deg, var(--gold), var(--gold-300));
  border-radius: 2px;
}
.cover-sub { color: var(--text-dim); font-size: 17px; max-width: 58ch; margin: 0 auto 36px; }
.legend { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 72px; }

.chip {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 4px;
  border: 1px solid currentColor;
}
.chip-measured { color: var(--teal-bright); }
.chip-estimated { color: var(--gold-300); }
.chip-withdrawn { color: var(--mauve-light); }

.cover-scroll {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--gold);
  animation: coverPulse 2.6s ease-in-out infinite;
}
@keyframes coverPulse { 0%,100% { opacity: .45 } 50% { opacity: 1 } }

/* ---------- ledger layout ---------- */
.ledger {
  display: grid;
  grid-template-columns: minmax(380px, 46%) 1fr;
  background: var(--ink);
}
.viz-panel {
  position: sticky; top: 0;
  height: 100svh;
  overflow: hidden;
  border-right: 1px solid rgba(198,154,88,.14);
  background:
    radial-gradient(ellipse 80% 50% at 50% 110%, rgba(89,54,64,.35), transparent 60%),
    var(--ink-deep);
}
#viz { width: 100%; height: 100%; display: block; }
.viz-caption {
  position: absolute; left: 28px; bottom: 22px; right: 28px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-dim);
  margin: 0; transition: opacity .5s;
}

.chapters { padding: 0 clamp(24px, 5vw, 84px); }

.chapter {
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 96px 0;
  max-width: 620px;
}
.ch-no {
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .24em;
  text-transform: uppercase; color: var(--gold);
  margin: 0 0 14px;
}
.chapter h2 {
  font-size: clamp(30px, 3.6vw, 44px);
  margin: 0 0 22px; color: var(--text);
}
.chapter > p { color: var(--text-dim); margin: 0 0 1.1em; max-width: 58ch; }

/* entry lines — the accounting rows */
.entry-lines { list-style: none; margin: 30px 0 0; padding: 0; }
.entry-lines li {
  display: flex; align-items: baseline; gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(198,154,88,.14);
  opacity: 0; transform: translateY(12px);
  transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
}
.entry-lines li.in { opacity: 1; transform: none; }
.entry-lines li:first-child { border-top: 1px solid rgba(198,154,88,.14); }
.e-label { font-size: 15px; color: var(--text-dim); flex-shrink: 0; }
.e-dots {
  flex: 1; min-width: 30px;
  border-bottom: 1px dotted rgba(184,174,192,.35);
  transform: translateY(-4px);
}
.e-value {
  font-family: var(--font-mono); font-size: 20px; font-weight: 700;
  color: var(--gold-300); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.e-value.strike { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--mauve); color: var(--text-dim); }
.entry-lines .chip { padding: 3px 8px; font-size: 9.5px; }

.withdrawn-note {
  margin-top: 30px; padding: 22px 26px;
  border-left: 3px solid var(--mauve);
  background: rgba(154,107,126,.08);
  border-radius: 0 10px 10px 0;
}
.withdrawn-note p { margin: 0; font-size: 15px; color: var(--mauve-light); }

/* quote */
.ledger-quote { margin: 10px 0 26px; }
.ledger-quote blockquote {
  margin: 0 0 16px;
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(18px, 2vw, 22px); line-height: 1.55;
  color: var(--purple-200);
}
.ledger-quote figcaption {
  font-family: var(--font-mono); font-size: 13px;
  letter-spacing: .08em; color: var(--gold);
}

.close-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 34px; }
.btn-gold, .btn-line {
  display: inline-block; padding: 13px 26px;
  font-size: 15px; font-weight: 700; border-radius: 8px;
  text-decoration: none;
  transition: transform .25s var(--ease-out), box-shadow .25s, background .25s, color .25s;
}
.btn-gold { background: var(--gold); color: var(--ink-deep); }
.btn-gold:hover { background: var(--gold-300); transform: translateY(-2px); box-shadow: 0 10px 28px rgba(198,154,88,.25); }
.btn-line { color: var(--gold-300); border: 1.5px solid rgba(198,154,88,.4); }
.btn-line:hover { border-color: var(--gold); color: var(--gold); transform: translateY(-2px); }

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid rgba(198,154,88,.14);
  padding: 44px clamp(24px, 5vw, 84px);
  background: var(--ink-deep);
}
.footer-inner p { margin: 0 0 10px; color: var(--text-dim); font-size: 14px; max-width: 90ch; }
.footer-credit { opacity: .65; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .ledger { grid-template-columns: 1fr; }
  .viz-panel {
    position: sticky; top: 0; height: 38svh;
    border-right: none; border-bottom: 1px solid rgba(198,154,88,.14);
    z-index: 5;
  }
  .viz-caption { left: 16px; bottom: 10px; right: 16px; font-size: 10.5px; }
  .chapter { min-height: auto; padding: 72px 0; }
  .chapter:last-child { padding-bottom: 96px; }
  .topbar-tag { display: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cover-scroll { animation: none; }
  .entry-lines li { opacity: 1; transform: none; transition: none; }
}
