/* Twenty Nights — the yard, measured.
   A committed, art-directed single look: the scroll runs dusk → deep night → dawn.
   Every surface is painted explicitly; sections restate their own tokens. */

/* ---------- tokens ---------- */
:root {
  /* night grounds */
  --dusk:   #10141d;
  --night:  #0e1117;
  --deep:   #0a0d13;
  --dawn:   #f6f5f1;

  /* ink on night */
  --ink:    #eef1f5;
  --ink-2:  #a7aeba;
  --ink-3:  #6f7683;

  /* ink on dawn */
  --ink-d:  #1a1d23;
  --ink-d2: #575d68;
  --ink-d3: #8a9099;

  /* chart furniture, night */
  --card:   #151a23;
  --line:   #232a36;
  --grid:   #1a2029;

  /* chart furniture, dawn */
  --card-d: #fffefa;
  --line-d: #e2dfd4;
  --grid-d: #eceade;

  /* data hues — validated (dark surface #0e1117 / light surface #f6f5f1) */
  --amber:      #c38616;
  --blue:       #5887c3;
  --amber-day:  #b37903;
  --blue-day:   #346aac;

  /* decorative accent only (never a data mark, never body text) */
  --glow: #e8ae4a;

  --sans: "Hanken Grotesk", -apple-system, system-ui, "Segoe UI", sans-serif;
  --mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --col: 1120px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--night);
  color: var(--ink);
  font: 400 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
::selection { background: rgba(232, 174, 74, 0.28); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--glow); color: #14100a; padding: 10px 18px;
  font: 500 14px var(--sans); border-radius: 0 0 10px 0;
}
.skip:focus { left: 0; }

:is(a, summary, button):focus-visible {
  outline: 2px solid var(--glow); outline-offset: 3px; border-radius: 4px;
}

/* ---------- top bar (appears after the hero) ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px clamp(20px, 4vw, 40px);
  background: rgba(10, 13, 19, 0.72);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transform: translateY(-110%);
  transition: transform 0.45s var(--ease);
}
.bar.on { transform: none; }
.bar-mark { font: 600 15px/1 var(--sans); letter-spacing: 0.01em; }
.bar-link {
  font: 400 13px/1 var(--mono); color: var(--ink-2); text-decoration: none;
  padding: 8px 2px;
}
.bar-link:hover { color: var(--ink); }

/* ---------- shared type ---------- */
.eyebrow {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  font: 400 12.5px/1.4 var(--mono);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--glow);
  margin-bottom: 28px;
}
.eyebrow-right { color: var(--ink-3); letter-spacing: 0.1em; }

h2 {
  font: 600 clamp(34px, 5vw, 54px)/1.08 var(--sans);
  letter-spacing: -0.022em;
  text-wrap: balance;
  margin-bottom: 26px;
  max-width: 20ch;
}
.dek {
  font-size: clamp(17.5px, 2vw, 20px); line-height: 1.6;
  color: var(--ink-2); max-width: 62ch; margin-bottom: 22px;
}
.dek b, .dek em { color: var(--ink); }
.dek em { font-style: italic; }
.dek--follow { margin-top: 56px; }

/* ---------- bands (the sky) ---------- */
.band { padding: clamp(110px, 16vh, 170px) clamp(20px, 5vw, 48px); }
.band--dusk  { background: linear-gradient(180deg, #131826 0%, var(--dusk) 30%, var(--night) 100%); }
.band--night { background: var(--night); }
.band--deep  { background: var(--deep); }
.band--night + .band--deep { background: linear-gradient(180deg, var(--night) 0%, var(--deep) 18%); }

.col { max-width: var(--col); margin: 0 auto; }

/* dawn sections restate the token set — same roles, light values */
.band--dawn {
  background: var(--dawn);
  color: var(--ink-d);
  --ink: var(--ink-d); --ink-2: var(--ink-d2); --ink-3: var(--ink-d3);
  --card: var(--card-d); --line: var(--line-d); --grid: var(--grid-d);
  --glow: #9a6a06;
}

/* ---------- hero ---------- */
.hero {
  position: relative; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: clamp(22px, 4vw, 44px);
  overflow: hidden;
  background: #060708;
}
.hero-photo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 62% 40%;
}
.hero-scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 7, 8, 0.62) 0%, rgba(6, 7, 8, 0.18) 30%,
                    rgba(6, 7, 8, 0.12) 55%, rgba(9, 11, 15, 0.9) 88%, #0d1119 100%);
}
.hero-inner { position: relative; max-width: var(--col); width: 100%; margin: 0 auto; padding-top: 4vh; }
.hero .eyebrow { color: #f0d9a8; margin-bottom: clamp(28px, 6vh, 64px); }
.hero .eyebrow-right { color: rgba(240, 217, 168, 0.62); }
.hero-title {
  font: 250 clamp(72px, 13.5vw, 176px)/0.98 var(--sans);
  letter-spacing: -0.035em;
  text-shadow: 0 2px 40px rgba(0, 0, 0, 0.45);
}
.hero-dek {
  margin-top: 26px;
  font-size: clamp(17px, 2.2vw, 21px); line-height: 1.55;
  color: rgba(238, 241, 245, 0.9);
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.5);
}
.hero-stats {
  position: relative;
  max-width: var(--col); width: 100%; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, auto);
  justify-content: space-between; gap: 28px;
  padding-top: 26px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.hero-stats div { min-width: 0; }
