/* Joined by scripts/sync-nav.mjs (scripts/lib/asset-bundles.mjs) from /css/tabs/lessons.css, /css/search.css, /css/theme.css.
   Do not edit: change those and run npm run sync:nav. */
/* /css/tabs/lessons.css */
.lessons-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 35px 5vw 60px;
}
/* The games hub has only a handful of large tiles, so it reads better
   filling more of the page than the dense lesson/MCQ grids do. */
.lessons-page.games-hub { max-width: 1600px; }
/* Tiles sit in one row with descriptions of differing length, so let the
   inner column stretch and push the play pill to the bottom - otherwise
   the pills sit at three different heights across the row. */
.games-hub .lessons-hub-tile { align-items: stretch; margin-bottom: 0; }
.games-hub .lessons-hub-tile > div { display: flex; flex-direction: column; height: 100%; }
.games-hub .lessons-hub-tile .lessons-hub-link { margin-top: auto; align-self: flex-start; }
/* Connections carries two actions (play + build your own): a flex row that
   sits at the foot of the tile, the second pill an outline variant. */
.games-hub .lessons-hub-tile .lessons-hub-actions {
  margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; align-self: stretch;
}
/* Two pills share the tile foot, so they're smaller than a single-action
   pill - this keeps them alongside rather than stacking in a narrow tile. */
.games-hub .lessons-hub-tile .lessons-hub-actions .lessons-hub-link {
  margin-top: 0; align-self: auto; font-size: 12px; padding: 8px 14px; gap: 4px;
}
.lessons-hub-link.secondary { background: transparent; color: var(--ink); }
.lessons-hub-link.secondary:hover { background: var(--ink); color: var(--paper-white); border-color: var(--ink); box-shadow: 2px 2px 0 var(--riso-green); }

/* ── Page header ─────────────────────────────────────────────── */
.lessons-head {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 60px;
  align-items: end;
  margin-bottom: 52px;
}
.lessons-head .illo { width: 100%; max-width: 340px; aspect-ratio: 1 / 1; }
.lessons-head .meta {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  display: inline-flex; gap: 10px; align-items: center;
  margin-bottom: 22px;
}
.lessons-head .meta .pin {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--riso-green);
  box-shadow: 2px 2px 0 var(--riso-pink);
}
.lessons-head h1 {
  font-size: clamp(40px, 5vw, 72px);
  line-height: 1;
  letter-spacing: -.01em;
  font-weight: 600;
  max-width: 22ch;
  text-wrap: balance;
  margin-bottom: 18px;
}
.lessons-head h1 em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--riso-green);
  text-shadow: 2px 1px 0 var(--riso-pink);
}
.lessons-head .lede {
  font-size: 18px;
  color: var(--ink-dim);
  max-width: 56ch;
  line-height: 1.55;
}

/* ── Filter bar ──────────────────────────────────────────────── */
.lessons-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 32px;
  align-items: center;
  margin-bottom: 30px;
  padding: 18px 22px;
  background: var(--paper-white);
  border: 1.5px solid var(--ink);
  border-radius: 16px;
  box-shadow: 3px 3px 0 var(--riso-pink);
}

/* ── Course toggle: two-up segmented card that swaps IB / AP ─── */
.course-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 5px;
  margin-bottom: 18px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 16px;
}
.course-toggle-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 15px 20px;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 11px;
  color: var(--ink-dim);
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, color 0.14s, border-color 0.14s, box-shadow 0.14s, transform 0.14s;
}
.course-toggle-btn:hover { color: var(--ink); background: var(--paper-white); }
.course-toggle-btn[aria-selected="true"] {
  background: var(--riso-green);
  border-color: var(--ink);
  color: var(--paper-white);
  box-shadow: 3px 3px 0 var(--riso-pink);
  transform: translate(-1px, -1px);
}
.course-toggle-btn[aria-selected="true"]:hover { background: var(--riso-green); }
.course-toggle-btn[aria-selected="true"] .course-toggle-sub { color: var(--paper-white); opacity: 0.85; }
.course-toggle-btn[aria-selected="true"] .course-toggle-check {
  opacity: 1;
  transform: scale(1);
}
.course-toggle-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.course-toggle-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px; height: 19px;
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.14s, transform 0.14s;
}
.course-toggle-check svg { width: 100%; height: 100%; }
.course-toggle-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
@media (max-width: 560px) {
  .course-toggle { grid-template-columns: 1fr; gap: 6px; }
  .course-toggle-btn { padding: 12px 16px; }
  .course-toggle-btn[aria-selected="true"] { transform: none; }
  .course-toggle-name { font-size: 20px; }
  .course-toggle-sub { font-size: 12px; }
}
/* Label in a fixed column, chips wrapping in their own track beside it.
   The chips used to be flex children of the group alongside the label,
   so a second row of chips restarted at the group's left edge - tucked
   under the label instead of lining up with the first chip above it. */
.lessons-filter-group {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.lessons-filter-group[hidden] { display: none; }
.lessons-filter-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  margin-right: 2px;
  /* Fixed column so COURSE / THEME / LEVEL / SL / HL all start their
     chips at the same x when the groups stack. Wide enough for the
     longest label ("SL / HL") at this size and tracking. */
  flex: 0 0 auto;
  min-width: 58px;
  /* Match a chip's box height so the label centres against the FIRST
     row of chips, not the middle of a wrapped block. Kept in step with
     .lessons-chip below, whose height is pinned by its line-height. */
  min-height: 31px;
  display: flex;
  align-items: center;
}
.lessons-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
.lessons-chip {
  font-family: var(--font-mono);
  font-size: 13px;
  /* Pinned rather than left to the font's "normal" so the chip's height
     is deterministic (13 x 1.25 + 12 padding + 3 border = 31.25px) and
     .lessons-filter-label's min-height can be matched to it. */
  line-height: 1.25;
  letter-spacing: 0.05em;
  color: var(--ink-dim);
  background: var(--paper);
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.13s, color 0.13s, border-color 0.13s, box-shadow 0.13s;
  white-space: nowrap;
}
.lessons-chip:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.lessons-chip[aria-pressed="true"] {
  background: var(--riso-green);
  border-color: var(--riso-green);
  color: var(--paper-white);
  box-shadow: 2px 2px 0 var(--riso-pink);
}

/* ── Sort + count bar ────────────────────────────────────────── */
.lessons-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.lessons-count {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.lessons-sort {
  display: inline-flex;
  gap: 0;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 3px;
  background: var(--paper-white);
  box-shadow: 2px 2px 0 var(--riso-green);
}
.lessons-sort-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
}
.lessons-sort-btn:hover { color: var(--ink); }
.lessons-sort-btn.active {
  background: var(--riso-green);
  color: var(--paper-white);
}

