/*
 * OpenNIH — light, simple, powerful. See DESIGN.md.
 * Self-contained (no external fonts/CDN). Light-first; no dark auto-flip.
 */
:root {
  --bg: #ffffff;
  --bg-alt: #f7f8fb;
  --surface: #ffffff;
  --text: #0b0d12;
  --text-muted: #565d6b;
  --text-faint: #6b7280;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eaf0ff;
  --border: #e8eaf0;
  --shadow-sm: 0 1px 2px rgba(11, 13, 18, 0.06);
  --shadow: 0 10px 30px rgba(11, 13, 18, 0.08);
  --shadow-lg: 0 24px 60px rgba(11, 13, 18, 0.10);
  --radius: 14px;
  --maxw: 1080px;
  --ok: #047857;
  --warn: #92400e;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-strong); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; color: var(--text); }
p { margin: 0 0 1em; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent-strong); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0; z-index: 100; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.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; }

/* Nav */
.nav { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,0.85); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-strong); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 0.85rem; letter-spacing: -0.02em; }
.nav__links { display: flex; gap: 26px; align-items: center; }
.nav__links a { color: var(--text-muted); font-weight: 500; font-size: 0.95rem; }
.nav__links a:hover { color: var(--text); text-decoration: none; }
@media (max-width: 720px) { .nav__links a.hide-sm { display: none; } .nav__links { gap: 18px; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.97rem; padding: 12px 20px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn--primary { background: var(--accent-strong); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--accent); }
.btn--primary { padding: 13px 24px; font-size: 1rem; }
.btn--ghost, .btn--on-grad { background: #fff; color: var(--text-muted); border-color: var(--border); }
.btn--ghost:hover, .btn--on-grad:hover { background: var(--bg-alt); border-color: #d6dae3; color: var(--text); }
.btn[disabled] { opacity: .55; cursor: progress; transform: none; }

/* Hero */
.hero { background: var(--bg); padding: 96px 0 64px; position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(680px 320px at 88% -8%, var(--accent-soft), transparent 70%); pointer-events: none; }
.hero__inner { position: relative; max-width: 800px; }
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 650; color: var(--accent-strong); background: var(--accent-soft); border: 1px solid #dbe5ff; padding: 6px 13px; border-radius: 999px; margin-bottom: 24px; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-strong); }
.hero h1 { font-size: clamp(2.6rem, 6vw, 4.4rem); margin: 0 0 20px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.04; }
.hero p.lead { font-size: clamp(1.1rem, 2.2vw, 1.35rem); color: var(--text-muted); margin: 0 0 14px; max-width: 660px; }
.hero p.sub { font-size: 1.02rem; color: var(--text-muted); margin: 0 0 32px; max-width: 620px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }

/* Sections */
section.block { padding: 88px 0; }
section.block.alt { background: var(--bg-alt); }
.eyebrow { text-transform: uppercase; letter-spacing: .085em; font-size: .78rem; font-weight: 700; color: var(--accent-strong); margin: 0 0 12px; }
.block h2 { font-size: clamp(1.7rem, 3.6vw, 2.4rem); margin: 0 0 16px; font-weight: 750; }
.block .intro { color: var(--text-muted); max-width: 680px; font-size: 1.06rem; margin: 0 0 40px; }

/* Feature grid */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; position: relative; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.card::before { content: ""; position: absolute; left: 0; top: 22px; bottom: 22px; width: 3px; border-radius: 3px; background: var(--accent-strong); opacity: 0; transition: opacity .14s ease; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #dbe0ea; }
.card:hover::before { opacity: 1; }
.card .ico { width: 42px; height: 42px; border-radius: 11px; background: var(--accent-soft); display: grid; place-items: center; margin-bottom: 16px; color: var(--accent-strong); }
.card .ico svg { width: 22px; height: 22px; }
.card h3 { font-size: 1.12rem; margin: 0 0 8px; }
.card p { color: var(--text-muted); margin: 0; font-size: 0.97rem; }

/* Steps */
.steps { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); counter-reset: step; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.step::before { counter-increment: step; content: counter(step); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-strong); color: #fff; font-weight: 800; margin-bottom: 14px; }
.step h3 { font-size: 1.05rem; margin: 0 0 6px; }
.step p { color: var(--text-muted); font-size: 0.95rem; margin: 0; }

/* Note */
.note { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent-strong); border-radius: 12px; padding: 20px 22px; box-shadow: var(--shadow-sm); }
.note .ico { color: var(--accent-strong); flex-shrink: 0; margin-top: 2px; }
.note p { margin: 0; color: var(--text-muted); }
.note strong { color: var(--text); }

/* Sources */
.sources { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.src { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.src .tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 9px; border-radius: 999px; }
.tag--live { color: var(--ok); background: #e7f6f0; }
.tag--annual { color: var(--warn); background: #fbf0e1; }
.tag--planned { color: var(--text-faint); background: var(--bg-alt); }
.src h3 { font-size: 1rem; margin: 10px 0 6px; }
.src p { color: var(--text-muted); font-size: 0.92rem; margin: 0; }

/* CTA band */
.cta-band { background: var(--accent-soft); border: 1px solid #dbe5ff; border-radius: 18px; padding: 48px 40px; text-align: center; }
.cta-band h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 10px; }
.cta-band p { color: var(--text-muted); margin: 0 0 26px; }
.cta-band .cta { justify-content: center; }

/* Footer */
.footer { border-top: 1px solid var(--border); padding: 44px 0; color: var(--text-faint); font-size: 0.9rem; background: var(--bg); }
.footer__grid { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; align-items: flex-start; }
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text); }
.footer .cols { display: flex; gap: 48px; flex-wrap: wrap; }
.footer .col { display: flex; flex-direction: column; gap: 9px; }
.footer .col strong { color: var(--text); font-size: 0.82rem; text-transform: uppercase; letter-spacing: .05em; }
.footer .disclaimer { margin-top: 28px; font-size: 0.82rem; max-width: 760px; line-height: 1.55; }

/* Data viz (D3) */
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0 0 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.stat .num { font-size: clamp(1.9rem, 4.5vw, 2.6rem); font-weight: 800; color: var(--text); line-height: 1.05; letter-spacing: -0.03em; }
.stat .lbl { color: var(--text-muted); font-size: 0.9rem; margin-top: 5px; }
.data-asof { color: var(--text-faint); font-size: 0.85rem; margin: 0 0 32px; }
.charts { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 22px 16px; box-shadow: var(--shadow-sm); }
.chart-card h3 { font-size: 1.05rem; margin: 0 0 4px; }
.chart-card .cap { color: var(--text-faint); font-size: 0.82rem; margin: 0 0 14px; }
.chart-card svg { display: block; max-width: 100%; }
.chart-track { fill: var(--bg-alt); }
/* utility classes (replacing former inline styles, so CSP can be style-src 'self') */
.chart-h { min-height: 444px; }
.chart-h-lg { min-height: 552px; }
.note--mt { margin-top: 28px; }
.note--warn { border-left-color: var(--warn); }
.ico--warn { color: var(--warn); }
.brand--footer { margin-bottom: 8px; }
.chart-label { fill: var(--text-muted); font-size: 12px; }
.chart-value { fill: var(--text); font-size: 12.5px; font-weight: 700; }
#data-error { color: var(--warn); font-size: 0.9rem; }

/* AI chat */
.chat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); max-width: 820px; }
.chat__examples { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { font-size: 0.85rem; font-weight: 600; color: var(--accent-strong); background: var(--accent-soft); border: 1px solid #dbe5ff; border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.chip:hover { background: #dfe9ff; }
.chat__thread { display: flex; flex-direction: column; gap: 12px; max-height: 440px; overflow-y: auto; margin-bottom: 14px; }
.chat__thread:empty { display: none; }
.msg { display: flex; flex-direction: column; gap: 3px; }
.msg__who { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.msg__body { white-space: pre-wrap; line-height: 1.55; border-radius: 12px; padding: 12px 14px; font-size: 0.96rem; }
.msg--user .msg__body { background: var(--accent-soft); color: var(--text); align-self: flex-start; }
.msg--ai .msg__body { background: var(--bg-alt); color: var(--text); border: 1px solid var(--border); }
.msg__h { font-weight: 700; margin: 8px 0 2px; }
.msg__h:first-child { margin-top: 0; }
.msg__body ul { margin: 4px 0 4px 18px; padding: 0; }
.msg__body li { margin: 2px 0; }
.msg__body div:empty { min-height: 0.5em; }
.msg__body--pending { color: var(--text-faint); font-style: italic; }
.chat__form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chat__input { flex: 1 1 280px; min-width: 0; height: 46px; border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; font-size: 0.97rem; background: #fff; color: var(--text); }
.chat__input:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.chat__toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--text-muted); white-space: nowrap; }
.chat__note { color: var(--text-faint); font-size: 0.8rem; margin: 12px 0 0; }
