/* H3, the Hallam Homework Hub. The look is carried over from the claude.ai
 * version. Dark mode is the single :root[data-theme="dark"] block below: the
 * head-top partial stamps data-theme before paint, the same as the IT site, so
 * a student's light/dark choice there carries over here. */
/* Layout: graph-paper masthead, one centred column of question cards; teacher view is a wide results grid. */
:root {
  --paper: #f5f7fa;
  --surface: #ffffff;
  --ink: #16213a;
  --muted: #5b6680;
  --line: #d9e0ec;
  --grid: rgba(11, 34, 64, 0.06);
  --accent: #0b2240;
  --accent-ink: #ffffff;
  --accent-soft: #e6ebf3;
  --brand-red: #c31030;
  --good: #137a4b;
  --good-soft: #e3f4ea;
  --bad: #c0352b;
  --bad-soft: #fbe7e5;
  --warn: #9a6400;
  --warn-soft: #fff3d6;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
  --note: #1f9d55;
  --note-fold: #e9f7ef;
  --note-soft: #e3f4ea;
  /* The H3 logo green. Light uses a deeper shade of it: the logo's glow
     green itself is too pale to read on white. */
  --h3-green: #0c9447;
  --h3-glow: transparent;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #0f1524; --surface: #172036; --ink: #e8edf7; --muted: #9aa6c0; --line: #2a3654;
  --grid: rgba(120, 155, 255, 0.07); --accent: #9db8ec; --accent-ink: #0b1626; --accent-soft: #1d2c48; --brand-red: #e0445e;
  --good: #5fd09a; --good-soft: #16352a; --bad: #ff8a80; --bad-soft: #3d1f22; --warn: #f2c25b; --warn-soft: #3a2f14;
  --note: #4cc985; --note-fold: #12321f; --note-soft: #16352a; --h3-green: #3ff58a; --h3-glow: rgba(63, 245, 138, 0.45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 17px/1.55 var(--f-body); }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; line-height: 1.15; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--f-mono); }

/* masthead */
.mast {
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  border-top: 4px solid var(--brand-red);
  border-bottom: 1px solid var(--line);
}
.mast-inner { max-width: 1040px; margin: 0 auto; padding: 18px 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand { gap: 14px; }
.brand-logo { display: block; height: 52px; width: auto; background: #ffffff; border-radius: 8px; }
/* Dark theme swaps in a transparent version with light lettering
   (hallam-logo-dark.webp), instead of a white box glaring off the header. */
.brand-logo.logo-dark { display: none; background: none; border-radius: 0; }
:root[data-theme="dark"] .brand-logo.logo-light { display: none; }
:root[data-theme="dark"] .brand-logo.logo-dark { display: block; }
.brand h1 { font-size: 22px; font-weight: 800; padding-left: 14px; border-left: 2px solid var(--line); }
@media (max-width: 520px) { .brand-logo { height: 42px; } .brand h1 { font-size: 18px; padding-left: 10px; } }
nav { display: flex; gap: 4px; margin-left: auto; }
nav a { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 700; font-size: 15px; }
nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
/* light/dark switch: shows the moon in light (go dark), the sun in dark */
.theme-btn { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); white-space: nowrap; }
.chip.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: var(--good-soft); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-soft); }

main { max-width: 1040px; margin: 0 auto; padding: 28px 20px 64px; }
.narrow { max-width: 760px; margin: 0 auto; }
.lede { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }

/* home: set cards */
.chapter { margin-top: 28px; }
.chapter > h2 { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-family: var(--f-body); font-weight: 700; margin-bottom: 10px; }
.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.set-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; transition: border-color .15s, transform .15s; }
.set-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.set-card h3 { font-size: 19px; }
.set-card p { margin: 0; color: var(--muted); font-size: 15px; }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.meter-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* set view */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); text-decoration: none; font-weight: 700; font-size: 15px; margin-bottom: 14px; }
.back-arrow { flex: 0 0 auto; transition: transform .15s; }
.back:hover .back-arrow { transform: translateX(-3px); }
@media (prefers-reduced-motion: reduce) { .back-arrow { transition: none; } }
.set-head { display: flex; gap: 20px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.set-head h2 { font-size: 32px; font-weight: 800; }
.score { text-align: right; font-variant-numeric: tabular-nums; }
.score b { font: 800 30px/1 var(--f-display); }
.score small { display: block; color: var(--muted); font-size: 13px; }
.how { margin: 18px 0 0; padding: 12px 16px; border-radius: var(--radius); background: var(--accent-soft); font-size: 15px; }
.how summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.how ul { margin: 8px 0 2px; padding-left: 20px; }
.how code { font-family: var(--f-mono); font-size: 14px; background: var(--surface); padding: 1px 5px; border-radius: 4px; }

.qlist { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; padding: 0; list-style: none; }
.q { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.q.is-correct { border-left-color: var(--good); }
.q.is-wrong { border-left-color: var(--bad); }
.qnum { font: 800 18px/1.4 var(--f-display); color: var(--muted); min-width: 1.6em; }
.qbody { min-width: 0; }
.prompt { margin: 0 0 12px; overflow-x: auto; }
.prompt mjx-container { font-size: 108% !important; }
.answer-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.answer-row input[type="text"] { flex: 1 1 220px; min-width: 0; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--paper); font-family: var(--f-mono); font-size: 16px; }
.answer-row input[type="text"]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.answer-row input[readonly] { opacity: .85; }
.units { color: var(--muted); font-size: 15px; }
.btn { border: 0; border-radius: 8px; padding: 10px 18px; font-weight: 700; cursor: pointer; background: var(--accent); color: var(--accent-ink); }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }
.choices { display: flex; flex-direction: column; gap: 6px; flex: 1 1 100%; }
.choice { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--paper); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { accent-color: var(--accent); width: 18px; height: 18px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.mark { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; padding: 6px 12px; border-radius: 8px; font-size: 15px; }
.mark.good { color: var(--good); background: var(--good-soft); }
.mark.bad { color: var(--bad); background: var(--bad-soft); }
.mark svg { width: 18px; height: 18px; }
.feedback { margin-top: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-height: 0; }
.feedback .note { color: var(--muted); font-size: 14px; }
.tries { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.section-head { margin-top: 18px; list-style: none; }
.section-head h3 { font: 700 13px/1 var(--f-body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.section-head h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.stem { list-style: none; display: grid; grid-template-columns: auto 1fr; gap: 14px; padding: 4px 20px 0 25px; margin-top: 4px; }
.stem p { margin: 0; font-weight: 700; max-width: 65ch; }
.stem-num { font: 800 18px/1.4 var(--f-display); color: var(--accent); min-width: 1.6em; }
.q .qnum { font-size: 16px; }

/* teacher */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 22px; }
.panel h2 { font-size: 22px; margin-bottom: 4px; }
.tbl-wrap { overflow-x: auto; margin-top: 14px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 15px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 13px; color: var(--muted); font-weight: 700; }
td.cell button { border: 0; background: var(--paper); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-weight: 700; }
td.cell button.full { background: var(--good-soft); color: var(--good); }
td.cell button.part { background: var(--warn-soft); color: var(--warn); }
td.cell button.none { color: var(--muted); }
.empty { color: var(--muted); padding: 18px 0 4px; }
.key-q { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 2.5em 1fr; gap: 10px; }
.key-q:last-child { border-bottom: 0; }
.key-ans { font-family: var(--f-mono); font-size: 14px; color: var(--good); }
.key-meta { font-size: 13px; color: var(--muted); }
.detail-ok { color: var(--good); font-weight: 700; }
.detail-bad { color: var(--bad); font-weight: 700; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
select { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .set-head h2 { font-size: 26px; }
  .q { grid-template-columns: 1fr; padding: 16px; }
  .score { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- added for the site version ---------- */
.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; }
a { color: var(--accent); }
.eyebrow { margin: 0 0 4px; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.list-head { margin: 30px 0 12px; font: 700 14px/1 var(--f-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.btn.small { padding: 5px 10px; font-size: 14px; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: 14px; }
textarea, .small-input { width: 100%; font: 15px/1.4 var(--f-mono); color: var(--ink); background: var(--paper); border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.small-input { width: 9em; padding: 6px 10px; }

/* masthead: who is signed in */
.who { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--ink); }
.who[hidden], .chip[hidden] { display: none; }

/* the H3 mark (h3-mark.svg): an H made of glowing tritium tubes. Its tile is
   dark in both themes on purpose, so it needs no theme rules here. */
.h3-mark { display: inline-block; width: 44px; height: 44px; }
.h3-mark.big { width: 72px; height: 72px; }
.brand-mark { display: block; width: 52px; height: 52px; }
@media (max-width: 520px) { .brand-mark { width: 42px; height: 42px; } }
/* Light theme shows the tubes alone (h3-mark-light.svg, no tile); dark
   theme shows the tiled mark, where the dark tile blends into the page. */
.brand-mark.on-dark, .h3-mark.on-dark { display: none; }
:root[data-theme="dark"] .brand-mark.on-light,
:root[data-theme="dark"] .h3-mark.on-light { display: none; }
:root[data-theme="dark"] .brand-mark.on-dark { display: block; }
:root[data-theme="dark"] .h3-mark.on-dark { display: inline-block; }
/* The light-theme tubes breathe: a dark green glow that slowly swells and
   fades, like a tritium light. Off for anyone who prefers reduced motion. */
.brand-mark.on-light, .h3-mark.on-light { animation: tube-glow 2.8s ease-in-out infinite alternate; }
@keyframes tube-glow {
  from { filter: drop-shadow(0 0 1px rgba(6, 95, 45, 0.25)); }
  to   { filter: drop-shadow(0 0 7px rgba(6, 95, 45, 0.75)) drop-shadow(0 0 2px rgba(6, 95, 45, 0.5)); }
}
@media (prefers-reduced-motion: reduce) {
  .brand-mark.on-light, .h3-mark.on-light { animation: none; filter: drop-shadow(0 0 4px rgba(6, 95, 45, 0.5)); }
}

/* sign in */
.signin-wrap { display: grid; place-items: center; padding: 30px 0; }
.signin-card { position: relative; width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px 22px; text-align: center; }
.signin-card h2 { font-size: 28px; font-weight: 800; margin: 12px 0 4px; }
.signin-card .lede { margin: 0 auto 16px; }
.signin-card .answer-row input { text-transform: uppercase; }
.signin-card #staff-key { text-transform: none; }
.signin-msg { min-height: 1.4em; margin: 10px 0 0; font-size: 15px; color: var(--muted); }
.signin-msg.is-error { color: var(--bad); font-weight: 700; }
.portal-badge { position: absolute; top: 14px; left: 14px; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); border: 1px solid var(--line); transition: transform .15s; }
.portal-badge:hover { transform: scale(1.08); }

/* welcome */
.welcome { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.welcome h2 { font-size: 32px; font-weight: 800; }
.gn-total { text-align: center; background: var(--note-soft); border: 1px solid var(--line); border-radius: 14px; padding: 12px 20px; }
.gn-total small { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.gn-stack { display: flex; align-items: center; gap: 8px; color: var(--note); }
.gn-stack .gn-icon { width: 34px; height: 34px; }
.gn-stack b { font: 800 34px/1 var(--f-display); color: var(--ink); }
.gn-icon { width: 18px; height: 18px; flex: none; }
.gn-row { display: inline-flex; gap: 2px; }
.gn-dot { color: var(--line); display: inline-flex; }
.gn-dot.on { color: var(--note); }
.chapter-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chapter-id { display: flex; align-items: center; gap: 10px; }
.chapter-year { margin: 0 0 -6px; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
/* Share of the chapter's questions answered correctly, in the H3 logo green. */
.chapter-pct { font: 800 22px/1 var(--f-display); color: var(--h3-green); text-shadow: 0 0 10px var(--h3-glow); font-variant-numeric: tabular-nums; }
/* the same, per sub-chapter, once it has been started */
.set-pct { font: 800 19px/1 var(--f-display); color: var(--h3-green); text-shadow: 0 0 10px var(--h3-glow); font-variant-numeric: tabular-nums; }
.chapter-num { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font: 800 17px/1 var(--f-display); }
.set-card .next { font-size: 14px; color: var(--muted); }
.set-card.is-full { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.set-code { color: var(--accent); }
.gn-banner { display: flex; align-items: center; gap: 10px; margin: 18px 0; padding: 12px 16px; border-radius: var(--radius); background: var(--note-soft); color: var(--ink); font-size: 15px; }
.gn-banner > .gn-icon { color: var(--note); width: 24px; height: 24px; }
.gn-banner.celebrate { border: 1.5px solid var(--note); }
.gn-banner a { font-weight: 700; margin-left: 6px; }

/* teacher */
.notes-tbl tr.is-owed td { background: var(--note-soft); }
.owed { display: inline-block; min-width: 1.8em; text-align: center; font-weight: 800; color: var(--good); }
.row-actions { display: flex; gap: 6px; }

/* sub-chapter finished: popup with confetti and the green note ring.
   The dialog fills the screen (transparent) so the confetti canvas can
   cover everything; the card sits in the middle. */
.cele { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 16px; border: 0; background: transparent; overflow: hidden; }
.cele[open] { display: grid; place-items: center; }
.cele::backdrop { background: rgba(6, 14, 10, 0.55); }
.cele canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.cele-card { position: relative; z-index: 1; width: min(400px, 100%); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 18px; padding: 26px 24px 22px; text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); animation: cele-pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.cele-card h2 { font-size: 26px; margin: 6px 0 6px; }
.cele-card p { margin: 0 0 18px; color: var(--muted); }
.cele-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cele-actions .btn { text-decoration: none; }
.cele-ring { position: relative; width: 150px; height: 150px; margin: 0 auto 6px; }
.cele-ring > svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { stroke: var(--line); }
.ring-fill { stroke: var(--h3-green); transition: stroke-dashoffset 1s cubic-bezier(.3, .9, .3, 1) .25s; filter: drop-shadow(0 0 5px var(--h3-glow)); }
.ring-tick { stroke: var(--surface); }
.ring-mid { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 2px; }
.ring-mid b { font: 800 34px/1 var(--f-display); color: var(--h3-green); text-shadow: 0 0 12px var(--h3-glow); font-variant-numeric: tabular-nums; }
.ring-mid small { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ring-note { display: block; width: 46px; height: 46px; color: var(--note); animation: note-pop .5s cubic-bezier(.2, 1.6, .4, 1) 1.1s both; }
.ring-note .gn-icon { width: 100%; height: 100%; }
.ring-mid .ring-plus { font-size: 22px; animation: note-pop .5s cubic-bezier(.2, 1.6, .4, 1) 1.25s both; }
.cele.is-full .ring-fill { animation: ring-glow 1s ease-in-out 1.3s 2; }
@keyframes cele-pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes note-pop { from { transform: scale(0); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ring-glow { 50% { filter: drop-shadow(0 0 14px var(--note)); } }
@media (prefers-reduced-motion: reduce) {
  .cele-card, .ring-note, .ring-mid .ring-plus, .cele.is-full .ring-fill { animation: none; }
  .ring-fill { transition: none; }
}

/* "How do I work this out?" help panels (helps.js). One per type of question,
   folded away under the answer box until the student opens it. Everything
   inside starts with hp- so it cannot collide with the rest of H3. */
.qhelp { margin: 10px 0 0; border: 1px solid color-mix(in srgb, var(--h3-green) 40%, transparent); border-radius: var(--radius); background: var(--note-soft); }
.qhelp > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 12px; font-weight: 700; font-size: 15px; color: var(--h3-green); }
.qhelp > summary::-webkit-details-marker { display: none; }
.qhelp-mark { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid currentColor; display: grid; place-items: center; font: 800 13px/1 var(--f-display); flex: none; }
.qhelp-chev { margin-left: auto; transition: transform .2s; flex: none; }
.qhelp[open] .qhelp-chev { transform: rotate(180deg); }
.qhelp-body { padding: 2px 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; font-size: 16px; }   /* minmax: a wide division or table scrolls inside its own box, never the page */
.qhelp-body p { margin: 0; }

.hp-key { display: flex; flex-wrap: wrap; gap: 6px; }
.hp-k { display: inline-grid; justify-items: center; min-width: 46px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.hp-k b { font: 800 18px/1.1 var(--f-mono); }
.hp-k span { font: 600 11px/1.2 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.hp-tag { font-size: 15px; color: var(--muted); }
.hp-tag b { color: var(--ink); font-family: var(--f-mono); }

.hp-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; counter-reset: hp; }
.hp-steps > li { counter-increment: hp; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.hp-steps > li::before { content: counter(hp); width: 28px; height: 28px; border-radius: 50%; background: var(--h3-green); color: var(--surface); display: grid; place-items: center; font: 800 14px/1 var(--f-display); }
.hp-step { display: grid; gap: 8px; min-width: 0; }

.hp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.hp-col { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px; display: grid; gap: 5px; justify-items: center; text-align: center; }
.hp-h { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hp-v { font: 800 17px/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.hp-arrow { color: var(--muted); font-size: 12px; line-height: 1; }
.hp-r { font: 800 21px/1 var(--f-mono); color: var(--h3-green); letter-spacing: .04em; }
.hp-why { font-size: 12px; color: var(--muted); }
.hp-col.hp-pair { border-color: var(--warn); background: var(--warn-soft); }
.hp-col.hp-pair .hp-r { color: var(--warn); }

.hp-tiles { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.hp-t { display: grid; justify-items: center; gap: 4px; }
.hp-t b { width: 42px; height: 46px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); border-radius: 7px; font: 800 23px/1 var(--f-mono); }
.hp-t span { font: 700 13px/1 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.hp-group { display: grid; justify-items: center; gap: 4px; padding: 6px 6px 4px; border: 2px dashed var(--warn); border-radius: 10px; background: var(--warn-soft); }
.hp-group em { font: 700 13px/1 var(--f-mono); color: var(--warn); font-style: normal; }

.qhelp-body .hp-sum { font: 700 16px/1.6 var(--f-mono); font-variant-numeric: tabular-nums; overflow-x: auto; }
.hp-ans { color: var(--h3-green); font-weight: 800; }
.hp-answer { justify-self: start; font: 800 24px/1 var(--f-mono); color: var(--h3-green); background: var(--surface); border: 2px solid var(--h3-green); border-radius: 8px; padding: 8px 13px; letter-spacing: .04em; }

.hp-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hp-box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; font: 700 15px/1.3 var(--f-mono); }
.hp-box small { display: block; font: 600 10px/1.2 var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hp-to { color: var(--muted); font-weight: 700; }

.qhelp-body .hp-story { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; }
.hp-hl { background: var(--accent); color: var(--accent-ink); border-radius: 5px; padding: 1px 6px; font: 800 .95em var(--f-mono); }
.hp-kw { text-decoration: underline wavy var(--warn) 2px; text-underline-offset: 4px; font-weight: 700; }
.hp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hp-chip { font: 700 13px/1 var(--f-mono); padding: 6px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.hp-chip.hp-add { border-color: var(--h3-green); color: var(--h3-green); }
.hp-chip.hp-take { border-color: var(--warn); color: var(--warn); }

.hp-pairs { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; }
.hp-pairs div { background: var(--surface); border: 1px solid var(--warn); border-radius: 8px; padding: 7px; text-align: center; font: 800 17px/1.2 var(--f-mono); }
.hp-pairs div span { display: block; font: 600 11px/1.2 var(--f-mono); color: var(--muted); }

.hp-tip { display: grid; grid-template-columns: auto 1fr; gap: 10px; background: var(--surface); border-left: 4px solid var(--h3-green); border-radius: 0 8px 8px 0; padding: 9px 12px; font-size: 15px; }
.hp-tip strong { color: var(--h3-green); }

@media (prefers-reduced-motion: reduce) { .qhelp-chev { transition: none; } }

/* Help visuals added for 1B to 1I: place-value chart, column working,
   bus-stop division, area model, rounding line, strategy tables, the order
   of operations ladder, and the "do this bit now" highlight. */
.hp-chart { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 0; max-width: 460px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.hp-ch-h { font: 600 11px/1.2 var(--f-mono); color: var(--muted); text-align: center; padding: 6px 2px; border-bottom: 1px solid var(--line); background: var(--paper); font-variant-numeric: tabular-nums; }
.hp-ch-d { font: 800 22px/1 var(--f-mono); text-align: center; padding: 9px 2px; min-height: 40px; }
.hp-ch-h + .hp-ch-h, .hp-ch-d + .hp-ch-d { border-left: 1px solid var(--line); }
.hp-ch-h.hp-hot { color: var(--h3-green); background: color-mix(in srgb, var(--h3-green) 14%, var(--surface)); }
.hp-ch-d.hp-hot { color: var(--h3-green); background: color-mix(in srgb, var(--h3-green) 10%, var(--surface)); }

.hp-algo { display: grid; grid-template-columns: repeat(var(--n), 1.5em) auto; justify-content: start; align-items: end; font: 800 24px/1.35 var(--f-mono); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; width: max-content; max-width: 100%; overflow-x: auto; }
.hp-a { text-align: center; font-variant-numeric: tabular-nums; }
.hp-a-carry { font-size: 13px; line-height: 1.2; color: var(--h3-green); }
.hp-a-res { border-top: 2px solid var(--ink); }
.hp-x { text-decoration: line-through; text-decoration-color: var(--warn); text-decoration-thickness: 2px; color: var(--muted); }
.hp-a-note { font: 600 12px/1.2 var(--f-body); color: var(--muted); padding-left: 12px; align-self: center; white-space: nowrap; }

.hp-bus { display: grid; grid-template-columns: auto repeat(var(--n), 1.6em) auto; justify-content: start; font: 800 24px/1.3 var(--f-mono); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; width: max-content; max-width: 100%; }
.hp-bus-q { text-align: center; color: var(--h3-green); }
.hp-bus-r { color: var(--h3-green); padding-left: 8px; white-space: nowrap; }
.hp-bus-d { padding: 0 8px 0 2px; border-right: 2.5px solid var(--ink); }
.hp-bus-n { text-align: center; border-top: 2.5px solid var(--ink); }
.hp-bus-n sup { font-size: 12px; color: var(--warn); vertical-align: top; margin-right: 1px; }

.hp-area { display: flex; align-items: stretch; gap: 0; max-width: 460px; }
.hp-area-side { align-self: center; font: 800 18px/1 var(--f-mono); padding-right: 8px; }
.hp-area-box { display: grid; place-items: center; gap: 4px; padding: 10px 6px; min-height: 76px; text-align: center; background: color-mix(in srgb, var(--h3-green) 12%, var(--surface)); border: 2px solid var(--h3-green); min-width: 0; }
.hp-area-box + .hp-area-box { border-left-style: dashed; background: var(--surface); }
.hp-area-top { font: 700 13px/1 var(--f-mono); color: var(--muted); }
.hp-area-box b { font: 800 14px/1.2 var(--f-mono); }

.hp-line { max-width: 460px; padding: 30px 10px 0; }
.hp-track { position: relative; height: 4px; background: var(--ink); border-radius: 2px; }
.hp-track::before, .hp-track::after { content: ""; position: absolute; top: -7px; width: 3px; height: 18px; background: var(--ink); }
.hp-track::before { left: 0; } .hp-track::after { right: 0; }
.hp-mid { position: absolute; top: 12px; transform: translateX(-50%); font: 600 11px/1 var(--f-mono); color: var(--muted); display: grid; justify-items: center; gap: 2px; }
.hp-mid i { position: absolute; top: -17px; width: 2px; height: 10px; background: var(--muted); }
.hp-dot { position: absolute; top: -6px; transform: translateX(-50%); width: 16px; height: 16px; border-radius: 50%; background: var(--h3-green); }
.hp-dot b { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); font: 800 15px/1 var(--f-mono); color: var(--h3-green); }
.hp-ends { display: flex; justify-content: space-between; margin: 16px -10px 0; font: 700 14px/1 var(--f-mono); }

.hp-table { display: grid; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); font-size: 14px; }
.hp-tr { display: grid; grid-template-columns: 1.1fr 1fr 1.2fr; }
.hp-tr + .hp-tr { border-top: 1px solid var(--line); }
.hp-tr span { padding: 8px 10px; min-width: 0; }
.hp-tr span:last-child { font-family: var(--f-mono); font-weight: 700; }
.hp-th { background: var(--paper); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hp-th span:last-child { font-family: inherit; }

.hp-ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; counter-reset: lad; max-width: 360px; }
.hp-ladder li { counter-increment: lad; display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 15px; }
.hp-ladder li::before { content: counter(lad); font: 800 13px/1 var(--f-display); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.hp-ladder li:nth-child(2) { margin-left: 14px; } .hp-ladder li:nth-child(3) { margin-left: 28px; }
.hp-now { -webkit-box-decoration-break: clone; box-decoration-break: clone; background: color-mix(in srgb, var(--warn) 22%, transparent); color: inherit; border-radius: 4px; padding: 0 3px; box-shadow: inset 0 -2px 0 var(--warn); }

@media (max-width: 480px) {
  .hp-tr { grid-template-columns: 1fr 1fr; }
  .hp-tr span:first-child { grid-column: 1 / -1; padding-bottom: 0; font-weight: 700; }
  .hp-th span:first-child { display: none; }
}
@media (max-width: 480px) { .hp-ch-h { font-size: 9.5px; padding: 6px 0; letter-spacing: -0.02em; } }

/* Question figures (figures.js): Cartesian planes, matchstick and dot
   patterns, and input/output tables. Colours follow the theme tokens. */
.stem-body { display: grid; gap: 10px; min-width: 0; }
.qfig { margin: 0 0 12px; overflow-x: auto; }
.fig { display: block; max-width: 100%; height: auto; }
.fig-plane { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.fg-grid { stroke: var(--line); stroke-width: 1; }
.fg-axis { stroke: var(--ink); stroke-width: 2; }
.fg-tick { fill: var(--muted); font: 600 11px var(--f-mono); }
.fg-label { fill: var(--ink); font: 700 italic 14px var(--f-body); }
.fg-pt { fill: var(--h3-green); }
.fg-ptl { fill: var(--ink); font: 800 14px var(--f-display); }
.fg-path { fill: none; stroke: var(--h3-green); stroke-width: 2.5; stroke-linejoin: round; }
.fig-stages { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.fig-stage { margin: 0; display: grid; justify-items: center; gap: 4px; }
.fig-stage svg { max-width: 100%; height: auto; }
.fig-stage figcaption { font-size: 13px; color: var(--muted); }
.fg-stick { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.fg-tip { fill: var(--brand-red); }
.fg-dot { fill: var(--accent); }
.fig-table-wrap { overflow-x: auto; }
.fig-table { border-collapse: collapse; font: 700 16px var(--f-mono); background: var(--surface); }
.fig-table th, .fig-table td { border: 1px solid var(--line); padding: 7px 12px; text-align: center; min-width: 2.6em; }
.fig-table th { font: 700 13px var(--f-body); color: var(--muted); background: var(--paper); text-align: left; }
.fig-table td.gap { color: var(--h3-green); background: color-mix(in srgb, var(--h3-green) 10%, var(--surface)); }

/* Fraction pictures (figures.js): pies, bars, grids and number lines. Several
   figures on one question sit side by side, each with an optional caption. */
.qfig:has(.fig-frac) { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.fig-frac { margin: 0; display: grid; justify-items: center; gap: 4px; max-width: 100%; }
.fig-frac svg { max-width: 100%; height: auto; }
.fig-frac figcaption { font: 800 14px var(--f-display); color: var(--muted); }
.fg-on { fill: color-mix(in srgb, var(--h3-green) 55%, var(--surface)); stroke: var(--ink); stroke-width: 1.5; }
.fg-off { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.fg-grid-dark { stroke: var(--muted); stroke-width: 1.5; }
.fg-dotred { fill: var(--brand-red); }

/* Labelled shapes for algebra (figures.js rect and tri). */
.fg-shape { fill: color-mix(in srgb, var(--h3-green) 10%, var(--surface)); stroke: var(--ink); stroke-width: 2; }
.fg-div { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 4; }
.fg-side { fill: var(--ink); font: italic 700 16px "Times New Roman", Georgia, serif; }
.fg-cell { fill: var(--h3-green); font: italic 700 16px "Times New Roman", Georgia, serif; }

/* Geometry, measurement and statistics figures (figures.js diagram, columns,
   dotplot, stemleaf, linegraph, sector, dividedbar, spinner). */
.fg-line { stroke: var(--ink); stroke-width: 2; fill: none; }
.fg-dash { stroke-dasharray: 6 5; }
.fg-outline { fill: none; stroke: var(--ink); stroke-width: 2; }
.fg-head { fill: var(--ink); }
.fg-mark { stroke: var(--ink); stroke-width: 1.8; }
.fg-angle { fill: none; stroke: var(--h3-green); stroke-width: 2; }
.fg-alabel { fill: var(--h3-green); font: 700 14px var(--f-body); }
.fg-dimline { stroke: var(--muted); stroke-width: 1.4; }
.fg-title { fill: var(--ink); font: 700 14px var(--f-display); }
.fg-col { fill: color-mix(in srgb, var(--h3-green) 60%, var(--surface)); stroke: var(--ink); stroke-width: 1.2; }
.fg-spin { fill: var(--ink); font: 700 13px var(--f-body); }
.fg-c0 { fill: color-mix(in srgb, var(--h3-green) 70%, var(--surface)); }
.fg-c1 { fill: color-mix(in srgb, var(--accent) 60%, var(--surface)); }
.fg-c2 { fill: color-mix(in srgb, var(--warn) 65%, var(--surface)); }
.fg-c3 { fill: color-mix(in srgb, var(--brand-red) 55%, var(--surface)); }
.fg-c4 { fill: color-mix(in srgb, var(--muted) 55%, var(--surface)); }
.fg-c5 { fill: color-mix(in srgb, var(--good) 40%, var(--accent)); }
.fg-c0, .fg-c1, .fg-c2, .fg-c3, .fg-c4, .fg-c5 { stroke: var(--surface); stroke-width: 1.5; }
.fig-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font: 600 13px var(--f-body) !important; color: var(--ink) !important; }
.fig-key { display: inline-flex; align-items: center; gap: 6px; }
.fig-key i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.fig-key i.fg-c0 { background: color-mix(in srgb, var(--h3-green) 70%, var(--surface)); }
.fig-key i.fg-c1 { background: color-mix(in srgb, var(--accent) 60%, var(--surface)); }
.fig-key i.fg-c2 { background: color-mix(in srgb, var(--warn) 65%, var(--surface)); }
.fig-key i.fg-c3 { background: color-mix(in srgb, var(--brand-red) 55%, var(--surface)); }
.fig-key i.fg-c4 { background: color-mix(in srgb, var(--muted) 55%, var(--surface)); }
.fig-key i.fg-c5 { background: color-mix(in srgb, var(--good) 40%, var(--accent)); }
.fig-stemleaf { border-collapse: collapse; font: 700 16px var(--f-mono); background: var(--surface); }
.fig-stemleaf th, .fig-stemleaf td { padding: 5px 12px; }
.fig-stemleaf th { border-right: 2px solid var(--ink); text-align: right; }
.fig-stemleaf td.sl-back { border-right: 2px solid var(--ink); text-align: right; letter-spacing: .12em; }
.fig-stemleaf td.sl-leaf { letter-spacing: .12em; }
.fig-stemleaf .sl-h { font: 700 12px var(--f-body); color: var(--muted); border-bottom: 1px solid var(--line); }

.fig-cap { flex-basis: 100%; text-align: center; font: 800 14px var(--f-display); color: var(--muted); }

/* Phone-width fixes found in the full preview: long stems of comma-joined
   data must wrap, the stem column must not grow past the screen, and wide
   bus-stop working scrolls inside its own box. */
.stem { grid-template-columns: auto minmax(0, 1fr); }
.stem p, .prompt { overflow-wrap: anywhere; }
.hp-bus, .hp-algo { overflow-x: auto; }
.stem p { overflow-x: auto; }
.hp-steps > li { grid-template-columns: 28px minmax(0, 1fr); }
.hp-step > * { max-width: 100%; }
.hp-step { grid-template-columns: minmax(0, 1fr); }

/* Year picker on the home page: Year 7 / Year 8 tabs beside the chapter heading. */
.list-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.year-tabs { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.year-tab { font: 700 15px var(--f-body); color: var(--muted); background: none; border: 0; border-radius: 999px; padding: 7px 16px; cursor: pointer; }
.year-tab:hover { color: var(--ink); }
.year-tab.on { background: var(--h3-green); color: var(--accent-ink); }

/* Year levels: the "other year levels" link, the are-you-sure dialog, and the
   banner shown while a student looks outside their own year. */
.other-years { font: 700 14px var(--f-body); color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.other-years:hover { color: var(--ink); border-color: var(--muted); }
.other-years span { font-size: 18px; line-height: 0; margin-left: 2px; }
.yr-modal { max-width: 460px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 22px 22px 18px; }
.yr-modal::backdrop { background: rgba(10, 18, 34, 0.55); }
.yr-modal h2 { font-size: 21px; margin: 0 0 10px; }
.yr-modal p { margin: 0 0 16px; color: var(--muted); }
.yr-modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.yr-outside { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 0; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