/* ── Keyword search ──────────────────────────────────────────── */
.lessons-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1 1 220px;
  max-width: 340px;
}
.lessons-search-icon {
  position: absolute;
  left: 13px;
  width: 14px;
  height: 14px;
  color: var(--ink-faint);
  pointer-events: none;
}
.lessons-search-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink);
  background: var(--paper-white);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 8px 34px;
  box-shadow: 2px 2px 0 var(--riso-pink);
  transition: box-shadow 0.14s, border-color 0.14s;
  -webkit-appearance: none;
  appearance: none;
}
.lessons-search-input::placeholder { color: var(--ink-faint); }
.lessons-search-input:focus {
  outline: none;
  box-shadow: 2px 2px 0 var(--riso-green);
}
/* Hide the browser's native search clear affordance; we render our own. */
.lessons-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
.lessons-search-clear {
  position: absolute;
  right: 8px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--ink-dim);
  background: var(--paper);
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}
.lessons-search-clear:hover {
  color: var(--ink);
  border-color: var(--ink);
  background: color-mix(in srgb, var(--riso-pink) 18%, var(--paper));
}
.lessons-search-clear[hidden] { display: none; }

/* ── Lesson grid ─────────────────────────────────────────────── */
.lessons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ── Lesson card ─────────────────────────────────────────────── */
.lesson-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper-white);
  border: 1.5px solid var(--ink);
  border-radius: 18px;
  padding: 22px 24px 20px;
  box-shadow: 3px 3px 0 var(--riso-pink);
  text-decoration: none;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s;
}
.lesson-card::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("/img/grain.svg");
  background-repeat: repeat;
  mix-blend-mode: multiply;
  opacity: 0.28;
  pointer-events: none;
  border-radius: inherit;
}
.lesson-card > * { position: relative; z-index: 1; }
.lesson-card-icon {
  position: absolute;
  bottom: 64px;
  right: 18px;
  width: 60px;
  height: 60px;
  opacity: 0.92;
  pointer-events: none;
  z-index: 0;
}
.lesson-card-venue {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
}
.lesson-card-venue.is-home {
  color: var(--riso-pink-deep);
  border-color: var(--riso-pink);
  box-shadow: 1.5px 1.5px 0 var(--riso-pink);
  background: color-mix(in srgb, var(--riso-pink) 10%, var(--paper));
}
.lesson-card-venue.is-school {
  color: var(--riso-green-deep);
  border-color: var(--riso-green);
  box-shadow: 1.5px 1.5px 0 var(--riso-green);
  background: color-mix(in srgb, var(--riso-green) 10%, var(--paper));
}
.lesson-card-venue.is-screen {
  color: var(--ink);
  border-color: var(--ink-dim);
  box-shadow: 1.5px 1.5px 0 var(--ink-faint);
  background: var(--paper-white);
}
.lesson-card-pdfs {
  position: absolute;
  top: 22px;
  right: 96px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 2;
}
/* The longer "Simulation" badge leaves no room beside it, so a
   simulation's extra pages stack under the badge instead. */
.lesson-card.is-sim .lesson-card-pdfs { right: var(--sim-pill-right, 24px); top: 54px; }
.lesson-card.is-sim .lesson-card-header { margin-bottom: 40px; }
.lesson-card-pdf {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--riso-pink-deep);
  background: var(--paper);
  border: 1.5px solid var(--riso-pink);
  border-radius: 999px;
  padding: 3px 11px;
  text-decoration: none;
  box-shadow: 1.5px 1.5px 0 var(--riso-pink);
  transition: transform 0.14s, box-shadow 0.14s;
  white-space: nowrap;
}
.lesson-card-pdf:hover {
  transform: translate(-1px, -1px);
  box-shadow: 2.5px 2.5px 0 var(--riso-green);
}
.lesson-card-teacher {
  color: var(--riso-green-deep);
  border-color: var(--riso-green);
  box-shadow: 1.5px 1.5px 0 var(--riso-green);
}
.lesson-card-teacher:hover {
  box-shadow: 2.5px 2.5px 0 var(--riso-pink);
}
/* A second pill stacks below the first, so the header needs more headroom. */
.lesson-card:has(.lesson-card-pdfs .lesson-card-teacher) .lesson-card-header {
  margin-bottom: 40px;
}
.labs-skill-note {
  max-width: 60ch;
  margin: 32px auto 0;
  text-align: center;
  font-size: 14px;
  color: var(--ink-dim);
  line-height: 1.55;
}
.labs-skill-note em {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink);
  font-size: 16px;
}
.labs-skill-note a {
  color: var(--riso-pink-deep);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.labs-skill-note a:hover { color: var(--riso-green-deep); }
.lesson-card:nth-child(2n) { box-shadow: 3px 3px 0 var(--riso-green); }
.lesson-card:hover {
  transform: translateY(-3px);
  box-shadow: 3px 3px 0 var(--riso-green), 0 12px 28px rgba(255, 126, 182, 0.18);
}
.lesson-card:nth-child(2n):hover {
  box-shadow: 3px 3px 0 var(--riso-pink), 0 12px 28px rgba(45, 184, 118, 0.18);
}

.lesson-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}
.lesson-card-codes { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.lesson-card-code {
  font-family: var(--font-mono);
  max-width: 100%;
  white-space: normal;
  font-size: 12px;
  line-height: 1.1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-white);
  background: var(--ink);
  border: 1.5px solid var(--ink);
  padding: 3px 11px;
  border-radius: 999px;
}


.lesson-card-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--riso-green-deep);
  background: var(--paper);
  border: 1.5px solid var(--riso-green);
  padding: 3px 11px;
  border-radius: 999px;
  box-shadow: 1.5px 1.5px 0 var(--riso-green);
}
.lesson-card-badge.exam { color: var(--riso-pink-deep); border-color: var(--riso-pink); box-shadow: 1.5px 1.5px 0 var(--riso-pink); }

.lesson-card h3 {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.lesson-card-sub {
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.45;
  flex: 1;
  padding-right: 56px;
}

.lesson-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  /* MCQ cards carry two pills plus the share button. On a narrow
     (3-across) card that won't fit beside the meta, and space-between
     lets the items overflow into each other rather than reflow. Allow
     the footer to wrap so the actions drop to their own line intact. */
  flex-wrap: wrap;
  row-gap: 12px;
  /* The decorative corner icon is absolutely positioned, so by default
     it paints ABOVE this normal-flow footer and lands on top of the
     pills. Give the footer its own stacking context so the controls sit
     above the icon; the icon's opaque backdrop then hides behind the
     pills and only shows in the surrounding whitespace. */
  position: relative;
  z-index: 1;
}
.lesson-card-type {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.lesson-card-arrow {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-dim);
  transition: transform 0.18s, color 0.18s;
}
.lesson-card:hover .lesson-card-arrow {
  color: var(--riso-green);
  transform: translateX(4px);
}

