/* ==========================================================================
   CoolRoute — "Warm Paper Atlas" design system
   Source of truth: coolroute/src/uhi_battery/dashboard/theme.py (palette,
   Georgia serif + Inter body, hairline-framed white cards, honest callouts).
   Order: tokens → reset/base → typography → nav → sections → components →
   hero → per-section styles → night/veil → footer → reduced motion →
   fallback gating → responsive.
   ========================================================================== */

/* ---------- 1. tokens ---------- */

:root {
  --paper: #f7f5f1;
  --paper-deep: #efece6;
  --ink: #1a2330;
  --night: #141b26;
  --night-edge: #2a3546;
  --ink-soft: #38445a; /* body text darkened for readability (was #4a5568, 7.5:1) → 9.8:1 on white */
  /* muted darkened to 7.2:1 on white (was #8a93a2, 3.10:1) so secondary text reads clearly too.
     -muted-dim keeps the old faint tone for text on dark ink (terminal comments). */
  --muted: #4d5866;
  --muted-dim: #8a93a2;
  --card: #ffffff;
  --line: #e3ddd2;
  --accent: #c75d2c; /* data ink: lines, dots, borders, icons */
  --accent-ink: #a34a20; /* accent as TEXT on light bg (AA: 5.0:1+ on paper-deep/callout) */
  --accent-deep: #b04e1f; /* accent as BACKGROUND under white/paper text (4.9:1+) */
  --accent-bright: #d97a45; /* accent as TEXT on dark ink/night (5.1:1+) */
  --hot: #d7301f;
  --cold: #2b8cbe;
  --cold-ink: #175a86; /* cold as TEXT on light bg (7.4:1 solid, 4.6:1 at 0.8 opacity) */
  --good: #2f855a;
  --warn: #b7791f; /* borders / band edges only */
  --warn-ink: #8a5a13; /* warn as TEXT on light bg (5.0:1+) */
  --callout: #fbf3e6;
  --grid: #e8e3d9;

  --font-serif: Georgia, 'Times New Roman', serif;
  --font-body: Inter, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 35, 48, 0.05);
  --nav-h: 64px;
}

/* ---------- 2. reset / base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  background: var(--paper); /* veil paints above this, below content */
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: transparent;
}

img, svg, canvas { max-width: 100%; }
h1, h2, h3, h4, p, ul, ol, blockquote, table, pre { margin: 0; }
ul, ol { padding: 0; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(199, 93, 44, 0.22); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

/* ---------- 3. typography ---------- */

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 700; letter-spacing: -0.01em; }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

.section-title {
  font-size: clamp(1.8rem, 3.6vw, 2.6rem);
  line-height: 1.15;
  margin: 0.7rem 0 0.9rem;
}

.lede {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 46rem;
}

caption, .caption, small { color: var(--muted); }

/* ---------- 4. nav + progress ---------- */

.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(247, 245, 241, 0.86);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  height: var(--nav-h);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.4rem;
}

.wordmark {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}
.wordmark:hover { text-decoration: none; color: var(--accent-ink); }

.nav-links {
  margin-left: auto;
  display: flex;
  gap: 1.05rem;
}
.nav-links a {
  font-size: 0.84rem;
  color: var(--ink-soft);
  padding: 0.2rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-links a.is-active { color: var(--accent-ink); border-bottom-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-deep);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.68rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(199, 93, 44, 0.25); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { box-shadow: var(--shadow); border-color: var(--muted); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.82rem; }

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  padding: 0.4rem;
}
.nav-toggle-box { display: block; width: 22px; }
.nav-toggle-box span {
  display: block;
  height: 2px;
  margin: 5px 0;
  background: var(--ink);
  border-radius: 2px;
}

.scroll-progress {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  pointer-events: none;
}
.scroll-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2c3a8c, #2b8cbe 20%, #7bccc4 40%, #edf8b1 55%, #fd8d3c 70%, #d7301f 85%, #7f0a0a);
  transform: scaleX(0);
  transform-origin: left center;
}

