/* ── Signal Rank · ceremony-dark design tokens ─────────────────────────── */
:root {
  --plane:        #0d1626;   /* page: deep scholar navy */
  --surface:      #152238;   /* cards / chart surface */
  --surface-2:    #1d2c47;   /* raised */
  --ink:          #e9eef6;
  --ink-2:        #b6c2d4;
  --ink-muted:    #8294ac;
  --grid:         #22314d;
  --baseline:     #33476e;
  --ring:         rgba(255,255,255,0.09);
  /* two-family tier palette: scarce gold (prizes) + quiet ink-blue (selection).
     validated: CVD worst-pair 14.7, chroma & contrast pass; bright-gold lightness
     is a deliberate prestige-luminance encoding (legend + labels + table as relief) */
  --tier-tot:     #ffd76a;
  --tier-best:    #dfa93f;
  --tier-hm:      #7fa5e3;
  --tier-oral:    #4a6cb2;
  --accent:       #7fb3e8;
  --de-emph:      #3a4c6e;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* light theme — gold #94600a/#c08a14 + ink-blue #3c62a8/#6f93d4 on #faf8f2 (validated) */
:root[data-theme="light"] {
  --plane:        #ffffff;
  --surface:      #f9f9f9;   /* bootstrap stripe gray */
  --surface-2:    #eef3f8;
  --ink:          #333333;
  --ink-2:        #555555;
  --ink-muted:    #777777;
  --grid:         #e8e8e8;
  --baseline:     #d5d5d5;
  --ring:         rgba(0,0,0,0.09);
  --tier-tot:     #94600a;
  --tier-best:    #c08a14;
  --tier-hm:      #3c62a8;
  --tier-oral:    #6f93d4;
  --accent:       #337ab7;
  --de-emph:      #dde3ea;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--plane); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
h2 { font-family: var(--serif); font-weight: 500; font-size: 26px; letter-spacing: .01em; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-muted); font-weight: 600; }
a { color: var(--ink-2); }
a:hover { color: var(--accent); }

/* ── masthead ───────────────────────────────────────────────────────────── */
.masthead { max-width: 1060px; margin: 0 auto; padding: 84px 24px 48px; text-align: center; }
.wordmark-block { display: flex; align-items: center; gap: 22px; justify-content: center; }
.wordmark-rule { flex: 1; max-width: 190px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent)); }
.wordmark-rule:last-child { background: linear-gradient(90deg, var(--accent), transparent); }
.wordmark {
  font-family: var(--serif); font-weight: 500; font-size: clamp(44px, 7vw, 76px);
  letter-spacing: .04em;
  background: linear-gradient(175deg, #cfe3f7 15%, #7fb3e8 60%, #4a7fb8);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-wrap: nowrap;
}
:root[data-theme="light"] .wordmark {
  background: linear-gradient(175deg, #4a90cd 5%, #337ab7 55%, #23527c);
  -webkit-background-clip: text; background-clip: text;
}
.manifesto {
  font-family: var(--serif); font-size: clamp(17px, 2.2vw, 21px); color: var(--ink-2);
  max-width: 640px; margin: 26px auto 0; line-height: 1.6;
}
.manifesto .gold { color: var(--accent); }
.manifesto em { color: var(--ink); }

.kpi-row { display: flex; justify-content: center; gap: clamp(28px, 6vw, 72px); margin-top: 46px; flex-wrap: wrap; }
.stat-value { font-size: 42px; font-weight: 600; letter-spacing: -.01em; }
.stat-value-sm { font-size: 24px; padding-top: 14px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-muted); margin-top: 2px; }

/* ── control dock ───────────────────────────────────────────────────────── */
.dock {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(10px); border-block: 1px solid var(--grid);
}
.dock-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
}
.dock-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-muted); margin-right: 8px; }
.dock-group { display: flex; align-items: center; }