/* ── Empty state ─────────────────────────────────────────────── */
.lessons-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
  border: 1.5px dashed var(--ink);
  border-radius: 18px;
  background: var(--paper-white);
  color: var(--ink-dim);
  font-size: 18px;
  font-style: italic;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1060px) {
  .lessons-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .lessons-head { grid-template-columns: 1fr; gap: 32px; }
  .lessons-head .illo { max-width: 240px; }
}
@media (max-width: 640px) {
  .lessons-grid { grid-template-columns: 1fr; }
  .lessons-page { padding: 30px 5vw 40px; }
  .lessons-head h1 { font-size: clamp(28px, 9vw, 42px); }
  .lessons-head .lede { font-size: 15px; }
  .lessons-filters { gap: 14px 20px; padding: 14px 16px; }
  /* Stack the toolbar: count + sort on one row, search full-width below. */
  .lessons-toolbar { flex-wrap: wrap; }
  .lessons-sort { order: 1; }
  .lessons-search { order: 2; flex-basis: 100%; max-width: none; }
}

/* ── Resources page: lessons hub tile ───────────────────────── */
.lessons-hub-tile {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px 36px;
  align-items: start;
  background: var(--paper-white);
  border: 1.5px solid var(--ink);
  border-radius: 18px;
  padding: 26px 30px;
  box-shadow: 3px 3px 0 var(--riso-green);
  margin-bottom: 28px;
  overflow: hidden;
}
.lessons-hub-tile::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("/img/grain.svg");
  background-repeat: repeat;
  mix-blend-mode: multiply;
  opacity: 0.26;
  pointer-events: none;
  border-radius: inherit;
}
.lessons-hub-tile > * { position: relative; z-index: 1; }
.lessons-hub-tile-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--riso-green-deep);
  background: var(--paper);
  border: 1.5px solid var(--riso-green);
  padding: 3px 11px;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 12px;
  box-shadow: 1.5px 1.5px 0 var(--riso-green);
}
.lessons-hub-tile h2 {
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.1;
  letter-spacing: -.01em;
  font-weight: 600;
  margin-bottom: 10px;
}
.lessons-hub-tile h2 em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--riso-green);
  text-shadow: 1.5px 1px 0 var(--riso-pink);
}
.lessons-hub-tile-desc {
  font-size: 14px;
  color: var(--ink-dim);
  line-height: 1.5;
  max-width: 52ch;
  margin-bottom: 10px;
}
.lessons-hub-tile-objective {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  max-width: 52ch;
  margin-bottom: 18px;
}
.lessons-hub-tile-objective b { color: var(--riso-green-deep); font-weight: 700; }
.lessons-hub-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-white);
  background: var(--ink);
  border: 1.5px solid var(--ink);
  padding: 9px 20px;
  border-radius: 999px;
  text-decoration: none;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}
.lessons-hub-link:hover {
  background: var(--riso-green);
  border-color: var(--riso-green);
  box-shadow: 2px 2px 0 var(--riso-pink);
}
.lessons-hub-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}
.lessons-hub-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--ink-dim);
  text-decoration: none;
  transition: border-color 0.14s, color 0.14s, box-shadow 0.14s;
}
a.lessons-hub-preview-item:hover {
  border-color: var(--riso-green);
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--riso-green);
}
.lessons-hub-preview-code {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper-white);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.lessons-hub-preview-more {
  color: var(--ink-faint);
  font-style: italic;
}

/* Labs variant: pink accents instead of green so the two hub tiles
   sit distinct on the resources page. */
.lessons-hub-tile.is-labs {
  box-shadow: 3px 3px 0 var(--riso-pink);
}
.lessons-hub-tile-note {
  font-size: 12px;
  color: var(--ink-dim);
  line-height: 1.5;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line, rgba(26,58,42,0.18));
  max-width: 52ch;
}
.lessons-hub-tile-note em {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink);
  font-size: 14px;
}
.lessons-hub-tile-note a {
  color: var(--riso-pink-deep);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.lessons-hub-tile-note a:hover { color: var(--riso-green-deep); }
.lessons-hub-tile.is-labs .lessons-hub-tile-label {
  color: var(--riso-pink-deep);
  border-color: var(--riso-pink);
  box-shadow: 1.5px 1.5px 0 var(--riso-pink);
}
.lessons-hub-tile.is-labs h2 em {
  color: var(--riso-pink-deep);
  text-shadow: 1.5px 1px 0 var(--riso-green);
}
.lessons-hub-tile.is-labs .lessons-hub-link:hover {
  background: var(--riso-pink);
  border-color: var(--riso-pink);
  box-shadow: 2px 2px 0 var(--riso-green);
}

/* Side-by-side row of hub tiles (Labs + Lessons + Summary Doodles). */
.hub-tiles-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

/* Summary-doodles variant: green shadow with pink accents, so all three
   hub tiles read as distinct siblings. */
.lessons-hub-tile.is-doodles {
  box-shadow: 3px 3px 0 var(--riso-green);
}
.lessons-hub-tile.is-doodles .lessons-hub-tile-label {
  color: var(--riso-pink-deep);
  border-color: var(--riso-pink);
  box-shadow: 1.5px 1.5px 0 var(--riso-pink);
}
.lessons-hub-tile.is-doodles h2 em {
  color: var(--riso-pink-deep);
  text-shadow: 1.5px 1px 0 var(--riso-green);
}
.lessons-hub-tile.is-doodles .lessons-hub-link:hover {
  background: var(--riso-green);
  border-color: var(--riso-green);
  box-shadow: 2px 2px 0 var(--riso-pink);
}
.lessons-hub-tile.in-pair {
  margin-bottom: 0;
  grid-template-columns: 1fr;
}
.lessons-hub-tile.in-pair .lessons-hub-preview {
  min-width: 0;
  flex-direction: row;
  flex-wrap: wrap;
  margin-top: 4px;
}
.lessons-hub-tile.in-pair .lessons-hub-preview-item {
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
}

@media (max-width: 900px) {
  .hub-tiles-row { grid-template-columns: 1fr; gap: 16px; }
}
@media (max-width: 700px) {
  .lessons-hub-tile { grid-template-columns: 1fr; }
  .lessons-hub-tile:not(.in-pair) .lessons-hub-preview { display: none; }
}

/* === Spotlight: when /resources?spotlight=labs lands here === */
.lessons-hub-tile.spotlit {
  position: relative;
  z-index: 3;
  transform: scale(1.025);
  box-shadow:
    0 0 0 3px var(--riso-pink),
    6px 6px 0 var(--riso-pink),
    0 18px 36px -12px rgba(0, 0, 0, 0.18);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  animation: spotlight-pulse 1100ms ease-out 1;
}
@keyframes spotlight-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 126, 182, 0.65),
                     6px 6px 0 var(--riso-pink),
                     0 6px 12px -6px rgba(0, 0, 0, 0.1);
         transform: scale(1.0); }
  55%  { box-shadow: 0 0 0 18px rgba(255, 126, 182, 0),
                     6px 6px 0 var(--riso-pink),
                     0 18px 36px -12px rgba(0, 0, 0, 0.18);
         transform: scale(1.04); }
  100% { box-shadow: 0 0 0 3px var(--riso-pink),
                     6px 6px 0 var(--riso-pink),
                     0 18px 36px -12px rgba(0, 0, 0, 0.18);
         transform: scale(1.025); }
}
@media (prefers-reduced-motion: reduce) {
  .lessons-hub-tile.spotlit { animation: none; transition: none; }
}