/* ---------- 5. sections ---------- */

main { display: block; }

.section {
  padding: 6.5rem 0;
  scroll-margin-top: calc(var(--nav-h) + 12px);
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section-head { max-width: 62rem; }

.head-rule {
  display: block;
  width: 3.4rem;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  margin-bottom: 1.1rem;
}

.mask { display: block; overflow: hidden; }
.mask-line { display: block; }

/* ---------- 6. components ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.note-callout {
  background: var(--callout);
  border-left: 3px solid var(--warn);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  font-size: 0.93rem;
  color: var(--ink-soft);
  margin-top: 2.2rem;
}
.note-callout strong { color: var(--ink); }

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 0.28rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pill-warm { background: var(--accent-deep); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.formula-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
}
.formula-chip-muted { color: var(--muted); }

.term {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 1.15rem 1.3rem;
  overflow-x: auto;
}
.term pre { margin: 0; }
.term code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  white-space: pre;
}
.term-c { color: var(--muted-dim); }
.term-cursor { color: var(--accent-bright); animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.stylised-tag,
.live-tag,
.scan-tag {
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
}
.stylised-tag { color: var(--warn-ink); border: 1px solid var(--warn); margin-left: 0.4rem; }
.live-tag { color: var(--good); border: 1px solid var(--good); margin-left: 0.4rem; }
.scan-tag { color: var(--warn-ink); margin-left: 0.4rem; }

/* demo fallbacks: visible without JS, hidden once JS boots */
.demo-fallback { display: block; }
html.js .demo-fallback { display: none; }
.fallback-note { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }

/* ---------- 7. hero ---------- */

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  background: var(--night);
  color: var(--paper);
  overflow: hidden;
  padding: calc(var(--nav-h) + 3rem) 1.5rem 4rem;
}

#hero-canvas {
  position: absolute;
  inset: -5%;
  width: 110%;
  height: 110%;
  will-change: transform; /* continuous pointer parallax + scrub scale */
}

.hero-shade {
  position: absolute;
  inset: 0;
  background: var(--night);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}
/* Mobile (≤960px): hero exit dim as a one-shot class toggle — no scroll-tied
   compositing. Desktop drives the same layer with a scrubbed opacity tween. */
body.hero-dim .hero-shade {
  opacity: 0.45;
  transition: opacity 0.5s ease;
}

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: 62rem;
  margin: 0 auto;
  width: 100%;
}

.hero-title {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  line-height: 1.06;
  margin: 1rem 0 1.6rem;
}
.hero .eyebrow { color: rgba(247, 245, 241, 0.66); }

.hero-lede p { max-width: 44rem; margin-bottom: 0.9rem; color: rgba(247, 245, 241, 0.88); }
.hero-lede strong { color: #f0b695; }

.hero-quote {
  position: relative;
  border-left: 3px solid var(--accent);
  padding: 0.4rem 0 0.4rem 1.4rem;
  margin: 1.8rem 0;
  max-width: 40rem;
}
.hero-quote .quote-mark {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 2.6rem;
  line-height: 0;
  color: var(--accent);
  vertical-align: -0.35em;
  margin-right: 0.2rem;
}
.hero-quote p {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--paper);
  vertical-align: middle;
}
.hero-quote cite {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  font-style: normal;
  color: rgba(247, 245, 241, 0.6);
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 1.6rem 0 2.2rem;
}
.hero-ctas .btn-ghost { color: var(--paper); border-color: var(--night-edge); }
.hero-ctas .btn-ghost:hover { border-color: rgba(247, 245, 241, 0.5); }

.hero-stats {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 0 0 1.6rem;
}
.stat-chip {
  /* #222832 = old rgba(247,245,241,0.06) veil pre-composited over --night;
     solid so text contrast is measured against the real backing colour */
  background: #222832;
  border: 1px solid var(--night-edge);
  border-radius: var(--radius);
  padding: 0.75rem 1.05rem;
  min-width: 9.5rem;
}
.chip-value {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--paper);
}
.chip-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(247, 245, 241, 0.6);
  margin-top: 0.2rem;
}

