/* ===========================================================================
   Theme — Report 2026-21, "Polycrisis Resilience in the Twenty-First Century"

   Aesthetic: operations dashboard. The first entry in the series built as a
   dashboard rather than an essay, so it is the first to commit to a fully
   dark page: a wider canvas (1240px), panels on a slate ground, KPI tiles
   coloured by role — coral for pressure, teal for capacity, amber for
   buffers — and the four World Bank income groups held to fixed colours in
   every chart. Geist and Geist Mono throughout; no serif anywhere.

   Loaded after report.css. Because report.js reads the palette from these
   tokens, the dark values also re-colour every chart's axes and labels.
   =========================================================================== */

:root {
  --bg: #0f1419;
  --bg-card: #161d24;
  --bg-accent: #1c252e;
  --bg-dark: #0a0e12;
  --bg-dark-2: #070a0d;

  --text: #e6edf3;
  --text-secondary: #c2ccd6;
  --text-muted: #8b98a5;
  --text-inverse: #e6edf3;

  --primary: #2dd4bf;
  --primary-light: #5eead4;
  --accent: #f5b942;
  --accent-light: #fbd38d;

  --border: #2a3540;
  --border-light: #222c36;
  --rule: #2f3b47;

  --pressure: #ff6b5b;
  --capacity: #2dd4bf;
  --buffer: #f5b942;

  --chart-blue: #7aa2f7;
  --chart-blue-light: #a9c1fa;
  --chart-gold: #f5b942;
  --chart-red: #ff6b5b;
  --chart-teal: #2dd4bf;
  --chart-gray: #8b98a5;
  --chart-orange: #fb923c;
  --chart-purple: #b794f6;

  --serif: Geist, -apple-system, BlinkMacSystemFont, "system-ui", "Segoe UI", sans-serif;
  --sans: Geist, -apple-system, BlinkMacSystemFont, "system-ui", "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --max-width: 1240px;
}

html { color-scheme: dark; }
body { background: var(--bg); color: var(--text); font-size: 0.98rem; line-height: 1.68; }

::selection { background: rgba(45, 212, 191, 0.28); }
:where(a, button, input, select, [tabindex]):focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

a { color: var(--primary-light); }
a:hover { color: var(--accent); }

.progress__bar { background: var(--primary); }
.skip-link { background: var(--primary); color: #0f1419; }

/* --- masthead: a status bar, not a banner --------------------------------- */

.masthead {
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, rgba(230, 237, 243, 0.07) 1px, transparent 1.5px) 0 0 / 22px 22px,
    linear-gradient(180deg, #121a21 0%, #0f1419 100%);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: 2.6rem var(--gutter) 2.4rem;
}
/* A three-segment status strip: pressure, capacity, buffers. */
.masthead::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 4px;
  background: linear-gradient(90deg, var(--pressure) 0 33.33%, var(--capacity) 33.33% 66.66%, var(--buffer) 66.66% 100%);
}
.masthead .overline {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  color: var(--primary);
  margin-bottom: 1rem;
}
.masthead .overline::before {
  content: "● DASHBOARD · ";
  color: var(--pressure);
}
.masthead h1 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(1.9rem, 4.4vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  max-width: 26ch;
  color: #ffffff;
}
.masthead .subtitle {
  font-weight: 400;
  color: var(--text-secondary);
  max-width: 70ch;
}
.masthead .strapline {
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.98rem;
  color: var(--text-muted);
  border-left: 3px solid var(--primary);
  max-width: 80ch;
}
.masthead .meta-row {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.74rem;
}
.masthead .meta-row strong {
  color: var(--primary);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
}

/* --- site bar, nav ---------------------------------------------------------- */

.sitebar { background: var(--bg-dark-2); border-bottom-color: var(--border); }
.sticky-nav {
  background: rgba(15, 20, 25, 0.94);
  border-bottom: 1px solid var(--border);
}
.nav-inner a {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}
.nav-inner a:hover { color: var(--text); }
.nav-inner a.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- section headings -------------------------------------------------------- */

