/* ─────────────────────────────────────────────────────────────────────────────
   Bitsaga onchain — chart shell.

   Colour: the categorical slots, the sequential ramp and the chrome are the
   dataviz skill's validated reference palette, re-validated against Bitsaga's
   OWN surfaces (light #f9fbfc, dark #07111f) rather than the skill's defaults:

     node scripts/validate_palette.js "#2a78d6,#eb6834,#1baf7a,#eda100,#e87ba4" \
          --mode light --surface "#f9fbfc"     -> ALL CHECKS PASS
     node scripts/validate_palette.js "#3987e5,#d95926,#199e70,#c98500,#d55181" \
          --mode dark  --surface "#07111f"     -> ALL CHECKS PASS

   Light mode carries a contrast WARN on slots 3/4/5 (aqua, yellow, magenta sit
   below 3:1 on the light surface). That WARN is not dismissable: the relief is
   shipped, in the form of always-on direct end-labels and a table view on every
   chart. Do not remove either without re-reading the validator output.

   Dark mode is SELECTED, not flipped: the dark column is its own set of steps
   from the same ramps, validated against the dark surface.
   ───────────────────────────────────────────────────────────────────────────── */

@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(../fonts/outfit_v15_QGYvz_MVcBeNP4NJtEtq.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(../fonts/outfit_v15_QGYvz_MVcBeNP4NJuktqQ4E.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(../fonts/spacegrotesk_v22_V8mDoQDjQSkFtoMM3T6r8E7mPbF4Cw.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(../fonts/spacegrotesk_v22_V8mDoQDjQSkFtoMM3T6r8E7mPb94C-s0.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+2C60-2C7F, U+A720-A7FF; }

/* ── tokens ────────────────────────────────────────────────────────────────── */

.viz-root {
  color-scheme: light;
  --page:           #f2f5f7;
  --surface-1:      #f9fbfc;
  --text-primary:   #07111f;
  --text-secondary: #45566b;
  --text-muted:     #7a8795;
  --grid:           #e2e8ee;
  --axis:           #c3ccd6;
  --border:         rgba(7, 17, 31, 0.10);
  --brand:          #d97706;          /* bitsaga orange, chrome only — never a series */
  --brand-ink:      #b45c04;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;

  /* sequential ramp, one hue light→dark, for the heatmap only */
  --seq-0: #cde2fb; --seq-1: #b7d3f6; --seq-2: #9ec5f4; --seq-3: #86b6ef;
  --seq-4: #6da7ec; --seq-5: #5598e7; --seq-6: #3987e5; --seq-7: #2a78d6;
  --seq-8: #256abf; --seq-9: #1c5cab; --seq-10: #184f95; --seq-11: #104281; --seq-12: #0d366b;

  /* VALUE RAMP — a single-series line coloured by its own percentile. Same blue
     hue as the sequential ramp, but clipped to the ORDINAL-safe sub-range: a
     line mark has to stay visible at every step, so the light end may not recede
     into the surface the way a heatmap's near-zero cells are allowed to.
       node scripts/validate_palette.js "#86b6ef,#5598e7,#2a78d6,#184f95,#0d366b" \
            --ordinal --mode light --surface "#f9fbfc"   -> ALL CHECKS PASS
       node scripts/validate_palette.js "#cde2fb,#86b6ef,#3987e5,#256abf,#184f95" \
            --ordinal --mode dark  --surface "#07111f"   -> ALL CHECKS PASS
     Declared light→dark in BOTH modes because that is the order the validator
     checks. WHICH END MEANS "HIGH" is decided by the surface, in
     js/palette.js § valueRampCSS: on light, high = the dark step; on dark, high
     = the LIGHT step, because a navy line on a navy surface is not a line. */
  --val-0: #86b6ef; --val-1: #5598e7; --val-2: #2a78d6; --val-3: #184f95; --val-4: #0d366b;

  /* THE DIVERGING RAMP IS NOT A TOKEN SET — it lives in js/palette.js §
     DIVERGING, because its two arms have a different step COUNT per mode and a
     padded token array would be a lie about the ramp's shape. It is listed here
     so this file stays the place you look for "what colours does this page use".
     Two hues plus a neutral GREY midpoint, never a hue in the middle, and one
     definition serving the ribbon cells, the consensus strip, the composite line
     and every value-coloured line whose metric has a declared polarity.

     fill (wide cells — the midpoint MAY recede into the surface)
       light  cold #0d366b→#cde2fb · hot #5f1414→#fbd9d6 · neutral #f0efec
       dark   cold #86b6ef→#184f95 · hot #f0a49d→#94211f · neutral #1d2430
     ink (line marks — a 2px line may NOT vanish at its own midpoint, so the same
          two hues are clipped to the ordinal-safe sub-range and the midpoint is
          a real grey. Same relationship --val-* has to --seq-*.)
       light  cold #0d366b,#184f95,#2a78d6 · hot #5f1414,#94211f,#c03332
              neutral #8e99a6  (2.79:1 on #f9fbfc)
       dark   cold #86b6ef,#3987e5,#256abf · hot #f0a49d,#e35b58,#c03332
              neutral #4a5563  (2.50:1 on #07111f)

     Each INK arm validated separately as a single-hue ordinal ramp, excluding
     the neutral (whose hue is by definition arbitrary):
       node scripts/validate_palette.js "#2a78d6,#184f95,#0d366b" --ordinal --mode light --surface "#f9fbfc" -> ALL PASS
       node scripts/validate_palette.js "#c03332,#94211f,#5f1414" --ordinal --mode light --surface "#f9fbfc" -> ALL PASS
       node scripts/validate_palette.js "#256abf,#3987e5,#86b6ef" --ordinal --mode dark  --surface "#07111f" -> ALL PASS
       node scripts/validate_palette.js "#c03332,#e35b58,#f0a49d" --ordinal --mode dark  --surface "#07111f" -> ALL PASS
     And the two ARMS re-checked against each other at matched intensity, which
     per-arm validation cannot see: worst pair 15.4 CVD / 19.0 normal (light
     extremes) and 11.8 / 17.4 (dark extremes), both clear of the 8 / 15 gates.
     That cross-arm check is also why both dark ramps stop one step short of
     #cde2fb / #fbd9d6: that pair measures 5.0 CVD / 7.3 normal, below the 15
     floor, and on DARK it is the pair of extremes — the loudest "near a top"
     and the loudest "near a bottom" rendering as the same pale wash. On LIGHT
     the same pair sits at the NEUTRAL end, where indistinguishable is correct,
     so light keeps it. See README § Cycle dashboard colour. */
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) .viz-root { color-scheme: dark;
    --page:           #050b14;
    --surface-1:      #07111f;
    --text-primary:   #ffffff;
    --text-secondary: #b6c2d0;
    --text-muted:     #7f8c9c;
    --grid:           #142235;
    --axis:           #1e3049;
    --border:         rgba(255, 255, 255, 0.10);
    --brand:          #f7931a;
    --brand-ink:      #f7931a;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
    --val-0: #cde2fb; --val-1: #86b6ef; --val-2: #3987e5; --val-3: #256abf; --val-4: #184f95;
  }
}
:root[data-theme='dark'] .viz-root { color-scheme: dark;
  --page:           #050b14;
  --surface-1:      #07111f;
  --text-primary:   #ffffff;
  --text-secondary: #b6c2d0;
  --text-muted:     #7f8c9c;
  --grid:           #142235;
  --axis:           #1e3049;
  --border:         rgba(255, 255, 255, 0.10);
  --brand:          #f7931a;
  --brand-ink:      #f7931a;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  --val-0: #cde2fb; --val-1: #86b6ef; --val-2: #3987e5; --val-3: #256abf; --val-4: #184f95;
}

/* ── page ──────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* the overscroll plane: .viz-root sits on <body>, so <html> needs its own */
:root { background: #f2f5f7; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme='light'])) { background: #050b14; } }
:root[data-theme='dark'] { background: #050b14; }
body {
  background: var(--page);
  color: var(--text-primary);
  font-family: Outfit, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .num { font-family: 'Space Grotesk', Outfit, system-ui, sans-serif; }
a { color: var(--brand-ink); }

/* ── explorer shell ────────────────────────────────────────────────────────
   Two columns: the catalogue on the left, one main column on the right. The
   left column scrolls independently and stays put, because the whole point of
   a tree is that you can keep browsing it while looking at the chart. */

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 0 28px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 20px 96px;
  align-items: start;
}
.main { min-width: 0; }

.explorer {
  position: sticky; top: 0; align-self: start;
  height: 100vh; display: flex; flex-direction: column;
  padding: 20px 0 12px;
  border-right: 1px solid var(--border);
  margin-right: -14px; padding-right: 14px;
}
.explorer-head { flex: none; padding-bottom: 10px; }
.explorer .search { display: block; }
.explorer .search input {
  width: 100%; font: inherit; font-size: 13.5px; padding: 8px 11px; min-height: 36px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-1); color: var(--text-primary);
}
.explorer .search input::placeholder { color: var(--text-muted); }
.explorer .search input:focus-visible { outline: 2px solid var(--brand); outline-offset: -1px; }
.explorer-count { margin: 6px 2px 0; font-size: 11px; color: var(--text-muted); }

.tree { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.tree-empty { font-size: 12.5px; color: var(--text-muted); padding: 10px 2px; }

/* level 1 — the category */
.tree .cat { border-top: 1px solid var(--border); }
.tree .cat:first-child { border-top: 0; }
.tree .cat > summary {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline;
  gap: 0 8px; padding: 9px 4px 9px 2px; cursor: pointer; list-style: none;
  min-height: 34px;
}
.tree .cat > summary::-webkit-details-marker { display: none; }
.tree .cat > summary:hover { background: color-mix(in srgb, var(--text-primary) 5%, transparent); }
.tree .cat > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.cat-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.cat-n { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cat-q { grid-column: 1 / -1; font-size: 11.5px; color: var(--text-muted); line-height: 1.35; }
.tree .cat[open] > summary .cat-label { color: var(--brand-ink); }

/* A category IS a chart — this is the button that draws it. */
.cat-load {
  appearance: none; font: inherit; font-size: 11px; cursor: pointer;
  margin: 0 0 6px 2px; padding: 3px 9px; min-height: 24px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-1); color: var(--text-secondary);
}
.cat-load:hover { background: color-mix(in srgb, var(--brand) 14%, var(--surface-1)); color: var(--text-primary); }
.cat-load[aria-pressed='true'] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* level 2 — the metric. There is no level 3. */
.tree ul { list-style: none; margin: 0 0 8px; padding: 0; }
.tree li { display: flex; align-items: stretch; gap: 2px; }
.tree .metric {
  appearance: none; border: 0; background: transparent; font: inherit; cursor: pointer;
  flex: 1 1 auto; min-width: 0; text-align: left;
  display: grid; gap: 0 6px; padding: 5px 6px; border-radius: 6px;
  border-left: 3px solid transparent;
  min-height: 32px;
}
.tree .metric:hover { background: color-mix(in srgb, var(--text-primary) 6%, transparent); }
.tree .metric:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.tree .metric[data-instack='1'] { border-left-color: color-mix(in srgb, var(--brand) 55%, transparent); }
.tree .metric[aria-current='true'] {
  border-left-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
}
.m-label { font-size: 12.5px; color: var(--text-primary); }
.tree .metric[data-missing='1'] .m-label { color: var(--text-muted); }
/* The beginner subtitle is part of the name, not a tooltip. */
.m-sub { font-size: 11px; color: var(--text-muted); line-height: 1.3; }
.m-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }

.pin {
  appearance: none; border: 1px solid transparent; background: transparent; cursor: pointer;
  font: inherit; font-size: 15px; line-height: 1; color: var(--text-muted);
  width: 26px; min-height: 32px; flex: none; border-radius: 6px;
}
.pin:hover { background: color-mix(in srgb, var(--text-primary) 8%, transparent); color: var(--text-primary); }
.pin[aria-pressed='true'] { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.pin:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* Trust, visible while browsing — never three clicks down. */
.badge {
  font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase;
  border-radius: 4px; padding: 1px 5px; white-space: nowrap; line-height: 1.5;
  border: 1px solid var(--border); color: var(--text-muted);
}
.badge-prov { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.badge-missing { color: var(--text-muted); border-style: dashed; }
.chart-head .badge { align-self: center; }

.banner-quiet { border-left-color: var(--axis); }

.ghost {
  appearance: none; font: inherit; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 7px; padding: 4px 10px; min-height: 28px;
  background: var(--surface-1); color: var(--text-secondary);
}
.ghost:hover { background: color-mix(in srgb, var(--text-primary) 6%, transparent); }
.ghost[hidden] { display: none; }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.seg button:disabled:hover { background: transparent; }

/* the per-metric page body */
.metric-page {
  margin: 0 0 18px; padding: 14px 16px; border-radius: 10px;
  background: var(--surface-1); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary); max-width: 84ch;
}
.metric-page[hidden] { display: none; }
.metric-page p { margin: 0 0 8px; }
.metric-page p:last-child { margin-bottom: 0; }
.metric-page .mp-plain { color: var(--text-primary); font-size: 14px; }
.metric-page .mp-tech, .metric-page .mp-also { font-size: 12.5px; }
.metric-page .mp-limit {
  color: var(--text-muted); font-size: 12.5px;
  border-left: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); padding-left: 9px;
}
.mp-lbl { font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); margin-right: 7px; }
.mp-cat {
  appearance: none; border: 0; background: transparent; font: inherit; font-size: 12.5px;
  color: var(--brand-ink); cursor: pointer; padding: 2px 0; text-decoration: underline;
}

.chart-missing { opacity: 0.75; }
.page-foot { margin-top: 34px; font-size: 12px; color: var(--text-muted); max-width: 78ch; }

#tree-toggle { display: none; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  #tree-toggle { display: inline-block; }
  .explorer {
    position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(360px, 88vw);
    background: var(--page); border-right: 1px solid var(--border);
    padding: 16px 14px; margin: 0;
    transform: translateX(-102%); transition: transform 160ms;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
    visibility: hidden;
  }
  body.tree-open .explorer { transform: none; visibility: visible; }
  /* A drawer with nothing behind it has no "outside" to click, and the button
     that opened it is underneath the panel. This is the outside. */
  .scrim {
    position: fixed; inset: 0; z-index: 55; border: 0; padding: 0;
    background: rgba(8, 14, 24, 0.34); backdrop-filter: blur(1px);
    opacity: 0; pointer-events: none; transition: opacity 160ms;
  }
  body.tree-open .scrim { opacity: 1; pointer-events: auto; }
  /* CHART FIRST ON A PHONE. A metric's explainer is three paragraphs and it sat
     above the plot, so on a 390px screen the chart — the thing the page is —
     started ~700px down. The words stay first in the SOURCE, which is what the
     pre-rendered pages and a crawler read; only the reading order moves. */
  .main { display: flex; flex-direction: column; }
  .main > .masthead { order: 1; }
  .main > .controls { order: 2; }
  .main > #charts { order: 3; }
  .main > .metric-page { order: 4; }
  .main > .page-nav { order: 5; }
  .main > noscript { order: 5; }
  .main > .page-foot { order: 6; }
}

header.masthead { padding: 34px 0 6px; }
header.masthead h1 { font-size: 28px; line-height: 1.15; margin: 0; font-weight: 600; letter-spacing: -0.015em; }
header.masthead .lede { margin: 5px 0 0; color: var(--text-secondary); font-size: 14px; }
.kicker {
  font-size: 12px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--brand-ink); font-weight: 600; margin: 0 0 6px;
}

