/* ============================================================================
   CREATINE — Evidence Explorer
   Design system. Everything downstream is written against these tokens.
   ============================================================================ */

:root {
  color-scheme: dark;

  /* Surfaces */
  --plane:        #0d0d0d;
  --surface-1:    #1a1a19;
  --surface-2:    #222220;
  --surface-3:    #2c2c2a;

  /* Ink */
  --ink:          #ffffff;
  --ink-2:        #c3c2b7;
  --ink-3:        #898781;

  /* Lines */
  --grid:         #2c2c2a;
  --axis:         #383835;
  --hair:         rgba(255,255,255,0.10);
  --hair-strong:  rgba(255,255,255,0.18);

  /* Categorical series (dark steps, fixed order — never cycled) */
  --s1: #3987e5;  /* blue    */
  --s2: #d95926;  /* orange  */
  --s3: #199e70;  /* aqua    */
  --s4: #c98500;  /* yellow  */
  --s5: #d55181;  /* magenta */
  --s6: #008300;  /* green   */
  --s7: #9085e9;  /* violet  */
  --s8: #e66767;  /* red     */

  /* Status — reserved. Never used as a series colour. */
  --st-good:     #0ca30c;
  --st-warning:  #fab219;
  --st-serious:  #ec835a;
  --st-critical: #d03b3b;

  /* Sequential blue ramp */
  --seq-100: #cde2fb; --seq-250: #86b6ef; --seq-400: #3987e5;
  --seq-500: #256abf; --seq-600: #184f95; --seq-700: #0d366b;

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

  --r-sm: 4px;
  --r:    8px;
  --r-lg: 14px;

  --maxw: 1180px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { line-height: 1.15; margin: 0; font-weight: 600; letter-spacing: -0.02em; }
p { margin: 0 0 1em; }
a { color: var(--s1); text-decoration-color: rgba(57,135,229,.4); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--s1);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--s1); color: #fff; padding: 10px 16px; border-radius: var(--r);
  transition: top .18s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------------------------------------------------------------- layout -- */
.wrap { width: min(100% - 40px, var(--maxw)); margin-inline: auto; }
.wrap-wide { width: min(100% - 32px, 1420px); margin-inline: auto; }

section[id] { scroll-margin-top: 76px; }

.section {
  padding: clamp(72px, 10vh, 128px) 0;
  border-top: 1px solid var(--hair);
  position: relative;
}
.section:first-of-type { border-top: none; }

.section-head { max-width: 780px; margin-bottom: clamp(32px, 5vh, 56px); }

.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.eyebrow::before {
  content: ''; width: 22px; height: 1px; background: var(--s1); flex: none;
}

.section-head h2 { font-size: clamp(28px, 4.2vw, 46px); margin-bottom: 16px; }
.section-head .lede { font-size: clamp(16px, 1.7vw, 19px); color: var(--ink-2); margin: 0; }

