/* ---------- HELIX site styles ----------
 * Design goals:
 *  - WCAG AA contrast in both light and dark modes (>= 4.5:1 body, >= 3:1 large)
 *  - System font stack, zero CDN deps
 *  - Honor prefers-color-scheme; user override via data-theme on <html>
 *  - Honor prefers-reduced-motion
 *  - Visible focus rings, keyboard navigable
 */

:root {
  --bg:           #ffffff;
  --bg-elev:     #f7f7f9;
  --bg-code:     #f2f3f5;
  --fg:          #1a1d22;
  --fg-muted:    #525866;
  --fg-faint:    #8c92a0;
  --accent:      #1a56db;        /* contrast 7.3:1 on white */
  --accent-fg:   #ffffff;
  --border:      #d8dbe1;
  --border-strong: #b6bcc7;
  --ok-bg:       #d6f5e0;
  --ok-fg:       #0a4f23;        /* contrast > 7:1 on ok-bg */
  --warn-bg:     #fff1d6;
  --warn-fg:     #6b4400;        /* contrast > 7:1 on warn-bg */
  --info-bg:     #dde9ff;
  --info-fg:     #143580;        /* contrast > 7:1 on info-bg */
  --focus:       #1a56db;
  --shadow:      0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --radius:      10px;
  --radius-sm:   6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0e1116;
    --bg-elev:     #161a22;
    --bg-code:     #11141b;
    --fg:          #e6e9ef;
    --fg-muted:    #aab1be;
    --fg-faint:    #7a818f;
    --accent:      #76a9ff;       /* contrast 7.4:1 on bg */
    --accent-fg:   #0e1116;
    --border:      #262b35;
    --border-strong: #3a414e;
    --ok-bg:       #0f3a1e;
    --ok-fg:       #b8efc8;
    --warn-bg:     #3a2a0a;
    --warn-fg:     #ffd591;
    --info-bg:     #14264f;
    --info-fg:     #c6daff;
    --focus:       #76a9ff;
    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
  }
}

/* Theme override (user-toggled). */
html[data-theme="light"] {
  color-scheme: light;
  --bg:           #ffffff;
  --bg-elev:     #f7f7f9;
  --bg-code:     #f2f3f5;
  --fg:          #1a1d22;
  --fg-muted:    #525866;
  --fg-faint:    #8c92a0;
  --accent:      #1a56db;
  --accent-fg:   #ffffff;
  --border:      #d8dbe1;
  --border-strong: #b6bcc7;
  --ok-bg:       #d6f5e0;
  --ok-fg:       #0a4f23;
  --warn-bg:     #fff1d6;
  --warn-fg:     #6b4400;
  --info-bg:     #dde9ff;
  --info-fg:     #143580;
  --focus:       #1a56db;
  --shadow:      0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg:           #0e1116;
  --bg-elev:     #161a22;
  --bg-code:     #11141b;
  --fg:          #e6e9ef;
  --fg-muted:    #aab1be;
  --fg-faint:    #7a818f;
  --accent:      #76a9ff;
  --accent-fg:   #0e1116;
  --border:      #262b35;
  --border-strong: #3a414e;
  --ok-bg:       #0f3a1e;
  --ok-fg:       #b8efc8;
  --warn-bg:     #3a2a0a;
  --warn-fg:     #ffd591;
  --info-bg:     #14264f;
  --info-fg:     #c6daff;
  --focus:       #76a9ff;
  --shadow:      0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
}

/* ----------- Base ----------- */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, "Liberation Sans", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

p, ul, ol, dl { margin: 0 0 1em 0; }
ul, ol { padding-left: 1.4em; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }

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

code, pre, kbd, samp {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
               "Liberation Mono", monospace;
  font-size: 0.93em;
}
code {
  background: var(--bg-code);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
pre.code {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1em 1.2em;
  overflow-x: auto;
  margin: 0 0 1.5em 0;
}
pre.code code {
  background: transparent;
  border: none;
  padding: 0;
}

h1, h2, h3, h4 {
  color: var(--fg);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.5em 0;
}
h1 { font-size: clamp(2rem, 4vw + 1rem, 3.25rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 1.5vw + 1rem, 2rem); margin-top: 1em; }
h3 { font-size: 1.2rem; }

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: 0;
  top: -40px;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 8px 14px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.brand:hover { text-decoration: none; }
.brand-text { font-size: 1.05rem; }
.brand-mark { color: var(--accent); }

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--fg-muted);
  text-decoration: none;
  padding: 0.35rem 0.1rem;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