.spotlight-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  margin-bottom: 14px;
  background: color-mix(in srgb, var(--riso-pink) 14%, var(--paper));
  border: 1.5px solid var(--riso-pink);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
  max-width: 100%;
}
.spotlight-chip:hover {
  background: color-mix(in srgb, var(--riso-pink) 22%, var(--paper));
  transform: translateX(-2px);
}
.spotlight-chip-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--riso-pink-deep);
  font-size: 12px;
}
.spotlight-chip-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  color: var(--ink);
  border-bottom: 1px dashed var(--ink);
  padding-bottom: 1px;
}
.spotlight-chip-arrow { color: var(--ink-mute); }
.spotlight-chip-foot {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  font-size: 12px;
}

/* === Card share button === */
.lesson-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  /* MCQ cards carry two pills (start + download) as well as the share
     button. When they don't fit, wrap the row rather than letting each
     pill break its own label across two lines. */
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: 8px;
  /* Once the footer wraps this onto its own line, keep it right-aligned:
     space-between on a single wrapped item would otherwise pin it left. */
  margin-left: auto;
}
.lesson-card-print,
.lesson-card-dl { white-space: nowrap; }
.lesson-card-share {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.lesson-card-share:hover,
.lesson-card-share:focus-visible {
  background: color-mix(in srgb, var(--riso-pink) 20%, var(--paper));
  transform: translateY(-1px);
  box-shadow: 1.5px 1.5px 0 var(--riso-pink);
  outline: none;
}
.lesson-card-share svg { width: 13px; height: 13px; }
.lesson-card-share.copied {
  background: color-mix(in srgb, var(--riso-green) 22%, var(--paper));
  border-color: var(--riso-green-deep);
  box-shadow: 1.5px 1.5px 0 var(--riso-green);
}

/* === Spotlight a single lab card when arriving from a shared link === */
.lesson-card.spotlit {
  position: relative;
  z-index: 3;
  transform: translateY(-3px) scale(1.025);
  box-shadow:
    0 0 0 3px var(--riso-pink),
    5px 5px 0 var(--riso-pink),
    0 20px 40px -12px rgba(0, 0, 0, 0.2);
  animation: lesson-card-spotlight 1100ms ease-out 1;
}
.lesson-card.spotlit:hover {
  box-shadow:
    0 0 0 3px var(--riso-pink),
    5px 5px 0 var(--riso-pink),
    0 20px 40px -12px rgba(0, 0, 0, 0.2);
}
@keyframes lesson-card-spotlight {
  0%   { box-shadow:
           0 0 0 0 rgba(255, 126, 182, 0.7),
           3px 3px 0 var(--riso-pink);
         transform: translateY(0) scale(1); }
  55%  { box-shadow:
           0 0 0 22px rgba(255, 126, 182, 0),
           5px 5px 0 var(--riso-pink),
           0 20px 40px -12px rgba(0, 0, 0, 0.2);
         transform: translateY(-5px) scale(1.045); }
  100% { box-shadow:
           0 0 0 3px var(--riso-pink),
           5px 5px 0 var(--riso-pink),
           0 20px 40px -12px rgba(0, 0, 0, 0.2);
         transform: translateY(-3px) scale(1.025); }
}
@media (prefers-reduced-motion: reduce) {
  .lesson-card.spotlit { animation: none; transition: none; }
}

/* === Card share popover (custom, replaces native share sheet) === */
.lesson-card-share-pop {
  position: absolute;
  z-index: 1000;
  background: var(--paper-white);
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--riso-pink);
  padding: 12px 14px 14px;
  transform: translate(-50%, -6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.lesson-card-share-pop.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.lesson-card-share-pop-arrow {
  position: absolute;
  top: -7px; left: 50%;
  width: 12px; height: 12px;
  background: var(--paper-white);
  border-top: 1.5px solid var(--ink);
  border-left: 1.5px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}
.lesson-card-share-pop-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 9px;
  text-align: center;
  white-space: nowrap;
}
.lesson-card-share-pop-buttons {
  display: flex;
  gap: 8px;
}
.lesson-card-share-pop-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}
.lesson-card-share-pop-btn:hover,
.lesson-card-share-pop-btn:focus-visible {
  background: color-mix(in srgb, var(--riso-pink) 22%, var(--paper));
  transform: translateY(-1px);
  box-shadow: 1.5px 1.5px 0 var(--riso-pink);
  outline: none;
}
.lesson-card-share-pop-btn svg { width: 15px; height: 15px; }
.lesson-card-share-pop-btn.copied {
  background: color-mix(in srgb, var(--riso-green) 24%, var(--paper));
  border-color: var(--riso-green-deep);
  box-shadow: 1.5px 1.5px 0 var(--riso-green);
}

/* === Download-HTML pill on lesson cards === */
.lesson-card-footer .lesson-card-dl {
  margin-left: auto;
  margin-right: 12px;
}
.lesson-card-dl {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--riso-green-deep);
  background: var(--paper);
  border: 1.5px solid var(--riso-green);
  border-radius: 999px;
  padding: 3px 11px;
  text-decoration: none;
  box-shadow: 1.5px 1.5px 0 var(--riso-green);
  transition: transform 0.14s, box-shadow 0.14s;
  z-index: 2;
}
.lesson-card-dl:hover {
  transform: translate(-1px, -1px);
  box-shadow: 2.5px 2.5px 0 var(--riso-pink);
}