.hero-stats dd {
  font: 300 clamp(30px, 4.6vw, 56px)/1 var(--sans);
  letter-spacing: -0.02em;
}
.hero-stats dt {
  font: 400 11.5px/1.4 var(--mono);
  letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 10px;
}

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- figures ---------- */
.fig {
  margin-top: 46px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: clamp(20px, 3.4vw, 36px);
}
.fig--bare { background: none; border: 0; padding: 0; }
.fig-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  margin-bottom: 20px;
}
.fig-title { font: 600 16.5px/1.3 var(--sans); letter-spacing: -0.005em; }
.fig-tag { font: 400 12px/1.4 var(--mono); color: var(--ink-3); letter-spacing: 0.06em; text-align: right; }
.fig-cap {
  margin-top: 20px;
  font-size: 13.5px; line-height: 1.6; color: var(--ink-3); max-width: 68ch;
}
.fig-cap b { color: var(--ink-2); font-weight: 600; }
.prov { font-family: var(--mono); font-size: 0.92em; letter-spacing: 0; color: var(--ink-3); }

.fig svg { display: block; width: 100%; height: auto; }
.fig svg text { font-family: var(--mono); }

/* the accessibility twin */
.tbl { margin-top: 14px; }
.tbl summary {
  cursor: pointer; font: 400 12.5px var(--mono); color: var(--ink-3);
  letter-spacing: 0.06em; width: max-content; padding: 4px 0;
}
.tbl summary:hover { color: var(--ink-2); }
.tbl table { border-collapse: collapse; margin-top: 12px; font-size: 13.5px; min-width: 320px; }
.tbl th {
  text-align: left; font: 500 11.5px var(--mono); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 6px 22px 6px 0; border-bottom: 1px solid var(--line);
}
.tbl td {
  padding: 7px 22px 7px 0; border-bottom: 1px solid var(--grid);
  color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.tbl td:first-child { color: var(--ink); }
.tbl-scroll { overflow-x: auto; }

/* ---------- funnel (ch 01) ---------- */
.funnel { margin-top: 54px; }
.funnel-step { text-align: center; }
.funnel-n {
  font: 250 clamp(64px, 11vw, 148px)/1 var(--sans);
  letter-spacing: -0.03em;
}
.funnel-n--accent { color: var(--glow); }
.funnel-k {
  margin-top: 10px;
  font: 400 12.5px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3);
}
.funnel-join {
  display: flex; align-items: center; gap: 18px;
  max-width: 560px; margin: 34px auto;
}
.funnel-rule { flex: 1; height: 1px; background: var(--line); }
.funnel-note { font: 400 12px/1.4 var(--mono); color: var(--ink-3); letter-spacing: 0.08em; white-space: nowrap; }
.funnel + .fig-cap { margin-top: 54px; text-align: center; margin-left: auto; margin-right: auto; }

