/* Diesel Winter — dark-first. Tokens follow the RAAK design guide
   (RAAK.work/raak-design-guide.md), inverted for night: the maroon darkened
   as ground, blush as text, RAAK red kept for one job only: the story.
   Light mode is a token swap for later; nothing below hard-codes a colour. */
:root {
  --bg: #160B0A;        /* ground */
  --fg: #F8DFDB;        /* text, blush */
  --accent: #FC221C;    /* RAAK red: the story side only */
  --muted: #8A7A76;     /* labels, axes, secondary text */
  --blush: #E7C2BA;     /* kickers, real-data lines */
  --wash: #2A1310;      /* dark wash, panels, map land */
  --hair: rgba(248, 223, 219, 0.15);
  --serif: "orpheus-pro", "Cormorant Garamond", Georgia, serif;
  --body: "adobe-garamond-pro", "EB Garamond", Georgia, serif;
  --mono: "Courier Prime", "Courier New", monospace;
  --rail: 220px;
  --col: 65ch;
  --gap: 48px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--body); font-size: 20px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--fg); text-decoration-color: var(--hair); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
img { display: block; max-width: 100%; height: auto; }

.kicker, .mono {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}

/* Masthead */
.masthead {
  position: relative; z-index: 1; background: var(--bg);
  max-width: 1100px; margin: 0 auto; padding: 96px 32px 48px;
}
.masthead h1 {
  margin: 12px 0 24px; font-family: var(--serif); font-weight: 500;
  font-size: clamp(56px, 9vw, 112px); line-height: 0.95; letter-spacing: -0.01em;
}
.masthead .stand { max-width: var(--col); font-size: 24px; line-height: 1.4; margin: 0 0 16px; }
.masthead .stand b { color: var(--accent); font-weight: 500; }
.masthead .byline { margin: 0 0 40px; color: var(--muted); }

.jump { display: flex; flex-wrap: wrap; gap: 6px 24px; border-top: 1px solid var(--hair); padding-top: 14px; }
.jump a, .jump span { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; text-decoration: none; }
.jump a { color: var(--blush); }
.jump span { color: var(--muted); opacity: 0.6; }

/* The one map, fixed behind the page; visible only while an opener is in view. */
#map { position: fixed; inset: 0; z-index: 0; opacity: 0; transition: opacity 1.2s ease; pointer-events: none; }
#map.on { opacity: 1; }
#map-canvas { position: absolute; inset: 0; }
#map .vignette {
  position: absolute; inset: 0;
  background:
    linear-gradient(to bottom, var(--bg) 0%, transparent 25%, transparent 60%, var(--bg) 100%),
    radial-gradient(ellipse 80% 70% at 50% 50%, transparent 55%, var(--bg) 100%);
}

/* Chapter openers: full height, transparent so the map shows through. */
.opener {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 72px; max-width: 1100px; margin: 0 auto;
}
.opener::before { /* settles the title on the map without hiding it */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 60%; z-index: -1;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--bg) 88%, transparent));
}
.opener .kicker { color: var(--blush); font-size: 13px; letter-spacing: 0.14em; }
.opener h2 {
  margin: 12px 0 0; max-width: 760px; font-family: var(--serif); font-weight: 500;
  font-size: clamp(44px, 6vw, 72px); line-height: 1.02;
}
.opener .place { margin-top: 18px; }

/* Chapter body: rail + text */
.chapter { position: relative; z-index: 1; background: var(--bg); }
.body {
  display: grid; grid-template-columns: var(--rail) minmax(0, var(--col));
  gap: var(--gap); max-width: 1100px; margin: 0 auto; padding: 64px 32px 96px;
}
.text { display: flex; flex-direction: column; gap: 26px; min-width: 0; }
.text p { margin: 0; }

/* The rail: sticky, changes as the text passes */
.rail { position: sticky; top: 40px; align-self: start; display: flex; flex-direction: column; gap: 22px; }
.rail .when { font-family: var(--mono); font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--blush); }
.rail .when .side.story { color: var(--accent); }
.rail .fig { display: flex; flex-direction: column; gap: 2px; }
.rail .num { font-family: var(--serif); font-size: 40px; line-height: 1; font-weight: 500; font-variant-numeric: tabular-nums; }
.rail .lab { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--muted); }
.rail .line { display: flex; gap: 12px; height: 140px; }
.rail .track { position: relative; width: 2px; background: var(--hair); }
.rail .track i { position: absolute; left: 0; width: 2px; display: block; }
.rail .track .done-real { top: 0; height: min(var(--pos, 0%), var(--cut, 100%)); background: var(--muted); }
.rail .track .done-story { top: var(--cut, 100%); height: max(0%, calc(var(--pos, 0%) - var(--cut, 100%))); background: var(--accent); }
.rail .track .dot { top: calc(var(--pos, 0%) - 3px); left: -2px; width: 6px; height: 6px; border-radius: 50%; background: var(--blush); }
.rail .track.story .dot { background: var(--accent); }
.rail .ends { display: flex; flex-direction: column; justify-content: space-between; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--muted); }

