:root {
  color-scheme: light;
  --paper: #f3f0e8;
  --ink: #161713;
  --quiet: #65675f;
  --line: #cbc8bd;
  --maths: #6849e8;
  --english: #ad7621;
  --grid-line: rgba(22, 23, 19, 0.035);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #16140f;
  --ink: #ece6df;
  --quiet: #a79e8e;
  --line: #2e2921;
  --maths: #a387f0;
  --english: #cf9a45;
  --grid-line: rgba(236, 230, 223, 0.04);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

/* 2.1: skip link — Ruled Notebook ink, square, mono */
.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 50;
  padding: 10px 16px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-decoration: none;
  transition: top 160ms ease;
}
.skip-link:focus-visible { top: 12px; outline: 3px solid var(--ink); outline-offset: 3px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.desk {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.mast-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
}

.theme-toggle:hover { color: var(--paper); background: var(--ink); }
.theme-toggle:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.subjects-toggle .subjects-icon { flex: 0 0 auto; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--paper);
  background: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.board-tag,
.eyebrow,
.course-code,
.subject-kicker,
.availability,
dt {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.board-tag {
  color: var(--quiet);
  font-size: 11px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.7fr);
  align-items: end;
  gap: 48px;
  padding: 64px 0 52px;
}

.eyebrow {
  grid-column: 1 / -1;
  margin: 0 0 -28px;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 700;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(48px, 7.4vw, 94px);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: -0.055em;
}

.headline-hierarchy {
  max-width: 820px;
  font-size: clamp(48px, 7.4vw, 94px);
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.headline-hierarchy em {
  display: inline-block;
  margin-top: 0.04em;
  font-size: 1.06em;
  font-style: italic;
}

.intro-copy {
  margin: 0 0 4px;
  color: var(--quiet);
  font-size: 17px;
  line-height: 1.65;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.subject-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 500px;
  padding: 28px 34px 32px;
  overflow: hidden;
}

.subject-card + .subject-card { border-left: 1px solid var(--ink); }

.subject-card::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -105px;
  width: 260px;
  height: 260px;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0.15;
  pointer-events: none;
}

.maths-card { color: #201a3d; background: #e2dcff; }
.higher-card { color: #173b35; background: #d0e9df; }
.english-card { color: #3e2911; background: #ebddbd; }

:root[data-theme='dark'] .maths-card { color: #d2c6ff; background: #241d3e; }
:root[data-theme='dark'] .higher-card { color: #a9e3cf; background: #173b35; }
:root[data-theme='dark'] .english-card { color: #e3c287; background: #352b1a; }
:root[data-theme='dark'] .availability.ready i { background: #4fc08f; box-shadow: 0 0 0 3px rgba(79, 192, 143, 0.18); }
:root[data-theme='dark'] .maths-card .enter-link:hover { background: #d5c6ff; }
:root[data-theme='dark'] .higher-card .enter-link:hover { background: #a9e3cf; }
:root[data-theme='dark'] .english-card .enter-link:hover { background: #f0d9a8; }

.card-topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.course-code,
.availability,
.subject-kicker,
dt { font-size: 10px; font-weight: 800; }

.availability { display: inline-flex; align-items: center; gap: 7px; }
.availability i { width: 7px; height: 7px; border-radius: 50%; background: #8c806b; }
.availability.ready i { background: #237b55; box-shadow: 0 0 0 3px rgba(35, 123, 85, 0.12); }

.subject-lockup {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 54px 0 26px;
}

.subject-lockup > div { min-width: 0; }

.subject-lockup h2 {
  overflow-wrap: break-word;
  hyphens: auto;
  text-wrap: balance;
  font-size: clamp(30px, 2.8vw, 42px);
}

.subject-letter {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
  line-height: 1;
}

.subject-kicker { margin: 0 0 4px; opacity: 0.7; }

h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 5vw, 62px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.045em;
}

.subject-copy {
  max-width: 480px;
  min-height: 76px;
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
}

.course-guide-link {
  width: fit-content;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 750;
  text-underline-offset: 4px;
}

.course-guide-link:hover { text-decoration-thickness: 2px; }
.course-guide-link:focus-visible { outline: 3px solid currentColor; outline-offset: 4px; }

.subject-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 32px 0;
  padding: 20px 0;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
}

.subject-facts div { min-width: 0; }
dt { margin-bottom: 5px; opacity: 0.6; }
dd { margin: 0; font-size: 14px; font-weight: 750; }

.enter-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 54px;
  margin-top: auto;
  padding: 0 18px;
  border: 1px solid currentColor;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.enter-link span { font-size: 20px; transition: transform 160ms ease; }
.enter-link:hover { color: var(--paper); transform: translateY(-2px); }
.maths-card .enter-link:hover { background: #201a3d; }
.higher-card .enter-link:hover { background: #173b35; }
.english-card .enter-link:hover { background: #3e2911; }
.enter-link:hover span { transform: translateX(4px); }
.enter-link:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

.desk-note {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  padding: 24px 0 0;
  color: var(--quiet);
  font-size: 13px;
}

.desk-note strong { color: var(--ink); }

/* v3 — continue banner + mistake-to-mastery loop strip. */
.continue-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: 0 0 18px; padding: 14px 18px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
}
.continue-banner[hidden] { display: none; }
.continue-banner strong { display: block; font-size: 14px; }
.continue-banner span { display: block; font-size: 12px; opacity: 0.8; }
.continue-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--paper); color: var(--ink); background: var(--paper);
  font-size: 13px; font-weight: 800; text-decoration: none;
}
.continue-link:hover { filter: brightness(1.06); }

.loop-strip { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.loop-strip ol {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
}
.loop-strip li { padding: 14px 18px; }
.loop-strip li + li { border-left: 1px solid var(--line); }
.loop-strip b {
  display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
}
.loop-strip span { display: block; margin-top: 4px; color: var(--quiet); font-size: 12.5px; }

@media (max-width: 1080px) and (min-width: 761px) {
  .subject-card { min-height: 460px; padding: 24px 22px 28px; }
  .subject-lockup { gap: 16px; margin: 40px 0 20px; }
  .subject-letter { width: 64px; height: 64px; font-size: 36px; }
  h2 { font-size: clamp(30px, 3.6vw, 44px); }
}

@media (max-width: 760px) {
  .desk { width: min(100% - 28px, 600px); padding-top: 18px; }
  .intro { display: block; padding: 46px 0 36px; }
  .eyebrow { margin: 0 0 18px; }
  h1 { font-size: clamp(48px, 15vw, 68px); }
  .intro-copy { margin-top: 28px; }
  .loop-strip ol { grid-template-columns: 1fr 1fr; }
  .loop-strip li:nth-child(3) { border-left: 0; }
  .loop-strip li:nth-child(n+3) { border-top: 1px solid var(--line); }
  .subject-grid { grid-template-columns: 1fr; }
  .subject-card { min-height: 480px; padding: 24px; }
  .subject-card + .subject-card { border-left: 0; border-top: 1px solid var(--ink); }
  .subject-lockup { margin-top: 42px; }
  .subject-copy { min-height: auto; }
  .desk-note { flex-direction: column; gap: 6px; }
}

@media (max-width: 420px) {
  .board-tag { display: none; }
  .subject-lockup { gap: 15px; }
  .subject-letter { width: 62px; height: 62px; font-size: 35px; }
  .subject-facts { gap: 10px; }
  dd { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
