/* ---------------------------------------------------------------------------
   Candidate Atlas — site chrome.

   Roles, not colours, everywhere. Light and dark are stepped separately against
   their own surfaces and both passed the palette validator; dark is not an
   inversion of light. The three class hues (PLSI / frontier / control) are the
   same values the figure module uses, so a swatch here and a mark in the figure
   are literally the same colour.
   --------------------------------------------------------------------------- */

:root {
  --surface: #fcfcfb;
  --raised: #ffffff;
  --sunken: #f4f4f1;
  --ink: #17181a;
  --ink-2: #4a4e55;
  --muted: #868c95;
  --rule: #e2e2dd;
  --rule-strong: #c9c9c2;
  --accent: #00A607;
  --frontier: #3B5BA5;
  --control: #B5443A;
  --warn: #8a6d1f;
  --shadow: 0 1px 2px rgb(20 22 26 / .04), 0 8px 24px -12px rgb(20 22 26 / .18);
  --glow: radial-gradient(60rem 28rem at 12% -8%, rgb(0 166 7 / .09), transparent 60%);
  --radius: 14px;
  color-scheme: light;
}

:root[data-mode="dark"] {
  --surface: #16181c;
  --raised: #1d2026;
  --sunken: #121418;
  --ink: #eef0f3;
  --ink-2: #b4bac4;
  --muted: #7f8792;
  --rule: #2b2f37;
  --rule-strong: #3a404a;
  --accent: #2BAF55;
  --frontier: #5C8FE0;
  --control: #A64B39;
  --warn: #cfa94a;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 30px -14px rgb(0 0 0 / .7);
  --glow: radial-gradient(60rem 28rem at 12% -8%, rgb(43 175 85 / .12), transparent 60%);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  margin: 0;
  background: var(--surface);
  background-image: var(--glow);
  background-repeat: no-repeat;
  color: var(--ink);
  font: 16px/1.6 "Inter", "Helvetica Neue", -apple-system, system-ui, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--raised); color: var(--ink); padding: .6rem 1rem;
}
.skip:focus { left: .5rem; top: .5rem; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem max(1.5rem, calc((100vw - 1180px) / 2));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px) saturate(1.3);
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 650; letter-spacing: -.015em; color: var(--ink); text-decoration: none;
  white-space: nowrap;
}
.wordmark .dot {
  width: .55rem; height: .55rem; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.topbar nav { display: flex; gap: 1.35rem; margin-left: auto; overflow-x: auto; }
.topbar nav a {
  color: var(--ink-2); text-decoration: none; font-size: .85rem; white-space: nowrap;
  padding-bottom: 2px; border-bottom: 2px solid transparent;
}
.topbar nav a:hover, .topbar nav a.on { color: var(--ink); border-bottom-color: var(--accent); }
#mode {
  font: inherit; font-size: .8rem; padding: .3rem .8rem; border-radius: 999px;
  border: 1px solid var(--rule-strong); background: var(--raised); color: var(--ink-2);
  cursor: pointer;
}
#mode:hover { color: var(--ink); border-color: var(--accent); }

/* -------------------------------------------------------------------- page */
main { max-width: 1180px; margin: 0 auto; padding: 0 1.5rem; }

.hero { padding: 4.5rem 0 3rem; }
.eyebrow {
  margin: 0 0 1rem; font-size: .74rem; font-weight: 650; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted);
}
h1 {
  margin: 0 0 1.25rem; max-width: 25ch;
  font-size: clamp(1.95rem, 4.1vw, 3.05rem); line-height: 1.1;
  font-weight: 680; letter-spacing: -.028em;
}
h1 .hl {
  background-image: linear-gradient(transparent 62%, color-mix(in srgb, var(--accent) 26%, transparent) 0);
  padding: 0 .02em;
}
.lede { max-width: 66ch; margin: 0; font-size: 1.07rem; color: var(--ink-2); }

.section { padding: 4rem 0 1rem; border-top: 1px solid var(--rule); }
.section:first-of-type { border-top: 0; }
.kicker {
  margin: 0 0 .6rem; font-size: .76rem; font-weight: 650; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent);
}
h2 {
  margin: 0 0 1rem; max-width: 26ch;
  font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.16;
  font-weight: 650; letter-spacing: -.021em;
}
h3 { margin: 0 0 .35rem; font-size: 1rem; font-weight: 640; letter-spacing: -.01em; }
h3.sub { margin: 2.5rem 0 .8rem; font-size: 1.15rem; }
.prose { max-width: 72ch; color: var(--ink-2); }
.prose strong { color: var(--ink); font-weight: 620; }
.caption { max-width: 86ch; font-size: .83rem; line-height: 1.55; color: var(--muted); margin: .7rem 0 0; }
.fineprint { margin: 1.4rem 0 0; font-size: .82rem; color: var(--muted); max-width: 80ch; }