.hero-disclaimer {
  /* #242a34 = old rgba(247,245,241,0.07) veil pre-composited over --night */
  background: #242a34;
  border: 1px solid var(--night-edge);
  color: rgba(247, 245, 241, 0.78);
  font-weight: 500;
}

/* ---------- 8. problem ---------- */

.problem-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.6rem;
  margin-top: 3rem;
}

.problem-card { padding: 1.7rem; }
.problem-card h3 { font-size: 1.2rem; margin: 0.9rem 0 0.6rem; }
.problem-card p { font-size: 0.95rem; color: var(--ink-soft); }
.problem-card strong { color: var(--ink); }

.card-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--paper-deep);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.card-icon svg { width: 26px; height: 26px; }

.thermo { margin-top: 3.4rem; }
.thermo-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.8rem;
}
.thermo-track {
  position: relative;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  overflow: hidden;
}
.thermo-fill {
  position: absolute;
  inset: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2b89bc, #72c5c3 25%, #efeca4 50%, #ef6a31 75%, #9f1812);
  transform-origin: left center;
}
.thermo-marker {
  position: absolute;
  top: 50%;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink);
  transform: translateY(-50%);
}
.thermo-min { left: 8px; }
.thermo-max { right: 8px; }

.thermo-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.thermo-badge {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--accent-ink);
  background: var(--callout);
  border: 1px solid var(--warn);
  border-radius: 999px;
  padding: 0.25rem 0.9rem;
}
.thermo-caption { font-size: 0.82rem; color: var(--muted); margin-top: 0.8rem; max-width: 52rem; }

.why-matters { margin-top: 3.4rem; }
.why-title { font-size: 1.25rem; margin-bottom: 1.2rem; }
.why-list { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; counter-reset: why; }
.why-list li { display: flex; gap: 0.9rem; align-items: flex-start; }
.why-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.why-icon svg { width: 22px; height: 22px; }
.why-list h4 { font-size: 1.02rem; margin-bottom: 0.25rem; }
.why-list p { font-size: 0.88rem; color: var(--ink-soft); }

/* ---------- 9. pipeline (how it works) ---------- */

.pipeline {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  gap: 3.5rem;
  align-items: start;
  margin-top: 3rem;
}

.pipeline-sticky {
  position: sticky;
  top: calc(var(--nav-h) + 28px);
}
#pipe-svg { width: 100%; height: auto; display: block; }

.pipe-node rect {
  fill: var(--card);
  stroke: var(--line);
  stroke-width: 1.5;
  transition: fill 0.3s ease, stroke 0.3s ease;
}
.pipe-node text {
  font-family: var(--font-body);
  font-size: 13px;
  fill: var(--ink);
  transition: fill 0.3s ease;
}
.pipe-node.is-lit rect { fill: var(--accent-deep); stroke: var(--accent-deep); }
/* background-color mirrors the lit rect fill: contrast tools read CSS backgrounds,
   not SVG rect fills, and paper-on-accent-deep is the measured pairing (4.9:1) */
.pipe-node.is-lit text {
  fill: var(--paper);
  background-color: var(--accent-deep);
}
a:hover .pipe-node rect { stroke: var(--accent); }

.pipe-links line { stroke: var(--line); stroke-width: 2; }
#pipe-dot { fill: var(--accent); stroke: var(--paper); stroke-width: 2; }

.pipeline-step {
  padding: 1.9rem 0 1.4rem;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: calc(var(--nav-h) + 40px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.pipeline-step:last-child { border-bottom: 0; }
.pipeline-steps.is-armed .pipeline-step { opacity: 0.35; }
.pipeline-steps.is-armed .pipeline-step.is-active { opacity: 1; }

.step-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-ink);
  margin-bottom: 0.4rem;
}
.pipeline-step h3 { font-size: 1.45rem; margin-bottom: 0.6rem; }
.pipeline-step p { color: var(--ink-soft); max-width: 34rem; }
.pipeline-step strong { color: var(--ink); }

