/* SafeScan - styles
   Tokens first, then base, layout, sections. Light + dark follow the visitor's system setting. */

:root {
  color-scheme: light;
  --ink: #14232e;
  --ink-2: #4b5c69;
  --paper: #eef2f4;
  --panel: #ffffff;
  --rule: #d6dee3;
  --accent: #0f7c87;
  --on-accent: #ffffff;
  --focus: #0f7c87;

  --safe: #0aac23;
  --caution: #fbb315;
  --risky: #dc3c3d;
  --safe-text: #0b5e2f;
  --caution-text: #7a5200;
  --risky-text: #a02020;

  /* chart (validated categorical slots 1-4) */
  --s1: #257de0;
  --s2: #f47230;
  --s3: #00b894;
  --s4: #f2a600;
  --grid: #e7e7e7;
  --axis: #c2c2c2;

  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e8eef2;
    --ink-2: #9db0be;
    --paper: #0e161c;
    --panel: #16212a;
    --rule: #2a3843;
    --accent: #4cc2ce;
    --on-accent: #0e161c;
    --focus: #4cc2ce;

    --safe-text: #62d487;
    --caution-text: #f2c25a;
    --risky-text: #ff8a8a;

    --s1: #338ced;
    --s2: #e76624;
    --s3: #00a888;
    --s4: #d28e05;
    --grid: #303030;
    --axis: #474747;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.9em; background: color-mix(in srgb, var(--ink) 8%, transparent); padding: 0.1em 0.35em; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--ink-2); }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font: 700 1.15rem var(--font-display); color: var(--ink); text-decoration: none; }
.brand-mark { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: 0.95rem; }
.nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.nav a.nav-cta { background: var(--accent); color: var(--on-accent); }
.nav a.nav-cta:hover { background: var(--accent); filter: brightness(1.08); }

/* ---------- intro ---------- */
.intro { padding: 72px 0 24px; }
.intro h1 { font-size: clamp(2.2rem, 5.5vw, 3.75rem); font-weight: 700; max-width: 16ch; }
.lede { margin-top: 20px; max-width: 58ch; font-size: 1.15rem; color: var(--ink-2); }
.lede strong { color: var(--ink); }

/* ---------- sections ---------- */
.block { padding: 56px 0 24px; border-top: 1px solid var(--rule); margin-top: 48px; }
.block h2 { font-size: clamp(1.6rem, 3.2vw, 2.1rem); font-weight: 700; }
.block h3 { font-size: 1.15rem; font-weight: 600; margin: 40px 0 12px; }
.section-lede { margin-top: 12px; max-width: 68ch; color: var(--ink-2); }
.section-lede strong { color: var(--ink); }

/* facts */
.facts { display: flex; flex-wrap: wrap; gap: 8px 48px; margin: 28px 0 0; }
.facts div { min-width: 140px; }
.facts dt { color: var(--ink-2); font-size: 0.9rem; order: 2; }
.facts dd { margin: 0; font: 700 1.9rem/1.1 var(--font-display); }
.facts div { display: flex; flex-direction: column; }

/* tables */
.table-wrap { overflow-x: auto; margin-top: 4px; }
table.plain { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.plain th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 10px 16px 10px 0; border-bottom: 2px solid var(--rule); white-space: nowrap; }
table.plain td { padding: 10px 16px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.plain td:first-child, table.plain th:first-child { padding-left: 0; }
table.plain code { white-space: nowrap; }
table.nums td, table.nums th { text-align: right; font-variant-numeric: tabular-nums; }
table.nums td:first-child, table.nums th:first-child { text-align: left; }
table.nums tr.is-rf td { background: color-mix(in srgb, var(--accent) 11%, transparent); font-weight: 600; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.key-normal { background: var(--s1); }
.key-sus { background: var(--s2); }

.avg-cell { min-width: 150px; }
.avg-cell .bar { display: block; height: 8px; border-radius: 0 4px 4px 0; margin-bottom: 4px; min-width: 2px; }
.avg-cell .bar-normal { background: var(--s1); }
.avg-cell .bar-sus { background: var(--s2); }
.avg-cell span.v { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--ink-2); }

.previews details { border-bottom: 1px solid var(--rule); }
.previews summary { cursor: pointer; padding: 12px 0; font-weight: 500; }
.previews summary span { color: var(--ink-2); font-weight: 400; }
.previews .table-wrap { padding-bottom: 14px; }

.output-note { margin-top: 32px; max-width: 72ch; padding-left: 16px; border-left: 3px solid var(--accent); }

/* ---------- chart ---------- */
.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-top: 28px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 10px; padding: 3px; margin: 0; gap: 2px; background: var(--panel); }
.seg label span { display: block; padding: 6px 12px; border-radius: 7px; font-size: 0.9rem; cursor: pointer; color: var(--ink-2); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); font-weight: 500; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.chart { margin-top: 16px; background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 12px 8px 4px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-body); fill: var(--ink-2); font-size: 12px; }
.chart text.group { fill: var(--ink); font-weight: 600; font-size: 13px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .rf-band { fill: color-mix(in srgb, var(--accent) 11%, transparent); }
.chart .bar { transition: opacity .12s; }
.chart.has-hover .bar { opacity: .45; }
.chart.has-hover .bar.on { opacity: 1; }
#axis-note { margin: 10px 0 20px; font-size: 0.9rem; }
.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 8px; font-size: 0.88rem; line-height: 1.4; box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
.tooltip b { font-variant-numeric: tabular-nums; }

/* ---------- test ---------- */
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 24px; }
.examples-label { color: var(--ink-2); margin-right: 4px; }
.chip { font: 500 0.92rem var(--font-body); color: var(--ink); background: var(--panel); border: 1px solid var(--rule); padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip:active { transform: translateY(1px); }

.test-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 40px; margin-top: 28px; align-items: start; }
.inputs fieldset { border: 0; padding: 0; margin: 0 0 28px; min-width: 0; }
.inputs legend { font: 600 1.05rem var(--font-display); padding: 0 0 8px; margin-bottom: 4px; width: 100%; border-bottom: 1px solid var(--rule); }
.slider { padding: 14px 0 6px; }
.slider-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.slider label { font-weight: 500; }
.slider .hint { color: var(--ink-2); font-size: 0.85rem; margin-top: 2px; }
.slider input[type=number] { width: 76px; font: 600 0.95rem var(--font-body); text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: 4px 8px; }
.slider input[type=range] { width: 100%; margin: 10px 0 0; accent-color: var(--accent); height: 28px; cursor: pointer; }

