/* Citizenship Prep — Modernist design system.
   Flat, architectural, set in Archivo: one red accent on a light ground, a
   visible grid, zero corner radius and strong 2px rules. Nothing floats and
   nothing is decorated; alignment and the dividers do the organising. */

:root {
  --color-bg: #f3f2f2;
  --color-surface: #eae9e9;
  --color-text: #201e1d;
  --color-accent: #ec3013;
  --color-divider: color-mix(in srgb, #201e1d 40%, transparent);

  --color-neutral-100: #f8f4f4;
  --color-neutral-200: #eae7e7;
  --color-neutral-300: #d7d3d3;
  --color-neutral-400: #bab6b6;
  --color-neutral-500: #9b9797;
  --color-neutral-600: #7d7979;
  --color-neutral-700: #605d5d;
  --color-neutral-800: #444141;
  --color-neutral-900: #2d2b2b;

  --color-accent-100: #fff2ef;
  --color-accent-200: #ffe0d9;
  --color-accent-600: #dd2b0f;
  --color-accent-700: #ae1800;
  --color-accent-800: #7c1405;

  --font: "Archivo", system-ui, -apple-system, sans-serif;
  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-6: 24px; --space-8: 32px;

  /* Comfort levels. The system is otherwise mono, so these four are the one
     place a second hue is allowed - they encode meaning, not decoration. All
     sit near 5:1 against white so 14px bold labels clear WCAG AA, and they are
     always paired with a word so colour is never the only signal. */
  /* The design system's accent is the app's one selection colour: buttons,
     the active filter, reviewed checkboxes and every progress bar. */
  --color-selected: var(--color-accent);

  --color-hard:  var(--color-accent-700);
  --color-good:  #2f7d4f;
  --color-easy:  #2b6ca3;

  --app-width: 480px;
  --tap: 48px; /* every control clears the minimum touch target */
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  /* Zoom is locked on mobile (see the viewport meta), so guard the two things
     that would otherwise resize text on their own: iOS rotating into landscape,
     and a double-tap being read as a zoom gesture. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  background: var(--color-neutral-300);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* ── shell ─────────────────────────────────────────────────────────────── */

/* App shell: the content area is the only thing that scrolls, so the tab bar
   stays put and the session's own header and footer stay pinned. */
.app {
  display: flex;
  flex-direction: column;
  max-width: var(--app-width);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--color-bg);
  overflow: hidden;
}
@media (min-width: 520px) {
  .app { border-inline: 2px solid var(--color-divider); }
}

.screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--space-6);
}
.screen[hidden] { display: none; }

/* During a session the screen itself becomes the flex column so that only
   .session-body scrolls. */
.screen.session-host {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

.pad { padding: var(--space-4) var(--space-4); }
.rule-top { border-top: 2px solid var(--color-divider); }
.rule-bottom { border-bottom: 2px solid var(--color-divider); }
.hair-top { border-top: 1px solid var(--color-neutral-300); }

/* ── type ──────────────────────────────────────────────────────────────── */

.kicker {
  font-size: 12px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--color-neutral-700);
}
.kicker-accent { color: var(--color-accent-700); }
/* A kicker that heads a headline figure rather than labelling a section. */
.kicker-strong { font-weight: 800; color: var(--color-text); }
.display { font-size: 40px; font-weight: 800; line-height: 1.02; letter-spacing: -0.02em; margin: 6px 0 0; }

/* Each tab opens with its name. One per screen, so it is a real h1. */
.page-title {
  font-size: 40px; font-weight: 800; line-height: 1.02; letter-spacing: -0.02em;
  margin: 0; padding: var(--space-6) var(--space-4) var(--space-4);
}
.stat { font-size: 40px; font-weight: 800; line-height: 1; }
.stat-accent { color: var(--color-accent-700); }
.muted { color: var(--color-neutral-700); }
.tabular { font-variant-numeric: tabular-nums; }

/* ── grid cells ────────────────────────────────────────────────────────── */

.split { display: grid; grid-template-columns: 1fr 1fr; }
.split > * + * { border-left: 2px solid var(--color-divider); }
.cell { padding: var(--space-4); }

/* ── meters ────────────────────────────────────────────────────────────── */

.meter {
  height: 16px; margin-top: var(--space-3);
  background: var(--color-neutral-100);
  border: 1px solid var(--color-divider);
}
.meter-sm { height: 10px; }
.meter-bar { height: 100%; background: var(--color-selected); transition: width 0.3s ease; }