.delivery-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.55rem;
  align-items: baseline;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.95rem 1.25rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin-top: 3rem;
}
.delivery-strip span:first-child { font-weight: 700; color: var(--ink); }

/* ---------- 10. demo shell (shared) ---------- */

.demo-shell {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 2.4rem;
  align-items: start;
  margin-top: 3rem;
}

.demo-canvas-wrap {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.demo-canvas-wrap canvas { display: block; width: 100%; }

#heat-canvas { aspect-ratio: 3 / 2; cursor: crosshair; }
#soh-canvas { aspect-ratio: 16 / 10; }

.demo-panel { display: flex; flex-direction: column; gap: 1.15rem; }
.demo-panel-card { padding: 1.5rem; }
.demo-panel-title { font-size: 1.15rem; margin-bottom: 0.2rem; }

.demo-control label { display: block; font-size: 0.86rem; font-weight: 600; margin-bottom: 0.45rem; }
.demo-slider-value { font-family: var(--font-mono); font-size: 0.76rem; color: var(--muted); margin-top: 0.4rem; }

.demo-toggle { display: flex; align-items: center; gap: 0.6rem; }
.demo-toggle label { margin: 0; }
.demo-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  /* bar drawn on the track pseudos; side padding (= half thumb width) keeps
     the thumb inside the box at min/max instead of overhanging the ends */
  padding: 0 9px;
  background: transparent;
  outline: none;
  margin: 0.3rem 0 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(26, 35, 48, 0.3);
  cursor: pointer;
  margin-top: -6px; /* center the 18px thumb on the 6px track */
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(26, 35, 48, 0.3);
  cursor: pointer;
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.readout-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  display: grid;
  gap: 0.4rem;
}
.readout { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.88rem; }
.readout-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding-top: 0.2em;
  white-space: nowrap;
}
.readout-value { font-weight: 600; color: var(--ink); text-align: right; }
.readout-note { font-size: 0.72rem; color: var(--muted); }
.readout-mini { padding: 0.7rem 0.9rem; }

.pareto-readouts { display: grid; gap: 0.6rem; }

.alpha-ends {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.colorbar { margin-top: 0.2rem; }
.colorbar-scale {
  position: relative;
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, #2c3a8c, #2b8cbe 20%, #7bccc4 40%, #edf8b1 55%, #fd8d3c 70%, #d7301f 85%, #7f0a0a);
}
.colorbar-tick {
  position: absolute;
  top: -4px;
  width: 2px; height: 20px;
  background: var(--ink);
  opacity: 0.75;
}
.colorbar-ends {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}
.colorbar-refs { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); margin-top: 0.15rem; }

#heat-curve { width: 100%; height: auto; }
.curve-grid line { stroke: var(--grid); stroke-width: 1; }
#heat-curve-path { stroke: var(--accent); stroke-width: 2; }
#heat-curve-marker { fill: var(--ink); stroke: var(--paper); stroke-width: 1.5; }

.foot-note { font-size: 0.8rem; color: var(--muted); margin-top: 1.1rem; max-width: 52rem; }

/* ---------- 11. energy demo ---------- */

.bars {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 2rem 0 0.4rem;
}
.bars-band {
  position: absolute;
  top: 0.6rem;
  bottom: 2.6rem;
  /* track column starts at 11.5rem name + 0.7rem gap; track width is
     100% - 11.5rem - 6.5rem - 2*0.7rem */
  left: calc(12.2rem + (100% - 19.4rem) * 0.40);
  width: calc((100% - 19.4rem) * 0.60);
  /* #f9f3eb = old rgba(183,121,31,0.09) tint pre-composited over the white card */
  background: #f9f3eb;
  border-left: 1px dashed var(--warn);
  border-right: 1px dashed var(--warn);
  border-radius: 4px;
}
.bars-band-label {
  position: absolute;
  top: -1.15rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--warn-ink);
  white-space: nowrap;
}
.bar-row {
  display: grid;
  grid-template-columns: 11.5rem 1fr 6.5rem;
  gap: 0.7rem;
  align-items: center;
  position: relative;
  z-index: 1;
}
.bar-name { font-size: 0.84rem; font-weight: 600; color: var(--ink-soft); }
.bar-track {
  position: relative;
  height: 20px;
  background: var(--paper-deep);
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: var(--w, 0%);
  border-radius: 6px;
  background: var(--cold);
  transform-origin: left center;
}
.bar-fill-hot { background: var(--accent); }
.bar-val { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-soft); }
.bar-val-strong { color: var(--ink); font-weight: 700; }