/* ------------------------------------------------------------------- stats */
.stats {
  display: grid; gap: 1px; margin-top: 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius);
  overflow: hidden;
}
.stat { background: var(--raised); padding: 1.15rem 1.15rem 1.25rem; }
.stat b {
  display: block; font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 680;
  letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.stat b small { font-size: .55em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat span { display: block; margin-top: .3rem; font-size: .82rem; color: var(--ink-2); }
.stat em { display: block; margin-top: .25rem; font-size: .72rem; font-style: normal; color: var(--muted); }

/* ------------------------------------------------- pull quote & takeaways */
/* One sentence a reader should leave with, set large enough that it is not a caption. */
.pull {
  margin: 1.75rem 0 0; padding-left: 1.1rem; border-left: 3px solid var(--accent);
  max-width: 74ch;
}
.pull p { margin: 0; font-size: 1.08rem; line-height: 1.55; color: var(--ink-2); }
.pull strong { color: var(--ink); font-weight: 620; }

.takeaways {
  list-style: none; padding: 0; margin: 2rem 0 0; max-width: 84ch;
  display: grid; gap: .9rem;
}
.takeaways li {
  padding-left: 1.1rem; border-left: 1px solid var(--rule);
  font-size: .92rem; color: var(--ink-2);
}
.takeaways b { color: var(--ink); font-weight: 620; }

/* ------------------------------------------------- progressive disclosure */
/* The detail that used to crowd the page lives here: present, one click away, closed. */
details.more {
  margin-top: 1.5rem; border-top: 1px solid var(--rule); padding-top: 1rem;
}
details.more > summary {
  cursor: pointer; list-style: none; font-size: .92rem; font-weight: 600;
  color: var(--ink-2); display: flex; align-items: center; gap: .55rem;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before {
  content: "+"; display: inline-grid; place-items: center;
  width: 1.3rem; height: 1.3rem; border-radius: 50%;
  border: 1px solid var(--rule-strong); color: var(--muted); font-size: .9rem; line-height: 1;
}
details.more[open] > summary::before { content: "−"; border-color: var(--accent); color: var(--accent); }
details.more > summary:hover { color: var(--ink); }
details.more > *:not(summary) { margin-top: 1.1rem; }

/* ------------------------------------------------------------------ plates */
.plate { margin: 2rem 0 0; }
.plate svg { width: 100%; height: auto; display: block; border-radius: 10px; }
.plate.wide { width: min(1400px, calc(100vw - 3rem)); margin-left: calc((100% - min(1400px, 100vw - 3rem)) / 2); }
.plate[aria-busy="true"] { min-height: 220px; border: 1px dashed var(--rule); border-radius: var(--radius); }

/* -------------------------------------------------------------- quadrants */
.quadrants {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 2rem;
  background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
}
.quad { background: var(--raised); padding: 1.1rem 1.15rem 1.25rem; }
.quad.lead { background: color-mix(in srgb, var(--accent) 7%, var(--raised)); }
.quad b { display: block; font-size: 2.1rem; font-weight: 680; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.quad span { display: block; margin-top: .4rem; font-size: .82rem; font-weight: 600; }
.quad em { display: block; margin-top: .15rem; font-size: .76rem; font-style: normal; color: var(--muted); }

/* ------------------------------------------------- the graph: focus layer */
/* Hovering a node dims everything it is not attached to. That is the whole reason to draw
   a graph rather than a table — you can see what a claim rests on — so it ships by
   default rather than as an enhancement. */
.plate svg g.g-node, .plate svg path.g-edge { transition: opacity .12s ease; }
.plate svg.focused g.g-node { opacity: .18; }
.plate svg.focused g.g-node.on { opacity: 1; }
.plate svg.focused path.g-edge { opacity: .08; }
.plate svg.focused path.g-edge.on { opacity: 1; }

/* ------------------------------------------------------------------ audit */
.audit { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); margin-top: 2rem; }
.pass { background: var(--raised); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.15rem; }
.pass .score { font-size: 1.7rem; font-weight: 680; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.pass .score.ok { color: var(--accent); }
.pass h3 { margin-top: .5rem; }
.pass p { margin: .3rem 0 0; font-size: .85rem; color: var(--ink-2); }
.pass .blind { margin-top: .7rem; font-size: .78rem; color: var(--muted); }

.limits { max-width: 80ch; padding-left: 1.1rem; margin: 0; color: var(--ink-2); font-size: .92rem; }
.limits li { margin-bottom: .55rem; }
.limits b { color: var(--ink); font-weight: 620; }

/* ---------------------------------------------------------------- explorer */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1.8rem 0 1rem; }
.filters input, .filters select {
  font: inherit; font-size: .85rem; padding: .42rem .7rem; border-radius: 8px;
  border: 1px solid var(--rule-strong); background: var(--raised); color: var(--ink);
}
.filters input { min-width: 15rem; }
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters .count { font-size: .82rem; color: var(--muted); margin-left: auto; }

.tablewrap { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--raised); }
table.data { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.data th, table.data td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data thead th {
  position: sticky; top: 3.3rem; z-index: 5; background: var(--sunken);
  color: var(--muted); font-weight: 650; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
}
table.data thead th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
table.data thead th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--sunken); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }

.dots { display: inline-flex; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; display: block; border: 1px solid var(--rule-strong); }
.dots i.on { border-color: transparent; }

.chip {
  display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .74rem;
  font-weight: 620; border: 1px solid var(--rule-strong); color: var(--ink-2); white-space: nowrap;
}
.chip.supported { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }
.chip.contested { border-color: color-mix(in srgb, var(--warn) 55%, transparent); color: var(--warn); }

/* ----------------------------------------------------------------- drawer */
.drawer {
  position: fixed; top: 0; right: 0; z-index: 60; height: 100dvh;
  width: min(560px, 100vw); background: var(--raised);
  border-left: 1px solid var(--rule); box-shadow: var(--shadow);
  overflow-y: auto; padding: 0 1.5rem 3rem;
}
.drawer[hidden] { display: none; }
.drawer-head {
  position: sticky; top: 0; display: flex; justify-content: flex-end;
  padding: .6rem 0; background: var(--raised); border-bottom: 1px solid var(--rule); margin-bottom: 1rem;
}
#drawer-close {
  font: inherit; font-size: 1.3rem; line-height: 1; width: 2rem; height: 2rem;
  border-radius: 8px; border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink-2); cursor: pointer;
}
#drawer-close:hover { border-color: var(--accent); color: var(--ink); }
.drawer h3 { font-size: 1.15rem; margin-bottom: .5rem; }
.drawer .meta { display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0 1rem; }
.drawer .meta span {
  border: 1px solid var(--rule); border-radius: 999px; padding: .1rem .6rem;
  font-size: .76rem; color: var(--ink-2);
}
.drawer .why { font-size: .85rem; color: var(--ink-2); background: var(--sunken);
  border-radius: 10px; padding: .7rem .85rem; margin: 0 0 1.2rem; }
