/* HAKGED — the subject-page template (2026-11 redesign, P1), shared by /science/,
 * /social-studies/ (and /math/, /rla/ for BASE students). ONE template so the subjects can never
 * drift apart. Decisions: docs/plan-website-practice-exam-2026-11-04.md ("Subject page", "The Exam
 * tab", "Foundation students") as revised by docs/plan-polish-grill-2026-11-08.md (A, B, F1-F4).
 * /account/ and /report-card/ borrow the top row (.sp-top / .sp-corner) and the list row (.sp-row)
 * from here too, so a change here moves them as well — on purpose: one corner line, one row.
 * Needs /site-tokens.css first.
 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: #fff; color: var(--hk-ink);
  font-family: var(--hk-ui-family);
  -webkit-font-smoothing: antialiased;
  opacity: 0;
}
body.loaded { opacity: 1; transition: opacity .25s var(--hk-ease); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus, a:focus { outline: none; }

:root {
  /* A5: logo, centre title and house share ONE centre line, 26px from the top of the screen — the
     same line the home and admin bars already centre on, so the logo never jumps between pages.
     (Was 43px: a 28px top gap plus half of the old 30px number-button row.) */
  --sp-line: 26px;
  --sp-top-h: 52px;        /* the top row's box: twice the centre line */
  --sp-side: 16px;         /* screen edge → logo / house */
  --sp-logo: 24px;
  --sp-house: 22px;
  --sp-main-top: 24px;     /* the top row → the big heading, the same as Student Achievements */
  --sp-bar-h: 68px;        /* F4: 58px + 10px under the labels */
  --sp-bar-w: 420px;
  --sp-topic-h: 34px;      /* F3b: 34px rows, 15px titles */
  /* F3b / W3: the list column is 400px on a computer, so its hover band (10px past the text on each
     side = 420px) meets the 420px tab bar's edges exactly. */
  --sp-col: 400px;
  --sp-band: 10px;         /* how far the hover band reaches past the text, each side */
  --sp-pad: 20px;          /* the page's side margin under the column */
  --sp-sec-gap: 24px;      /* between two sections */
  --sp-tab-grey: #8e8e93;
  --sp-tab-off: #c7c7cc;
}

/* ---- Top row: logo · house on the 26px line (the subject title moved below it, 2026-11-09) ---- */
.sp-top { position: relative; z-index: 2; height: var(--sp-top-h); }
.sp-corner {
  position: absolute; top: var(--sp-line);
  transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
}
.sp-logo { left: var(--sp-side); width: var(--sp-logo); height: var(--sp-logo); flex: none; }
.sp-logo svg { width: var(--sp-logo); height: var(--sp-logo); fill: var(--hk-ink); display: block; }
.sp-house { right: calc(var(--sp-side) - 6px - (100vw - 100%)); width: 34px; height: 34px; border-radius: 8px; transition: background-color var(--hk-dur-fast) var(--hk-ease); }
.sp-house:hover, .sp-house.kbd:focus { background: var(--hk-hover); }
/* A3: a 1.5px line on screen at 22px = 1.5 x 24 / 22 in the icon's own units. */
.sp-house svg { width: var(--sp-house); height: var(--sp-house); fill: none; stroke: var(--hk-ink); stroke-width: 1.636; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* The page heading (2026-11-09: the Student Achievements heading block, no caption; ~~the centre of
   the top row, 24px~~). Practice: "Science ⌄", the standard drop-down (B list) that switches subject.
   Exam: the status heading, the same size, no chevron. 24px to the list, as between two sections. */
.sp-mid {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--sp-sec-gap);
}
.sp-mid.gone { display: none; }
.sp-head, .sp-pick {
  font-family: var(--hk-title-family); font-weight: var(--hk-title-wght);
  font-variation-settings: 'opsz' var(--hk-title-opsz);
  font-size: var(--hk-fs-page); line-height: 1.1; letter-spacing: -0.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  /* overflow:hidden cuts at the line box, and at line-height 1.1 the tail of a y or g hangs 3px
     past it. The padding keeps the tail; the negative margin keeps the 24px measured the same. */
  padding: 0 0 .12em; margin-bottom: -.12em;
}
.sp-pick { gap: 8px; }
/* 22px beside the 34px title, with the same 1.5px line as the house (A3). */
.sp-pick .hk-chev { width: 22px; height: 22px; stroke-width: 1.636; margin-top: 2px; }