section > h2 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  letter-spacing: -0.025em;
  color: #ffffff;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}
section > .section-dek {
  font-style: normal;
  color: var(--text-muted);
  font-size: 0.98rem;
  max-width: none;
}
section > h3 { color: var(--text); font-family: var(--sans); font-weight: 600; }

.content > section > p:not(.section-dek) { color: var(--text-secondary); }

.section-rule { border-top: 1px solid var(--border-light); margin: 2.6rem 0 2.8rem; }

/* --- generated blocks --------------------------------------------------------- */

.abstract {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
}
.abstract h2 { color: var(--primary); font-family: var(--mono); letter-spacing: 0.14em; border-bottom: 0; }
.abstract p { color: var(--text-secondary); }

.endmatter h2 { color: #ffffff; border-bottom-color: var(--border); }
.endmatter .kw {
  background: var(--bg-accent);
  border-color: var(--border);
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 0.68rem;
}
.endmatter dt { font-family: var(--mono); font-size: 0.64rem; color: var(--text-muted); }
.endmatter dd { color: var(--text-secondary); }

/* --- KPI board ------------------------------------------------------------------ */

.kpi-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 1.4rem 0 1.6rem;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--text-muted);
  border-radius: 6px;
  padding: 0.95rem 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.kpi--pressure { border-top-color: var(--pressure); }