/* ── buttons ───────────────────────────────────────────────────────────── */

.btn {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%; min-height: 60px; padding: 0 var(--space-4);
  font-size: 19px; font-weight: 800; letter-spacing: 0.01em;
  text-align: left; border: 2px solid var(--color-text); border-radius: 0;
  background: transparent; cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-600); border-color: var(--color-accent-600); }
.btn-primary:active:not(:disabled) { background: var(--color-accent-700); border-color: var(--color-accent-700); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-spread { justify-content: space-between; }
.btn svg { display: block; flex: none; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); min-height: 0; padding: 0;
  border: 2px solid var(--color-text); background: transparent; cursor: pointer;
}
.btn-icon.is-on { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }

/* Small inline speaker button that sits after a run of text. */
.btn-say {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; margin: 0 0 0 var(--space-2);
  vertical-align: middle; border: none; background: transparent;
  color: inherit; cursor: pointer;
}
.btn-say:hover { background: var(--color-accent-200); }
.btn-say.is-on { background: var(--color-accent); color: #fff; }

.btn-chip {
  min-height: var(--tap); padding: 0 var(--space-3);
  font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  border: 2px solid var(--color-text); background: transparent; cursor: pointer;
  white-space: nowrap;
}
.btn-chip.is-on { background: var(--color-text); color: var(--color-bg); }

.word {
  min-height: var(--tap); padding: 0 14px;
  font-size: 18px; font-weight: 700;
  border: 2px solid var(--color-neutral-400); background: var(--color-neutral-100);
  cursor: pointer;
}
.word:hover { border-color: var(--color-accent); }
.word-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

/* ── tags ──────────────────────────────────────────────────────────────── */

.tag {
  display: inline-flex; align-items: center; padding: 4px 10px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  border: 1px solid var(--color-accent); color: var(--color-accent-700);
}

/* The learner's own difficulty rating, in the same colours as the buttons that
   set it. Each fill clears 4.5:1 under white at this weight. */
.tag-grade { border-color: transparent; color: #fff; }

/* ── rows ──────────────────────────────────────────────────────────────── */

.row {
  display: flex; align-items: flex-start; gap: var(--space-3);
  width: 100%; padding: var(--space-4);
  text-align: left; background: transparent;
  border: 0; border-top: 1px solid var(--color-neutral-300); cursor: pointer;
}
.row:hover { background: var(--color-neutral-200); }
.row-static { cursor: default; }
.row-static:hover { background: transparent; }
.row-q { font-size: 17px; font-weight: 700; line-height: 1.3; }
.row-a { font-size: 18px; font-weight: 800; color: var(--color-accent-700); margin-top: var(--space-2); line-height: 1.3; }

/* — bulleted answers — */
.bullets { margin: var(--space-2) 0 0; padding-left: 1.15em; }
.bullets li { font-size: 16px; font-weight: 500; line-height: 1.45; }
.bullets li::marker { color: var(--color-neutral-500); }
.bullets-answer li {
  font-size: 20px; font-weight: 700; line-height: 1.35;
  color: var(--color-accent-700); margin-bottom: var(--space-1);
}
.bullets-answer li::marker { color: var(--color-accent-700); }
.bullets .muted { font-weight: 500; color: var(--color-neutral-700); font-size: 15px; }

/* ── filters / tabs ────────────────────────────────────────────────────── */

.filters { display: flex; }
.filters button {
  flex: 1; min-height: 52px; padding: 0 var(--space-1);
  border: 0; border-right: 1px solid var(--color-neutral-300);
  font-size: 13px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  background: transparent; cursor: pointer;
}
.filters button:last-child { border-right: 0; }
.filters button[aria-pressed="true"] {
  background: var(--color-selected);
  color: #fff;
}

.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 2px solid var(--color-divider); background: var(--color-bg);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  min-height: 62px; border: 0; border-right: 1px solid var(--color-neutral-300);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  background: transparent; color: var(--color-neutral-700); cursor: pointer;
}
.tabs button:last-child { border-right: 0; }
.tabs button[aria-current="page"] { color: var(--color-accent); }

/* ── session ───────────────────────────────────────────────────────────── */

.session { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.session-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.session-body { flex: 1; overflow-y: auto; padding: var(--space-4); }
.session-foot { padding: var(--space-3) var(--space-4) var(--space-6); }

.prompt { font-size: 27px; font-weight: 800; line-height: 1.3; letter-spacing: -0.02em; margin: var(--space-2) 0 0; text-wrap: pretty; }
.answer { font-size: 28px; font-weight: 800; line-height: 1.3; color: var(--color-accent-700); margin: var(--space-2) 0 0; text-wrap: pretty; }
.answer-alt { font-size: 17px; font-weight: 600; line-height: 1.4; margin-top: var(--space-2); }
.note { font-size: 15px; font-weight: 500; line-height: 1.4; color: var(--color-neutral-700); margin-top: var(--space-2); }

.block { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--color-neutral-300); }
.block-strong { border-top: 2px solid var(--color-divider); }

.grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.grades .btn {
  min-height: 56px; padding: 0 var(--space-2); font-size: 15px;
  justify-content: center; text-align: center;
  color: #fff; border: 2px solid transparent;
}
.grade-hard  { background: var(--color-hard); }
.grade-good  { background: var(--color-good); }
.grade-easy  { background: var(--color-easy); }
.grades .btn:hover { filter: brightness(0.9); }
.grades .btn:active { filter: brightness(0.82); }
/* The suggested answer is raised by weight and a rule, not by hue, so the
   colour keeps meaning one thing only. */
.grades .btn.is-suggested { outline: 3px solid var(--color-text); outline-offset: 2px; }

/* Review state — a checkbox, not a swatch, filled in the selection colour. */
.check {
  width: 24px; height: 24px; flex: none; margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--color-neutral-400); background: transparent;
}
.check.is-checked {
  border-color: var(--color-selected);
  background: var(--color-selected);
  color: #fff;
}
.check svg { width: 16px; height: 16px; display: block; }