/* === Print-sheet pill on summary-doodle cards === */
.lesson-card-print {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--riso-green-deep);
  background: var(--paper);
  border: 1.5px solid var(--riso-green);
  border-radius: 999px;
  padding: 3px 11px;
  text-decoration: none;
  box-shadow: 1.5px 1.5px 0 var(--riso-green);
  transition: transform 0.14s, box-shadow 0.14s;
  z-index: 2;
}
.lesson-card-print:hover {
  transform: translate(-1px, -1px);
  box-shadow: 2.5px 2.5px 0 var(--riso-pink);
}

/* ── Games hub: Zombio up front, the rest on a sideways rail ── */
.gh-feature {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 28px 36px; align-items: center;
  background: var(--paper-white); border: 1.5px solid var(--ink); border-radius: 18px;
  padding: 22px; box-shadow: 4px 4px 0 var(--riso-pink); margin: 8px 0 40px;
}
.gh-feature-shots {
  position: relative; display: block; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden;
  border: 1.5px solid var(--ink); background: #f6c1c9;
}
.gh-feature-shots img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .8s ease;
}
.gh-feature-shots img.on { opacity: 1; }
.gh-film { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.gh-film[hidden] { display: none; }
.gh-play {
  position: absolute; left: 14px; bottom: 14px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase; background: var(--riso-pink); color: #fff; padding: 7px 14px; border-radius: 999px;
  box-shadow: 2px 2px 0 var(--ink); transition: transform .15s ease;
}
.gh-feature-shots:hover .gh-play { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.gh-feature-text h2 { font-size: clamp(30px, 3.6vw, 46px); line-height: 1; letter-spacing: -.01em; font-weight: 600; margin: 0 0 14px; }
.gh-points { margin: 0 0 22px; padding: 0; list-style: none; display: grid; gap: 9px; }
.gh-points li { position: relative; padding-left: 22px; font-size: 15px; line-height: 1.45; color: var(--ink-dim); }
.gh-points li::before {
  content: ""; position: absolute; left: 2px; top: .45em; width: 9px; height: 9px; border-radius: 50%;
  background: var(--riso-green); box-shadow: 1.5px 1.5px 0 var(--riso-pink);
}
.gh-rail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.gh-rail-head h2 { font-size: clamp(22px, 2.4vw, 28px); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.gh-arrows { display: flex; gap: 8px; }
.gh-arrow {
  width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--paper-white);
  color: var(--ink); font-size: 18px; cursor: pointer; box-shadow: 2px 2px 0 var(--riso-green);
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.gh-arrow:hover { background: var(--riso-pink); color: #fff; transform: translate(-1px, -1px); }
.gh-rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 300px); gap: 18px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 6px 18px 2px; margin-bottom: 30px;
  scrollbar-width: thin; scrollbar-color: var(--riso-green) transparent;
}
.gh-rail:focus-visible { outline: 2px solid var(--riso-pink); outline-offset: 4px; border-radius: 12px; }
.gh-card {
  scroll-snap-align: start; display: flex; flex-direction: column; background: var(--paper-white);
  border: 1.5px solid var(--ink); border-radius: 16px; overflow: hidden; box-shadow: 3px 3px 0 var(--riso-green);
  transition: transform .15s ease, box-shadow .15s ease;
}
.gh-card:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--riso-green); }
.gh-shot { display: block; aspect-ratio: 16 / 10; border-bottom: 1.5px solid var(--ink); overflow: hidden; background: var(--paper); }
.gh-shot img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; transition: transform .3s ease; }
.gh-card:hover .gh-shot img { transform: scale(1.04); }
.gh-body { display: flex; flex-direction: column; flex: 1; padding: 16px 18px 18px; }
.gh-body .lessons-hub-tile-label { align-self: flex-start; margin-bottom: 10px; }
.gh-body h3 { font-size: 21px; line-height: 1.1; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 8px; }
.gh-body h3 a { color: inherit; text-decoration: none; }
.gh-body h3 a:hover { color: var(--riso-pink); }
.gh-desc { font-size: 14px; line-height: 1.45; color: var(--ink-dim); margin: 0 0 10px; }
.gh-body .lessons-hub-tile-objective { margin-bottom: 14px; }
.gh-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.gh-actions .lessons-hub-link { font-size: 12px; padding: 8px 14px; }
@media (max-width: 820px) {
  .gh-feature { grid-template-columns: 1fr; padding: 14px; }
  .gh-arrows { display: none; }
  .gh-rail { grid-auto-columns: 78%; }
}

/* ── Labs: a preview scene across the top of each card ─────────── */
.lesson-card-preview {
  position: relative;
  margin: -22px -24px 16px;
  aspect-ratio: 16 / 9;
  border-bottom: 1.5px solid var(--ink);
  background: var(--paper);
  overflow: hidden;
  z-index: 1;
}
.lesson-card-preview img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
.lesson-card:hover .lesson-card-preview img { transform: scale(1.04); }
.lesson-card.has-preview { display: flex; }
.lesson-card.has-preview .lesson-card-header,
.lesson-card.is-sim.has-preview .lesson-card-header,
.lesson-card.has-preview:has(.lesson-card-pdfs .lesson-card-teacher) .lesson-card-header { margin-bottom: 12px; }
.lesson-card.has-preview .lesson-card-sub { padding-right: 0; }
.lesson-card.has-preview .lesson-card-pdfs,
.lesson-card.is-sim.has-preview .lesson-card-pdfs {
  position: static;
  order: 4;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-top: 14px;
}
.lesson-card.has-preview .lesson-card-footer { order: 5; }
.lesson-card.is-sim.has-preview { box-shadow: 4px 4px 0 var(--riso-pink); }
.lesson-card.is-sim.has-preview .lesson-card-badge { background: var(--riso-pink); color: var(--ink); }

/* /css/search.css */
/* ── Search overlay (Cmd/Ctrl+K) ───────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 5vw 5vh;
}
.search-overlay.is-open { display: flex; }
body.search-open { overflow: hidden; }

.search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 58, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.search-modal {
  position: relative;
  width: 100%;
  max-width: 640px;
  background: var(--paper-white);
  border: 1.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--riso-pink), 0 24px 56px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: search-in 0.18s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes search-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .search-modal { animation: none; }
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.search-glyph {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--ink-faint);
  width: 22px;
  text-align: center;
}
.search-input {
  flex: 1;
  font-family: var(--font-display);
  font-size: 19px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  padding: 4px 0;
}
.search-input::placeholder { color: var(--ink-faint); }
.search-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}
kbd {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 6px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--ink-dim);
  margin: 0 2px;
}

.search-results {
  max-height: 56vh;
  overflow-y: auto;
  padding: 8px 8px 10px;
}
.search-result {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 4px 14px;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.12s;
  cursor: pointer;
}
.search-result.is-selected {
  background: rgba(255, 126, 182, 0.14);
  outline: 1.5px solid var(--riso-pink-deep);
}
.search-kind {
  grid-row: 1 / span 2;
  align-self: center;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--riso-pink-deep);
  text-align: left;
}
.search-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
.search-desc {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.4;
}
.search-empty {
  padding: 30px 14px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.search-foot {
  display: flex;
  justify-content: center;
  gap: 22px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  background: var(--paper);
}

/* Tiny "/" hint in the topbar -- subtle visible cue that search exists */
.search-hint-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  margin-left: auto;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.search-hint-pill:hover {
  color: var(--ink);
  border-color: var(--ink);
}
@media (max-width: 760px) {
  .search-hint-pill { display: none; }
}