/* ---------- asides (ch 02 stats row) ---------- */
.asides {
  margin-top: 34px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.aside {
  border: 1px solid var(--line); border-radius: 18px;
  padding: 22px 24px; background: rgba(21, 26, 35, 0.5);
}
.aside-n { font: 300 44px/1 var(--sans); letter-spacing: -0.02em; }
.aside-unit { font-size: 22px; color: var(--ink-2); margin-left: 4px; }
.aside-k { margin-top: 10px; font-size: 13.5px; line-height: 1.5; color: var(--ink-3); }

/* ---------- dial (ch 02) ---------- */
.dial-wrap { display: flex; justify-content: center; }
.dial { width: min(600px, 100%); margin-top: 6px; }
.dial svg { width: 100%; height: auto; display: block; }

/* ---------- strip figures (pixel-space plots, HTML labels) ---------- */
.strips { display: grid; gap: 22px; }
.strip-row { display: grid; gap: 8px; }
.strip-lab {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  min-height: 20px;
}
.strip-name { font: 600 14.5px/1.3 var(--sans); }
.strip-sub { font: 400 12px/1.4 var(--mono); color: var(--ink-3); letter-spacing: 0.03em; }
.strip-note { font: 400 12px/1.4 var(--mono); color: var(--glow); letter-spacing: 0.03em; }
.strip-mean { margin-left: auto; font: 400 12px/1.4 var(--mono); color: var(--ink-2); letter-spacing: 0.03em; }
.strip-plot { position: relative; }
.strip-plot svg { display: block; width: 100%; }
.cut-chip {
  position: absolute; left: var(--x); top: -30px; transform: translateX(-50%);
  font: 400 11.5px/1 var(--mono); color: var(--glow); letter-spacing: 0.05em;
  white-space: nowrap;
}
.strips.has-cut .strip-row:first-of-type { margin-top: 26px; } /* room for the cut chip */
.strip-axis {
  display: flex; justify-content: space-between;
  font: 400 11.5px/1 var(--mono); color: var(--ink-3); letter-spacing: 0.04em;
  padding-top: 2px;
}

/* gait annotations pinned by percent */
.gait-plot { margin-top: 22px; }
.gait-note {
  position: absolute; top: 6px; left: var(--x);
  font: 400 12px/1.4 var(--mono); color: var(--ink-2); letter-spacing: 0.03em;
  white-space: nowrap; transform: translateX(-50%);
}
.gait-note--end { transform: translateX(-88%); top: -8px; }
.gait-axis { position: relative; height: 16px; padding: 0; }
.gait-axis span { position: absolute; left: var(--x); transform: translateX(-50%); }

/* ---------- cast (ch 03) ---------- */
.cast { display: grid; gap: 18px; }
.cast-row {
  display: grid; grid-template-columns: 84px 1fr; gap: 20px; align-items: center;
}
.cast-face {
  width: 84px; height: 84px; border-radius: 20px; overflow: hidden;
  border: 1px solid var(--line); background: var(--deep);
  position: relative;
}
.cast-face img { width: 100%; height: 100%; object-fit: cover; }
.cast-face--none {
  display: flex; align-items: center; justify-content: center;
  border-style: dashed;
}
.cast-face--none span { font: 300 26px var(--sans); color: var(--ink-3); }
.cast-meta { min-width: 0; }
.cast-name-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 9px; }
.cast-name { font: 600 16.5px/1.2 var(--sans); white-space: nowrap; }
.cast-sub { font: 400 12px/1.3 var(--mono); color: var(--ink-3); letter-spacing: 0.04em; text-align: right; }
.cast-track { position: relative; height: 16px; }
.cast-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: calc(var(--w) * 1%); min-width: 3px;
  background: var(--amber);
  border-radius: 0 4px 4px 0;
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.9s var(--ease);
}
.in .cast-bar, .cast-bar.in { transform: none; }
.cast-n {
  position: absolute; left: calc(var(--w) * 1% + 12px); top: 50%;
  transform: translateY(-50%);
  font: 500 13.5px var(--sans); color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ---------- callouts ---------- */
.callout {
  margin-top: 44px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: clamp(22px, 3vw, 32px);
  background: linear-gradient(135deg, rgba(232, 174, 74, 0.06), rgba(21, 26, 35, 0.4) 55%);
  max-width: 760px;
}
.callout-title {
  font: 400 12.5px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--glow); margin-bottom: 12px;
}
.callout p:last-child { color: var(--ink-2); font-size: 16px; line-height: 1.65; }
.callout b, .callout em { color: var(--ink); }
.callout--honest { background: linear-gradient(135deg, rgba(88, 135, 195, 0.07), rgba(21, 26, 35, 0.4) 55%); }
.callout--honest .callout-title { color: var(--blue); }

