/* Contributors include people using screen magnification, high-contrast modes
 * and keyboard-only navigation, in a language most of them read less fluently
 * than the person who wrote this. Every colour pair below is measured against
 * WCAG 2.1: body text >= 4.5:1, and the borders that identify a form control
 * >= 3:1 (1.4.11). Most text sits nearer 7:1, because "technically passes" is
 * not the same as comfortable to read for an hour.
 *
 * Colour is never the only signal: states also carry a mark and a text label.
 */

:root {
  color-scheme: light dark;

  --bg: #f7f8fa;
  --card: #ffffff;
  --fg: #16181d;
  --muted: #54585e;          /* 7.16:1 on card */

  --line: #e3e6ea;           /* decorative rules only */
  --field-border: #818992;   /* 3.33:1 on page, 3.54:1 on card (1.4.11) */

  --accent: #0369a1;         /* 5.93:1 on card; white on it 5.93:1 */
  --accent-fg: #ffffff;
  --accent-soft: #e7f1f8;
  --accent-strong: #0b3f5e;  /* 9.72:1 on --accent-soft */

  --note-bg: #fdf3dd;
  --note-fg: #7a4b00;        /* 6.72:1 on --note-bg */
  --note-edge: #b3761b;

  --ok: #1b6e2f;             /* 6.33:1 on card */
  --danger: #9a3412;         /* 7.31:1 on card */

  --radius: 10px;
  --focus-width: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1c1f24;
    --fg: #e9ebee;
    --muted: #a8aeb6;        /* 7.39:1 on card */

    --line: #30353b;
    --field-border: #828b97; /* 5.25:1 on page, 4.79:1 on card */

    --accent: #5cc8ff;       /* 8.78:1 on card; dark text on it 9.98:1 */
    --accent-fg: #08131a;
    --accent-soft: #10303f;
    --accent-strong: #cfe8f7;

    --note-bg: #332a17;
    --note-fg: #f5c86b;      /* 9.00:1 on --note-bg */
    --note-edge: #c98f2e;

    --ok: #6ddb84;
    --danger: #ff9f7a;
  }
}

/* Readers who have asked their OS for more contrast get the extremes. */
@media (prefers-contrast: more) {
  :root {
    --muted: #2b2e33;
    --field-border: #16181d;
    --accent: #024e79;
    --line: #7b8289;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --muted: #f2f4f6;
      --field-border: #dfe3e8;
      --accent: #a5e0ff;
      --line: #98a1ab;
    }
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* -- accessibility utilities ---------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 0; }

/* One visible focus style everywhere, never removed. */
:focus-visible {
  outline: var(--focus-width) solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
/* Against an accent-filled button the accent outline would vanish. */
button:not(.secondary):not(.link):focus-visible,
.button:not(.secondary):focus-visible,
.skip-link:focus-visible {
  outline-color: var(--fg);
}

/* -- layout ---------------------------------------------------------- */

header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  background: var(--card);
  border-bottom: 2px solid var(--line);
}

.wordmark {
  font-weight: 650;
  color: inherit;
  text-decoration: none;
  margin-inline-end: auto;
}
.wordmark:hover { text-decoration: underline; }

.chip {
  border: 1px solid var(--field-border);
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  font-size: 0.85rem;
  color: var(--fg);
  background: var(--accent-soft);
}

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 5rem;
}

h1 { font-size: 1.55rem; line-height: 1.3; margin: 0 0 0.75rem; }

/* Section headers ("The situation") are a landmark, not a caption: accent
 * coloured, with a rule that visibly ends the section above. */
h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.9rem 0 0.75rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
h2::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--accent-soft);
}

.lede { font-size: 1.08rem; }
.muted { color: var(--muted); font-size: 0.95rem; }