.seg { display: inline-flex; border: 1px solid var(--baseline); border-radius: 7px; overflow: hidden; }
.seg button { padding: 5px 12px; font-size: 13px; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--baseline); }
.seg button.on { background: var(--surface-2); color: var(--accent); }
.seg button:hover:not(.on) { color: var(--ink); }
.seg-sm button { padding: 3px 10px; font-size: 12px; }

/* ── nations ────────────────────────────────────────────────────────────── */
.nations { margin-top: 18px; display: grid; gap: 8px; }
.nation-row {
  display: grid; grid-template-columns: 26px 190px 1fr; gap: 12px; align-items: center;
  border-radius: 8px; padding: 2px 4px;
}
.nation-row:hover { background: var(--surface); }
.nation-rank { text-align: right; color: var(--ink-muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.nation-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nation-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nation-stack { display: flex; height: 16px; flex: none; }
.nation-seg { height: 100%; }
.nation-seg + .nation-seg { margin-left: 2px; }
.nation-seg:last-child { border-radius: 0 4px 4px 0; }
.nation-score { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); flex: none; }

/* ── the map (treemap; 7 groups, both palettes validator-checked:
      light all-pass ≥12.9; dark in the 8–12 floor band, legal with the
      all-cells-labeled + tooltip relief) ──────────────────────────────── */
:root {
  --map-us: #7fb0ef; --map-cn: #e66767; --map-uk: #2fbf94; --map-eu: #c98500;
  --map-ca: #2e5fb0; --map-as: #d95926; --map-row: #17803c;
}
:root[data-theme="light"] {
  --map-us: #2a78d6; --map-cn: #e34948; --map-uk: #1baf7a; --map-eu: #eda100;
  --map-ca: #4a3aa7; --map-as: #e87ba4; --map-row: #008300;
}

.map { position: relative; margin-top: 20px; }
.map-cell {
  position: absolute; overflow: hidden; border-radius: 3px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; line-height: 1.15; padding: 2px;
}
.map-cell:hover { filter: brightness(1.13); z-index: 2; }
.map-cell .mc-name { font-weight: 600; width: 100%; overflow: hidden; }
.map-cell .mc-share { opacity: .85; font-weight: 500; }
.map-country {
  position: absolute; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  font-size: 12px; padding: 3px 10px; border: 1px solid var(--baseline); border-radius: 20px;
  color: var(--ink-muted);
}
.chips button.on { color: var(--ink); border-color: var(--accent); background: var(--surface-2); }
.chips button:hover { color: var(--ink); }

.halflife { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); margin-left: 12px; }
.halflife input { accent-color: var(--accent); width: 110px; }

.country-select {
  font: inherit; font-size: 13px; color: var(--ink-2);
  background: transparent; border: 1px solid var(--baseline); border-radius: 7px;
  padding: 4px 8px; max-width: 190px; cursor: pointer;
}
.country-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tier-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.tier-filters .tier-chip { font-size: 12px; padding: 3px 9px; opacity: .45; }
.tier-filters .tier-chip.on { opacity: 1; border-color: var(--accent); }
.tier-filters .tier-chip b { font-variant-numeric: tabular-nums; }