/* The primary action on Today, pinned above the tab bar. */
.dock {
  border-top: 2px solid var(--color-divider);
  background: var(--color-bg);
  padding: var(--space-4);
}
.dock:empty { display: none; }

/* — per-category practice — */
.topic-practice { display: flex; align-items: center; gap: var(--space-3); }
.topic-practice .meter { flex: 1; margin-top: 0; }

/* A play glyph rather than a labelled button: it sits on the progress bar it
   belongs to, and eight labelled buttons down the screen read as clutter. */
.topic-go {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 2px solid var(--color-divider); background: transparent;
  color: var(--color-text); cursor: pointer;
}
.topic-go:hover { background: var(--color-selected); border-color: var(--color-selected); color: #fff; }
.topic-go:active { background: var(--color-accent-700); border-color: var(--color-accent-700); }
.topic-go svg { fill: currentColor; }

/* — end-of-session comfort counts — */
.comfort {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4) 0; border-bottom: 1px solid var(--color-neutral-300);
}
.comfort:last-child { border-bottom: 0; }
.comfort-swatch { width: 24px; height: 48px; flex: none; }
.comfort-count { font-size: 44px; font-weight: 800; line-height: 1; min-width: 2ch; }
.comfort-label { font-size: 19px; font-weight: 700; }

/* ── forms ─────────────────────────────────────────────────────────────── */

.field { margin-top: var(--space-4); }
.field label { display: block; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-neutral-700); margin-bottom: 6px; }
.input {
  width: 100%; min-height: var(--tap); padding: var(--space-2) var(--space-3);
  font-size: 17px; background: var(--color-neutral-100);
  border: 2px solid var(--color-divider); border-radius: 0;
  caret-color: var(--color-accent);
}
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
.hint { font-size: 14px; font-weight: 500; line-height: 1.4; color: var(--color-neutral-700); margin-top: 6px; }
.hint a { color: var(--color-accent-700); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); width: 100%; padding: var(--space-4); border: 0; border-top: 1px solid var(--color-neutral-300); background: transparent; text-align: left; cursor: pointer; }
.switch-title { font-size: 17px; font-weight: 700; }

.banner { padding: var(--space-3) var(--space-4); background: var(--color-accent-200); color: var(--color-accent-800); font-size: 15px; font-weight: 600; line-height: 1.4; }
.banner a { color: inherit; }

.callout { margin: var(--space-3) 0 0; padding: var(--space-3) var(--space-4); background: var(--color-neutral-200); font-size: 15px; font-weight: 600; line-height: 1.4; }

.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;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