@media (max-width: 540px) {
  .search-overlay { padding: 6vh 4vw; }
  .search-result { grid-template-columns: 56px 1fr; }
  .search-foot { gap: 14px; font-size: 12px; }
}

/* /css/theme.css */
/* ============================================================
   theme.css: four independent display axes, all opt-in.
   Loaded site-wide via each page's head + js/theme.js.

   Axis 1  data-theme="dark"        light  <->  dark
   Axis 2  data-palette="accessible" riso  <->  high-contrast, colourblind-safe
   Axis 3  data-textsize="lg|xl"     everything a size up, or two
   Axis 4  data-font="reading"       a face built to be unambiguous, with air

   Everything is driven by redefining the ~12 core tokens from
   base.css. Because the site's chrome and components read those tokens
   (var(--ink), var(--paper), var(--riso-pink)…), overriding them here
   restyles the whole page with no per-component work.

   The default (no attributes) stays the riso brand exactly as it was.
   ============================================================ */

/* ── DARK · riso identity, dark ground ─────────────────────── */
:root[data-theme="dark"] {
  --paper:            #14201b;
  --on-brand:         #14201b;   /* brand fills are light here, so dark text */
  --paper-white:      #1b2a24;
  --ink:              #e9f1ea;
  --ink-dim:          #b1c3b8;
  --ink-faint:        #7d8f85;

  --riso-pink:        #ff9ec4;
  --riso-pink-deep:   #ffb3d1;   /* emphasis reads *lighter* on dark */
  --riso-green:       #46d99f;
  --riso-green-deep:  #6fe6b8;
  --riso-coral:       #ff9e80;
  --riso-yellow:      #f2cf5c;

  --line:             rgba(233, 241, 234, 0.18);
  --line-strong:      rgba(233, 241, 234, 0.34);
}

/* ── ACCESSIBLE · light ────────────────────────────────────
   High contrast (near-black ink on white, AA+), and the pink/green
   pairing, the red-green colourblind trap, is replaced by
   blue/orange, which stays distinguishable in every common colour-
   vision deficiency. Hue never carries meaning alone on this site
   (labels, borders and shape do too), which is what makes the swap
   safe rather than merely different. */
:root[data-palette="accessible"] {
  --paper:            #ffffff;
  --on-brand:         #ffffff;   /* accessible fills are deep, so light text */
  --paper-white:      #ffffff;
  --ink:              #111418;
  --ink-dim:          #3d444d;   /* AA on white */
  --ink-faint:        #5a626c;   /* lifted from the faint riso tone */

  --riso-pink:        #c2410c;   /* orange, was pink */
  --riso-pink-deep:   #9a3412;
  --riso-green:       #1d63c9;   /* blue, was green */
  --riso-green-deep:  #174ea6;
  --riso-coral:       #b45309;   /* amber-brown, third distinct hue */
  --riso-yellow:      #a16207;   /* darkened so it holds on white */

  --line:             rgba(17, 20, 24, 0.30);
  --line-strong:      rgba(17, 20, 24, 0.52);
}

/* ── ACCESSIBLE · dark ─────────────────────────────────────
   Same blue/orange logic, brightened to hold contrast on a near-black
   neutral ground. */
:root[data-theme="dark"][data-palette="accessible"] {
  --paper:            #0c0e12;
  --on-brand:         #0c0e12;   /* fills lighten again on dark */
  --paper-white:      #15181e;
  --ink:              #f4f6f9;
  --ink-dim:          #c3ccd6;
  --ink-faint:        #98a2ae;

  --riso-pink:        #ff9e5c;   /* orange */
  --riso-pink-deep:   #ffb784;
  --riso-green:       #6ba6f5;   /* blue */
  --riso-green-deep:  #9cc4fb;
  --riso-coral:       #f0a35e;
  --riso-yellow:      #e2c14e;

  --line:             rgba(244, 246, 249, 0.22);
  --line-strong:      rgba(244, 246, 249, 0.40);
}

/* Smooth the switch, but never fight reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
  body { transition: background-color 0.18s ease, color 0.18s ease; }
}

/* ============================================================
   The control. A small fixed panel, bottom-right, legible in all four
   modes because it too is built from tokens.
   ============================================================ */
.a11y-controls {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--paper-white);
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--riso-green);
}
.a11y-tab { display: none; border: 0; background: none; color: var(--ink); cursor: pointer; padding: 2px; line-height: 0; }
.a11y-tab svg { width: 18px; height: 18px; }
/* The closed button says what it is: a bare half-moon was missed by readers who came looking for text size. */
.a11y-tab-lbl { display: none; font-family: var(--font-body, inherit); font-size: 14px; font-weight: 700; color: var(--ink); }
.a11y-controls.a11y-min .a11y-tab { display: inline-flex; align-items: center; gap: 7px; }
.a11y-controls.a11y-min .a11y-tab-lbl { display: inline; }
.a11y-controls.a11y-min { border-radius: 999px; padding: 9px 14px; }
.a11y-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.a11y-hide { border: 0; background: none; color: var(--ink-faint); cursor: pointer; padding: 0 2px 2px; line-height: 0; }
.a11y-hide:hover { color: var(--ink); }
@media (pointer: coarse) {
  .a11y-hide { min-width: 26px; min-height: 26px; padding: 6px; line-height: 0; }
}
.a11y-hide svg { width: 12px; height: 12px; }
.a11y-controls.a11y-min .a11y-head,
.a11y-controls.a11y-min .a11y-btn,
.a11y-controls.a11y-min .a11y-rule,
.a11y-controls.a11y-min .a11y-seg-lbl,
.a11y-controls.a11y-min .a11y-seg,
.a11y-controls.a11y-min .a11y-lang-sel { display: none; }