/* ---- Body: one column on every screen size (F2) ---- */
.sp-main { padding: var(--sp-main-top) var(--sp-pad) calc(var(--sp-bar-h) + 32px); }
.sp-sec { max-width: var(--sp-col); margin: 0 auto; }
.sp-sec + .sp-sec { margin-top: var(--sp-sec-gap); }
/* A9 header: the unit / subject name only, starting at the SAME left edge as the numbers (the hover
   band overhangs both by --sp-band). */
.sp-sec-h { display: flex; align-items: center; height: 28px; }
.sp-list { list-style: none; margin: 0 auto; max-width: var(--sp-col); }
.sp-row {
  display: flex; align-items: center; gap: 10px;
  height: var(--sp-topic-h); padding: 0 var(--sp-band); margin: 0 calc(-1 * var(--sp-band));
  font-size: var(--hk-fs-list); font-weight: 400; line-height: 1; white-space: nowrap;
  border-radius: 6px; cursor: pointer;
  transition: background-color var(--hk-dur-fast) var(--hk-ease);
}
.sp-row:hover, .sp-row.kbd:focus { background: var(--hk-hover); }
/* F3b: 14px, muted, equal-width digits in a FIXED column — so every title starts at the same x.
   (The mock-up's ragged titles came from proportional digits.) 2ch = two tabular digits. */
.sp-row .n { flex: none; width: 2ch; font-size: 14px; color: var(--hk-muted); font-variant-numeric: tabular-nums; }
.sp-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* TODAY / DONE on the right (A1 Small: 12px). Inter 600, never 500 (A2). */
.sp-row .d { flex: none; font-size: var(--hk-fs-small); font-weight: 600; letter-spacing: .08em; color: var(--hk-red); }
/* A8b date in a list: three aligned columns, no dot — the day right-aligned (no leading zero), the
   month left-aligned, the weekday left-aligned and muted. Fixed widths are what line the columns up
   from row to row. 14px regular. */
.sp-row .dt { flex: none; font-size: 14px; font-weight: 400; font-variant-numeric: tabular-nums; color: var(--hk-muted); }
.sp-row .dt.red { color: var(--hk-red); }
.sp-row.muted { color: var(--hk-muted); cursor: default; }
.sp-row.muted:hover { background: none; }
.sp-row.muted .d { color: var(--hk-muted); }
/* F3: on an exam day the exam's WHOLE row is red, its number included. */
.sp-row.red, .sp-row.red .n { color: var(--hk-red); }
.sp-empty { text-align: center; color: var(--hk-muted); font-size: var(--hk-fs-list); margin-top: 12px; }

/* W3 on a phone: the side margin drops to 20px and the hover band runs edge to edge (the screen's
   width), like the full-width tab bar; the text still starts 20px in. 440px = the 400px column plus
   two 20px margins, i.e. the width below which the computer layout no longer fits. */
@media (max-width: 439px) {
  :root { --sp-band: var(--sp-pad); }
}

/* ---- Bottom bar: Lessons · Practice · Exam (Lessons greyed until slides exist) ----
   F4: no selection line any more — the chosen tab is marked only by its black icon and Inter 600
   label. 10px under the labels (the bar is 68px, not 58px); .sp-main clears it via --sp-bar-h. */