.mc-badge {
  align-self: flex-end;
  display: inline-flex;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent-deep);
  border-radius: 999px;
  padding: 0.25rem 0.95rem;
  margin: -0.4rem 0 0;
}

.dist-strip { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-soft); }
.cond-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
}

.scan-panel h4 { font-family: var(--font-body); font-size: 0.85rem; font-weight: 700; }
#scan-svg { width: 100%; height: auto; margin-top: 0.5rem; }
.scan-axis line { stroke: var(--line); stroke-width: 1.5; }
.scan-ticks text { font-family: var(--font-mono); font-size: 9.5px; fill: var(--ink-soft); text-anchor: middle; }
.scan-ticks text:first-child { text-anchor: start; }
.scan-lane text { font-family: var(--font-mono); font-size: 10px; font-weight: 600; fill: var(--ink-soft); }
/* #8a5a13 = --warn darkened to ~5.9:1 on white (AA) — small italic text needs it */
.scan-lane .scan-insensitive { font-size: 11px; fill: #8a5a13; font-style: italic; }
.scan-dot { fill: var(--accent); stroke: var(--ink); stroke-width: 1; }
.scan-leader { stroke: #a49d90; stroke-width: 1; }
.scan-dot-label { font-family: var(--font-mono); font-size: 11px; font-weight: 500; fill: var(--ink); }
.scan-caption { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-soft); margin-top: 0.4rem; }

.energy-readout { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.energy-big { font-family: var(--font-serif); font-size: 3.2rem; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 3.4em; }
/* 3.4em ≈ worst-case "54.81 Wh/km" width: keeps the eta-gauge pinned while
   the count tween changes digit count (e.g. 6.52 → 48.61). */
.energy-unit { font-family: var(--font-body); font-size: 0.95rem; color: var(--muted); margin-left: 0.5rem; }

.eta-gauge { text-align: center; }
.eta-gauge svg { width: 118px; }
.eta-track { stroke: #e7e0d4; stroke-width: 8; stroke-linecap: round; }
.eta-zone { stroke: var(--good); stroke-width: 8; stroke-linecap: round; }
#en-eta-needle { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.eta-gauge circle { fill: var(--ink); }
.eta-cap { display: block; font-family: var(--font-mono); font-size: 0.64rem; color: var(--muted); margin-top: 0.2rem; }

.decomp-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper-deep);
  border: 1px solid var(--line);
}
.decomp-seg { display: block; height: 100%; }
.decomp-roll { background: #7bccc4; width: 62%; }
.decomp-aero { background: #2b8cbe; width: 38%; }
.decomp-grade { background: var(--accent); width: 0%; }
.decomp-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 0.55rem;
}
.decomp-legend li { display: flex; align-items: center; gap: 0.4rem; }
.decomp-legend span[id$="-val"] { font-family: var(--font-mono); color: var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-roll { background: #7bccc4; }
.dot-aero { background: #2b8cbe; }
.dot-grade { background: var(--accent); }

/* ---------- 12. pareto demo ---------- */

.demo-map-wrap { aspect-ratio: 400 / 340; }
#pareto-map, #pareto-map svg { display: block; width: 100%; height: 100%; }

.map-grid line { stroke: var(--grid); stroke-width: 1; }
.map-warm-street { transition: opacity 0.5s ease; }
.map-coast { stroke: var(--cold); stroke-width: 2.5; }
.map-water-label { font-family: var(--font-serif); font-style: italic; font-size: 13px; fill: var(--cold-ink); opacity: 0.8; }
.map-district-dot { fill: var(--ink-soft); }
.map-district-label { font-family: var(--font-body); font-size: 12px; font-weight: 600; fill: var(--ink); }
.map-od { fill: var(--ink); stroke: var(--paper); stroke-width: 2; }
.map-route { stroke: var(--accent); stroke-width: 4.5; stroke-linecap: round; }
.map-route-ghost { stroke: var(--ink-soft); stroke-width: 2; stroke-dasharray: 5 5; opacity: 0.35; }

#pareto-scatter { width: 100%; height: auto; }
.scatter-grid line { stroke: var(--line); stroke-width: 1.5; }
.axis-label { font-family: var(--font-body); font-size: 10px; fill: var(--muted); }
.frontier-point { cursor: pointer; }
.frontier-point circle { fill: var(--card); stroke: var(--accent); stroke-width: 2; transition: fill 0.2s ease; }
.frontier-point.is-near circle { fill: var(--accent); }
.frontier-label { font-family: var(--font-mono); font-size: 8.5px; fill: var(--muted); }
#pareto-selected {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  animation: pulse-ring 2.2s ease-out infinite;
}
@keyframes pulse-ring {
  0% { stroke-opacity: 0.9; r: 9; }
  70% { stroke-opacity: 0.25; r: 13; }
  100% { stroke-opacity: 0.9; r: 9; }
}

.scatter-caption { font-size: 0.84rem; color: var(--ink-soft); }
.obj-note { font-size: 0.78rem; color: var(--ink-soft); border-left: 2px solid var(--line); padding-left: 0.8rem; }

/* ---------- 13. battery demo ---------- */

.curve-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  padding: 0.8rem 1.1rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.curve-legend li { display: flex; align-items: center; gap: 0.4rem; transition: opacity 0.2s ease; }
.curve-legend li.is-near { font-weight: 700; color: var(--ink); }
.curve-legend li:not(.is-near) { opacity: 0.6; }
.curve-legend .dot { width: 12px; height: 4px; border-radius: 2px; }

.gauge-wrap { text-align: center; }
.gauge-wrap svg { width: 210px; }
.gauge-track { stroke: #e7e0d4; stroke-width: 14; stroke-linecap: round; }
.gauge-value { stroke: var(--accent); stroke-width: 14; stroke-linecap: round; }
.gauge-threshold { stroke: var(--ink); stroke-width: 2.5; }
.gauge-hub { fill: var(--ink); }
.gauge-num { font-family: var(--font-serif); font-size: 2.1rem; color: var(--ink); margin-top: -2.4rem; }
.gauge-sentence { font-size: 0.88rem; color: var(--ink-soft); margin-top: 0.3rem; }

.soh-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.soh-card { padding: 1.05rem 1.15rem; }
.soh-card h3 { font-size: 0.98rem; margin-bottom: 0.35rem; }
.soh-card p { font-size: 0.82rem; color: var(--ink-soft); }

.label-strip {
  font-size: 0.76rem;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 0.75rem;
}

/* ---------- 14. results ---------- */

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.4rem;
  margin-top: 3rem;
}
.metric-card { padding: 1.6rem; }
.metric-value {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  line-height: 1.1;
  color: var(--ink);
}
.metric-unit { font-size: 1.05rem; color: var(--muted); }
.metric-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin-top: 0.5rem;
}
.metric-note { font-size: 0.84rem; color: var(--ink-soft); margin-top: 0.55rem; }

.chip-strip {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 2rem;
}

.review-block {
  margin-top: 3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 1.7rem;
}
.review-title { font-size: 1.25rem; margin-bottom: 1.1rem; }
.review-table { width: 100%; border-collapse: collapse; max-width: 680px; }
.review-table th, .review-table td {
  text-align: left;
  padding: 0.55rem 0.8rem 0.55rem 0;
  border-bottom: 1px solid var(--grid);
  font-size: 0.9rem;
}
.review-table thead th {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.review-table tbody th { font-weight: 600; color: var(--ink-soft); }
.review-table .old { color: var(--muted); font-family: var(--font-mono); font-size: 0.84rem; }
.review-table .arrow { color: var(--accent-ink); width: 2rem; transform-origin: left center; }
.review-table .new { color: var(--accent-ink); font-family: var(--font-serif); font-weight: 700; font-size: 1.05rem; }
.review-caption { font-size: 0.85rem; color: var(--ink-soft); margin-top: 1rem; font-style: italic; }

/* ---------- 15. product ---------- */

.product-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 3rem;
  margin-top: 3rem;
  align-items: start;
}
.product-col-title { font-size: 1.2rem; margin-bottom: 1.2rem; }

.tab-list { list-style: none; display: grid; gap: 0.9rem; }
.tab-card { display: flex; gap: 1rem; padding: 1.1rem 1.2rem; }
.tab-icon {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--paper-deep);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.tab-icon svg { width: 22px; height: 22px; }
.tab-card h4 { font-size: 1.02rem; margin-bottom: 0.2rem; }
.tab-card p { font-size: 0.83rem; color: var(--ink-soft); }

.api-table { width: 100%; border-collapse: collapse; }
.api-table td {
  padding: 0.5rem 0.6rem 0.5rem 0;
  border-bottom: 1px solid var(--grid);
  font-size: 0.84rem;
  color: var(--ink-soft);
  vertical-align: top;
}
.api-table code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink);
  background: var(--paper-deep);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
}
.api-footnote { font-size: 0.76rem; color: var(--muted); margin-top: 0.8rem; }

.curl-line { font-size: 0.78rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.curl-line code { font-family: var(--font-mono); background: var(--paper-deep); border-radius: 4px; padding: 0.12rem 0.4rem; }

/* ---------- 16. honesty + night veil ---------- */

.night-veil {
  position: fixed;
  inset: 0;
  background: var(--night);
  opacity: 0;
  z-index: -1;
  pointer-events: none;
}
body.is-night .night-veil { opacity: 1; transition: opacity 0.5s ease; }

.panel-night {
  background: var(--night);
  color: var(--paper);
}
/* The panel's own background stays opaque in every mode: the fixed .night-veil
   only dims the surrounding paper while the panel takes or leaves the viewport
   (compositor-only transition). Paper-coloured text never sits on paper. */

.panel-night .eyebrow { color: rgba(247, 245, 241, 0.6); }
.panel-night .lede { color: rgba(247, 245, 241, 0.78); }
.panel-night .section-title { color: var(--paper); }
.head-rule-night { background: var(--accent); }

.honest-quote {
  border-left: 3px solid var(--accent);
  /* #262227 = old rgba(199,93,44,0.1) tint pre-composited over --night */
  background: #262227;
  border-radius: 0 10px 10px 0;
  padding: 1.2rem 1.5rem;
  margin: 2.4rem 0;
  max-width: 44rem;
}
.honest-quote p {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.08rem;
  color: var(--paper);
}
.honest-quote cite {
  display: block;
  margin-top: 0.5rem;
  font-style: normal;
  font-size: 0.8rem;
  color: rgba(247, 245, 241, 0.55);
}

.honest-list { list-style: none; margin-top: 1rem; max-width: 62rem; }
.honest-list li {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 1.2rem;
  padding: 1.35rem 0;
  border-bottom: 1px solid rgba(247, 245, 241, 0.12);
}
.honest-list li:last-child { border-bottom: 0; }
.honest-num {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  color: var(--accent);
  line-height: 1.1;
}
.honest-list h3 { font-size: 1.08rem; color: var(--paper); margin-bottom: 0.3rem; }
.honest-list p { font-size: 0.9rem; color: rgba(247, 245, 241, 0.72); }

/* ---------- 17. roadmap ---------- */

.timeline { position: relative; margin-top: 3.4rem; }
.timeline-line {
  position: absolute;
  top: 26px;
  left: 0; right: 0;
  height: 2px;
  background: var(--grid);
  border-radius: 2px;
}
#roadmap-line {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--cold), #7bccc4 35%, var(--accent) 70%, var(--hot));
  transform-origin: left center;
}
.timeline-nodes {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.4rem;
  position: relative;
}
.timeline-node {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-top: 0;
}
.node-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--accent);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}
.node-icon svg { width: 24px; height: 24px; }
.timeline-node h3 { font-size: 1rem; }
.timeline-node p { font-size: 0.82rem; color: var(--ink-soft); }
.timeline-node .pill-badge { align-self: flex-start; }
.timeline-node-close .node-icon { color: var(--ink); }