.kicker {
  margin: 0 0 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

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

/* -- forms ----------------------------------------------------------- */

label {
  display: block;
  font-weight: 650;
  font-size: 1.05rem;
  margin-top: 1.5rem;
}

.hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

input[type="text"], textarea {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem 0.8rem;
  font: inherit;
  color: var(--fg);
  background: var(--card);
  border: 2px solid var(--field-border);
  border-radius: var(--radius);
}

input[type="text"]:focus-visible, textarea:focus-visible {
  border-color: var(--accent);
  outline: var(--focus-width) solid var(--accent);
  outline-offset: 1px;
}

::placeholder { color: var(--muted); opacity: 1; }

textarea { resize: vertical; line-height: 1.8; }

button, .button {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 650;
  color: var(--accent-fg);
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { filter: brightness(1.12); }

button.secondary, .secondary.button {
  background: var(--card);
  color: var(--accent);
  border-color: var(--field-border);
}

button.link {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 400;
  text-decoration: underline;
}

form.inline { display: inline; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--line);
}
.actions .button, .actions button { margin-top: 0; }
.actions button[value="next"] { margin-inline-start: auto; }

details {
  margin-top: 1.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
details[open] summary { margin-bottom: 0.5rem; }

/* -- the licence notice on the front page ---------------------------- */

/* A rights waiver has to be read, so it gets a surface of its own and full
 * body-text contrast -- never the muted grey reserved for asides. Accent rather
 * than amber: this is a condition of taking part, not a warning. */
.licence {
  margin: 1.75rem 0;
  padding: 1.1rem 1.3rem;
  background: var(--accent-soft);
  color: var(--fg);
  border: 1px solid var(--accent);
  border-inline-start: 5px solid var(--accent);
  border-radius: var(--radius);
}

.licence h2 {
  /* Not one of the small uppercase section labels. */
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin: 0 0 0.6rem;
  padding-top: 0;
  border-top: none;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
}
.licence h2::after { content: none; }

.licence .mark {
  flex: none;
  padding: 0.15rem 0.5rem;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.licence p { margin: 0.5rem 0 0; }
.licence a { color: var(--accent-strong); font-weight: 650; }
.licence .accept { font-weight: 650; }

/* -- the prompt card ------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-inline-start: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem 1.5rem;
  margin: 1.25rem 0;
}
.card h2:first-of-type { margin-top: 1.5rem; }

/* The pinned names are the whole point of the page: give them a surface of
 * their own so they cannot be mistaken for prose. */
.facts { margin: 0; }
.facts > div + div { margin-top: 1rem; }
.facts dt {
  color: var(--muted);
  font-size: 0.95rem;
}
.facts dd { margin: 0.2rem 0 0; }
.facts .value {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid var(--note-edge, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 6px;
  font-size: 1.15rem;
  font-weight: 700;
}

/* "Do not say the area's name" and friends. Colour, an edge, and a marker --
 * so it still reads as a caution with colour removed or overridden. */
.callout {
  display: flex;
  gap: 0.6rem;
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.85rem;
  background: var(--note-bg);
  color: var(--note-fg);
  border-inline-start: 4px solid var(--note-edge);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.95rem;
}
.callout .mark {
  flex: none;
  font-weight: 700;
}
p.callout { margin-top: 1rem; }

.examples {
  margin: 0;
  padding: 0.75rem 0.9rem;
  list-style: none;
  background: var(--accent-soft);
  border-inline-start: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.examples li {
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
}
.examples li + li { margin-top: 0.3rem; }

.warnings {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem 0.7rem 2.2rem;
  background: var(--note-bg);
  color: var(--note-fg);
  border-inline-start: 4px solid var(--note-edge);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.95rem;
}

q { font-style: normal; font-weight: 650; color: var(--fg); }

.detail {
  overflow-x: auto;
  padding: 0.85rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* -- progress -------------------------------------------------------- */

.bar {
  height: 12px;
  background: var(--card);
  border: 1px solid var(--field-border);
  border-radius: 999px;
  overflow: hidden;
}
.bar.slim { height: 8px; }
.bar span { display: block; height: 100%; background: var(--accent); }
.progress p { margin: 0.5rem 0 1rem; }

.crumbs {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.7rem;
  font-size: 0.95rem;
}

/* -- the queue ------------------------------------------------------- */

.intent { margin-top: 2.25rem; }
.intent h2 {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
  color: var(--fg);
}
.intent h2::after { background: var(--line); }

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}
.rows li + li { border-top: 1px solid var(--line); }
.rows a {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.7rem 0.9rem;
  color: inherit;
  text-decoration: none;
}
.rows a:hover { background: var(--accent-soft); text-decoration: underline; }
.rows a:focus-visible { outline-offset: -3px; }

.rows .mark {
  flex: none;
  width: 1.1rem;
  font-weight: 700;
  color: var(--muted);
}
.rows .answered .mark { color: var(--ok); }
.rows .skipped .mark { color: var(--danger); }
.rows .what { flex: 1; }
.rows .axis {
  flex: none;
  padding: 0.05rem 0.45rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}
.rows .skipped .what { color: var(--muted); }

/* -- flashes --------------------------------------------------------- */

.flash {
  display: flex;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  border-inline-start: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.flash.error {
  background: var(--note-bg);
  color: var(--note-fg);
  border-inline-start-color: var(--danger);
}

/* -- wake word review ------------------------------------------------ */

/* One screen: hear it, drag over the wake word, continue. The waveform is the
 * only unusual control here, so it gets a visible border like a form field
 * (1.4.11) and the same focus ring as everything else. */

.wake-word, .tickbox q { font-weight: 650; font-style: normal; }

/* The wake word in the heading, doubling as the button that plays the example.
 * It has to read as a control without reading as a form field in the middle of
 * a sentence: a play mark, an underline, and a background on hover and while
 * playing. */
h1 .play-word {
  margin: 0;
  /* No horizontal padding: it would hold the question mark away from the
     closing quote, and the underline has to end where the phrase does. */
  padding: 0.05em 0;
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  border-bottom: 2px dashed var(--accent);
  border-radius: 5px 5px 0 0;
  cursor: pointer;
}
h1 .play-word:hover { background: var(--accent-soft); filter: none; }
h1 .play-word[aria-pressed="true"] {
  background: var(--accent-soft);
  border-bottom-style: solid;
}
h1 .play-word .mark {
  width: 0.62em;
  height: 0.62em;
  margin-inline-end: 0.3em;
  fill: currentColor;
}
/* Which shape shows follows aria-pressed, so playing state lives in one place. */
h1 .play-word .is-stop,
h1 .play-word[aria-pressed="true"] .is-play { display: none; }
h1 .play-word[aria-pressed="true"] .is-stop { display: inline; }

.player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 0.5rem;
}
.player button { margin-top: 0; min-width: 7rem; }
.player .clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.95rem;
}

.player .boost {
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--note-edge);
  border-radius: 999px;
  background: var(--note-bg);
  color: var(--note-fg);
  font-size: 0.85rem;
  font-weight: 650;
}

#waveform {
  display: block;
  width: 100%;
  height: 200px;
  margin-top: 0.6rem;
  background: var(--card);
  border: 2px solid var(--field-border);
  border-radius: var(--radius);
  touch-action: none;
  cursor: crosshair;
}
#waveform.disabled { opacity: 0.45; cursor: not-allowed; }

details.keys { margin-top: 0.75rem; }
details.keys .hint { margin: 0; }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  padding: 0.05rem 0.3rem;
  border: 1px solid var(--field-border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}

.marks {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.marks:empty { display: none; }
.marks li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.9rem;
  min-height: 2.5rem;
}
.marks li + li { border-top: 1px solid var(--line); }
.marks .range {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.marks button { min-height: 1.5rem; }
/* The base button rule spaces buttons away from the text above them; inside a
 * row it has to sit on the line instead. */
.marks .play-mark {
  margin: 0;
  padding: 0.15rem 0.75rem;
  min-height: 1.75rem;
  font-size: 0.9rem;
}
.marks .play-mark[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* A note is an aside, so its label does not shout like the question above it. */
.notes-label { font-size: 0.95rem; margin-top: 1.5rem; }
.notes-label .optional { font-weight: 400; color: var(--muted); }
#notes { min-height: 3.2rem; line-height: 1.5; }

/* The only either/or on the page, so it is a target you can hit rather than a
 * checkbox sitting on its own. */
.tickbox {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin-top: 1.5rem;
  padding: 0.85rem 0.9rem;
  border: 2px solid var(--field-border);
  border-radius: var(--radius);
  background: var(--card);
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
}
.tickbox:hover { background: var(--accent-soft); }
.tickbox input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}
.tickbox:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* -- Windows High Contrast / forced colours -------------------------- */

@media (forced-colors: active) {
  .card, .callout, .examples, .warnings, .flash, .rows, .bar, details,
  .marks, .tickbox, .player .boost {
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--note-edge);
  border-radius: 999px;
  background: var(--note-bg);
  color: var(--note-fg);
  font-size: 0.85rem;
  font-weight: 650;
}

#waveform {
    border: 1px solid CanvasText;
  }
  .bar span { background: Highlight; }
  .facts .value, .rows .axis { border: 1px solid CanvasText; }
  :focus-visible { outline-color: Highlight; }
}