.a11y-controls-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0 2px 2px;
}
.a11y-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.a11y-btn:hover { border-color: var(--ink); }
.a11y-btn svg { width: 15px; height: 15px; flex: none; }
.a11y-btn .on-dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: transparent;
  margin-left: auto;
}
/* Pressed = this mode is active. */
.a11y-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper-white);
  border-color: var(--ink);
}
.a11y-btn[aria-pressed="true"] .on-dot { background: var(--riso-green); border-color: var(--paper-white); }
.a11y-btn:focus-visible { outline: 3px solid var(--riso-pink-deep); outline-offset: 2px; }

/* Text size: three stops, not a slider; a slider invites fiddling, three
   stops is a decision. The letters are drawn at the sizes they stand for. */
.a11y-rule { border: 0; border-top: 1px dashed var(--line-strong); margin: 8px 2px 7px; }
.a11y-seg-lbl {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-faint); padding: 0 2px 4px;
}
.a11y-seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.a11y-size {
  border: 0; border-right: 1.5px solid var(--line-strong);
  background: var(--paper); color: var(--ink);
  font-family: var(--font-display); font-weight: 700; line-height: 1;
  padding: 7px 0 8px; cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.a11y-size { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; }
.a11y-size-w { font-family: var(--font-body, inherit); font-size: 11px; font-weight: 600; letter-spacing: 0; }
.a11y-size:last-child { border-right: 0; }
.a11y-size:hover { background: var(--paper-white); }
.a11y-size[aria-checked="true"] { background: var(--ink); color: var(--paper-white); }
.a11y-size:focus-visible { outline: 3px solid var(--riso-pink-deep); outline-offset: -3px; }
/* Language is a dropdown: one row however many languages there are. */
.a11y-seg-lbl[for] { display: block; }
.a11y-lang-sel {
  display: block; width: 100%; box-sizing: border-box;
  border: 1.5px solid var(--line-strong); border-radius: 999px;
  background: var(--paper); color: var(--ink);
  font-family: var(--font-body, inherit); font-size: 14px;
  padding: 6px 12px; cursor: pointer;
}
.a11y-lang-sel:hover { background: var(--paper-white); }
.a11y-lang-sel:focus-visible { outline: 3px solid var(--riso-pink-deep); outline-offset: 2px; }

/* The moon shows in light, the sun in dark: mirrors the games' toggle. */
.a11y-btn .icon-sun { display: none; }
:root[data-theme="dark"] .a11y-btn .icon-sun { display: block; }
:root[data-theme="dark"] .a11y-btn .icon-moon { display: none; }

@media (max-width: 560px) {
  /* A phone gets the whole panel, as a sheet along the bottom: labels, text
     size and language included. A student who needs bigger text is the
     student on a phone, so none of it is left to a wider screen. The small
     round button (a11y-min) still keeps it out of the page until pressed. */
  .a11y-controls { right: 10px; bottom: 10px; padding: 8px; }
  .a11y-controls:not(.a11y-min) { left: 10px; max-height: 80vh; overflow-y: auto; padding: 14px; gap: 10px; }
  .a11y-controls:not(.a11y-min) .a11y-btn { padding: 12px 14px; font-size: 14px; }
  .a11y-controls:not(.a11y-min) .a11y-size { padding: 12px 0; }
  .a11y-controls:not(.a11y-min) .a11y-lang-sel { padding: 11px 12px; font-size: 16px; }
  .a11y-controls.a11y-min { min-height: 44px; display: inline-flex; align-items: center; }
  .a11y-controls.a11y-min .a11y-tab { min-height: 44px; }
}

/* Cosmetic leak handling: the lesson-card icons are external two-tone
   (green/pink) SVG images, so page tokens can't reach inside them. In
   the accessible palette that green/pink clashes with the blue/orange
   scheme, so neutralise them to a quiet monochrome - decorative only,
   no meaning is carried by their colour. */
:root[data-palette="accessible"] .lesson-card-icon { filter: grayscale(1) contrast(0.95); }

/* Flat type in the accessible palette. The riso "misregistration" offset
   (a coloured text-shadow ghost behind headings) is a brand flourish, but
   it doubles the letterforms and lowers legibility - the opposite of what
   a high-contrast mode is for. Strip it so accessible type is crisp. */
:root[data-palette="accessible"] * { text-shadow: none !important; }
:root[data-palette="accessible"] main::after { opacity: 0 !important; }


/* ── TEXT SIZE · scale the surface, don't stretch the type ──
   The exam maker is drawn in fixed pixels, so growing only the words would
   burst its buttons and squeeze its option letters. Zooming the whole body
   keeps every proportion the design already has: bigger words in bigger
   boxes, with the same air between them.

   Two things zoom does not do for us. Media queries still measure the real
   viewport, so a desktop layout does not fall back to its phone one just
   because it got 30% bigger; the steps are therefore gentler the narrower
   the screen. And viewport units are not scaled, so `100vw` inside a zoomed
   body paints wider than the window; --zoom is published here for the
   handful of rules that need to divide it back out. */
:root { --zoom: 1; }
/* Steps sized for a reader who needs them, eased on a narrower window: the top
   bar is about 900px wide before zoom, and media queries do not see the zoom, so
   a big step on a small window pushed the bar off the screen. */
:root { --zoom: 1; }
:root[data-textsize="lg"] { --zoom: 1.25; }
:root[data-textsize="xl"] { --zoom: 1.5; }
:root[data-textsize="lg"] body { zoom: 1.25; }
:root[data-textsize="xl"] body { zoom: 1.5; }
@media (max-width: 1450px) {
  :root[data-textsize="xl"] { --zoom: 1.3; }
  :root[data-textsize="xl"] body { zoom: 1.3; }
}
@media (max-width: 1200px) {
  :root[data-textsize="lg"] { --zoom: 1.12; }
  :root[data-textsize="lg"] body { zoom: 1.12; }
  :root[data-textsize="xl"] { --zoom: 1.2; }
  :root[data-textsize="xl"] body { zoom: 1.2; }
}
@media (max-width: 1000px) {
  :root[data-textsize="lg"] { --zoom: 1.05; }
  :root[data-textsize="lg"] body { zoom: 1.05; }
  :root[data-textsize="xl"] { --zoom: 1.1; }
  :root[data-textsize="xl"] body { zoom: 1.1; }
}
@media (max-width: 820px) {
  :root[data-textsize="lg"] { --zoom: 1.2; }
  :root[data-textsize="lg"] body { zoom: 1.2; }
  :root[data-textsize="xl"] { --zoom: 1.35; }
  :root[data-textsize="xl"] body { zoom: 1.35; }
}
/* Zoom can leave a few pixels of a wide child past the edge; a reader at this size should never have to scroll sideways for them. */
:root[data-textsize], :root[data-textsize] body { overflow-x: clip; }
/* Wider spacing: the British Dyslexia Association's guidance is wider letter,
   word and line spacing; this is the whole of it, left to the reader to turn on. */
:root[data-spacing="wide"] body { letter-spacing: 0.04em; word-spacing: 0.12em; }
:root[data-spacing="wide"] p, :root[data-spacing="wide"] li, :root[data-spacing="wide"] td { line-height: 1.8; }
/* A lesson's own switches (HL, theme) are a fixed corner toolbar that zoom pushes past the right edge: let it scroll with the page, inside it. */
:root[data-textsize] .toolbar { position: absolute; left: .5rem; right: .5rem; justify-content: flex-end; }
/* Paper is paper: the setting is about this screen, not the printout. */
@media print { :root[data-textsize] body { zoom: 1 !important; } }

/* ── READING FONT · unambiguous letterforms, and room to breathe ──
   Not a "dyslexia font": those do not survive testing. What does help is a
   face whose b/d/p/q and I/l/1 cannot be confused, more space between the
   letters and the lines, and a shorter line to return from. Atkinson
   Hyperlegible was drawn for low vision by the Braille Institute; the rest
   is spacing. The stylesheet is fetched by js/theme.js only when the switch
   is on, so nobody downloads a font they never asked for. */
:root[data-font="reading"] {
  --font-display: 'Atkinson Hyperlegible', 'Atkinson Hyperlegible', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --sans: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --serif: 'Atkinson Hyperlegible', system-ui, sans-serif;
}
:root[data-font="reading"] body {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  letter-spacing: 0.012em;
  word-spacing: 0.08em;
  line-height: 1.65;
}
/* The exam paper is set in a serif on purpose, it is a facsimile of a real
   paper, so it changes with everything else rather than staying the odd
   one out. */
:root[data-font="reading"] .sheet,
:root[data-font="reading"] .sheet .q,
:root[data-font="reading"] .qdemo,
:root[data-font="reading"] .lede,
:root[data-font="reading"] .sub,
:root[data-font="reading"] .figcap,
:root[data-font="reading"] .mis,
:root[data-font="reading"] h1, :root[data-font="reading"] h2, :root[data-font="reading"] h3 {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
}
:root[data-font="reading"] .sheet .q,
:root[data-font="reading"] .sheet .stem,
:root[data-font="reading"] .sheet .part,
:root[data-font="reading"] .sheet .opts li { line-height: 1.7; }
/* A long line is the other half of the problem: the eye has to find the
   start of the next one. */
:root[data-font="reading"] .sheet .stem-body,
:root[data-font="reading"] .sheet .ptext,
:root[data-font="reading"] .passage,
:root[data-font="reading"] .card p,
:root[data-font="reading"] .sub { max-width: 62ch; }
/* Mono stays mono: codes, units and the paper code are read character by
   character, and that is what a monospace is for. */
:root[data-font="reading"] .mono,
:root[data-font="reading"] code, :root[data-font="reading"] kbd,
:root[data-font="reading"] .sit-clock, :root[data-font="reading"] .code-chip { font-family: var(--font-mono); letter-spacing: 0; }


/* ── LANGUAGE · support around the question, never inside it ──
   The paper stays in the language of the exam. What arrives beside it is a
   translated rubric, a bilingual command term, and a glossary the reader can
   tap: in two modes, because the exam allows the word and not the
   definition. */
.i18n-rubric { display: block; font-family: var(--font-body, system-ui), system-ui, sans-serif; font-style: normal; color: var(--riso-green-deep); margin-top: 3px; }
.sheet .gl, .gl {
  font-weight: inherit; border-bottom: 1.8px dotted var(--riso-pink-deep);
  cursor: help; background: none;
}
.sheet .gl:hover, .gl:hover { background: color-mix(in srgb, var(--riso-pink) 22%, transparent); }
.gl-pop {
  position: absolute; z-index: 60; width: min(340px, calc(100vw / var(--zoom, 1) - 24px));
  background: var(--paper-white); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 11px; box-shadow: 4px 4px 0 var(--riso-pink);
  padding: 11px 13px; font-family: var(--font-body, system-ui), system-ui, sans-serif; font-size: 13.5px; line-height: 1.5;
}
.gl-w { font-weight: 700; font-size: 15px; }
.gl-w span { color: var(--riso-pink-deep); }
.gl-d { color: var(--ink-dim); font-size: 12.8px; margin-top: 5px; }
.gl-mode { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); margin-top: 6px; }
/* The paper prints as the exam prints: no dots, no glosses. */
@media print { .sheet .gl { border-bottom: 0; } .gl-pop, .i18n-offer { display: none !important; } }