/* ------------------------------------------------------------------ nav --- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  background: rgba(13,13,13,.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
.nav.scrolled { border-bottom-color: var(--hair); }
.nav-inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.nav-brand {
  font-weight: 600; font-size: 15px; letter-spacing: -.01em; color: var(--ink);
  text-decoration: none; white-space: nowrap; display: flex; align-items: center; gap: 9px;
}
.nav-brand .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--s1);
  box-shadow: 0 0 12px var(--s1);
}
.nav-links {
  display: flex; gap: 2px; margin-left: auto; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  font-size: 13px; color: var(--ink-3); text-decoration: none; padding: 7px 11px;
  border-radius: 6px; white-space: nowrap; transition: color .18s, background .18s;
}
.nav-links a:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.nav-links a.active { color: var(--ink); background: rgba(57,135,229,.16); }
@media (max-width: 900px) { .nav-links { display: none; } }

/* ------------------------------------------------------- language toggle -- */
.lang-toggle {
  display: inline-flex; flex: none; margin-left: 14px;
  border: 1px solid var(--hair); border-radius: 999px;
  background: var(--surface-1); padding: 2px; gap: 2px;
}
.lang-btn {
  font: inherit; font-size: 11.5px; font-weight: 600; letter-spacing: .06em;
  background: none; border: none; color: var(--ink-3);
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
  transition: background .16s, color .16s;
}
.lang-btn:hover { color: var(--ink); }
.lang-btn.on { background: rgba(57,135,229,.22); color: #dce9fb; }
@media (max-width: 900px) { .lang-toggle { margin-left: auto; } }
@media print { .lang-toggle { display: none; } }

.progress {
  position: fixed; top: 0; left: 0; height: 2px; z-index: 101;
  background: linear-gradient(90deg, var(--s1), var(--s3));
  width: 0%;
}

/* ----------------------------------------------------------------- cards -- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  padding: 22px;
}
.card-quiet { background: var(--surface-1); border: 1px solid var(--hair); border-radius: var(--r); padding: 16px 18px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ---------------------------------------------------------------- badges -- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
  border: 1px solid currentColor;
}
.badge .ic { font-size: 9px; letter-spacing: -.5px; }

.grade-high     { color: var(--st-good); }
.grade-moderate { color: var(--st-warning); }
.grade-low      { color: var(--st-serious); }
.grade-verylow  { color: var(--st-critical); }

.badge.solid-high     { background: rgba(12,163,12,.14); }
.badge.solid-moderate { background: rgba(250,178,25,.14); }
.badge.solid-low      { background: rgba(236,131,90,.14); }
.badge.solid-verylow  { background: rgba(208,59,59,.14); }

.tag {
  display: inline-block; font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--hair); border-radius: 999px; padding: 3px 9px;
}

.coi-flag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; color: var(--st-warning);
  background: rgba(250,178,25,.10); border: 1px solid rgba(250,178,25,.32);
  padding: 4px 9px; border-radius: 999px;
}

/* ----------------------------------------------------------------- stats -- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface-1); border: 1px solid var(--hair);
  border-radius: var(--r); padding: 16px 18px;
}
.stat .val {
  font-size: clamp(26px, 3.4vw, 36px); font-weight: 600; letter-spacing: -.03em;
  line-height: 1.05; display: block;
}
.stat .lab { font-size: 12px; color: var(--ink-3); margin-top: 6px; display: block; }

/* ----------------------------------------------------------------- table -- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--hair); vertical-align: top; }
.tbl th {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600; white-space: nowrap;
}
.tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tbody tr:hover { background: rgba(255,255,255,.03); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --------------------------------------------------------------- buttons -- */
.btn {
  font: inherit; font-size: 13px; font-weight: 500;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--hair); border-radius: 999px;
  padding: 8px 16px; cursor: pointer;
  transition: background .16s, color .16s, border-color .16s;
}
.btn:hover { background: var(--surface-3); color: var(--ink); }
.btn.on { background: rgba(57,135,229,.18); border-color: rgba(57,135,229,.5); color: #dce9fb; }

.btn-primary {
  background: var(--s1); color: #fff; border-color: var(--s1); font-weight: 600;
}
.btn-primary:hover { background: #4d94ea; color: #fff; }

.chipbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

/* ------------------------------------------------------------- tooltips --- */
.tip {
  position: fixed; z-index: 300; pointer-events: none; opacity: 0;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--hair-strong); border-radius: var(--r);
  padding: 10px 12px; font-size: 12.5px; line-height: 1.45; max-width: 300px;
  box-shadow: 0 14px 40px rgba(0,0,0,.6);
  transition: opacity .12s var(--ease);
}
.tip.show { opacity: 1; }
.tip .tip-t { font-weight: 600; margin-bottom: 4px; }
.tip .tip-r { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- charts -- */
.chart-figure { margin: 0; }
.chart-figure figcaption {
  font-size: 12.5px; color: var(--ink-3); margin-top: 12px; line-height: 1.5;
}
.chart-title { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.chart-sub { font-size: 12.5px; color: var(--ink-3); margin-bottom: 16px; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart text { font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); margin-top: 12px; }
.legend .key { display: inline-flex; align-items: center; gap: 7px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }

/* ------------------------------------------------------------ disclosure -- */
.reveal { border-top: 1px solid var(--hair); }
.reveal-btn {
  width: 100%; background: none; border: none; color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500; text-align: left;
  padding: 14px 0; cursor: pointer; display: flex; align-items: center; gap: 10px;
}
.reveal-btn .chev { margin-left: auto; color: var(--ink-3); transition: transform .22s var(--ease); }
.reveal-btn[aria-expanded="true"] .chev { transform: rotate(90deg); }
.reveal-body { padding-bottom: 16px; font-size: 14px; color: var(--ink-2); }
.reveal-body[hidden] { display: none; }

.pro-con { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.pro-con li { padding: 7px 0 7px 24px; position: relative; color: var(--ink-2); line-height: 1.55; }
.pro-con li::before { position: absolute; left: 0; top: 7px; font-weight: 700; }
.pro-con.pros li::before { content: '+'; color: var(--st-good); }
.pro-con.cons li::before { content: '−'; color: var(--st-serious); }

.takeaway {
  border-left: 2px solid var(--s1); padding: 4px 0 4px 16px;
  font-size: 14.5px; color: var(--ink); margin-top: 18px;
}

/* -------------------------------------------------------------- utility --- */
.mono { font-family: var(--mono); font-size: .92em; }
.num  { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 32px; } .mb-2 { margin-bottom: 20px; } .mb-3 { margin-bottom: 32px; }
.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;
}

.footnote {
  font-size: 12.5px; color: var(--ink-3); line-height: 1.55;
  border-top: 1px solid var(--hair); padding-top: 14px; margin-top: 26px;
}

/* --------------------------------------------------------- scroll reveal -- */
.rise { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.rise.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .rise { opacity: 1; transform: none; } }

/* =========================================================== HERO ========= */
.hero {
  position: relative; min-height: 100svh;
  display: flex; align-items: center;
  overflow: hidden; border: none;
}
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, transparent 0%, rgba(13,13,13,.5) 70%, var(--plane) 100%),
    linear-gradient(180deg, transparent 60%, var(--plane) 100%);
}
.hero-inner { position: relative; z-index: 2; padding: 120px 0 90px; }
.hero h1 {
  font-size: clamp(44px, 8.5vw, 104px); font-weight: 600;
  letter-spacing: -.045em; line-height: .95; margin-bottom: 22px;
}
.hero .sub {
  font-size: clamp(17px, 2.4vw, 25px); color: var(--ink-2); font-weight: 300;
  max-width: 30ch; line-height: 1.3; letter-spacing: -.01em; margin-bottom: 30px;
}
.hero .meta { font-size: 13px; color: var(--ink-3); max-width: 58ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.scroll-hint {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 3; font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.scroll-hint .line {
  width: 1px; height: 30px;
  background: linear-gradient(180deg, var(--ink-3), transparent);
  animation: drop 2.1s ease-in-out infinite;
}
@keyframes drop { 0%,100% { opacity:.25; transform: scaleY(.55); transform-origin: top; } 50% { opacity:1; transform: scaleY(1); transform-origin: top; } }

/* ====================================================== MOLECULE VIEWER === */
.mol-stage {
  position: relative; background: var(--surface-1);
  border: 1px solid var(--hair); border-radius: var(--r-lg);
  min-height: 380px; overflow: hidden;
}
.mol-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.mol-stage canvas:active { cursor: grabbing; }
.mol-hud {
  position: absolute; left: 14px; top: 14px; right: 14px;
  display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none;
}
.mol-hud .btn { pointer-events: auto; backdrop-filter: blur(8px); background: rgba(34,34,32,.8); }
.mol-caption {
  position: absolute; left: 14px; bottom: 14px; right: 14px;
  font-size: 12px; color: var(--ink-3); pointer-events: none;
}
.mol-atom-label {
  position: absolute; pointer-events: none; font-size: 11px; font-family: var(--mono);
  background: rgba(13,13,13,.9); border: 1px solid var(--hair-strong);
  border-radius: 5px; padding: 3px 7px; white-space: nowrap;
  transform: translate(-50%, -160%); opacity: 0; transition: opacity .12s;
}
.mol-atom-label.show { opacity: 1; }

/* ================================================== PYRAMID / FLOW / MAP == */
.pyr-wrap { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,1fr); gap: 30px; align-items: start; }
@media (max-width: 940px) { .pyr-wrap { grid-template-columns: 1fr; } }
.pyr-stage {
  background: var(--surface-1); border: 1px solid var(--hair);
  border-radius: var(--r-lg); min-height: 420px; position: relative; overflow: hidden;
}
.pyr-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.pyr-stage canvas:active { cursor: grabbing; }

.flow-node {
  display: grid; grid-template-columns: 34px 1fr; gap: 14px;
  padding: 15px 17px; border: 1px solid var(--hair); border-radius: var(--r);
  background: var(--surface-1); cursor: pointer; text-align: left; width: 100%;
  font: inherit; color: inherit; transition: border-color .2s, background .2s, transform .2s;
}
.flow-node:hover { border-color: var(--hair-strong); transform: translateX(3px); }
.flow-node.lit { border-color: rgba(57,135,229,.5); background: rgba(57,135,229,.08); }
.flow-node .idx {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; border: 1px solid currentColor;
}
.flow-connector { width: 1px; height: 16px; background: var(--axis); margin-left: 32px; }

.verdict-pass    { color: var(--st-good); }
.verdict-partial { color: var(--st-warning); }
.verdict-split   { color: var(--st-warning); }
.verdict-fail    { color: var(--st-critical); }

.atlas { display: grid; grid-template-columns: minmax(0,340px) minmax(0,1fr); gap: 28px; align-items: start; }
@media (max-width: 860px) { .atlas { grid-template-columns: 1fr; } }
.atlas-fig { background: var(--surface-1); border: 1px solid var(--hair); border-radius: var(--r-lg); padding: 18px; }
.atlas-fig svg { display: block; width: 100%; height: auto; }
.organ-hit { cursor: pointer; transition: opacity .18s; }
.organ-hit:hover { opacity: .85; }

.scale-stage { background: var(--surface-1); border: 1px solid var(--hair); border-radius: var(--r-lg); padding: 20px; }
.scale-stage svg { display: block; width: 100%; height: auto; overflow: visible; }

/* ================================================================ DEBATE == */
.debate { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 20px; }
.debate-col h3 { font-size: 15px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 14px; }
.debate-col.for h3 { color: var(--st-good); }
.debate-col.against h3 { color: var(--st-serious); }
.claim {
  border: 1px solid var(--hair); border-radius: var(--r);
  background: var(--surface-1); margin-bottom: 10px; overflow: hidden;
}
.claim-btn {
  width: 100%; background: none; border: none; color: var(--ink); font: inherit;
  text-align: left; padding: 14px 16px; cursor: pointer;
  display: flex; align-items: flex-start; gap: 12px; line-height: 1.45;
}
.claim-btn:hover { background: rgba(255,255,255,.03); }
.claim-btn .txt { flex: 1; font-size: 14.5px; }
.claim-body { padding: 0 16px 16px; font-size: 13.5px; color: var(--ink-2); }
.claim-body[hidden] { display: none; }
.claim-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }

/* ============================================================== FILTERS === */
.filters { display: grid; grid-template-columns: minmax(0,320px) minmax(0,1fr); gap: 28px; align-items: start; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr; } }
.filter-panel { background: var(--surface-1); border: 1px solid var(--hair); border-radius: var(--r-lg); padding: 20px; position: sticky; top: 76px; }
@media (max-width: 900px) { .filter-panel { position: static; } }
.switch { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; cursor: pointer; border-top: 1px solid var(--hair); }
.switch:first-of-type { border-top: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--hair); position: relative; flex: none; margin-top: 2px;
  transition: background .18s, border-color .18s;
}
.switch .track::after {
  content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--ink-3); transition: transform .18s var(--ease), background .18s;
}
.switch input:checked + .track { background: rgba(57,135,229,.35); border-color: rgba(57,135,229,.6); }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--s1); outline-offset: 3px; }
.switch .lbl { font-size: 13.5px; line-height: 1.4; }
.switch .lbl small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; }