/* ---------- 18. footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--paper-deep);
  padding: 4.5rem 0 3rem;
  scroll-margin-top: var(--nav-h);
}
.footer-wordmark {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  color: var(--ink);
}
.wm-letter { display: inline-block; }
.footer-quote {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-soft);
  margin: 0.8rem 0 1.8rem;
  max-width: 44rem;
}
.footer-disclaimer { margin-top: 0; }
.footer-line { font-size: 0.85rem; color: var(--ink-soft); margin-top: 1.1rem; }
.footer-mini { font-size: 0.76rem; color: var(--muted); margin-top: 0.5rem; max-width: 52rem; }
.footer-links { font-size: 0.85rem; margin-top: 1.4rem; }

/* ---------- 19. reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .term-cursor { animation: none; }
  #pareto-selected { animation: none; }
}

/* ---------- 20. responsive ---------- */

@media (max-width: 960px) {
  .section { padding: 4.5rem 0; }

  /* Nav collapses to an accordion earlier than 640px: nine links do not fit
     a 768px row. (Pragmatic deviation from the plan's 640 breakpoint.)
     The accordion is JS-gated; without JS the links wrap inline instead so
     navigation never disappears. */
  html.js .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    margin-left: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0.6rem 1.5rem 1rem;
    box-shadow: 0 12px 24px rgba(26, 35, 48, 0.08);
  }
  html.js .nav-links a { padding: 0.65rem 0; border-bottom: 0; font-size: 0.95rem; }
  html.js .site-nav.nav-open .nav-links { display: flex; }
  html.js .nav-toggle { display: block; margin-left: auto; }
  html.js .nav-github { display: none; }

  html:not(.js) .nav-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--nav-h);
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
  }
  html:not(.js) .nav-toggle { display: none; }
  html:not(.js) .nav-github { margin-left: auto; }
  html:not(.js) .nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
    order: 3;
    flex-basis: 100%;
    margin-left: 0;
    padding: 0.3rem 0 0;
  }
  html:not(.js) .nav-links a { padding: 0.15rem 0; }

  .demo-shell { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; gap: 2rem; }
  .pipeline-sticky { position: static; max-width: 440px; }
  .pipeline-steps.is-armed .pipeline-step { opacity: 1; }

  .problem-grid { grid-template-columns: 1fr; }
  .why-list { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .product-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .soh-cards { grid-template-columns: 1fr; }

  .timeline-line { display: none; }
  .timeline-nodes { grid-template-columns: 1fr; gap: 2rem; }
  .timeline-node { border-left: 2px solid var(--grid); padding-left: 1.2rem; }

  .bars-band { display: none; }
}

@media (max-width: 640px) {
  .hero { padding-inline: 1.2rem; }
  .stat-chip { min-width: calc(50% - 0.4rem); flex: 1 1 calc(50% - 0.4rem); }
  .hero-ctas .btn { flex: 1 1 auto; justify-content: center; }

  .results-grid { grid-template-columns: 1fr; }
  .review-table .arrow, .review-table thead th:nth-child(3) { width: 1rem; }
  .bar-row { grid-template-columns: 1fr; gap: 0.3rem; }
  .bars-band { display: none; }
  .bar-val { margin-bottom: 0.4rem; }
  .honest-list li { grid-template-columns: 2.6rem 1fr; gap: 0.8rem; }
  .honest-num { font-size: 1.4rem; }
  .energy-big { font-size: 2.5rem; }
}