.result { position: sticky; top: 76px; background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; padding: 24px; }
.result h3 { margin: 0 0 16px; font-size: 1.15rem; }
.predict { width: 100%; font: 600 1.1rem var(--font-display); background: var(--accent); color: var(--on-accent); border: 0; border-radius: 10px; padding: 14px 18px; cursor: pointer; }
.predict:hover { filter: brightness(1.08); }
.predict:active { transform: translateY(1px); }

.verdict { margin: 22px 0 6px; min-height: 130px; }
.verdict-empty { color: var(--ink-2); }
.verdict-word { display: inline-flex; align-items: center; gap: 10px; font: 700 2.4rem/1 var(--font-display); letter-spacing: -0.02em; }
.verdict-word svg { flex: none; }
.verdict-text { margin-top: 10px; }
.verdict-prob { margin-top: 12px; color: var(--ink-2); }
.verdict-prob strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.stale-note { margin-top: 10px; font-size: 0.9rem; color: var(--caution-text); }
.verdict.is-safe .verdict-word { color: var(--safe-text); }
.verdict.is-caution .verdict-word { color: var(--caution-text); }
.verdict.is-risky .verdict-word { color: var(--risky-text); }
.verdict.is-stale .verdict-body > *:not(.stale-note) { opacity: .45; }

/* the scan gauge: probability 0-100%, cut at 20% and 80% */
.gauge { position: relative; margin-top: 44px; padding-bottom: 4px; }
.gauge-zones { display: grid; grid-template-columns: 20fr 60fr 20fr; gap: 3px; }
.zone { height: 16px; }
.zone-safe { background: var(--safe); border-radius: 8px 0 0 8px; }
.zone-caution { background: var(--caution); }
.zone-risky { background: var(--risky); border-radius: 0 8px 8px 0; }
.gauge-labels { display: grid; grid-template-columns: 20fr 60fr 20fr; gap: 3px; margin-top: 8px; font-size: 0.88rem; font-weight: 600; }
.gauge-labels small { display: block; font-weight: 400; color: var(--ink-2); font-size: 0.78rem; line-height: 1.25; }
.gl-caution { text-align: center; }
.gl-risky { text-align: right; }
.gauge-marker { position: absolute; top: -26px; height: 48px; width: 0; left: 0; transition: left .6s cubic-bezier(.2, .8, .2, 1); }
.gauge-marker::after { content: ""; position: absolute; left: -2px; top: 22px; bottom: 0; width: 4px; border-radius: 2px; background: var(--ink); outline: 2px solid var(--panel); }
.gauge-marker span { position: absolute; left: 0; top: 0; transform: translateX(-50%); background: var(--ink); color: var(--paper); font: 600 0.8rem var(--font-body); padding: 1px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gauge-marker.edge-left span { transform: translateX(-4px); }
.gauge-marker.edge-right span { transform: translateX(calc(-100% + 4px)); }

/* ---------- footer ---------- */
.foot { margin-top: 64px; border-top: 1px solid var(--rule); padding: 28px 0 56px; color: var(--ink-2); font-size: 0.9rem; }
.foot p { max-width: 80ch; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .test-grid { grid-template-columns: 1fr; gap: 12px; }
  .result { position: static; }
  .nav a:not(.nav-cta) { display: none; }
  .intro { padding-top: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .gauge-marker, .chart .bar { transition: none; }
}
