/* The visual system for every form. Every colour, size, radius and curve is a custom property on
   :root: a site restyles itself by overriding them in its own site.css, and nowhere else. */

@font-face {
  font-family: "Literata Variable"; font-style: normal; font-display: swap; font-weight: 200 900;
  src: url("fonts/literata-latin-opsz-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata Variable"; font-style: normal; font-display: swap; font-weight: 200 900;
  src: url("fonts/literata-latin-ext-opsz-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next Variable"; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next Variable"; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* colour roles; a site overrides the accent group in its site.css */
  --paper: #f9f6f2;
  --surface: #fefdfb;
  --ink: #211c17;
  --ink-muted: #615953;
  --rule: #dbd7d0;
  --rule-strong: #848078;
  --accent: #314c7e;
  --accent-strong: #213966;
  --accent-wash: #e5edfc;
  --on-accent: #fafcff;
  --danger: #ac312a;
  --danger-wash: #fcece9;
  --shadow: rgb(33 28 23 / 0.1);

  /* type */
  --font-display: "Literata Variable", Georgia, "Times New Roman", serif;
  --font-text: "Atkinson Hyperlegible Next Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.25rem;
  --text-question: clamp(1.625rem, 1.2rem + 1.9vw, 2.375rem);
  --text-display: clamp(2rem, 1.45rem + 2.4vw, 2.875rem);
  --text-count: 2.25rem;
  --text-ref: 1.75rem;

  /* space, on a 4px base */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  --badge: 4.5rem;
  --radius-control: 10px;
  --radius-button: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --measure: 40rem;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  color-scheme: light;
  accent-color: var(--accent);
  caret-color: var(--accent);
  scrollbar-color: var(--rule-strong) transparent;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100svh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  font: 400 var(--text-md) / 1.5 var(--font-text); font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-wash); color: var(--ink); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---- frame ---- */
.progress { position: fixed; inset: 0 0 auto; height: 3px; background: var(--rule); z-index: 10; }
.progress span {
  display: block; height: 100%; background: var(--accent);
  transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 320ms var(--ease-out);
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  width: min(100%, var(--measure)); margin: 0 auto; padding: var(--space-3) var(--space-5) 0;
}
.wordmark {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--ink); font: 600 var(--text-md) / 1 var(--font-display); text-decoration: none;
}
.where { margin: 0; color: var(--ink-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; text-align: right; }
main { flex: 1; width: min(100%, var(--measure)); margin: 0 auto; padding: var(--space-7) var(--space-5) var(--space-8); }
.foot { padding: var(--space-5); color: var(--ink-muted); font-size: var(--text-xs); text-align: center; }

/* ---- a screen ---- */
.step { animation: arrive 240ms var(--ease-out) both; }
@keyframes arrive { from { opacity: 0.4; transform: translateY(10px); } }
h1 {
  max-width: 26ch; margin: 0 0 var(--space-3);
  font: 460 var(--text-question) / 1.18 var(--font-display); letter-spacing: -0.012em; text-wrap: balance;
}
/* every screen moves focus here so assistive tech announces it; :focus-visible otherwise outranks
   a bare type selector, so a keyboard/touch ring would box the question on every arrival */
h1:focus-visible { outline: none; }
.intro h1, .done h1 { font-size: var(--text-display); line-height: 1.1; }
.badge { display: block; width: var(--badge); height: auto; margin-bottom: var(--space-4); }
h2 { margin: var(--space-6) 0 var(--space-2); font: 600 var(--text-lg) / 1.3 var(--font-display); }
.help { max-width: 60ch; margin: 0 0 var(--space-5); color: var(--ink-muted); }
.lead { max-width: 60ch; margin: 0 0 var(--space-4); }
.small { margin: var(--space-2) 0; color: var(--ink-muted); font-size: var(--text-sm); }

/* ---- answers ---- */
.field input {
  width: 100%; padding: var(--space-2) 0 var(--space-3); border: 0; border-bottom: 2px solid var(--rule-strong); border-radius: 0;
  background: transparent; color: var(--ink); font: 500 var(--text-lg) / 1.3 var(--font-text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.field input::placeholder { color: var(--ink-muted); opacity: 1; }
.field input:focus { outline: none; border-bottom-color: var(--accent); box-shadow: 0 2px 0 var(--accent); }

.options { display: grid; gap: var(--space-2); max-width: 32rem; }
.option {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  min-height: 52px; padding: var(--space-3) var(--space-4);
  border: 1px solid var(--rule); border-radius: var(--radius-control); background: var(--surface);
  font-weight: 500; cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease, transform 120ms var(--ease-out);
}
.option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.option .label { flex: 1; }
.option .note { color: var(--ink-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.option kbd {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px;
  border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--paper);
  color: var(--ink-muted); font: 700 var(--text-xs) / 1 var(--font-text);
}
.option::after {
  content: ""; flex: none; width: 18px; height: 18px; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0; transform: scale(0.8); transition: opacity 140ms ease, transform 180ms var(--ease-out);
}
.option.on { border-color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); }
.option.on kbd { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.option.on .note { color: var(--ink); }
.option.on::after { opacity: 1; transform: none; }
.option:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.option:active { transform: scale(0.985); }

.stepper { display: inline-flex; align-items: center; gap: var(--space-4); }
.stepper button {
  display: grid; place-items: center; width: 52px; height: 52px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: transform 120ms var(--ease-out), border-color 140ms ease;
}
.stepper button::before {
  content: ""; width: 20px; height: 20px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.stepper .less { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E"); }
.stepper .more { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.stepper button:active { transform: scale(0.95); }
.stepper button:disabled { opacity: 0.4; cursor: default; transform: none; }
.stepper output { min-width: 2ch; text-align: center; font: 500 var(--text-count) / 1 var(--font-display); font-variant-numeric: tabular-nums; }

.total {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4);
  max-width: 32rem; margin: var(--space-4) 0 0; padding-top: var(--space-3); border-top: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
}
.total strong { font: 650 var(--text-lg) / 1.2 var(--font-text); }

/* ---- actions ---- */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); margin-top: var(--space-5); }
.ok {
  min-height: 52px; padding: 0 var(--space-6); border: 0; border-radius: var(--radius-button);
  background: var(--accent); color: var(--on-accent); font: 650 var(--text-md) / 1 var(--font-text); letter-spacing: 0.01em;
  box-shadow: 0 1px 2px var(--shadow), 0 6px 16px -6px color-mix(in srgb, var(--accent) 45%, transparent);
  cursor: pointer; transition: background-color 140ms ease, transform 120ms var(--ease-out);
}
.ok:active { transform: scale(0.97); }
.back {
  order: -1; min-height: 44px; padding: 0 var(--space-2); border: 0; background: none;
  color: var(--ink-muted); font: 600 var(--text-sm) / 1 var(--font-text); cursor: pointer;
}
.hint { color: var(--ink-muted); font-size: var(--text-sm); }
.hint kbd { padding: 1px 6px; border: 1px solid var(--rule); border-radius: var(--radius-xs); background: var(--surface); font: 600 var(--text-xs) / 1.4 var(--font-text); }
.link {
  min-height: 44px; padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer;
  font: 600 var(--text-sm) / 1 var(--font-text); text-decoration: underline; text-underline-offset: 0.2em;
}
.link.danger { color: var(--danger); }
.later { margin: var(--space-5) 0 0; color: var(--ink-muted); font-size: var(--text-sm); }
@media (hover: hover) and (pointer: fine) {
  .option:hover { border-color: var(--rule-strong); }
  .ok:hover { background: var(--accent-strong); }
  .stepper button:hover:not(:disabled) { border-color: var(--ink-muted); }
}
@media (pointer: coarse) {
  .option kbd, .hint { display: none; }
}

/* ---- messages ---- */
.error {
  max-width: 32rem; margin: var(--space-4) 0 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  background: var(--danger-wash); color: var(--danger); font-size: var(--text-sm); font-weight: 600;
}
.error:empty { display: none; }
.notice { max-width: 60ch; margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-4); border-radius: var(--radius-control); background: var(--accent-wash); }

/* ---- review ---- */
.summary { display: grid; max-width: 34rem; margin: 0 0 var(--space-4); }
.summary .row {
  display: grid; grid-template-columns: 8.5rem 1fr auto; align-items: center; gap: var(--space-1) var(--space-4);
  padding: var(--space-1) 0; border-bottom: 1px solid var(--rule);
}
.summary dt { color: var(--ink-muted); font-size: var(--text-sm); }
.summary dd { margin: 0; font-weight: 500; overflow-wrap: break-word; }
.summary .change { min-height: 32px; } /* a text link, not a filled button: 32px clears the 24px floor without the full 44px control height */
.turnstile { min-height: 65px; margin: var(--space-3) 0 0; }

/* ---- details, done, lists ---- */
.guide { max-width: 60ch; margin: var(--space-5) 0 0; }
.guide summary { display: flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 600; cursor: pointer; }
.guide summary::marker { color: var(--accent); }
.guide p, .guide li { color: var(--ink-muted); }
.ref { margin: var(--space-4) 0 var(--space-5); font: 500 var(--text-ref) / 1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.ref small { display: block; margin-bottom: var(--space-2); color: var(--ink-muted); font: 400 var(--text-sm) / 1.4 var(--font-text); letter-spacing: 0; }
ol.next { max-width: 60ch; padding-left: 1.25em; }
ol.next li { margin-bottom: var(--space-2); }
.spinner {
  width: 28px; height: 28px; margin-top: var(--space-5);
  border: 3px solid var(--rule); border-top-color: var(--accent); border-radius: 50%; animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.links { display: grid; gap: var(--space-2); max-width: 32rem; padding: 0; list-style: none; }
.links a {
  display: flex; align-items: center; min-height: 52px; padding: 0 var(--space-4);
  border: 1px solid var(--rule); border-radius: var(--radius-control); background: var(--surface);
  color: var(--ink); font-weight: 500; text-decoration: none;
}
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 480px) {
  .top { padding-inline: var(--space-4); }
  main { padding: var(--space-4) var(--space-4) var(--space-7); }
  .actions { margin-top: var(--space-4); }
  .actions .ok { flex: 1; } /* a thumb-wide button on phones */
}
@media (max-width: 420px) {
  /* label, answer and Change stay on one line, so the total and the button stay on the first screen */
  .summary .row { grid-template-columns: 6.5rem 1fr auto; gap: var(--space-1) var(--space-3); }
}
@media (prefers-reduced-motion: reduce) {
  .step { animation: fade 160ms ease both; }
  @keyframes fade { from { opacity: 0.4; } }
  .progress span, .option, .ok, .stepper button { transition: none; }
  .spinner { animation-duration: 2s; }
}