.weights { position: relative; margin-left: auto; }
.weights summary {
  list-style: none; cursor: pointer; font-size: 13px; color: var(--ink-2);
  border: 1px solid var(--baseline); padding: 5px 12px; border-radius: 7px;
}
.weights summary::-webkit-details-marker { display: none; }
.weights[open] summary { color: var(--accent); background: var(--surface-2); }
.weights-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50;
  background: var(--surface-2); border: 1px solid var(--baseline); border-radius: 10px;
  padding: 14px 16px; width: 270px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.weight-row { display: grid; grid-template-columns: 1fr 90px 30px; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.weight-row .wname { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.weight-row input { accent-color: var(--accent); width: 100%; }
.weight-row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.weights-reset { margin-top: 8px; font-size: 12px; color: var(--ink-muted); text-decoration: underline; }
.weights-reset:hover { color: var(--accent); }

/* ── sections ───────────────────────────────────────────────────────────── */
.section { max-width: 1060px; margin: 0 auto; padding: 54px 24px 10px; scroll-margin-top: 110px; }
.section-head { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.section-head .seg { margin-left: auto; }
.section-sub { color: var(--ink-muted); font-size: 13.5px; margin-top: 6px; max-width: 640px; }
.section-sub em { color: var(--ink-2); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ── podium ─────────────────────────────────────────────────────────────── */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: end; }
.podium-card {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 14px;
  padding: 22px 20px 18px; text-align: center; cursor: pointer; position: relative;
  transition: transform .18s, border-color .18s;
}
.podium-card:hover { transform: translateY(-3px); border-color: var(--tier-hm); }
.podium-card.p1 {
  padding-top: 34px; padding-bottom: 30px;
  background: linear-gradient(180deg, #1b3050, var(--surface) 65%);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 0 60px rgba(127,179,232,.10);
}
:root[data-theme="light"] .podium-card.p1 {
  background: linear-gradient(180deg, #d9edf7, #ffffff 65%);
  border-color: #bce8f1;
  box-shadow: 0 10px 40px rgba(51,122,183,.14);
}
:root[data-theme="light"] .dossier { box-shadow: -20px 0 60px rgba(0,0,0,.15); }
:root[data-theme="light"] .scrim { background: rgba(0,0,0,.30); }
:root[data-theme="light"] .weights-pop { box-shadow: 0 12px 40px rgba(0,0,0,.14); }
:root[data-theme="light"] .tooltip { box-shadow: 0 10px 30px rgba(0,0,0,.14); }
:root[data-theme="light"] .switch input:checked + .track .thumb { background: #fff; }

.theme-btn {
  font-size: 13px; color: var(--ink-2); border: 1px solid var(--baseline);
  padding: 5px 12px; border-radius: 7px;
}
.theme-btn:hover { color: var(--ink); }
.podium-medal { font-size: 13px; letter-spacing: .3em; text-transform: uppercase; color: var(--accent); }
.podium-card.p2 .podium-medal, .podium-card.p3 .podium-medal { color: var(--ink-muted); }
.podium-name { font-family: var(--serif); font-size: 21px; margin: 8px 0 2px; line-height: 1.25; }
.podium-card.p1 .podium-name { font-size: 26px; }
.podium-score { font-size: 30px; font-weight: 600; margin-top: 6px; }
.podium-card.p1 .podium-score { font-size: 38px; color: var(--tier-tot); }
.podium-breakdown { font-size: 12px; color: var(--ink-muted); margin-top: 6px; }
.laurel { font-size: 22px; }

/* ── board ──────────────────────────────────────────────────────────────── */
.board { position: relative; margin-top: 18px; }
.board-row {
  position: absolute; left: 0; right: 0; height: 34px;
  display: grid; grid-template-columns: 34px minmax(180px, 300px) 1fr;
  gap: 12px; align-items: center;
  transition: transform .55s cubic-bezier(.22,1,.36,1);
  cursor: pointer; border-radius: 8px;
}
.board-row:hover { background: var(--surface); }
.board-rank { text-align: right; color: var(--ink-muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.board-rank.medal { color: var(--accent); font-weight: 700; }
.board-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.board-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.type-tag {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; flex: none;
  color: var(--ink-muted); border: 1px solid var(--baseline); border-radius: 4px; padding: 1px 5px;
}
.board-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.board-stack { display: flex; height: 18px; transition: width .55s cubic-bezier(.22,1,.36,1); flex: none; }
.board-seg { height: 100%; }
.board-seg + .board-seg { margin-left: 2px; }  /* surface gap */
.board-seg:last-child { border-radius: 0 4px 4px 0; } /* rounded data-end, square baseline */
.board-score { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); flex: none; }

.more-btn {
  display: block; margin: 16px auto 0; font-size: 13px; color: var(--ink-muted);
  border: 1px solid var(--baseline); border-radius: 20px; padding: 6px 18px;
}
.more-btn:hover { color: var(--ink); border-color: var(--ink-muted); }

/* table twin */
.table-wrap { margin-top: 18px; overflow-x: auto; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.table-wrap th {
  text-align: right; font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--baseline);
}
.table-wrap th:nth-child(2), .table-wrap td:nth-child(2) { text-align: left; }
.table-wrap td { padding: 7px 12px; border-bottom: 1px solid var(--grid); text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap tr:hover td { background: var(--surface); cursor: pointer; }

/* ── canon ──────────────────────────────────────────────────────────────── */
.canon-wrap { position: relative; margin-top: 20px; background: var(--surface);
  border: 1px solid var(--ring); border-radius: 14px; overflow: hidden; }
#canon { display: block; width: 100%; }
.canon-axis { border-top: 1px solid var(--grid); position: relative; height: 26px; }
.canon-axis span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--ink-muted); top: 5px; font-variant-numeric: tabular-nums; }

/* ── bump ───────────────────────────────────────────────────────────────── */
.bump-wrap { margin-top: 16px; overflow-x: auto; }
#bump { display: block; }
#bump .bump-line { fill: none; stroke: var(--de-emph); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: stroke .15s; }
#bump .bump-line.hot { stroke: var(--tier-tot); }
#bump .bump-dot { fill: var(--de-emph); stroke: var(--surface); stroke-width: 2; transition: fill .15s; }
#bump .bump-dot.hot { fill: var(--tier-tot); }
#bump .bump-label { font: 12px var(--sans); fill: var(--ink-2); }
#bump .bump-label.hot { fill: var(--ink); font-weight: 600; }
#bump .bump-year { font: 11px var(--sans); fill: var(--ink-muted); }
#bump .bump-rank { font: 10px var(--sans); fill: var(--ink-muted); }

/* ── dossier drawer ─────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60; }
.dossier {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 94vw); z-index: 70;
  background: var(--surface); border-left: 1px solid var(--baseline);
  padding: 26px 26px 40px; overflow-y: auto;
  box-shadow: -30px 0 80px rgba(0,0,0,.55);
  animation: slide-in .28s cubic-bezier(.22,1,.36,1);
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.dossier-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dossier-rank { font-size: 12px; letter-spacing: .25em; text-transform: uppercase; color: var(--accent); }
.dossier h3 { font-family: var(--serif); font-size: 27px; font-weight: 500; line-height: 1.2; margin-top: 4px; }
.dossier-meta { color: var(--ink-muted); font-size: 12.5px; margin-top: 4px; }
.dossier-close { font-size: 26px; color: var(--ink-muted); line-height: 1; padding: 2px 8px; }
.dossier-close:hover { color: var(--ink); }
.dossier-score { margin: 18px 0 6px; display: flex; align-items: baseline; gap: 10px; }
.dossier-score span:first-child { font-size: 44px; font-weight: 650; color: var(--ink); }
.dossier-score-label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-muted); }
.dossier-tiers { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.tier-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2);
  border: 1px solid var(--grid); background: var(--surface-2); border-radius: 8px; padding: 4px 9px;
  cursor: pointer;
}
.tier-chip:hover { border-color: var(--ink-muted); }
.tier-chip.active { border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 1px var(--accent); }
.tier-chip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.tier-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dossier h4 { margin: 20px 0 8px; }
.dossier-spark { width: 100%; height: 84px; display: block; }
.dossier-venues { display: grid; gap: 5px; }
.venue-bar-row { display: grid; grid-template-columns: 64px 1fr 44px; align-items: center; gap: 10px; font-size: 12.5px; }
.venue-bar-row .vb-name { color: var(--ink-2); }
.venue-bar-row .vb-track { height: 10px; display: flex; align-items: center; }
.venue-bar-row .vb-fill { height: 10px; background: var(--tier-hm); border-radius: 0 3px 3px 0; min-width: 1px; }
.venue-bar-row .vb-val { color: var(--ink-muted); font-variant-numeric: tabular-nums; text-align: right; }
.dossier-list { list-style: none; display: grid; gap: 10px; }
.dossier-list li { display: grid; grid-template-columns: 12px 1fr; gap: 10px; font-size: 13.5px; align-items: baseline; }
.dossier-list .tier-dot { position: relative; top: 1px; }
.dossier-list .aw-title { color: var(--ink); }
.dossier-list .aw-title a { color: inherit; text-decoration: none; }
.dossier-list .aw-title a:hover { color: var(--tier-tot); }
.dossier-list .aw-meta { color: var(--ink-muted); font-size: 12px; margin-top: 1px; }
.role-tag { border: 1px solid var(--baseline); border-radius: 4px; padding: 0 4px; font-size: 9.5px; letter-spacing: .06em; margin-left: 5px; color: var(--ink-2); }

.dossier-people { display: grid; gap: 3px; }
.person-row {
  display: grid; grid-template-columns: 1fr auto 44px; gap: 10px; align-items: baseline;
  font-size: 13px; padding: 3px 6px; border-radius: 6px;
}
.person-row:hover { background: var(--surface-2); }
.person-row .p-name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-row .p-counts { display: inline-flex; gap: 7px; color: var(--ink-muted); font-size: 11.5px; white-space: nowrap; }
.person-row .p-counts .pc { display: inline-flex; align-items: center; gap: 4px; }
.person-row .p-counts .tier-dot { width: 7px; height: 7px; }
.person-row .p-score { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.people-more { font-size: 12px; color: var(--ink-muted); text-decoration: underline; margin-top: 4px; width: fit-content; }
.people-more:hover { color: var(--accent); }
.person-row { cursor: pointer; }
.p-tri { color: var(--accent); font-size: 9px; margin-right: 2px; }
.person-papers { padding: 2px 6px 8px 22px; display: grid; gap: 4px; }
.pp-item { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: baseline; font-size: 12.5px; }
.pp-item .tier-dot { position: relative; top: 1px; }
.pp-title a { color: var(--ink-2); text-decoration: none; }
.pp-title a:hover { color: var(--accent); text-decoration: underline; }
.pp-meta { color: var(--ink-muted); font-size: 11.5px; white-space: nowrap; }

/* ── tooltip ────────────────────────────────────────────────────────────── */
.tooltip {
  position: fixed; z-index: 90; pointer-events: none; max-width: 340px;
  background: var(--surface-2); border: 1px solid var(--baseline); border-radius: 9px;
  padding: 9px 12px; font-size: 12.5px; box-shadow: 0 10px 34px rgba(0,0,0,.5);
}
.tooltip .tt-value { font-size: 15px; font-weight: 650; color: var(--ink); }
.tooltip .tt-label { color: var(--ink-muted); }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; color: var(--ink-2); }
.tooltip .tt-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }

/* ── footer ─────────────────────────────────────────────────────────────── */
footer { max-width: 1060px; margin: 70px auto 0; padding: 40px 24px 80px; border-top: 1px solid var(--grid); }
footer h2 { font-size: 21px; margin-bottom: 18px; }
.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 26px; }
.method-grid p { color: var(--ink-2); font-size: 13.5px; margin-top: 6px; }
.footnote { color: var(--ink-muted); font-size: 12.5px; margin-top: 18px; max-width: 760px; }

@media (max-width: 720px) {
  .podium { grid-template-columns: 1fr; }
  .board-row { grid-template-columns: 26px minmax(120px, 170px) 1fr 60px; gap: 8px; }
  .dock-inner { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