/* ---------- sunrise ---------- */
.sunrise {
  position: relative; height: clamp(300px, 44vh, 460px);
  background: linear-gradient(180deg,
    var(--deep) 0%, #121727 26%, #232a44 46%, #4c4a66 62%,
    #8f7f8b 74%, #cbb6a6 84%, #ecdfc9 92%, var(--dawn) 100%);
  overflow: hidden;
}
.sunrise-glow {
  position: absolute; left: 50%; bottom: -12%;
  width: min(880px, 120vw); height: 60%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 100%, rgba(240, 190, 98, 0.5), rgba(240, 190, 98, 0) 62%);
}

/* ---------- trust (ch 07, on dawn) ---------- */
.trust {
  margin-top: 56px;
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 6vw, 80px);
  max-width: 860px;
}
.trust-n { font: 250 clamp(88px, 13vw, 168px)/1 var(--sans); letter-spacing: -0.035em; }
.trust-n span { font-size: 0.42em; font-weight: 300; color: var(--ink-2); margin-left: 2px; }
.trust-bar { height: 10px; border-radius: 0 4px 4px 0; background: var(--grid); margin: 22px 0 14px; position: relative; overflow: hidden; }
.trust-fill {
  position: absolute; inset: 0 auto 0 0; width: var(--w);
  border-radius: 0 4px 4px 0;
  transform: scaleX(0); transform-origin: left;
  transition: transform 1s var(--ease) 0.15s;
}
.in .trust-fill { transform: none; }
.trust-fill--day { background: var(--amber-day); }
.trust-fill--night { background: var(--blue-day); }
.trust-k { font-size: 15px; color: var(--ink-2); display: flex; align-items: center; gap: 9px; }
.key { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.key--day { background: var(--amber-day); }
.key--night { background: var(--blue-day); }
.fineprint {
  margin-top: 44px; max-width: 62ch;
  font-size: 14px; line-height: 1.65; color: var(--ink-2);
  border-left: 2px solid var(--line); padding-left: 20px;
}
.fineprint b { color: var(--ink); }

/* ---------- coda ---------- */
.coda { padding-top: clamp(60px, 8vh, 90px); }
.coda-links { display: flex; flex-wrap: wrap; gap: 14px; margin: 38px 0 74px; }
.btn {
  display: inline-block; text-decoration: none;
  font: 500 15px/1 var(--sans);
  padding: 15px 26px; border-radius: 999px;
  background: var(--ink-d); color: var(--dawn);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(26, 29, 35, 0.18); }
.btn--ghost { background: none; color: var(--ink-d); border: 1px solid var(--line-d); box-shadow: none; }
.prov-block { border-top: 1px solid var(--line); padding-top: 34px; max-width: 720px; }
.prov-title {
  font: 400 12px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 14px;
}
.prov-block ul { list-style: none; }
.prov-block li {
  font-size: 13.5px; line-height: 1.6; color: var(--ink-2);
  padding: 7px 0; border-bottom: 1px solid var(--grid);
}
.prov-block li:last-child { border-bottom: 0; }
.foot { margin-top: 84px; font-size: 13px; color: var(--ink-3); line-height: 1.7; }
.foot p + p { margin-top: 4px; }

/* ---------- tooltip ---------- */
.tip {
  position: fixed; z-index: 40; pointer-events: none;
  background: rgba(10, 13, 19, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px; padding: 9px 12px;
  font: 400 12.5px/1.5 var(--sans); color: var(--ink-2);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  max-width: 240px;
}
.tip b { display: block; font-size: 15px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }

/* ---------- gait pulse ---------- */
.pulse-ring { transform-origin: center; transform-box: fill-box; }
.pulsing .pulse-ring { animation: pulse var(--period, 1s) ease-out infinite; }
@keyframes pulse {
  0% { transform: scale(0.55); opacity: 0.9; }
  100% { transform: scale(2.1); opacity: 0; }
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .asides { grid-template-columns: 1fr; }
  .trust { grid-template-columns: 1fr; gap: 44px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); gap: 22px 28px; }
  .hero-stats dt { min-height: 2.9em; display: flex; align-items: flex-end; }
  }
@media (max-width: 560px) {
  h2 { letter-spacing: -0.015em; }
  .cast-row { grid-template-columns: 64px 1fr; gap: 14px; }
  .cast-face { width: 64px; height: 64px; border-radius: 16px; }
  .cast-n { font-size: 12.5px; }
  .eyebrow { flex-direction: column; gap: 6px; }
  .eyebrow-right { display: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .cast-bar, .trust-fill { transform: none; transition: none; }
  .hero-cue span { animation: none; }
  .pulsing .pulse-ring { animation: none; opacity: 0; }
  .bar { transition: none; }
}