/* Offered once, to a browser that is already set to the language. */
.i18n-offer {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 70;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: min(680px, calc(100vw / var(--zoom, 1) - 24px));
  background: var(--paper-white); border: 1.5px solid var(--ink); border-radius: 12px;
  box-shadow: 4px 4px 0 var(--riso-green); padding: 11px 14px; font-size: 13.5px; color: var(--ink);
}
.i18n-offer-en { color: var(--ink-dim); }
.i18n-offer button {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em;
  border: 1.5px solid var(--ink); border-radius: 999px; padding: 7px 12px; cursor: pointer;
  background: var(--paper); color: var(--ink);
}
.i18n-offer .i18n-yes { background: var(--riso-green); color: var(--on-brand); font-weight: 700; }
.i18n-offer button:hover { background: var(--riso-pink); color: var(--on-brand); }
@media (max-width: 560px) { .i18n-offer { left: 10px; right: 10px; transform: none; max-width: none; } }

/* ---------------------------------------------------------------- Chinese
   Two things the Latin-tuned chrome gets wrong for a language written in
   characters: a line can break between any two of them, so a nav tab or a
   button label splits down the middle; and the tracking that opens up small
   uppercase Latin labels only pushes hanzi apart. Both are fixed on the
   chrome, never on the paper; the questions stay English and keep their own
   typography.  */
:root[data-lang="zh"] .topbar,
:root[data-lang="zh"] .em-rail,
:root[data-lang="zh"] .em-start,
:root[data-lang="zh"] .dt-actions,
:root[data-lang="zh"] .a11y-controls,
:root[data-lang="zh"] .sit-top,
:root[data-lang="zh"] .sit-how { letter-spacing: normal; }

:root[data-lang="zh"] .topbar a,
:root[data-lang="zh"] .tab,
:root[data-lang="zh"] .em-btn,
:root[data-lang="zh"] .share-lbl,
:root[data-lang="zh"] .dice-lbl,
:root[data-lang="zh"] .take-btn,
:root[data-lang="zh"] .a11y-lang,
:root[data-lang="zh"] .sit-mini { white-space: nowrap; }