/* Things between paragraphs */
figure { margin: 8px 0; }
figcaption { margin-top: 10px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); line-height: 1.6; }
figcaption .story { color: var(--accent); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair figcaption { grid-column: 1 / -1; }
.wide img, .pair img { width: 100%; background: var(--wash); }

.chart { padding: 18px 0 14px; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.chart .chart-title { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.chart .mount { position: relative; }
.chart .key { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--muted); margin: -6px 0 10px; }
.chart svg .axis.zero { stroke: var(--muted); }
.chart svg .bar.focus { fill: var(--fg); fill-opacity: 1; stroke: var(--fg); }
.closing { margin: 24px 0 0; font-family: var(--serif); font-weight: 500; font-size: 40px; line-height: 1.1; color: var(--accent); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg text { font-family: var(--body); font-size: 14px; fill: var(--blush); }
.chart svg .title { font-family: var(--serif); font-size: 17px; fill: var(--fg); }
.chart svg .tick { font-family: var(--mono); font-size: 12px; fill: var(--muted); }
.chart svg .label { font-size: 14px; fill: var(--blush); }
.chart svg .grid, .chart svg .axis { stroke: var(--hair); stroke-width: 1; }
.chart svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart svg .line.real { stroke: var(--blush); }
.chart svg .line.forecast { stroke: var(--muted); stroke-dasharray: 5 5; }
.chart svg .line.story { stroke: var(--accent); stroke-dasharray: 5 5; }
.chart svg .bar.real { fill: var(--blush); fill-opacity: 0.85; }
.chart svg .bar.forecast { fill: none; stroke: var(--blush); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart svg .bar.story { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart svg .band.forecast { fill: var(--blush); fill-opacity: 0.08; stroke: var(--muted); stroke-dasharray: 5 5; }
.chart svg .lit { filter: brightness(1.25); }
.chart svg .ring { fill: var(--bg); }
.chart svg .dot.real { fill: var(--blush); }
.chart svg .dot.story { fill: var(--accent); }
.chart svg .divider { stroke: var(--accent); stroke-width: 1; opacity: 0.7; }
.chart svg .divider-label { fill: var(--accent); }
.chart svg .crosshair { stroke: var(--blush); stroke-width: 1; opacity: 0.5; pointer-events: none; }
.tip {
  position: absolute; z-index: 3; pointer-events: none; min-width: 150px;
  background: var(--wash); border: 1px solid var(--hair); padding: 10px 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--fg);
}
.tip .tip-date { color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }
.tip .tip-row b { font-family: var(--serif); font-size: 20px; font-weight: 500; margin-right: 8px; }
.tip .tip-row span { color: var(--blush); }
.tip .tip-row.story b { color: var(--accent); }
.numbers { margin-top: 12px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.numbers summary { cursor: pointer; letter-spacing: 0.1em; text-transform: uppercase; }
.numbers summary:hover { color: var(--fg); }
.numbers p { margin: 14px 0 6px; }
.numbers table { border-collapse: collapse; width: 100%; max-width: 420px; }
.numbers td { padding: 3px 12px 3px 0; border-bottom: 1px solid var(--hair); color: var(--blush); font-variant-numeric: tabular-nums; }
.numbers td:last-child { color: var(--muted); }
.numbers tr.story td { color: var(--accent); }
.numbers tr.forecast td { color: var(--muted); }

.rail .rail-pic { margin: 0; width: 132px; }
.rail .rail-pic img { width: 132px; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 20%; display: block; filter: saturate(0.85); }
.rail .rail-pic figcaption { font-size: 10px; letter-spacing: 0.06em; text-transform: none; line-height: 1.5; margin-top: 6px; }
.rail .rail-pic figcaption .real { text-transform: uppercase; color: var(--blush); }
.photo img { width: 100%; filter: saturate(0.85); }
.photo figcaption .real { color: var(--blush); }
.credits ul { margin: 0 0 14px; padding-left: 18px; font-size: 15px; color: var(--muted); line-height: 1.5; }
.credits ul a { color: var(--blush); }
.rail.both .line { height: 96px; }
.rail.both .rail-pic { display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: start; width: 160px; }
.rail.both .rail-pic img { width: 48px; aspect-ratio: 1 / 1; }
.rail.both .rail-pic figcaption { margin-top: 0; font-size: 9px; }
.rail .rail-card { width: 160px; border-top: 1px solid var(--hair); padding-top: 10px; }
.rail .rail-card[hidden] { display: none; }
.rail .card-title { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; line-height: 1.5; }
.rail .card-row { display: flex; flex-direction: column; margin-bottom: 6px; }
.rail .card-row b { font-family: var(--serif); font-size: 23px; line-height: 1.05; font-weight: 500; color: var(--fg); }
.rail .card-row.story b, .rail .rail-card.story .card-row b { color: var(--accent); }
.rail .card-row span { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: var(--muted); line-height: 1.5; }
.rail .card-row i { display: block; height: 4px; margin-top: 4px; background: var(--blush); }
.rail .card-row.story i, .rail .rail-card.story .card-row i { background: var(--accent); }
.rail .card-note { font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; color: var(--muted); line-height: 1.5; }

/* The order book */
.orderbook { padding: 18px 0 14px; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.orderbook .chart-title { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.orderbook .mount { position: relative; }
.ob-map { height: 360px; background: var(--wash); }
.ob-pin { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
.ob-counter { position: absolute; left: 16px; top: 16px; z-index: 2; background: color-mix(in srgb, var(--bg) 80%, transparent); padding: 12px 14px; }
.ob-line { font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: var(--blush); line-height: 1.3; }
.ob-line b { font-family: var(--serif); font-size: 34px; font-weight: 500; color: var(--fg); margin-right: 4px; font-variant-numeric: tabular-nums; }
.ob-line.story b { color: var(--accent); }
.ob-bars { display: block; width: 100%; height: auto; margin-top: 12px; overflow: visible; }
.ob-bars text { font-family: var(--mono); font-size: 12px; fill: var(--muted); }
.ob-bars .label { fill: var(--blush); }
.ob-bars .bar.real { fill: var(--blush); fill-opacity: 0.85; }
.ob-bars .bar.orders.real { fill: var(--blush); fill-opacity: 0.45; }
.ob-bars .bar.story { fill: var(--accent); fill-opacity: 0.9; }
.ob-bars .bar.orders.story { fill: var(--accent); fill-opacity: 0.5; }
@media (max-width: 760px) { .rail .rail-card { display: none; } .ob-map { height: 260px; } .ob-line b { font-size: 26px; } }

.rail .spark { display: block; width: 160px; height: 40px; margin-top: 8px; overflow: visible; }
.rail .spark path { fill: none; stroke-width: 1.5; stroke-linejoin: round; }
.rail .spark .spark-real { stroke: var(--blush); }
.rail .spark .spark-story { stroke: var(--accent); stroke-dasharray: 3 3; }
.rail .spark .spark-dot { fill: var(--blush); stroke: var(--bg); stroke-width: 2; }
.rail .spark .spark-dot.story { fill: var(--accent); }

/* The qualified-majority interactive */
.qmv { padding: 18px 0 14px; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.qmv .chart-title { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.qmv-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.qmv-presets[hidden] { display: none; } /* display:flex would otherwise beat the hidden attribute */
.qmv-presets button {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: var(--blush);
  background: none; border: 1px solid var(--hair); padding: 6px 10px; cursor: pointer; border-radius: 0;
}
.qmv-presets button:hover { border-color: var(--blush); }
.qmv-presets button.on { background: var(--wash); border-color: var(--blush); color: var(--fg); }
.qmv-tiles { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px; margin-bottom: 16px; }
.qmv-tiles .tile {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--muted);
  background: none; border: 1px solid var(--muted); border-radius: 0; cursor: pointer; padding: 0;
  display: flex; align-items: flex-end; justify-content: flex-start; padding: 2px 3px; box-sizing: border-box; overflow: hidden;
}
.qmv-tiles .tile:hover { border-color: var(--blush); color: var(--blush); }
.qmv-tiles .tile.yes { background: var(--blush); border-color: var(--blush); color: var(--bg); }
.qmv-bars { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.qmv-bar .qmv-label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 5px; }
.qmv-bar.ok .qmv-label { color: var(--blush); }
.qmv-bar .track { position: relative; height: 10px; background: var(--wash); }
.qmv-bar .track .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--muted); transition: width 0.3s; }
.qmv-bar.ok .track .fill { background: var(--blush); }
.qmv-bar .track .need { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--accent); }
.qmv-verdict { margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 500; color: var(--muted); }
.qmv-verdict.pass { color: var(--fg); }
.qmv[data-compact] .qmv-tiles { gap: 3px; margin-bottom: 12px; }
.qmv[data-compact] .qmv-tiles .tile { font-size: 9px; padding: 1px 2px; }
.qmv[data-compact] .qmv-verdict { font-size: 20px; }
.qmv figcaption { margin-top: 12px; }

.pull { margin: 8px 0; font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.15; color: var(--accent); }

.note { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }

/* Credits */
.credits { position: relative; z-index: 1; background: var(--bg); border-top: 1px solid var(--hair); }
.credits .inner { max-width: 1100px; margin: 0 auto; padding: 48px 32px 96px; display: grid; grid-template-columns: var(--rail) minmax(0, var(--col)); gap: var(--gap); }
.credits h3 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 28px; }
.credits p { margin: 0 0 14px; font-size: 17px; color: var(--blush); }

/* Phone: the rail becomes a strip under the top edge */
@media (max-width: 760px) {
  body { font-size: 18.5px; }
  .masthead { padding: 56px 16px 32px; }
  .opener { min-height: 55vh; padding: 32px 16px; }
  .body, .credits .inner { display: block; padding: 0 16px 64px; }
  .rail {
    top: 0; z-index: 2; margin: 0 -16px 24px; padding: 10px 16px 8px;
    background: var(--bg); border-bottom: 1px solid var(--hair);
    display: grid; grid-template-columns: auto auto; justify-content: space-between; gap: 6px 18px; align-items: end;
  }
  .rail .when { grid-column: 1 / -1; font-size: 11px; white-space: nowrap; }
  .rail .lab { white-space: nowrap; }
  .rail .num { font-size: 22px; }
  .rail .spark { width: 120px; height: 28px; margin-top: 4px; }
  .rail .lab { font-size: 9px; }
  .rail .line { grid-column: 1 / -1; height: auto; flex-direction: column; gap: 4px; }
  .rail .rail-pic { display: none; } /* on a phone the rail is a strip; the pictures wait for a later pass */
  .rail .track { width: 100%; height: 2px; }
  .rail .track i { top: 0; height: 2px; width: auto; }
  .rail .track .done-real { left: 0; width: min(var(--pos, 0%), var(--cut, 100%)); }
  .rail .track .done-story { left: var(--cut, 100%); width: max(0%, calc(var(--pos, 0%) - var(--cut, 100%))); }
  .rail .track .dot { left: calc(var(--pos, 0%) - 3px); top: -2px; width: 6px; height: 6px; }
  .rail .ends { flex-direction: row; }
  .pair { grid-template-columns: 1fr; }
  /* The qualified-majority interactive */
.qmv { padding: 18px 0 14px; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.qmv .chart-title { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.qmv-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.qmv-presets[hidden] { display: none; } /* display:flex would otherwise beat the hidden attribute */
.qmv-presets button {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: var(--blush);
  background: none; border: 1px solid var(--hair); padding: 6px 10px; cursor: pointer; border-radius: 0;
}
.qmv-presets button:hover { border-color: var(--blush); }
.qmv-presets button.on { background: var(--wash); border-color: var(--blush); color: var(--fg); }
.qmv-tiles { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px; margin-bottom: 16px; }
.qmv-tiles .tile {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--muted);
  background: none; border: 1px solid var(--muted); border-radius: 0; cursor: pointer; padding: 0;
  display: flex; align-items: flex-end; justify-content: flex-start; padding: 2px 3px; box-sizing: border-box; overflow: hidden;
}
.qmv-tiles .tile:hover { border-color: var(--blush); color: var(--blush); }
.qmv-tiles .tile.yes { background: var(--blush); border-color: var(--blush); color: var(--bg); }
.qmv-bars { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.qmv-bar .qmv-label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 5px; }
.qmv-bar.ok .qmv-label { color: var(--blush); }
.qmv-bar .track { position: relative; height: 10px; background: var(--wash); }
.qmv-bar .track .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--muted); transition: width 0.3s; }
.qmv-bar.ok .track .fill { background: var(--blush); }
.qmv-bar .track .need { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--accent); }
.qmv-verdict { margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 500; color: var(--muted); }
.qmv-verdict.pass { color: var(--fg); }
.qmv[data-compact] .qmv-tiles { gap: 3px; margin-bottom: 12px; }
.qmv[data-compact] .qmv-tiles .tile { font-size: 9px; padding: 1px 2px; }
.qmv[data-compact] .qmv-verdict { font-size: 20px; }
.qmv figcaption { margin-top: 12px; }

.pull { font-size: 28px; }
  .credits h3 { margin-bottom: 16px; }
}