.sp-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  height: calc(var(--sp-bar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--hk-rule);
  transition: opacity var(--hk-dur) var(--hk-ease);
}
.sp-bar-in { display: flex; max-width: var(--sp-bar-w); height: var(--sp-bar-h); padding-bottom: 10px; margin: 0 auto; }
.sp-tab {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--sp-tab-grey); font-size: var(--hk-fs-cap); font-weight: 400; letter-spacing: .01em;
  transition: color var(--hk-dur-fast) var(--hk-ease);
}
.sp-tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.636; stroke-linecap: round; stroke-linejoin: round; }
.sp-tab.on { color: var(--hk-ink); font-weight: 600; }
.sp-tab:hover:not(.off):not(.on), .sp-tab.kbd:focus:not(.off) { color: #3a3a3c; }
.sp-tab.off { color: var(--sp-tab-off); cursor: default; }

/* ---- BASE (Foundation) page: title + one standard button, in the EXACT middle of the window
   (A5b — the old 24px optical lift is gone). ---- */
.sp-base {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  pointer-events: none;
}
.sp-base > * { pointer-events: auto; }
/* A page title (A1 "Page title", 34px Fraunces): the BASE page's subject, the account name, the
   Report Card heading. */
.sp-title {
  text-align: center;
  font-family: var(--hk-title-family); font-weight: var(--hk-title-wght);
  font-variation-settings: 'opsz' var(--hk-title-opsz);
  font-size: var(--hk-fs-page); line-height: 1.1; letter-spacing: -0.015em;
}
.sp-base .sp-title { margin-top: -.16em; }  /* A5b: the blank space above the letters doesn't count */
.sp-soon { color: var(--hk-muted); font-size: var(--hk-fs-list); }

/* ---- The Continue / Restart overlay (P2, F3c). Lies OVER the page, its block in the exact middle
   of the window (A5b). It carries its own corner logo (the page's own top row scrolls away, so it
   cannot be borrowed); the standard cross (A11) sits exactly where the house is; the bar goes away
   while it is open. ---- */
.sp-ov {
  position: fixed; inset: 0; z-index: 10; background: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity var(--hk-dur) var(--hk-ease), visibility 0s linear var(--hk-dur);
}
.sp-ov.open { opacity: 1; visibility: visible; transition: opacity var(--hk-dur) var(--hk-ease), visibility 0s; }
.sp-ov-in { max-width: calc(100% - 48px); text-align: center; display: flex; flex-direction: column; align-items: center; }
.sp-ov-q {
  font-family: var(--hk-title-family); font-weight: var(--hk-title-wght);
  font-variation-settings: 'opsz' var(--hk-title-opsz);
  font-size: var(--hk-fs-page); line-height: 1.15; letter-spacing: -0.015em; margin-top: -.185em; margin-bottom: 28px;
  overflow-wrap: anywhere;
}
/* F3c: CONTINUE and RESTART side by side, Continue on the left, one width (the widest label). */
.sp-ov-btns { min-width: 260px; }
.sp-x { position: fixed; top: var(--sp-line); right: calc(var(--sp-side) - 6px); transform: translateY(-50%); width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; z-index: 11; transition: background-color var(--hk-dur-fast) var(--hk-ease); }
.sp-x:hover, .sp-x.kbd:focus { background: var(--hk-hover); }
.sp-x svg { width: 22px; height: 22px; fill: none; stroke: var(--hk-ink); stroke-width: 1.636; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ---- The On-Campus Practice button (P5, renamed 2026-11-08 G2). Since A10 there is no solid black
   button anywhere, so the old red-and-black split button became the standard button holding a red
   dot + red LIVE and then the words. One tap target; still (no pulse); fades in over 0.4 s at the
   first release; in the exact middle of the window (A5b). ---- */
.sp-live {
  display: none;
  opacity: 0; transition: opacity var(--hk-dur) var(--hk-ease), background-color var(--hk-dur-fast) var(--hk-ease);
}
.sp-live.show { display: inline-flex; }
.sp-live.in { opacity: 1; }
.sp-live .lv { display: inline-flex; align-items: center; gap: 7px; color: var(--hk-red); padding-right: 4px; }
.sp-live .lv::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.sp-live-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.sp-live-wrap > * { pointer-events: auto; }