/* The synthetic-data warning is the one piece of prose that must survive any
   cut. It is compact but it is not quiet: brand rule down the left edge. */
.banner {
  margin: 12px 0 0; padding: 8px 12px; border-radius: 7px;
  border: 1px solid var(--border); border-left: 3px solid var(--brand);
  background: var(--surface-1); color: var(--text-secondary); font-size: 12.5px;
  max-width: 76ch;
}
.banner strong { color: var(--text-primary); }

/* ── the one filter row (never per-chart) ──────────────────────────────────── */

.controls {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  margin: 22px 0 20px; padding: 10px 0;
  background: color-mix(in srgb, var(--page) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.ctl { display: flex; align-items: center; gap: 6px; }
.ctl[hidden] { display: none; }
.ctl > .lbl { font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: var(--surface-1); }
.seg button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12.5px; padding: 5px 10px; color: var(--text-secondary);
  min-height: 28px;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { background: color-mix(in srgb, var(--text-primary) 6%, transparent); }
.seg button[aria-pressed='true'] { background: var(--brand); color: #fff; font-weight: 600; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); cursor: pointer; }
.chk input { accent-color: var(--brand); width: 15px; height: 15px; }

/* ── chart card ────────────────────────────────────────────────────────────── */

.chart {
  margin: 0 0 26px; padding: 16px 16px 10px;
  background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 12px;
}
.chart > figcaption { display: block; margin: 0 0 10px; }
.chart-head { display: flex; align-items: baseline; gap: 10px; }
.chart h2 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.chart .oneline { margin: 3px 0 0; font-size: 13px; color: var(--text-secondary); }
.chart .note { margin: 5px 0 0; font-size: 12px; color: var(--text-muted); }

.info-toggle {
  appearance: none; border: 1px solid var(--border); border-radius: 5px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  font: inherit; font-size: 11px; line-height: 1; padding: 3px 7px; min-height: 20px; flex: none;
}
.info-toggle:hover { background: color-mix(in srgb, var(--text-primary) 6%, transparent); color: var(--text-secondary); }
.about {
  margin: 8px 0 0; padding: 10px 12px; border-radius: 8px;
  background: color-mix(in srgb, var(--text-primary) 4%, transparent);
  font-size: 12.5px; color: var(--text-secondary); max-width: 84ch;
}
.about[hidden] { display: none; }
.about p { margin: 0 0 7px; }
.about p:last-child { margin-bottom: 0; }
.about .about-sub { color: var(--text-muted); font-size: 12px; }
.about table.record { border-collapse: collapse; margin-top: 6px; font-size: 11.5px; }
.about table.record td { padding: 2px 10px 2px 0; vertical-align: baseline; color: var(--text-muted); }
.about table.record td:nth-child(2) { color: var(--text-secondary); white-space: nowrap; }
.rec-key { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 2px; }
.legend button {
  appearance: none; border: 0; background: transparent; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-secondary); padding: 3px 4px; border-radius: 5px;
  min-height: 24px;
}
.legend button:hover { background: color-mix(in srgb, var(--text-primary) 6%, transparent); }
.legend button[aria-pressed='false'] { color: var(--text-muted); opacity: 0.55; }
.legend .key { width: 16px; height: 2px; border-radius: 1px; flex: none; }
.legend .key.band { height: 9px; border-radius: 2px; opacity: 0.28; }

.plot-wrap {
  position: relative; width: 100%; height: 340px;
  touch-action: none; cursor: crosshair;
  contain: layout paint;
}
.plot-wrap.tall { height: 400px; }
.plot-wrap canvas, .plot-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.plot-wrap svg { pointer-events: none; }
.plot-wrap canvas { display: block; }
.plot-wrap.loading canvas { opacity: 0.55; transition: opacity 120ms; }

svg .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
svg .axis-line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
svg text { fill: var(--text-muted); font-size: 11px; font-family: Outfit, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
svg text.end-label { fill: var(--text-secondary); font-size: 11.5px; font-variant-numeric: normal; }
svg .halving line { stroke: var(--axis); stroke-width: 1; stroke-opacity: 0.85; }
svg .halving text { fill: var(--text-muted); font-size: 10px; letter-spacing: 0.04em; }
svg .crosshair line { stroke: var(--text-secondary); stroke-width: 1; stroke-opacity: 0.5; shape-rendering: crispEdges; }
svg .brush rect { fill: var(--brand); fill-opacity: 0.12; stroke: var(--brand); stroke-width: 1; }
svg .gutter-hint { fill: var(--text-primary); fill-opacity: 0.04; }

/* NAMED ZONES. A hairline rule and a name in the right gutter, never a filled
   background band: on a value-coloured line a wash behind it would put a second
   value encoding on the same mark. Muted ink, so a convention someone else
   published never outshouts the data. */
svg .zones line { stroke: var(--text-secondary); stroke-width: 1; stroke-opacity: 0.42; shape-rendering: crispEdges; }
svg .zones text { fill: var(--text-muted); font-size: 10px; letter-spacing: 0.02em; font-variant-numeric: normal; }
svg .zones text.zone-val { font-variant-numeric: tabular-nums; }

/* A clamp that bites has to look like a limit, not like a dead gesture. */
.plot-wrap.limit-y svg .gutter-hint rect:first-child,
.plot-wrap.limit-x svg .gutter-hint rect:last-child { fill: var(--brand); fill-opacity: 0.22; }

/* Zone names: real buttons in the right gutter, so the citation is hoverable and
   focusable. Muted, small, never competing with the line they annotate. */
.zonelabels { position: absolute; inset: 0; pointer-events: none; z-index: 12; }
.zonelabels[hidden] { display: none; }
.zonelab {
  position: absolute; pointer-events: auto;
  appearance: none; border: 0; background: transparent; cursor: help;
  font: inherit; font-size: 10px; line-height: 1.1; letter-spacing: 0.02em;
  color: var(--text-muted); padding: 1px 0; text-align: right;
  /* max-width is set per render from the gutter that is actually there, so a
     long zone name truncates inside the gutter instead of growing back across
     the axis and sitting on the data. The full text is in title + aria-label. */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zonelab:hover, .zonelab:focus-visible { color: var(--text-primary); }

.y-auto-badge {
  position: absolute; left: 4px; top: 4px; z-index: 15;
  appearance: none; cursor: pointer; font: inherit; font-size: 10.5px; line-height: 1;
  padding: 4px 7px; min-height: 22px;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface-1); color: var(--text-secondary);
  white-space: nowrap;
}
.y-auto-badge:hover { background: color-mix(in srgb, var(--brand) 14%, var(--surface-1)); color: var(--text-primary); }
.y-auto-badge[hidden] { display: none; }

/* OFF-SCALE CHEVRONS. The frame is fitted to the line, so a band can run past
   it; this is the axis saying so. Muted enough to be chrome, a real button so
   the reader can have the rest back in one click. */
.clipmarks { position: absolute; inset: 0; pointer-events: none; z-index: 14; }
.clipmark {
  position: absolute; pointer-events: auto;
  appearance: none; border: 0; background: transparent; cursor: zoom-out;
  font: inherit; font-size: 9px; line-height: 1; padding: 2px 3px;
  color: var(--text-muted); opacity: 0.7;
}
.clipmark:hover, .clipmark:focus-visible { color: var(--brand-ink); opacity: 1; }
.clipmark[hidden] { display: none; }

.tooltip {
  position: absolute; z-index: 20; pointer-events: none;
  min-width: 168px; padding: 8px 10px;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14);
  font-size: 12.5px; opacity: 0; transition: opacity 90ms;
}
.tooltip[data-show='1'] { opacity: 1; }
.tooltip .tt-head { color: var(--text-muted); font-size: 11px; margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.tooltip .tt-row { display: flex; align-items: baseline; gap: 7px; margin-top: 3px; }
.tooltip .tt-key { width: 14px; height: 2px; border-radius: 1px; flex: none; transform: translateY(-3px); }
.tooltip .tt-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .tt-name { color: var(--text-secondary); font-size: 11.5px; }

.chart-foot {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-muted);
}
.chart-foot .res { font-variant-numeric: tabular-nums; }
.chart-foot button {
  appearance: none; background: transparent; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; font-size: 11.5px; color: var(--text-secondary); padding: 3px 9px; cursor: pointer; min-height: 24px;
}
.chart-foot button:hover { background: color-mix(in srgb, var(--text-primary) 6%, transparent); }

.tableview { display: none; margin-top: 10px; max-height: 300px; overflow: auto; }
.tableview[data-open='1'] { display: block; }
.tableview table { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
.tableview th, .tableview td { text-align: right; padding: 3px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tableview th { position: sticky; top: 0; background: var(--surface-1); color: var(--text-muted); font-weight: 500; text-align: right; }
.tableview th:first-child, .tableview td:first-child { text-align: left; }

/* heatmap colour-scale legend, and the value-coloured line's legend — a value
   scale without one is decoration, so this is not optional anywhere it appears */
.scale-legend { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; font-size: 11.5px; color: var(--text-muted); }
.scale-legend .ramp { width: 168px; height: 9px; border-radius: 2px; border: 1px solid var(--border); }
.scale-legend .ramp.line-ramp { height: 4px; border: 0; border-radius: 2px; }
.scale-legend .scale-note { color: var(--text-muted); }

/* The start-of-series notice: why the default view starts where it does, with
   the full range one click away. It sits under the one-liner, in muted ink. */
.chart .startnote { margin: 5px 0 0; font-size: 11.5px; color: var(--text-muted); }
.chart .startnote button {
  appearance: none; background: transparent; border: 0; border-bottom: 1px solid var(--border);
  font: inherit; font-size: 11.5px; color: var(--text-secondary); padding: 0 0 1px; cursor: pointer;
}
.chart .startnote button:hover { color: var(--text-primary); border-bottom-color: var(--brand); }

/* cycle dashboard */
.plot-wrap.cycle { height: 560px; }
.cycle-card { border-color: color-mix(in srgb, var(--brand) 28%, var(--border)); }
.seg.mini button { font-size: 11px; padding: 3px 8px; min-height: 22px; }

/* The category lane: the legend's four categorical hues, in the gutter, on the
   far side of the axis line from the diverging value scale. Identity and value
   never share a zone, so neither can be mistaken for the other. */
svg .catrules text {
  fill: var(--text-secondary); font-size: 9.5px; letter-spacing: 0.09em;
  text-transform: uppercase; font-weight: 600; font-variant-numeric: normal;
}
svg .rowlabels text.is-hover { fill: var(--text-primary); }
svg .row-hover rect {
  fill: none; stroke: var(--text-primary); stroke-opacity: 0.55; stroke-width: 1;
  shape-rendering: crispEdges;
}
.tooltip .tt-row.is-hover .tt-name { color: var(--text-primary); }

/* row-label hit targets: the full width of the gutter, one per row */
.rowhits { position: absolute; inset: 0; z-index: 12; pointer-events: none; }
.rowhits[hidden] { display: none; }
.rowhit {
  position: absolute; appearance: none; background: transparent; border: 0; padding: 0;
  pointer-events: auto; cursor: help; border-radius: 4px;
}
.rowhit:hover { background: color-mix(in srgb, var(--text-primary) 5%, transparent); }
.rowhit:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* The explanation itself. Hidden until asked for, which is the only reason it
   is allowed to be this long — none of it may leak onto the page surface. */
.rowpop {
  position: absolute; z-index: 22; pointer-events: none;
  width: 340px; max-width: calc(100% - 24px); padding: 10px 12px;
  background: var(--surface-1); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
  font-size: 12px; line-height: 1.5; opacity: 0; transition: opacity 90ms;
}
.rowpop[data-show='1'] { opacity: 1; }
.rowpop p { margin: 6px 0 0; }
.rowpop .pop-head { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.rowpop .pop-head strong { color: var(--text-primary); font-size: 12.5px; }
.rowpop .pop-key { width: 3px; height: 12px; border-radius: 1.5px; flex: none; }
.rowpop .pop-cat { font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); }
.rowpop .pop-flag {
  font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--brand-ink);
  border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent); border-radius: 4px; padding: 0 5px;
}
.rowpop .pop-plain { color: var(--text-primary); font-size: 12.5px; }
.rowpop .pop-tech { color: var(--text-secondary); }
.rowpop .pop-meta, .rowpop .pop-limit { color: var(--text-muted); font-size: 11.5px; }
.rowpop .pop-limit {
  border-left: 2px solid color-mix(in srgb, var(--brand) 45%, transparent);
  padding-left: 8px; margin-top: 8px;
}
.rowpop .pop-lbl {
  font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted);
  margin-right: 6px;
}

@media (max-width: 640px) {
  .plot-wrap.cycle { height: 460px; }
}

.perf {
  position: fixed; right: 12px; bottom: 12px; z-index: 50;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-1); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px;
  white-space: pre; font-variant-numeric: tabular-nums; opacity: 0.9;
}
.perf[hidden] { display: none; }

