:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f1ece3;
  --ink: #1f2a30;
  --ink-soft: #4a5961;
  --line: #ddd5c8;
  --brand: #1f5f5b;
  --brand-ink: #ffffff;
  --accent: #8f4e14;
  --focus: #2b7de9;
  --ok: #2f6b3a;
  --warn: #8a5a00;
  --high: #9b2c2c;
  --ok-bg: #e5f1e7;
  --warn-bg: #fbf0d9;
  --high-bg: #f8e3e3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05);
  --max: 980px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12181b;
    --surface: #1a2226;
    --surface-2: #222c31;
    --ink: #e8e4dc;
    --ink-soft: #a9b3b7;
    --line: #2f3b40;
    --brand: #5fb3ab;
    --brand-ink: #0d1a19;
    --accent: #e0a060;
    --focus: #7fb2ff;
    --ok: #8fd19c;
    --warn: #f0c26b;
    --high: #f19a9a;
    --ok-bg: #1d3323;
    --warn-bg: #3a2f17;
    --high-bg: #3d2020;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); margin: .2em 0 .4em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); margin: 2em 0 .5em; }
h3 { font-size: 1.15rem; margin: 1.4em 0 .3em; }

p, ul, ol { margin: 0 0 1em; }
li { margin-bottom: .35em; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--brand); color: var(--brand-ink); padding: 8px 14px; z-index: 100;
}
.skip:focus { left: 8px; top: 8px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
/* Keep the exit button on the same row as the logo; only the nav links may wrap. */
.site-header .wrap { display: flex; align-items: center; gap: 12px 20px; min-height: 64px; max-width: 1240px; padding-top: 8px; padding-bottom: 8px; }
.logo { font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.logo span { color: var(--brand); }
.nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 14px; font-size: .95rem; flex: 1 1 auto; min-width: 0; }
.nav a { color: var(--ink-soft); text-decoration: none; padding: 4px 0; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--brand); text-decoration: underline; }

.exit-btn {
  background: var(--high); color: #fff; border: 0; border-radius: 999px;
  padding: 8px 16px; font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .exit-btn { color: #1a0d0d; } }
.exit-hint { font-size: .8rem; color: var(--ink-soft); white-space: nowrap; flex-shrink: 0; }
@media (max-width: 1150px) { .exit-hint { display: none; } }

@media (max-width: 760px) {
  .site-header { position: static; }
  .site-header .wrap { flex-wrap: wrap; }
  .nav { justify-content: flex-start; }
  .progress { top: 0; }
  .exit-btn { position: fixed; right: 12px; bottom: 12px; z-index: 60; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
  .nav { order: 3; width: 100%; font-size: .9rem; }
  .exit-hint { display: none; }
}

/* Hero */
.hero { padding: 56px 0 32px; }
.hero .lede { font-size: 1.25rem; color: var(--ink-soft); max-width: 46ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; font-weight: 700; color: var(--accent); }

.doors { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 32px 0; }
.door {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.door:hover { transform: translateY(-2px); border-color: var(--brand); }
.door strong { display: block; font-size: 1.15rem; margin-bottom: 6px; color: var(--brand); }
.door span { color: var(--ink-soft); font-size: .98rem; }

/* Generic blocks */
main { padding-bottom: 48px; }
.page-head { padding: 40px 0 8px; }
.page-head p { font-size: 1.15rem; color: var(--ink-soft); max-width: 60ch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin: 0 0 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.callout { border-left: 4px solid var(--brand); background: var(--surface-2); padding: 16px 20px; border-radius: 0 var(--radius) var(--radius) 0; margin: 24px 0; }
.callout.warm { border-color: var(--accent); }
.callout p:last-child { margin-bottom: 0; }

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.pill-list li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .9rem; margin: 0; }

.btn {
  display: inline-block; background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 10px;
  padding: 12px 20px; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; color: var(--brand); border: 2px solid var(--brand); }

table { width: 100%; border-collapse: collapse; margin: 16px 0 24px; font-size: .97rem; }
th, td { text-align: left; vertical-align: top; padding: 12px; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); }
.table-scroll { overflow-x: auto; }

/* Help listings */
.resource { padding: 16px 0; border-bottom: 1px solid var(--line); }
.resource:last-child { border-bottom: 0; }
.resource h3 { margin: 0 0 4px; }
.resource .meta { font-size: .9rem; color: var(--ink-soft); }
.tel { font-weight: 700; white-space: nowrap; }
.emergency { background: var(--high-bg); border: 1px solid var(--high); border-radius: var(--radius); padding: 18px 22px; margin: 24px 0; }
.emergency strong { color: var(--high); }

/* Self-check */
.q-section { margin: 32px 0; }
.q-section h2 { margin-top: 0; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 12px; }
.q legend { padding: 0; font-weight: 600; margin-bottom: 10px; }
.q fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.scale { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.scale label {
  display: flex; align-items: center; justify-content: center; text-align: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 6px; cursor: pointer; font-size: .92rem;
  background: var(--bg); min-height: 44px; position: relative;
}
.scale input:checked + span { font-weight: 700; text-decoration: underline; }
.scale input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
.scale label:has(input:checked) { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
@media (max-width: 520px) { .scale { grid-template-columns: repeat(2, 1fr); } }

.progress { position: sticky; top: 64px; z-index: 5; background: var(--bg); padding: 10px 0; font-size: .9rem; color: var(--ink-soft); }
.progress-bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress-bar div { height: 100%; width: 0; background: var(--brand); transition: width .2s ease; }

.results { margin-top: 32px; }
.result-band { border-radius: var(--radius); padding: 20px 22px; margin: 0 0 20px; }
.result-band.low { background: var(--ok-bg); }
.result-band.some { background: var(--warn-bg); }
.result-band.many { background: var(--high-bg); }
.result-band h2 { margin-top: 0; }
.meter { display: grid; grid-template-columns: minmax(110px, 180px) 1fr auto; gap: 10px; align-items: center; margin: 10px 0; font-size: .95rem; }
.meter .bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter .bar div { height: 100%; border-radius: 999px; }
.meter .low { background: var(--ok); }
.meter .some { background: var(--warn); }
.meter .many { background: var(--high); }
.meter .label { font-weight: 600; font-size: .85rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 32px 0; font-size: .92rem; color: var(--ink-soft); }
.site-footer .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.site-footer h2 { font-size: 1rem; margin: 0 0 8px; color: var(--ink); }
.site-footer ul { list-style: none; padding: 0; }
.support { background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; }
.support p { margin-bottom: .6em; }

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

@media print {
  .site-header, .site-footer, .exit-btn { display: none; }
}

.meta { font-size: .92rem; color: var(--ink-soft); }