.survivor { transition: opacity .3s var(--ease), filter .3s var(--ease); }
.survivor.dropped { opacity: .22; filter: grayscale(1); }

/* =========================================================== REFERENCES === */
.ref-search {
  width: 100%; background: var(--surface-1); border: 1px solid var(--hair);
  border-radius: var(--r); color: var(--ink); font: inherit; font-size: 14px;
  padding: 12px 15px;
}
.ref-search::placeholder { color: var(--ink-3); }
.ref {
  border: 1px solid var(--hair); border-radius: var(--r); background: var(--surface-1);
  padding: 16px 18px; margin-bottom: 10px;
}
.ref h4 { font-size: 15px; margin-bottom: 6px; line-height: 1.35; }
.ref .cite { font-size: 13px; color: var(--ink-2); }
.ref .links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12.5px; }

.unverified {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  color: var(--st-warning); border: 1px dashed rgba(250,178,25,.5);
  border-radius: 999px; padding: 3px 8px;
}

/* ================================================================ FOOTER == */
.footer { border-top: 1px solid var(--hair); padding: 44px 0 60px; color: var(--ink-3); font-size: 13px; }
.footer strong { color: var(--ink-2); font-weight: 600; }

/* ================================================================= PRINT == */
@media print {
  .nav, .progress, .scroll-hint, #hero-canvas, .mol-hud { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .stat, .ref { border-color: #ccc; background: #fff; }
  .reveal-body[hidden], .claim-body[hidden] { display: block !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 10px; color: #555; }
}