.help { font-size: 12.5px; color: var(--text-muted); margin: -6px 0 18px; }
.help kbd {
  font: inherit; font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; background: var(--surface-1); color: var(--text-secondary);
}

@media (max-width: 640px) {
  .plot-wrap { height: 260px; }
  header.masthead h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Placeholder marker, inside the plot of every chart. It survives a crop of a
   single chart, which the masthead banner does not, and it disappears on its own
   when manifest.synthetic goes false. */
svg .placeholder-mark rect {
  fill: var(--surface-1); fill-opacity: 0.82;
  stroke: var(--brand); stroke-opacity: 0.55; stroke-width: 1;
}
svg .placeholder-mark text {
  fill: var(--brand-ink); font-size: 9px; letter-spacing: 0.11em; font-weight: 600;
}
svg .consensus-label text { fill: var(--text-secondary); font-weight: 600; letter-spacing: 0.06em; }

/* ── the generated static pages ────────────────────────────────────────────
   The words are the page; the chart is enrichment. These rules only style what
   the generator puts in the source, so a reader with JavaScript off still gets
   a readable document rather than a stylesheet's idea of an empty shell. */
.page-nav { margin: 22px 0 0; font-size: 13px; color: var(--text-secondary); max-width: 84ch; }
.page-nav ul { list-style: none; margin: 6px 0 10px; padding: 0; }
.page-nav li { padding: 3px 0; }
.page-nav a { color: var(--brand-ink); }
.nav-sub { color: var(--text-muted); font-size: 12px; }
.metric-page h2 { font-size: 15px; margin: 16px 0 2px; }
.metric-page h2:first-child { margin-top: 0; }
.metric-page ul { list-style: none; margin: 4px 0 0; padding: 0; }
.metric-page li { padding: 2px 0; font-size: 13px; }
.metric-page a { color: var(--brand-ink); }
.metric-page .mp-meta { color: var(--text-muted); font-size: 12.5px; }
.noscript-note {
  margin: 0 0 18px; padding: 12px 14px; border-radius: 10px; max-width: 84ch;
  border: 1px solid var(--border); border-left: 3px solid var(--brand);
  background: var(--surface-1); color: var(--text-secondary); font-size: 13px;
}
