/* Mobile first. Large type, calm colours, high contrast, big tap targets.
   No animation that blocks input, no confetti. System fonts only.
   Every colour is a variable so the dark block at the end can swap it. */

:root {
  color-scheme: light dark;
  --ink: #13212e;
  --ink-soft: #4a5b6b;
  --paper: #f7f6f2;
  --card: #ffffff;
  --line: #767b74;
  --accent: #1f5f7a;
  --accent-dark: #164658;
  --on-accent: #ffffff;
  --right: #1d6b45;
  --right-bg: #eef2ee;
  --wrong: #8a3324;
  --wrong-bg: #fbeeea;
  --current-bg: #e6ecef;
  --head-bg: #ebe9e3;
  --chip-new: #f1f1ef;
  --chip-learning: #fdf3e2;
  --chip-practised: #e6f0e9;
  --chip-mastered: #cfe6d8;
  --chip-stable: #b7dcc6;
  --chip-gap: #f7dcd6;
  --focus: #b8541c;
  --tap: 56px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 20px;
  line-height: 1.5;
}

body.kid { font-size: 22px; }

.wrap {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

body.parent .wrap { max-width: 84rem; font-size: 16px; }

h1 { font-size: 1.6rem; margin: 0 0 1rem; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
p { margin: 0 0 1rem; }

.lead { color: var(--ink-soft); }
.meta { color: var(--ink-soft); font-size: 0.85em; }

a { color: var(--accent); }

button {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  min-height: var(--tap);
  padding: 0.6rem 1rem;
  cursor: pointer;
}

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.big {
  display: block;
  width: 100%;
  margin: 1.25rem 0 0;
  padding: 1rem;
  min-height: 64px;
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--on-accent);
  background: var(--accent);
  border: 2px solid var(--accent-dark);
  border-radius: 14px;
}

/* Not ready yet, rather than gone: the button keeps its place in the tab order
   and keeps saying what it is, and the script holds an empty answer back. */
.big[disabled], .big[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

.quiet {
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 1rem;
  min-height: 44px;
  padding: 0.5rem 0;
  text-decoration: underline;
}

.error {
  background: var(--wrong-bg);
  border: 2px solid var(--wrong);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  color: var(--wrong);
}

/* A nudge, not a telling off. Nothing here is red, because nothing has gone
   wrong yet: the child has simply not answered. */
.notice {
  background: var(--current-bg);
  border-left: 5px solid var(--accent);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  margin: 0 0 1rem;
  color: var(--ink);
  font-size: 0.95rem;
}

/* -------------------------------------------------------------- maths type */

/* The maths filter writes a power as <sup>, so a power must not stretch the
   line it sits in. */
sup, sub { font-size: 0.75em; line-height: 0; }
sup { vertical-align: super; }
sub { vertical-align: sub; }

/* 3/4 arrives as <span class="frac"><sup>3</sup>&frasl;<sub>4</sub></span>.
   The slash is the only bare text in the span, so font-size: 0 collapses it
   and the two halves stack with a thin bar between them. Each half then names
   its own size, because an em of nothing is nothing: --frac-size carries it,
   and a bigger context, such as a stem, raises it. */
.frac {
  --frac-size: 1rem;
  display: inline-block;
  font-size: 0;
  line-height: 1;
  margin: 0 0.15em;
  text-align: center;
  vertical-align: middle;
}

.frac sup, .frac sub {
  display: block;
  font-size: var(--frac-size);
  line-height: 1.15;
  padding: 0 0.15em;
  vertical-align: baseline;
}

.frac sup { border-bottom: 1px solid currentColor; }

.stem .frac, .answer-line .frac, .given .frac { --frac-size: 1rem; }

/* -------------------------------------------------------------- pick a child */

.students { display: grid; gap: 0.75rem; }

.student {
  min-height: 84px;
  font-size: 1.4rem;
  font-weight: 600;
  border-color: var(--accent);
}

.student[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.pad { margin-top: 1.5rem; }

.pin {
  display: block;
  width: 100%;
  font-size: 2rem;
  letter-spacing: 0.5rem;
  text-align: center;
  padding: 0.5rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}

.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-top: 0.75rem; }
.keys .key { font-size: 1.4rem; min-height: 64px; }
.keys .go { background: var(--accent); color: var(--on-accent); border-color: var(--accent-dark); }

/* -------------------------------------------------------------- one question */

.progress {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}
.progress .dots { display: flex; gap: 0.6rem; align-items: flex-start; flex-wrap: wrap; row-gap: 0.5rem; }
.progress .group { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.progress .block { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; padding: 0.25rem 0.4rem; border-radius: 999px; }
.progress .group.current .block { background: var(--current-bg); }
.progress .label { font-size: 0.72rem; color: var(--ink-soft); line-height: 1; }
.progress .group.current .label { color: var(--accent); font-weight: 700; }
.progress .count { color: var(--ink-soft); font-size: 0.9rem; }
.progress .stop { margin: 0 0 0 auto; }
.progress .stop-button { min-height: 44px; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; background: transparent;
  box-shadow: inset 0 0 0 2px var(--line);
}
.dot.filled { background: var(--accent); box-shadow: none; }
.dot.now {
  width: 15px; height: 15px; background: var(--card);
  box-shadow: inset 0 0 0 3px var(--accent);
}

/* The skill behind the question. It names what is being practised without
   competing with the question itself. */
.working-on {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 0.25rem;
}

.stem { font-size: 1.35rem; font-weight: 600; margin: 0.5rem 0 1rem; }

/* The question's own diagram. It sits above the words, centred, and never wider
   than the figures inside the lesson card, so the page keeps one measure. */
.figure {
  max-width: 320px;
  margin: 0.75rem auto 1rem;
}
.figure svg { display: block; width: 100%; max-width: 320px; height: auto; margin: 0 auto; }

.example {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.example ol { margin: 0.5rem 0; padding-left: 1.25rem; }
.example li { margin-bottom: 0.35rem; }
.answer-line { font-weight: 600; }

.read-aloud { margin-bottom: 1rem; }
.read-aloud.choices, .read-aloud.hint-read { margin-top: 0.75rem; font-size: 0.95rem; min-height: 48px; }

/* The spelling word. It is the only way to hear the question, so it is the
   biggest thing under the stem and nothing else sits beside it. */
.read-aloud.big {
  display: block;
  width: 100%;
  min-height: var(--tap);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0.25rem 0 1rem;
  border-color: var(--accent);
}

/* The reading passage. A soft panel, a short line, and it stays on screen the
   whole time the child is answering. */
.passage {
  background: var(--card);
  border: 2px solid var(--line);
  border-left: 8px solid var(--accent);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  margin: 0 0 1.25rem;
}
.passage h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
.passage-text { max-width: 34em; }
.passage-text p { font-size: 1.05rem; line-height: 1.65; margin: 0 0 0.75rem; }
.passage-text p:last-child { margin-bottom: 0; }
body.kid.young .passage-text p { font-size: 1.15rem; line-height: 1.75; }

/* A spelling answer is letters, so the box gives them room and the child can
   see each one they have typed. */
.answer.word { letter-spacing: 0.05em; font-size: 1.6rem; max-width: 100%; }

.options { display: grid; gap: 0.75rem; }
.option {
  min-height: 72px;
  font-size: 1.25rem;
  text-align: left;
  padding-left: 1.25rem;
  border-color: var(--accent);
}
.option[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent-dark);
}

.answer {
  display: block;
  width: 100%;
  font-size: 1.8rem;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}

/* The keypad is there at every width. A tablet and a phone held sideways are
   both touch screens, and a child who taps digits keeps tapping digits. */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-top: 0.75rem; }
.keypad .key { font-size: 1.4rem; min-height: 64px; }

.symbols {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.symbols .key { font-size: 1.2rem; min-height: 48px; padding: 0.4rem 0.2rem; }
.symbols .key.wide { grid-column: span 5; font-size: 1rem; }

/* Ten keys across need a real tablet width. On a phone they are too narrow to
   hit, so the five wide grid holds until 560px. */
@media (min-width: 560px) {
  .symbols { grid-template-columns: repeat(10, 1fr); }
  .symbols .key.wide { grid-column: span 1; }
}

.hint-button { margin-top: 0.75rem; }
.hint {
  background: var(--right-bg);
  border-left: 4px solid var(--right);
  padding: 0.6rem 0.9rem;
  margin-top: 0.75rem;
}

.send-row { display: grid; gap: 0.6rem; margin-top: 0.5rem; }
.send.unsure {
  background: var(--card);
  color: var(--accent);
  border-color: var(--accent);
}
.send.unsure[disabled], .send.unsure[aria-disabled="true"] { opacity: 0.45; }

@media (min-width: 480px) {
  .send-row { grid-template-columns: 1fr 1fr; align-items: stretch; }
  .send-row .big { margin-top: 0.75rem; }
}

/* A phone held sideways leaves about 300px of page. The way to send stays on
   screen rather than below a keypad the child has to scroll past. */
@media (max-height: 480px) {
  .send-row {
    position: sticky;
    bottom: 0;
    background: var(--paper);
    padding: 0.4rem 0;
  }
}

.flag-wrap { margin-top: 2.5rem; }
.flag { display: grid; gap: 0.4rem; margin-top: 0.4rem; }
.flag input {
  padding: 0.6rem;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--card);
  color: var(--ink);
}
.stop { margin-top: 0.5rem; }

/* -------------------------------------------------------------- feedback */

h1.right { color: var(--right); }
h1.wrong { color: var(--wrong); }

/* The big right/wrong banner (_verdict.html). A correct answer is loud: a large
   green tick and a bold word, so a child sees the win at a glance. */
.verdict {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0 1rem;
}
.verdict-mark { width: 3rem; height: 3rem; flex: none; }
.verdict-word { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.verdict.is-right { color: var(--right); }
.verdict.is-right .verdict-word { color: var(--right); }
.verdict.is-wrong { color: var(--ink-soft); }
.verdict.is-wrong .verdict-word { color: var(--ink-soft); font-size: 1.5rem; }
.verdict.is-right { background: var(--right-bg); border-radius: 14px; padding: 0.5rem 0.9rem; }
@media (min-width: 34rem) {
  .verdict-mark { width: 3.5rem; height: 3.5rem; }
  .verdict.is-right .verdict-word { font-size: 2.4rem; }
}

.message { font-weight: 600; }
.reason { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 0.75rem 1rem; }
.reason.second { border-style: dashed; }

/* What the child typed, shown back in a plain even width so a digit that was
   misread stands out. It is a statement of fact, not a scolding. */
.given {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
}

/* The sentence of the passage that held the answer. It is a quotation, so it is
   set apart from the reason in the platform's own words. */
.quote {
  border-left: 6px solid var(--accent);
  background: var(--card);
  padding: 0.5rem 0.75rem;
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

/* On the feedback page the read aloud button sits above the reason, so it
   reads as part of that block rather than as another thing to press. */
body.feedback .read-aloud {
  display: block;
  width: 100%;
  margin: 0 0 0.5rem;
  font-size: 1rem;
  min-height: 48px;
  color: var(--accent);
  border-color: var(--accent);
}

/* -------------------------------------------------------------- done */

.tally { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.tally li { font-size: 1.2rem; margin-bottom: 0.35rem; }
.tally strong { font-size: 1.6rem; }
.skills { padding-left: 1.25rem; }
.skills li { margin-bottom: 0.2rem; }

/* What the child can now do without help. This list is the reward on the page,
   so it is cards rather than bullets, and it reads as settled. */
.skills.new {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.skills.new li {
  background: var(--right-bg);
  border-left: 5px solid var(--right);
  border-radius: 10px;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 0.4rem;
  padding: 0.45rem 0.85rem;
}
.trend { list-style: none; padding: 0; }
.trend li { display: grid; grid-template-columns: 6.5rem 1fr 3rem; align-items: center; gap: 0.5rem; }
.trend .bar { height: 14px; background: var(--accent); border-radius: 7px; min-width: 2px; }

/* -------------------------------------------------------------- parent */

table.grid { border-collapse: collapse; width: 100%; margin-bottom: 1.5rem; }
table.grid th, table.grid td {
  border: 1px solid var(--line);
  padding: 0.3rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
table.grid thead th { background: var(--head-bg); }
table.grid tr.no td { background: var(--wrong-bg); }
table.map th { width: 9rem; }

.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  margin: 0.1rem 0.15rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: var(--card);
}
.chip.new { background: var(--chip-new); color: var(--ink-soft); }
.chip.learning { background: var(--chip-learning); }
.chip.practised { background: var(--chip-practised); }
.chip.mastered { background: var(--chip-mastered); }
.chip.stable { background: var(--chip-stable); }
.chip.gap { background: var(--chip-gap); color: var(--wrong); font-weight: 600; }
.chip.frozen { border-style: dashed; }

/* ------------------------------------------------------------- lesson card */

/* Calm, and the same width as the question so a child's eye does not re-track.
   It is folded away until they ask for it or get the same skill wrong twice. */

.help-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 1rem 0 0.5rem; }
.help-row .quiet { flex: 1 1 10rem; min-height: 48px; }

.lesson {
  margin: 1rem 0 1.25rem;
  max-width: 40rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.lesson > summary {
  display: block;
  min-height: 48px;
  padding: 0.7rem 1rem;
  color: var(--accent-dark);
  font-weight: 600;
  cursor: pointer;
}

.lesson > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.lesson[open] > summary { border-bottom: 1px solid var(--line); }
.lesson > summary .sub { display: block; font-size: 0.9rem; font-weight: 400; color: var(--ink-soft); margin-top: 0.15rem; }

.lesson-body { padding: 0.9rem 1rem 1rem; }
.lesson-body h3 {
  margin: 1.1rem 0 0.35rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.lesson-body > *:first-child { margin-top: 0; }
.lesson-body .stem { font-size: 1.15rem; margin: 0.25rem 0 0.5rem; }

.lesson-intro {
  max-width: 40rem;
  margin: 0 0 1rem;
}
.lesson-lead { margin: 0 0 0.6rem; font-size: 1.05rem; line-height: 1.5; }

.lesson-figure { margin: 0.5rem 0 0.9rem; }
.lesson-figure svg { max-width: 320px; width: 100%; height: auto; display: block; }

.lesson-steps { margin: 0.35rem 0 0.6rem; padding-left: 1.3rem; }
.lesson-steps li { margin-bottom: 0.55rem; }
.lesson-steps .do { display: block; }
.lesson-steps .why { display: block; color: var(--ink-soft); font-size: 0.92rem; }

.lesson-mistake .what { margin: 0 0 0.3rem; font-weight: 600; }
.lesson-mistake .fix { margin: 0; color: var(--ink-soft); }

.lesson-other p { line-height: 1.5; }

.lesson-words dl { margin: 0.3rem 0 0; }
.lesson-words dt { font-weight: 600; }
.lesson-words dd { margin: 0 0 0.5rem; color: var(--ink-soft); }

.lesson-videos { display: grid; gap: 0.6rem; margin-top: 1rem; }
.lesson-videos .video-button { text-align: left; min-height: 48px; }

.lesson-player {
  display: block;
  width: 100%;
  max-width: 40rem;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 0.6rem;
}

/* -------------------------------------------------------------- dark mode */

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9eef3;
    --ink-soft: #b3c0cb;
    --paper: #10171d;
    --card: #1b252e;
    --line: #6b7c8a;
    --accent: #79c0e0;
    --accent-dark: #9ad3ec;
    --on-accent: #0c1318;
    --right: #7fd4a6;
    --right-bg: #16281f;
    --wrong: #f2a596;
    --wrong-bg: #331e1a;
    --current-bg: #24313b;
    --head-bg: #212b34;
    --chip-new: #262f38;
    --chip-learning: #3b3320;
    --chip-practised: #1d3128;
    --chip-mastered: #234436;
    --chip-stable: #2b5340;
    --chip-gap: #40231d;
    --focus: #ffb26b;
  }

  .hint { color: var(--ink); }
  .notice { color: var(--ink); }
  .lesson-steps .why { color: var(--ink-soft); }
  .lesson-figure svg, .figure svg { color: var(--ink); }
  .skills.new li { color: var(--ink); }
  .chip { color: var(--ink); }
  .chip.new { color: var(--ink-soft); }
}

/* ------------------------------------------------- third strand card (today) */

.thinking {
  margin-top: 2rem;
  padding: 1rem 1.1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.thinking h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.thinking-prompt { margin: 0 0 0.75rem; font-size: 1.15rem; line-height: 1.45; }

.thinking-form { margin: 0.75rem 0 0; }

.thinking-options {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.thinking-options .option { width: 100%; }

/* 16px, so tapping the box does not zoom the page on a phone. */
.thinking-input {
  width: 100%;
  min-height: 48px;
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.7rem;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.thinking-input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.thinking-check { min-height: 48px; }

.thinking-given { margin: 0.75rem 0 0.25rem; color: var(--ink-soft); }
.thinking-mark { margin: 0 0 0.5rem; font-size: 1.1rem; font-weight: 700; }
.thinking-mark.right { color: var(--accent-dark); }
.thinking-mark.wrong { color: var(--ink); }
.thinking-answer { margin: 0 0 0.5rem; font-size: 1.1rem; font-weight: 600; }
.thinking-why { margin: 0; color: var(--ink-soft); line-height: 1.45; }

.thinking-count {
  margin: 0.9rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.95rem;
}

@media (min-width: 34rem) {
  .thinking-options { grid-template-columns: 1fr 1fr; }
}

/* ------------------------------------------------------------------ the shop */

.shop-link { margin: 0 0 0.9rem; }

.points-big {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.points-line a { margin-left: 0.4rem; }

.shop-notice,
.shop-waiting {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
}

.prizes { list-style: none; margin: 0 0 1.4rem; padding: 0; display: grid; gap: 0.8rem; }

.prize {
  display: grid;
  gap: 0.35rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.prize-name { font-size: 1.15rem; font-weight: 600; }
.prize-cost { color: var(--ink-soft); }
.prize-note { color: var(--ink-soft); font-size: 0.95rem; }
.prize-off { color: var(--ink-soft); font-size: 0.95rem; }

.points-log { list-style: none; margin: 0 0 1.2rem; padding: 0; }

.points-log li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
}

.points-when { display: inline-block; min-width: 6.5rem; }
.points-delta { font-weight: 600; }
.points-minus { color: var(--danger, #b3261e); }

.points-rules { list-style: none; margin: 0 0 1.2rem; padding: 0; }

.points-rules li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.rule-worth { font-weight: 600; white-space: nowrap; text-align: right; }

@media (min-width: 34rem) {
  .prizes { grid-template-columns: 1fr 1fr; }
}