.origin { border-top: 1px solid var(--rule); padding: .85rem 0; }
.origin .who { font-size: .85rem; font-weight: 620; }
.origin .tags { display: flex; flex-wrap: wrap; gap: .3rem; margin: .35rem 0; }
.origin .tags span { font-size: .7rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: .04rem .35rem; }
.origin .tags span.human { color: #2F6FB5; border-color: color-mix(in srgb, #2F6FB5 40%, transparent); }
.origin .tags span.animal { color: #C2622F; border-color: color-mix(in srgb, #C2622F 40%, transparent); }
.origin .tags span.against { color: var(--control); border-color: color-mix(in srgb, var(--control) 45%, transparent); }
.origin q { display: block; font-size: .86rem; color: var(--ink-2); line-height: 1.55; }
.origin code { font-size: .74rem; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---------------------------------------------------------------- tooltip */
#tooltip {
  position: fixed; z-index: 70; pointer-events: none; max-width: 32ch;
  background: var(--ink); color: var(--surface); border-radius: 7px;
  padding: .4rem .6rem; font-size: .78rem; line-height: 1.4;
}
g.mark, g.row { cursor: pointer; }

/* ----------------------------------------------------------------- footer */
footer {
  max-width: 1180px; margin: 4rem auto 0; padding: 2rem 1.5rem 4rem;
  border-top: 1px solid var(--rule); font-size: .82rem; color: var(--muted);
}
footer p { max-width: 80ch; }
footer strong { color: var(--ink-2); }
.built { margin-top: 1.5rem; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .topbar nav { display: none; }
  /* A seven-facet plot scaled to a phone is unreadable, and a table squeezed to 390px
     drops its columns. Both get their own horizontal scroll instead, which keeps every
     mark and every column at a legible size. */
  .plate.wide { width: 100%; margin-left: 0; overflow-x: auto; }
  .plate.wide svg { min-width: 900px; }
  .tablewrap { overflow-x: auto; }
  table.data { min-width: 700px; }
  /* Sticky inside a horizontally scrolling box sticks to the box, not the page. */
  table.data thead th { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
@media print {
  .topbar, .filters, #tooltip, .drawer { display: none; }
  body { background: #fff; }
}
