/* ============================================================
   AAAC Organic Investigation — report site
   Editorial dossier aesthetic. Fraunces display / Archivo text.
   Chart chrome + palette from the validated dataviz reference.
   ============================================================ */

:root {
  color-scheme: light;
  /* chrome & ink (light) */
  --page:        #f9f9f7;
  --surface-1:   #fcfcfb;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --muted:       #898781;
  --grid:        #e1e0d9;
  --baseline:    #c3c2b7;
  --hairline:    rgba(11,11,11,0.10);
  /* categorical series (validated, light) */
  --series-1:    #2a78d6;
  --series-2:    #eb6834;
  --series-3:    #1baf7a;
  --shade-lo:    #86b6ef;   /* lighter step of series-1 ramp (dumbbell "before") */
  /* status (fixed) */
  --st-good:     #0ca30c;
  --st-warn:     #fab219;
  --st-serious:  #ec835a;
  --st-critical: #d03b3b;
  --success-text:#006300;
  --accent:      #2a78d6;
  --wash:        rgba(42,120,214,0.07);
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:      #0d0d0d;
    --surface-1: #1a1a19;
    --ink:       #ffffff;
    --ink-2:     #c3c2b7;
    --muted:     #898781;
    --grid:      #2c2c2a;
    --baseline:  #383835;
    --hairline:  rgba(255,255,255,0.10);
    --series-1:  #3987e5;
    --series-2:  #d95926;
    --series-3:  #199e70;
    --shade-lo:  #5598e7;
    --success-text:#0ca30c;
    --accent:    #3987e5;
    --wash:      rgba(57,135,229,0.10);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:      #0d0d0d;
  --surface-1: #1a1a19;
  --ink:       #ffffff;
  --ink-2:     #c3c2b7;
  --muted:     #898781;
  --grid:      #2c2c2a;
  --baseline:  #383835;
  --hairline:  rgba(255,255,255,0.10);
  --series-1:  #3987e5;
  --series-2:  #d95926;
  --series-3:  #199e70;
  --shade-lo:  #5598e7;
  --success-text:#0ca30c;
  --accent:    #3987e5;
  --wash:      rgba(57,135,229,0.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- header / nav ---------- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.site-head .inner {
  max-width: 1080px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 20px; min-height: 58px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--serif); font-weight: 600; font-size: 17px;
  color: var(--ink); text-decoration: none; letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand .sep { color: var(--muted); margin: 0 6px; font-weight: 300; }
.brand .sub { color: var(--ink-2); font-weight: 400; font-size: 14px; font-family: var(--sans); }
.site-nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.site-nav a {
  color: var(--ink-2); text-decoration: none; font-size: 13px;
  padding: 6px 10px; border-radius: 6px; letter-spacing: 0.01em;
}
.site-nav a .n { color: var(--muted); font-size: 11px; margin-right: 4px; font-variant-numeric: tabular-nums; }
.site-nav a:hover { background: var(--wash); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--wash); font-weight: 600; }
#themeToggle {
  background: none; border: 1px solid var(--hairline); color: var(--ink-2);
  border-radius: 6px; padding: 5px 10px; cursor: pointer; font: inherit; font-size: 13px;
}
#themeToggle:hover { color: var(--ink); border-color: var(--baseline); }