@media (max-width: 720px) {
  .site-nav { display: none; }
}

/* Header actions cluster (GitHub link + theme toggle) */
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.github-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--fg);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  text-decoration: none;
}
.github-link:hover {
  border-color: var(--border-strong);
  color: var(--accent);
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font: inherit;
}
.theme-toggle:hover { border-color: var(--border-strong); }
.theme-toggle-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, var(--fg) 40%, transparent 41%),
    var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--fg-muted);
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Hero ---------- */
.hero {
  padding: 3.5rem 0 2.5rem 0;
}
.eyebrow {
  margin: 0 0 0.5em 0;
  color: var(--fg-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lede {
  font-size: 1.15rem;
  color: var(--fg-muted);
  max-width: 62ch;
  margin: 0 0 1.5em 0;
}
.accent { color: var(--accent); }

.hero-badges {
  list-style: none;
  margin: 0 0 1.75em 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.badge {
  display: inline-block;
  padding: 0.35em 0.7em;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-pass { background: var(--ok-bg);  color: var(--ok-fg);  border-color: var(--ok-fg);  }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-fg); }

.hero-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.btn {
  display: inline-block;
  padding: 0.65em 1.15em;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  text-decoration: none;
  font-weight: 600;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-primary:hover { color: var(--accent-fg); filter: brightness(1.05); }

/* ---------- Sections ---------- */
section { margin: 2.5rem 0 3rem 0; }
section + section { border-top: 1px solid var(--border); padding-top: 2.5rem; }

/* ---------- Card list ---------- */
.card-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1em 1.2em;
}
.card h3 { margin-top: 0; color: var(--accent); }

/* ---------- Diagram ---------- */
.diagram-wrap {
  margin: 1.5em 0;
  padding: 1em;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.diagram {
  width: 100%;
  height: auto;
  color: var(--fg);
}
.d-node rect {
  fill: var(--bg);
  stroke: var(--border-strong);
  stroke-width: 1.5;
}
.d-node text {
  fill: var(--fg);
  font-size: 14px;
  font-weight: 600;
}
.d-node .d-meta {
  fill: var(--fg-muted);
  font-size: 11px;
  font-weight: 400;
}
.d-node .d-meta-out {
  fill: var(--accent);
  font-size: 11px;
  font-style: italic;
}
.d-l2 rect { fill: var(--info-bg); stroke: var(--info-fg); }
.d-l2 text { fill: var(--info-fg); }
.d-l2 .d-meta { fill: var(--info-fg); }
.d-edge { color: var(--fg-muted); }
.d-edge-label text { fill: var(--fg-muted); font-size: 11px; }
.d-edge-label-small { font-size: 10px !important; }

figcaption {
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin-top: 0.6em;
}

/* ---------- Results grid ---------- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.result-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2em 1.3em;
}
.result-card h3 { margin-top: 0; }
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4em 1em;
  margin: 0.5em 0 0.8em 0;
}
.kv dt { color: var(--fg-muted); font-weight: 400; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.result-source {
  color: var(--fg-faint);
  font-size: 0.85em;
  margin: 0;
}

/* ---------- Status table ---------- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.status-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.status-table th,
.status-table td {
  padding: 0.7em 1em;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.status-table thead th {
  background: var(--bg-elev);
  font-weight: 700;
  color: var(--fg-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.status-table tbody th {
  color: var(--fg-muted);
  font-weight: 600;
}
.status-table tbody tr:last-child td,
.status-table tbody tr:last-child th { border-bottom: none; }
.pill {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}
.pill-ok   { background: var(--ok-bg);   color: var(--ok-fg);   }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 3.5rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--fg-muted);
}
.footer-inner p { margin: 0 0 0.4em 0; font-size: 0.95rem; }
.footer-meta { color: var(--fg-faint); font-size: 0.85rem; }

/* ---------- 404 ---------- */
.error-page {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1rem;
}
.error-code {
  font-size: clamp(4rem, 12vw, 8rem);
  margin: 0;
  color: var(--accent);
  letter-spacing: -0.04em;
}