.kpi--capacity { border-top-color: var(--capacity); }
.kpi--finance { border-top-color: var(--buffer); }
.kpi-tag {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.kpi--pressure .kpi-tag { color: var(--pressure); }
.kpi--capacity .kpi-tag { color: var(--capacity); }
.kpi--finance .kpi-tag { color: var(--buffer); }
.kpi-value {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: #ffffff;
  margin: 0.35rem 0 0.25rem;
  font-variant-numeric: tabular-nums;
}
.kpi-label { font-size: 0.8rem; line-height: 1.4; color: var(--text-secondary); flex: 1; }
.kpi-delta {
  font-family: var(--mono);
  font-size: 0.7rem;
  margin-top: 0.55rem;
}
.kpi-delta--worse { color: var(--pressure); }
.kpi-delta--better { color: var(--capacity); }
.kpi-source {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  border-top: 1px solid var(--border-light);
  padding-top: 0.4rem;
}

/* --- readout box ------------------------------------------------------------------ */

.readout {
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.08), rgba(45, 212, 191, 0) 70%), var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 1rem 1.2rem 0.4rem;
  margin: 1.4rem 0;
}
.readout-title {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 0.4rem !important;
}
.readout p { color: var(--text-secondary); text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.readout strong { color: #ffffff; }

/* --- panel grid -------------------------------------------------------------------- */

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 1.2rem 0;
}
.dash-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.1rem 0.8rem;
  min-width: 0;
}
.panel--wide { grid-column: 1 / -1; }
.panel--hero { margin: 1.2rem 0; padding: 1.1rem 1.2rem 1rem; }
.panel-head { border-bottom: 1px solid var(--border-light); margin-bottom: 0.75rem; padding-bottom: 0.55rem; }
.panel-title { font-weight: 600; font-size: 0.95rem; color: #ffffff; margin: 0 !important; letter-spacing: -0.01em; }
.panel-meta { font-family: var(--mono); font-size: 0.64rem; color: var(--text-muted); margin: 0.2rem 0 0 !important; }
.panel-note {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0.6rem 0 0 !important;
  text-align: left !important;
}
.panel .chart-frame { height: 300px; }
.panel .chart-frame--short { height: 230px; }
.panel--wide .chart-frame { height: 320px; }
.chart-frame--explorer { height: 480px !important; }

/* --- risk ranking ------------------------------------------------------------------ */

.risk-rank {
  list-style: none;
  counter-reset: rank;
  padding: 0;
  margin: 0;
  max-width: none;
}
.risk-rank li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.38rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.86rem;
  color: var(--text-secondary);
}
.risk-rank li::before {
  content: counter(rank, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  width: 1.6rem;
}
.rk {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  color: #0f1419;
  min-width: 2.6rem;
  text-align: center;
}
.rk-env { background: var(--capacity); }
.rk-tech { background: #7aa2f7; }
.rk-soc { background: var(--buffer); }

/* --- explorer ---------------------------------------------------------------------- */

.explorer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0.9rem;
}
.ctl { display: flex; flex-direction: column; gap: 4px; min-width: 200px; flex: 1 1 220px; }
.ctl-label { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.ctl input, .ctl select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.88rem;
}
.ctl-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  cursor: pointer;
}
.ctl-btn:hover { color: #ffffff; border-color: var(--primary); }

.explorer-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
.explorer-chart { min-width: 0; }

.country-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--text-muted);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  align-self: start;
}
.country-card[data-income="H"] { border-top-color: #7aa2f7; }
.country-card[data-income="UM"] { border-top-color: #2dd4bf; }
.country-card[data-income="LM"] { border-top-color: #f5b942; }
.country-card[data-income="L"] { border-top-color: #ff6b5b; }
.cc-kicker { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 0.3rem !important; }
.cc-name { font-weight: 600; font-size: 1.25rem; letter-spacing: -0.02em; color: #ffffff; margin: 0 !important; line-height: 1.2; }
.cc-meta { font-size: 0.78rem; color: var(--text-muted); margin: 0.25rem 0 0.8rem !important; text-align: left !important; }
.cc-stats { margin: 0; display: grid; gap: 0; }
.cc-stats > div { display: flex; justify-content: space-between; gap: 10px; padding: 0.42rem 0; border-top: 1px solid var(--border-light); }
.cc-stats dt { font-size: 0.76rem; color: var(--text-muted); }
.cc-stats dd { margin: 0; font-family: var(--mono); font-size: 0.8rem; color: #ffffff; text-align: right; }

.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--pressure);
  border-radius: 6px;
  padding: 0.8rem 1rem;
}
.stat-tile-value { font-weight: 600; font-size: 1.5rem; letter-spacing: -0.03em; color: #ffffff; margin: 0 !important; font-variant-numeric: tabular-nums; }
.stat-tile-label { font-size: 0.8rem; color: var(--text-muted); margin: 0.2rem 0 0 !important; text-align: left !important; }

.gap-explainer p { font-size: 0.86rem; color: var(--text-secondary); margin: 0 0 0.7rem !important; text-align: left !important; }
.gap-explainer strong { color: #ffffff; }

/* --- references ---------------------------------------------------------------------- */

.ref-list li { border-color: var(--border-light); color: var(--text-secondary); }
.ref-list .ref-org { font-family: var(--mono); color: var(--accent); font-size: 0.64rem; }

/* --- footer ---------------------------------------------------------------------------- */

.report-footer { background: var(--bg-dark); border-top: 1px solid var(--border); }
.footer-inner h3 { color: #ffffff; font-family: var(--sans); font-weight: 600; letter-spacing: -0.02em; }
.footer-inner a { color: var(--primary-light); }
.cite-box { background: var(--bg-card); border-left-color: var(--primary); }
.cite-box strong { color: var(--primary); }

/* --- responsive ------------------------------------------------------------------------ */

@media (max-width: 1000px) {
  .kpi-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .explorer-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .dash-grid, .dash-grid--three { grid-template-columns: minmax(0, 1fr); }
  .chart-frame--explorer { height: 380px !important; }
  .masthead { padding-top: 2rem; padding-bottom: 2rem; }
}
@media (max-width: 460px) {
  .kpi-board { grid-template-columns: minmax(0, 1fr); }
}

/* --- print ------------------------------------------------------------------------------ */

@media print {
  html { color-scheme: light; }
  body, .panel, .kpi, .country-card, .readout, .stat-tile { background: #fff !important; color: #000 !important; }
  .masthead { background: #fff !important; }
  .masthead h1, .kpi-value, .panel-title, .cc-name, .stat-tile-value { color: #000 !important; }
  .explorer-controls { display: none; }
}
