/* HALLMARK companion site — design tokens + chrome.
   Palette/mark specs follow a validated dataviz reference palette:
   categorical slots pass CVD + normal-vision floors in both modes;
   light-mode aqua sits below 3:1 on the surface, so every chart ships
   direct labels and a table view as the relief channel. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --seq-lo: #cde2fb;
  --seq-hi: #0d366b;
  --status-good: #0ca30c;
  --status-good-text: #006300;
  --status-critical: #d03b3b;
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.08);
  --shade-pre: #86b6ef;
  --shade-post: #1c5cab;
  --code-bg: #f0efec;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #242423;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --seq-lo: #0d366b;
    --seq-hi: #cde2fb;
    --status-good: #0ca30c;
    --status-good-text: #0ca30c;
    --status-critical: #d03b3b;
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.12);
    --shade-pre: #1c5cab;
    --shade-post: #86b6ef;
    --code-bg: #242423;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #242423;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --seq-lo: #0d366b;
  --seq-hi: #cde2fb;
  --status-good: #0ca30c;
  --status-good-text: #0ca30c;
  --status-critical: #d03b3b;
  --accent: #3987e5;
  --accent-wash: rgba(57, 135, 229, 0.12);
  --shade-pre: #1c5cab;
  --shade-post: #86b6ef;
  --code-bg: #242423;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  overflow-wrap: break-word;
}

/* wide content scrolls inside its own container, never the page */
html, body { overflow-x: clip; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
}

/* ---------- nav ---------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--grid);
}

.site-nav .brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.site-nav .links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 14px;
}

.site-nav .links a { color: var(--text-secondary); }
.site-nav .links a:hover { color: var(--text-primary); text-decoration: none; }

.nav-spacer { flex: 1; }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text-primary); }

/* ---------- layout ---------- */

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

section { padding: 56px 0 8px; }

.kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.section-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.section-lead {
  color: var(--text-secondary);
  max-width: 72ch;
  margin: 0 0 24px;
}

/* ---------- hero ---------- */

.hero { padding: 72px 0 24px; }

.hero h1 {
  font-size: clamp(40px, 6vw, 64px);
  letter-spacing: 0.02em;
  margin: 0 0 4px;
}

.hero .expansion {
  color: var(--text-secondary);
  font-size: 17px;
  margin: 0 0 14px;
  max-width: 78ch;
}

.hero .tagline {
  font-size: 19px;
  color: var(--text-primary);
  max-width: 72ch;
  margin: 0 0 22px;
}

.hero-links { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 34px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.stat-tile .label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-tile .value { font-size: 32px; font-weight: 650; line-height: 1.1; }
.stat-tile .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* ---------- cards ---------- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin: 0 0 20px;
}

.card > h3 { margin: 0 0 4px; font-size: 17px; }
.card .card-sub { color: var(--text-secondary); font-size: 14px; margin: 0 0 16px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.card-grid .card { margin: 0; }

/* ---------- chips & filters ---------- */

.filter-block { margin: 0 0 22px; }

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.filter-row .filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 118px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.chip:hover { background: var(--surface-2); }
.chip.on {
  background: var(--accent-wash);
  border-color: var(--accent);
  color: var(--text-primary);
}

.chip .count { color: var(--text-muted); font-size: 12px; }

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface-1);
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  padding: 6px 14px;
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }

/* ---------- chart chrome ---------- */

.chart-card { margin-bottom: 22px; }

.chart-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.chart-head h3 { margin: 0; font-size: 17px; }
.chart-head .spacer { flex: 1; }

.table-toggle {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 0;
}
.table-toggle:hover { text-decoration: underline; }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0 4px;
}
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend .linekey { width: 14px; height: 3px; border-radius: 2px; }

.axis-note { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }

svg text { font-family: inherit; }
svg .gridline { stroke: var(--grid); stroke-width: 1; }
svg .axisline { stroke: var(--baseline); stroke-width: 1; }
svg .ticklab { fill: var(--text-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
svg .axistitle { fill: var(--text-secondary); font-size: 12.5px; }
svg .directlab { fill: var(--text-primary); font-size: 12px; }
svg .directlab.dim { fill: var(--text-secondary); }

/* horizontal bar rows */

.bar-rows { display: grid; gap: 7px; }

.bar-row {
  display: grid;
  grid-template-columns: minmax(130px, 200px) 1fr 64px;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.bar-row .name { color: var(--text-secondary); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { position: relative; height: 18px; background: none; border-left: 1px solid var(--baseline); }
.bar-row .fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}
.bar-row .val { font-variant-numeric: tabular-nums; color: var(--text-primary); }

/* stacked composition bar */

.stackbar { display: flex; height: 20px; gap: 2px; border-radius: 5px; overflow: hidden; }
.stackbar .segf { height: 100%; }
.stack-labels { display: flex; gap: 16px; margin-top: 7px; font-size: 13px; color: var(--text-secondary); flex-wrap: wrap; }
.stack-labels b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* heatmap */

.heat-wrap { overflow-x: auto; padding-bottom: 4px; }
.heatmap { display: grid; gap: 2px; font-size: 12px; min-width: 720px; }
.heat-corner { }
.heat-collab {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: var(--text-secondary);
  font-size: 11.5px;
  padding: 2px 0;
  justify-self: center;
  max-height: 158px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.heat-rowlab {
  color: var(--text-secondary);
  font-size: 12.5px;
  align-self: center;
  text-align: right;
  padding-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}
.heat-cell {
  height: 26px;
  border-radius: 3px;
  cursor: default;
  position: relative;
}
.heat-cell:hover, .heat-cell:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 1px; }
.heat-cell.empty { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 3px, var(--surface-1) 3px, var(--surface-1) 6px); }

.scale-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.scale-legend .ramp { width: 140px; height: 10px; border-radius: 4px; }

/* leaderboard table */

.table-wrap { overflow-x: auto; }

table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
}
table.data th, table.data td {
  padding: 7px 10px;
  text-align: right;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  background: var(--surface-1);
}
table.data th .arrow { font-size: 10px; color: var(--accent); }
table.data td { font-variant-numeric: tabular-nums; color: var(--text-primary); }
table.data td.name-cell { font-weight: 500; white-space: normal; }
.name-flex { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.hm-dot {
  display: inline-block;
  position: static;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  vertical-align: middle;
}
.name-flex .cat-tag { margin-left: 0; flex: 0 0 auto; }
table.data td.best { font-weight: 700; }
table.data tr:hover td { background: var(--accent-wash); }
.cat-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  padding: 1px 7px;
  margin-left: 8px;
  color: var(--text-secondary);
  background: var(--surface-2);
  vertical-align: 2px;
  white-space: nowrap;
}

/* ---------- examples ---------- */

.example-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  margin-bottom: 10px;
  overflow: hidden;
}

.example-card summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.example-card summary::-webkit-details-marker { display: none; }
.example-card summary:hover { background: var(--surface-2); }
.example-card summary .twist { color: var(--text-muted); font-size: 11px; transition: transform 0.15s; }
.example-card[open] summary .twist { transform: rotate(90deg); }
.example-card summary .ex-title {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  min-width: 200px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge.hallucinated { background: color-mix(in srgb, var(--status-critical) 14%, transparent); color: var(--status-critical); }
.badge.valid { background: color-mix(in srgb, var(--status-good) 14%, transparent); color: var(--status-good-text); }
.badge.tier { background: var(--surface-2); color: var(--text-secondary); }
.badge.type { background: var(--accent-wash); color: var(--text-secondary); }

.example-body { padding: 4px 16px 16px; border-top: 1px solid var(--grid); }

.example-body pre.bibtex {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 12px 0;
  line-height: 1.5;
}

.explain {
  font-size: 14px;
  color: var(--text-secondary);
  border-left: 3px solid var(--baseline);
  padding: 2px 0 2px 12px;
  margin: 12px 0;
}
.explain b { color: var(--text-primary); }

.subtests { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.subtest {
  font-size: 12px;
  border-radius: 999px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.subtest.fail { border-color: color-mix(in srgb, var(--status-critical) 45%, transparent); color: var(--status-critical); }
.subtest.pass { border-color: color-mix(in srgb, var(--status-good) 45%, transparent); color: var(--status-good-text); }

.examples-count { font-size: 13.5px; color: var(--text-muted); margin: 4px 0 14px; }

/* taxonomy cards */

.tax-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.tax-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.tax-card:hover { border-color: var(--accent); }
.tax-card.on { border-color: var(--accent); background: var(--accent-wash); }
.tax-card h4 { margin: 0 0 2px; font-size: 14.5px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tax-card h4 .n { color: var(--text-muted); font-weight: 500; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tax-card p { margin: 4px 0 0; font-size: 13px; color: var(--text-secondary); }
.tax-card .tiers { margin-top: 8px; display: flex; gap: 4px; }

.tax-detail { margin-top: 16px; }

/* ---------- tooltip ---------- */

.viz-tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
  padding: 8px 12px;
  font-size: 13px;
  max-width: 320px;
  display: none;
}
.viz-tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.viz-tooltip .tt-row { display: flex; align-items: center; gap: 7px; color: var(--text-secondary); }
.viz-tooltip .tt-row b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.viz-tooltip .tt-key { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* ---------- cite ---------- */

.cite-box { position: relative; }
.cite-box pre {
  background: var(--code-bg);
  border-radius: 10px;
  padding: 18px 20px;
  overflow-x: auto;
  line-height: 1.5;
  margin: 0;
}
.copy-btn { position: absolute; top: 10px; right: 10px; }

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

footer {
  margin-top: 64px;
  border-top: 1px solid var(--grid);
  padding: 28px 0 48px;
  color: var(--text-muted);
  font-size: 13.5px;
}
footer a { color: var(--text-secondary); }

/* ---------- misc ---------- */

.note {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 78ch;
}

.hidden { display: none !important; }

.failure-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 18px; }
.failure-grid .card { margin: 0; display: flex; flex-direction: column; padding: 24px 26px; }
.failure-grid .card .viz { margin-top: auto; }
.failure-grid .card-sub { font-size: 15px; }

.card-limit {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text-primary);
  margin: 0 0 16px;
}
.failure-num {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 6px;
}

@media (max-width: 640px) {
  .bar-row { grid-template-columns: minmax(90px, 120px) 1fr 56px; font-size: 12.5px; }
  .site-nav .links { display: none; }
  section { padding: 40px 0 4px; }
}
