/* ---- tokens -------------------------------------------------------- */
:root {
  color-scheme: light;
  --plane:  #f9f9f7;
  --surface:#fcfcfb;
  --ink:    #0b0b0b;
  --ink-2:  #52514e;
  --muted:  #898781;
  --rule:   #e1e0d9;
  --border: rgba(11,11,11,.10);
  --shadow: 0 1px 2px rgba(11,11,11,.05), 0 8px 24px rgba(11,11,11,.06);

  --t0: #104281;  /* Leading      */
  --t1: #256abf;  /* Upper middle */
  --t2: #3987e5;  /* Lower middle */
  --t3: #86b6ef;  /* Emerging     */
  --t0-ink: #ffffff;

  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:  #0d0d0d;
    --surface:#1a1a19;
    --ink:    #f0efec;
    --ink-2:  #c3c2b7;
    --muted:  #898781;
    --rule:   #2c2c2a;
    --border: rgba(255,255,255,.10);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.45);
    --t0: #9ec5f4;
    --t1: #5598e7;
    --t2: #256abf;
    --t3: #184f95;
    --t0-ink: #0b0b0b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:#0d0d0d; --surface:#1a1a19; --ink:#f0efec; --ink-2:#c3c2b7;
  --rule:#2c2c2a; --border:rgba(255,255,255,.10);
  --t0:#9ec5f4; --t1:#5598e7; --t2:#256abf; --t3:#184f95; --t0-ink:#0b0b0b;
}

/* ---- base ---------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 920px; margin: 0 auto; padding: 48px 16px 72px; }
.sr-only {
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}
a { color: inherit; text-underline-offset: 2px; }

/* ---- header -------------------------------------------------------- */
.eyebrow {
  margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
h1 {
  margin: 0 0 16px;
  font-size: clamp(28px, 6.2vw, 46px);
  line-height: 1.12;
  letter-spacing: -.02em;
  font-weight: 650;
  text-wrap: balance;
}
.deck {
  margin: 0; max-width: 62ch;
  font-size: clamp(16px, 2.4vw, 18px);
  color: var(--ink-2);
}
.deck strong { color: var(--ink); font-weight: 600; }

/* ---- hero figure --------------------------------------------------- */
.hero { margin: 32px 0 8px; }
.hero-fig {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--t0);
  border-radius: 12px;
}
.hero-num {
  font-size: clamp(40px, 10vw, 60px); font-weight: 680;
  line-height: 1; letter-spacing: -.03em; color: var(--ink);
}
.hero-lab { display: flex; flex-direction: column; font-size: 15px; color: var(--ink-2); }
.hero-lab strong { color: var(--ink); font-weight: 600; font-size: 16px; }

/* ---- cards --------------------------------------------------------- */
.card {
  margin: 28px 0 0;
  padding: 24px 22px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 4px; font-size: 19px; font-weight: 620; letter-spacing: -.01em;
}
.sub { margin: 0 0 18px; font-size: 14px; color: var(--ink-2); max-width: 58ch; }
.note { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---- map ----------------------------------------------------------- */
.map-wrap { position: relative; }
#map { display: block; width: 100%; height: auto; overflow: visible; touch-action: manipulation; }
#map path.state {
  stroke: var(--surface);
  stroke-width: 1;
  stroke-linejoin: round;
  cursor: pointer;
  outline: none;
  transition: fill 120ms ease;
}
#map path.state:hover,
#map path.state:focus-visible,
#map path.is-active { stroke: var(--ink); stroke-width: 2; }
/* SVG marks take fill; the HTML swatches take background */
#map .t0, #dcChip .t0 { fill: var(--t0); }
#map .t1 { fill: var(--t1); }
#map .t2 { fill: var(--t2); }
#map .t3 { fill: var(--t3); }
.sw.t0 { background: var(--t0); } .sw.t1 { background: var(--t1); }
.sw.t2 { background: var(--t2); } .sw.t3 { background: var(--t3); }
#dcLine { stroke: var(--muted); stroke-width: 1.5; fill: none; }
#dcChip rect { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
#dcChip text { fill: var(--t0-ink); font: 600 19px var(--sans); pointer-events: none; }
#dcChip:hover rect, #dcChip:focus-visible rect, #dcChip.is-active rect { stroke: var(--ink); }

/* ---- tooltip ------------------------------------------------------- */
.tip {
  position: absolute; z-index: 5; pointer-events: none;
  transform: translate(-50%, -100%);
  background: var(--ink); color: var(--plane);
  padding: 7px 11px; border-radius: 8px;
  font-size: 13px; line-height: 1.35; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.tip[hidden] { display: none; }
.tip-name { font-weight: 600; }
.tip-val  { font-weight: 600; margin-left: 8px; font-variant-numeric: tabular-nums; }
.tip-rank { display: block; opacity: .72; font-size: 11.5px; font-weight: 400; }

/* ---- legend -------------------------------------------------------- */
.legend {
  list-style: none; display: flex; flex-wrap: wrap; gap: 8px 18px;
  margin: 18px 0 0; padding: 14px 0 0; border-top: 1px solid var(--rule);
}
.legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.legend .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.legend .rng { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- top 10 -------------------------------------------------------- */
.top10 { list-style: none; margin: 0; padding: 0; }
.top10 li {
  display: grid;
  grid-template-columns: 22px minmax(88px, 1.1fr) minmax(70px, 3fr) 46px;
  align-items: center; gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
}
.top10 li:last-child { border-bottom: 0; }
.top10 .rk { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.top10 .nm { font-size: 14.5px; font-weight: 500; }
.top10 .bar { height: 10px; background: var(--rule); border-radius: 4px; overflow: hidden; }
.top10 .bar i { display: block; height: 100%; background: var(--t0); border-radius: 0 4px 4px 0; }
.top10 .vl {
  text-align: right; font-size: 14.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- table --------------------------------------------------------- */
details summary {
  cursor: pointer; font-size: 14px; font-weight: 550; color: var(--ink-2);
  padding: 4px 0;
}
details[open] summary { margin-bottom: 10px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--rule); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; padding-right: 18px; }
td.grp { color: var(--ink-2); white-space: nowrap; }
td.grp .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }

/* ---- footer -------------------------------------------------------- */
.foot { margin: 32px 0 0; padding-top: 18px; border-top: 1px solid var(--rule); }
.source { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); max-width: 70ch; }
.source.dim { color: var(--muted); font-size: 12.5px; }

/* ---- phone --------------------------------------------------------- */
@media (max-width: 560px) {
  .wrap { padding: 32px 14px 56px; }
  .card { padding: 20px 15px 18px; border-radius: 12px; }
  /* the map is the point of the page - let it use the full width */
  .map-wrap { margin: 0 -15px; }
  .legend { gap: 8px 14px; }
  .legend li { font-size: 12.5px; }
  /* stack the bar under the name so long names never wrap */
  .top10 li {
    grid-template-columns: 20px 1fr auto;
    grid-template-areas: "rk nm vl" ". bar bar";
    column-gap: 8px; row-gap: 7px;
    padding: 9px 0;
  }
  .top10 .rk { grid-area: rk; }
  .top10 .nm { grid-area: nm; font-size: 13.5px; }
  .top10 .vl { grid-area: vl; }
  .top10 .bar { grid-area: bar; height: 8px; }
  .tip { font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