/* ---------- layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; }
.narrow { max-width: 760px; }

.kicker {
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin: 0 0 10px;
}
h1 {
  font-family: var(--serif); font-weight: 560; font-optical-sizing: auto;
  font-size: clamp(30px, 5vw, 46px); line-height: 1.12;
  letter-spacing: -0.015em; margin: 0 0 14px;
}
.lede { font-size: 18px; color: var(--ink-2); max-width: 720px; margin: 0 0 8px; }
h2 {
  font-family: var(--serif); font-weight: 560; font-size: clamp(22px, 3vw, 29px);
  letter-spacing: -0.01em; line-height: 1.2; margin: 0 0 12px;
}
h3 { font-size: 17px; font-weight: 650; margin: 0 0 8px; letter-spacing: -0.005em; }
p { margin: 0 0 14px; }
a { color: var(--accent); }
section.block { margin: 56px 0 0; }
.secnum {
  font-family: var(--serif); color: var(--muted); font-weight: 400;
  font-size: 15px; display: block; margin-bottom: 6px;
}
.rule { border: 0; border-top: 1px solid var(--hairline); margin: 48px 0; }
.small { font-size: 13.5px; color: var(--ink-2); }
.mut { color: var(--muted); }

/* ---------- cards, grids ---------- */
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 719px) { .grid.c2 { grid-template-columns: 1fr; } }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.card {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 20px 22px;
}
.card h3 { margin-top: 2px; }
.card .tag {
  display: inline-block; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin-bottom: 8px;
}
a.card { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--baseline); transform: translateY(-2px); }
a.card .go { color: var(--accent); font-size: 13px; font-weight: 600; }

/* ---------- stat tiles ---------- */
.stat {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 18px 20px 16px;
}
.stat .label { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; line-height: 1.35; }
.stat .value { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.05; }
.stat .was {
  font-size: 14px; color: var(--muted); text-decoration: line-through;
  text-decoration-thickness: 1.5px; margin-right: 8px; font-weight: 500;
}
.stat .note { font-size: 12.5px; color: var(--muted); margin-top: 7px; line-height: 1.45; }
.hero-figure {
  font-size: clamp(46px, 7vw, 72px); font-weight: 650; letter-spacing: -0.025em;
  line-height: 1; margin: 6px 0 4px;
}

/* correction typography — the learning-journey mark */
.correct { white-space: nowrap; }
.correct .old { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.correct .arrow { color: var(--muted); padding: 0 4px; }
.correct .new { font-weight: 650; }

/* ---------- status badges (icon + label, never color alone) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 20px; border: 1px solid var(--hairline);
  color: var(--ink-2); background: var(--surface-1); white-space: nowrap;
}
.badge .ic { font-size: 12px; line-height: 1; }
.badge.confirmed .ic { color: var(--st-good); }
.badge.revised .ic { color: var(--st-warn); }
.badge.retracted .ic { color: var(--st-critical); }
.badge.rejected .ic { color: var(--st-serious); }
.badge.open .ic { color: var(--muted); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 12px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; min-width: 560px; }
table.data caption {
  text-align: left; padding: 14px 16px 4px; font-weight: 650; font-size: 14.5px; color: var(--ink);
}
table.data th {
  text-align: left; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
table.data td { padding: 9px 14px; border-bottom: 1px solid var(--grid); vertical-align: top; color: var(--ink-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td strong, table.data td b { color: var(--ink); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--wash); }

/* ---------- viz ---------- */
.viz {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 18px 18px 12px; margin: 20px 0;
}
.viz .viz-title { font-weight: 650; font-size: 15px; margin: 0 0 2px; color: var(--ink); }
.viz .viz-sub { font-size: 13px; color: var(--ink-2); margin: 0 0 10px; }
.viz .legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 4px 0 8px; }
.viz .legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.viz .legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.viz .legend .sw.line { height: 3px; border-radius: 2px; width: 16px; }
.viz svg { display: block; width: 100%; height: auto; }
.viz svg text { font-family: var(--sans); }
.viz .src { font-size: 12px; color: var(--muted); margin: 8px 0 2px; }
.viz .mark { cursor: default; outline: none; }
.viz .mark:hover, .viz .mark:focus-visible { filter: brightness(1.12); }
.viz .mark:focus-visible { stroke: var(--ink); stroke-width: 1; }
details.viz-table { margin-top: 6px; border-top: 1px solid var(--grid); padding-top: 6px; }
details.viz-table summary {
  cursor: pointer; font-size: 12.5px; color: var(--ink-2); font-weight: 600;
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
details.viz-table summary::before { content: "▸"; color: var(--muted); font-size: 10px; transition: transform .15s; }
details.viz-table[open] summary::before { transform: rotate(90deg); }
details.viz-table table { border-collapse: collapse; font-size: 12.5px; margin: 8px 0 4px; }
details.viz-table th, details.viz-table td { padding: 4px 12px 4px 0; text-align: left; border-bottom: 1px solid var(--grid); color: var(--ink-2); }
details.viz-table td.num, details.viz-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
details.viz-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }

#viz-tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  background: var(--ink); color: var(--page);
  border-radius: 8px; padding: 7px 11px; font-size: 12.5px; line-height: 1.4;
  max-width: 260px; opacity: 0; transition: opacity .1s; font-family: var(--sans);
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
#viz-tooltip .v { font-weight: 700; font-size: 13.5px; }
#viz-tooltip.on { opacity: 1; }

/* ---------- prose furniture ---------- */
.callout {
  border-left: 3px solid var(--accent); background: var(--wash);
  border-radius: 0 10px 10px 0; padding: 14px 18px; margin: 18px 0;
}
.callout.warn { border-left-color: var(--st-warn); background: color-mix(in srgb, var(--st-warn) 7%, var(--surface-1)); }
.callout.crit { border-left-color: var(--st-critical); background: color-mix(in srgb, var(--st-critical) 6%, var(--surface-1)); }
.callout p:last-child { margin-bottom: 0; }

blockquote.finding {
  font-family: var(--serif); font-size: clamp(19px, 2.6vw, 24px); line-height: 1.35;
  font-weight: 500; letter-spacing: -0.01em; color: var(--ink);
  border-left: 3px solid var(--accent); margin: 28px 0; padding: 4px 0 4px 22px;
}

pre.code {
  background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 10px;
  padding: 16px 18px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.55; color: var(--ink-2); margin: 14px 0;
}
pre.code .hl { color: var(--st-critical); font-weight: 600; }
pre.code .cm { color: var(--muted); }

ol.stack { counter-reset: st; list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
ol.stack > li {
  counter-increment: st; background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 16px 18px 16px 62px; position: relative;
}
ol.stack > li::before {
  content: counter(st, decimal-leading-zero);
  position: absolute; left: 18px; top: 15px;
  font-family: var(--serif); font-size: 21px; color: var(--muted); font-weight: 500;
}
ol.stack h3 { margin-bottom: 4px; }
ol.stack p { margin-bottom: 0; font-size: 14px; color: var(--ink-2); }

ul.tick { list-style: none; padding: 0; margin: 0 0 14px; }
ul.tick li { padding: 4px 0 4px 22px; position: relative; }
ul.tick li::before { content: "—"; position: absolute; left: 0; color: var(--muted); }

/* round timeline (journey) */
.round { display: grid; grid-template-columns: 90px 1fr; gap: 20px; margin: 34px 0; }
.round .rn {
  font-family: var(--serif); font-size: 40px; font-weight: 500; color: var(--muted);
  line-height: 1; padding-top: 4px;
}
.round .rn small { display: block; font-size: 11px; font-family: var(--sans); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 6px; }
@media (max-width: 640px) { .round { grid-template-columns: 1fr; gap: 6px; } .round .rn { font-size: 28px; } }

/* pager */
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 64px; }
.pager a {
  flex: 1; max-width: 340px; text-decoration: none; color: inherit;
  border: 1px solid var(--hairline); border-radius: 12px; padding: 14px 18px; background: var(--surface-1);
}
.pager a:hover { border-color: var(--baseline); }
.pager .dir { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.pager .t { font-weight: 650; font-size: 15px; }
.pager a.next { text-align: right; margin-left: auto; }

/* footer */
.site-foot { border-top: 1px solid var(--hairline); margin-top: 40px; }
.site-foot .inner { max-width: 1080px; margin: 0 auto; padding: 28px 24px 40px; font-size: 12.5px; color: var(--muted); }
.site-foot p { margin: 0 0 6px; }

/* hero band on index */
.hero {
  padding: 26px 0 6px;
}
.hero .datestamp { font-variant-numeric: tabular-nums; }
