/* Orca Systems training hub (/training/), its popup lessons and practice tests.
   Built on the tokens in /css/styles.css (navy ink, one orange accent, 8px/14px/20px radii).
   The last block (.practice-box, .th-crumbs) is also loaded by the six standalone lesson pages,
   which have their own small inline styles, so it falls back to their variable names. */

:root {
  --th-ok: #166534;
  --th-ok-bg: #E7F5EC;
  --th-ok-line: #86C79B;
  --th-bad: #B91C1C;
  --th-bad-bg: #FDEDED;
  --th-bad-line: #E8A0A0;
  --th-scrim: rgba(11, 19, 48, 0.68);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --th-ok: #86EFAC; --th-ok-bg: #12301F; --th-ok-line: #2F7A4A;
    --th-bad: #FCA5A5; --th-bad-bg: #3A1618; --th-bad-line: #8E3A3A;
  }
}
:root[data-theme="dark"] {
  --th-ok: #86EFAC; --th-ok-bg: #12301F; --th-ok-line: #2F7A4A;
  --th-bad: #FCA5A5; --th-bad-bg: #3A1618; --th-bad-line: #8E3A3A;
}

/* ---------- hub header ---------- */
.th-hero { padding: var(--space-7) 0 var(--space-4); }
.th-hero h1 { font-size: clamp(2rem, 4.6vw, 3.25rem); max-width: 18ch; margin-bottom: var(--space-3); }
.th-hero .th-lede { font-size: 1.125rem; max-width: 62ch; color: var(--color-foreground); }
.th-tag {
  display: inline-block; margin: 0 0 var(--space-3); padding: 4px 12px;
  border: 1px solid var(--color-border); border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm); background: var(--color-muted);
  color: var(--color-ink); font-size: 0.875rem; font-weight: 700; line-height: 1.4;
}
.th-preview {
  margin: var(--space-4) 0 0; padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--color-accent); border-radius: var(--radius-sm);
  background: var(--color-muted); color: var(--color-ink); font-weight: 600; max-width: 68ch;
}
.th-ref { margin: 0 0 var(--space-3); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.th-ref .btn { min-height: 44px; font-size: 1rem; }
.th-ref__d { color: var(--color-muted-foreground); font-size: 0.95rem; max-width: 52ch; }
.th-ref .btn:focus-visible, .th-startbtn:focus-visible, .th-all:focus-visible, .th-quiet:focus-visible, .th-group__sum:focus-visible, .th-card:focus-visible {
  outline: 3px solid var(--color-ring); outline-offset: 3px;
}
.th-card:focus:not(:focus-visible) { outline: none; }

/* ---------- Start here ---------- */
.th-start { margin-top: var(--space-4); }
.th-start h2 { font-size: 1.15rem; margin: 0 0 var(--space-2); }
.th-start[hidden] { display: none; }
.th-start__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); max-width: 900px; }
.th-startbtn {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; min-height: 72px;
  padding: 10px var(--space-4); border-radius: var(--radius-md); border: 2px solid var(--color-primary);
  background: var(--color-primary); color: var(--color-on-primary); font: inherit; text-align: left; cursor: pointer; touch-action: manipulation;
}
.th-startbtn[hidden] { display: none; }
.th-startbtn__t { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; line-height: 1.15; letter-spacing: -0.01em; }
.th-startbtn__s { font-size: 0.9rem; font-weight: 600; line-height: 1.3; }
.th-startbtn:hover { box-shadow: var(--shadow-lift); }
.th-startbtn[aria-pressed="true"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.th-all {
  margin-top: var(--space-2); min-height: 44px; padding: 0 var(--space-3); font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer; touch-action: manipulation;
  color: var(--color-ink); background: transparent; border: 1px solid var(--color-field-border, color-mix(in srgb, var(--color-ink) 35%, var(--color-border))); border-radius: var(--radius-sm);
}
.th-all:hover { background: var(--color-muted); border-color: var(--color-ink); }
@media (max-width: 720px) {
  .th-hero { padding-top: var(--space-4) !important; padding-bottom: var(--space-2); }
  .th-hero .th-lede { font-size: 1rem; }
  .th-tag { margin-bottom: var(--space-2); }
  .th-ref__d { display: none; }
  .th-start { margin-top: var(--space-3); }
  .th-start__row { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
  .th-startbtn { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0 var(--space-3); min-height: 52px; padding: 6px var(--space-3); }
  .th-startbtn__t { font-size: 1.2rem; }
}

/* ---------- the tools row (name, print, "stays on this device") now sits under the lessons ---------- */
.th-keep { padding: 0 0 var(--space-7); }
.th-keep__h { font-size: 1.15rem; margin: 0; }
.th-keep .th-tools { margin-top: var(--space-3); }
.th-tools {
  margin-top: var(--space-5); display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-5);
  align-items: flex-end; justify-content: space-between;
  padding-top: var(--space-4); border-top: 1px solid var(--color-border);
}
.th-note { margin: 0; max-width: 46ch; color: var(--color-muted-foreground); font-size: 0.95rem; }
.th-printbox { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; }
.th-field { display: flex; flex-direction: column; gap: 4px; }
.th-field label { font-weight: 700; font-size: 0.875rem; color: var(--color-ink); }
.th-input, .th-field input {
  min-height: 44px; padding: 0 var(--space-3); border: 1px solid var(--color-field-border, color-mix(in srgb, var(--color-ink) 35%, var(--color-border)));
  border-radius: var(--radius-sm); background: var(--color-card); color: var(--color-foreground);
  font: inherit; font-size: 1rem; width: 100%;
}
.th-field input { width: min(260px, 100%); }

/* ---------- lesson cards ---------- */
.th-lessons { padding: var(--space-5) 0 var(--section-m); }
.th-lessons h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin-bottom: var(--space-4); }
.th-grid[hidden], .th-results[hidden], .th-empty[hidden], .th-filters[hidden], .th-clear[hidden], .th-badge[hidden] { display: none; }
.th-results { scroll-margin-top: 88px; }

/* course headings: each a disclosure, open on desktop */
.th-group { margin: 0 0 var(--space-5); }
.th-group__sum {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 52px; padding: 8px var(--space-4);
  margin-bottom: var(--space-3); cursor: pointer; list-style: none; touch-action: manipulation;
  border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-card); color: var(--color-ink);
}
.th-group__sum::-webkit-details-marker { display: none; }
.th-group__sum:hover { border-color: var(--color-ink); background: var(--color-muted); }
.th-group:not([open]) > .th-group__sum { margin-bottom: 0; }
.th-group__h { margin: 0; font-size: clamp(1.15rem, 2.2vw, 1.4rem); }
.th-group__chev { flex: none; width: 20px; height: 20px; transition: transform var(--dur-2, 160ms) ease; }
.th-group[open] > .th-group__sum .th-group__chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .th-group__chev { transition: none; } }

/* ---------- search, filters and sort ---------- */
.th-filters {
  margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); display: grid; gap: var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-card);
}
.th-ftop { display: grid; gap: var(--space-2); }
.th-ctl { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.th-ctl label, .th-roles legend { font-weight: 700; font-size: 0.875rem; color: var(--color-ink); padding: 0; }
.th-ctl input, .th-ctl select {
  width: 100%; min-height: 44px; padding: 0 var(--space-3); font: inherit; font-size: 1rem;
  border: 1px solid var(--color-field-border, color-mix(in srgb, var(--color-ink) 35%, var(--color-border))); border-radius: var(--radius-sm);
  background: var(--color-card); color: var(--color-foreground);
}
.th-ctl select { padding-right: 8px; text-overflow: ellipsis; }
.th-search { max-width: 520px; }
.th-ftoggle { display: none; }
.th-fpanel { display: grid; gap: var(--space-3); }
.th-roles { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.th-roles legend { float: left; width: 100%; margin-bottom: 6px; }
.th-roles legend + * { clear: both; }
.th-rolechips { display: flex; flex-wrap: wrap; gap: 8px; }
.th-rolechip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--color-field-border, color-mix(in srgb, var(--color-ink) 35%, var(--color-border))); background: var(--color-card); color: var(--color-ink);
  font: inherit; font-size: 0.9375rem; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.th-rolechip:hover { border-color: var(--color-ink); background: var(--color-muted); }
.th-rolechip__tick { display: none; width: 16px; height: 16px; }
.th-rolechip[aria-pressed="true"] { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-card); }
.th-rolechip[aria-pressed="true"]:hover { background: var(--color-ink); }
.th-rolechip[aria-pressed="true"] .th-rolechip__tick { display: block; }
.th-selects { display: grid; gap: var(--space-3); grid-template-columns: repeat(5, minmax(0, 1fr)); }
.th-statusbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); min-height: 24px; }
.th-count { margin: 0; font-weight: 700; color: var(--color-ink); font-size: 0.95rem; }
.th-clear {
  min-height: 44px; padding: 0 var(--space-3); font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer; touch-action: manipulation;
  color: var(--color-ink); background: transparent; border: 1px solid var(--color-field-border, color-mix(in srgb, var(--color-ink) 35%, var(--color-border))); border-radius: var(--radius-sm);
}
.th-clear:hover { background: var(--color-muted); border-color: var(--color-ink); }
.th-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--color-accent); color: var(--color-on-accent); font-size: 0.8125rem; font-weight: 800; line-height: 1;
}
.th-filters :is(input, select, button):focus-visible { outline: 3px solid var(--color-ring); outline-offset: 2px; }
.th-empty { text-align: center; padding: var(--space-6) var(--space-4); border: 1px dashed color-mix(in srgb, var(--color-ink) 30%, var(--color-border)); border-radius: var(--radius-md); background: var(--color-muted); }
.th-empty p { margin-left: auto; margin-right: auto; }
.th-empty__t { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; color: var(--color-ink); margin-bottom: var(--space-1); }
.th-empty__s { margin-bottom: var(--space-3); }

/* wide screens: search and role chips share the first row, so the whole panel stays short */
@media (min-width: 761px) {
  .th-filters { grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); column-gap: var(--space-5); align-items: start; }
  .th-fpanel { display: contents; }
  .th-ftop { grid-column: 1; grid-row: 1; }
  .th-roles { grid-column: 2; grid-row: 1; }
  .th-selects { grid-column: 1 / -1; grid-row: 2; }
  .th-statusbar { grid-column: 1 / -1; grid-row: 3; }
}
@media (max-width: 1080px) {
  .th-selects { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* phones and narrow windows: search stays on view, the rest folds into "Filters and sort" */
@media (max-width: 760px) {
  .th-filters { padding: var(--space-3); gap: var(--space-2); }
  .th-search { max-width: none; }
  .th-ftoggle {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 var(--space-3);
    font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer; touch-action: manipulation;
    color: var(--color-ink); background: var(--color-card); border: 1px solid var(--color-field-border, color-mix(in srgb, var(--color-ink) 35%, var(--color-border))); border-radius: var(--radius-sm);
  }
  .th-ftoggle:hover { background: var(--color-muted); }
  .th-ftoggle[aria-expanded="true"] { background: var(--color-muted); border-color: var(--color-ink); }
  .th-ftoggle svg:first-child { flex: none; }
  .th-filters:not(.is-open) .th-fpanel { display: none; }
  .th-fpanel { gap: var(--space-2); }
  .th-selects { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); }
  .th-rolechip { min-height: 44px; }
  .th-statusbar { padding-top: var(--space-1); }
}
@media (max-width: 420px) {
  .th-selects { grid-template-columns: minmax(0, 1fr); }
  .th-ctl select { font-size: 1rem; }
}
.th-grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
}
.th-card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--color-card); color: var(--color-card-foreground);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .th-card { transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
  .th-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
}
/* media: one 16:9 frame for every card. Screen captures are cropped from the top left, where the page title is. */
.th-card__media {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
}
.th-card__media img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.th-card__media::after {      /* a very light shade at the foot, so the badge reads on any capture */
  content: ""; position: absolute; inset: auto 0 0 0; height: 38%; pointer-events: none;
  background: linear-gradient(to top, rgba(15, 30, 74, 0.16), rgba(15, 30, 74, 0));
}
.th-card__media--shot img { box-shadow: inset 0 0 0 1px rgba(15, 30, 74, 0.08); }
/* every lesson now uses the same designed thumbnail (a big title and a zoomed crop, no small print), so no badge or shade goes over it;
   the chips under the image already give the kind (Video or Hands-on), the topic and the time */
.th-card__media--shot .th-kind, .th-card__media:has(img[src$="-thumb.webp"]) .th-kind { display: none; }
.th-card__media--shot::after, .th-card__media:has(img[src$="-thumb.webp"])::after { display: none; }
.th-card__noimg {
  display: flex; align-items: center; justify-content: center; padding: var(--space-4); text-align: center;
  background:
    radial-gradient(120% 90% at 15% 0%, color-mix(in srgb, var(--color-accent) 14%, transparent), transparent 60%),
    linear-gradient(160deg, var(--color-muted), color-mix(in srgb, var(--color-muted) 70%, var(--color-card)));
}
.th-card__noimg::after { display: none; }
.th-card__noimg-t {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.25rem, 2.2vw, 1.6rem); line-height: 1.15;
  letter-spacing: -0.01em; color: var(--color-ink); text-wrap: balance;
}
.th-kind {
  position: absolute; right: 10px; top: 10px; z-index: 1; display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px 3px 7px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; line-height: 1.3;
  background: var(--color-card); color: var(--color-ink); border: 1px solid color-mix(in srgb, var(--color-ink) 24%, var(--color-border));
}
.th-kind svg { width: 13px; height: 13px; flex: none; }
.th-kind--video { background: var(--color-ink); color: var(--color-card); border-color: var(--color-ink); }
.th-kind--video path { fill: currentColor; }
.th-card__body { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); flex: 1; }
.th-card__kicker { margin: 0; font-size: 0.8125rem; font-weight: 700; color: var(--color-accent-text); line-height: 1.3; }
.th-card__title { font-size: 1.2rem; margin: 0; }
.th-card__meta { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: 0.925rem; color: var(--color-muted-foreground); }
.th-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.th-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--color-border); background: var(--color-muted); color: var(--color-ink);
  font-size: 0.8125rem; font-weight: 600; line-height: 1.25;
}
.th-chip svg { width: 13px; height: 13px; flex: none; }
.th-chip--topic { background: transparent; border-color: color-mix(in srgb, var(--color-ink) 30%, var(--color-border)); }
.th-chip--time { background: transparent; border-color: transparent; padding-left: 2px; color: var(--color-muted-foreground); font-weight: 600; }
.th-card__state { margin: var(--space-1) 0 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; }
.th-card__best { font-size: 0.875rem; color: var(--color-muted-foreground); }
.th-state {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 8px; min-height: 28px;
  border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-muted);
  color: var(--color-ink); font-weight: 700; font-size: 0.875rem; line-height: 1.2;
}
.th-state svg { flex: none; }
.th-state--passed { background: var(--th-ok-bg); border-color: var(--th-ok-line); color: var(--th-ok); }
.th-state--practised, .th-state--tried { border-color: color-mix(in srgb, var(--color-accent) 55%, var(--color-border)); }
.th-card__actions { margin-top: auto; padding-top: var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-2); }
.th-card__actions .btn, .th-quiet { flex: 1 1 calc(50% - 4px); min-width: 0; white-space: nowrap; }
.th-card__actions a.btn { flex-basis: 100%; }     /* Hands-on practice: the main button, a full row */
.th-quiet {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--color-ink); font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer; touch-action: manipulation;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px;
}
.th-quiet:hover { background: var(--color-muted); }

/* phones: a compact card. The thumbnail sits at the left (38% wide), the title, chips and state at its right, and the buttons run
   under both: "Hands-on practice" on its own row, then Quiz, Learn it and Watch video on one row (about 290 px a card instead of 516).
   The card body is flattened (display: contents) so its parts can be placed on the card's grid; the course name is already the group heading. */
@media (max-width: 720px) {
  .th-grid { gap: var(--space-3); }
  .th-card { display: grid; grid-template-columns: 38% minmax(0, 1fr); column-gap: var(--space-3); row-gap: var(--space-2); align-items: start; padding: var(--space-3); }
  .th-card__media { grid-column: 1; grid-row: 1 / span 4; align-self: start; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
  .th-card__body { display: contents; }
  .th-card__kicker { display: none; }
  .th-card__title { grid-column: 2; font-size: 1.0625rem; line-height: 1.2; }
  .th-chips, .th-card__meta, .th-card__state { grid-column: 2; }
  .th-chips { gap: 4px; }
  .th-chip { font-size: 0.875rem; min-height: 24px; padding: 1px 8px; }
  .th-card__meta { font-size: 0.875rem; }
  .th-card__state { margin: 0; }
  .th-card__actions { grid-column: 1 / -1; margin-top: 0; padding-top: var(--space-1); gap: 6px; flex-wrap: wrap; }
  .th-card__actions a.btn { flex-basis: 100%; }
  .th-card__actions .btn, .th-quiet { flex: 1 1 0; padding-left: 6px; padding-right: 6px; font-size: 0.9375rem; text-align: center; }
  .th-card__actions a.btn { flex: 1 1 100%; }
}

/* ---------- the popup ---------- */
html.th-lock { overflow: hidden; }
.th-dlg {
  padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  background: var(--color-card); color: var(--color-card-foreground);
  width: min(800px, calc(100% - 32px)); max-width: none; max-height: min(88dvh, 920px);
  box-shadow: var(--shadow-frame); overflow: hidden;
}
.th-dlg[open] { display: flex; flex-direction: column; }
.th-dlg::backdrop { background: var(--th-scrim); }
.th-dlg__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border); background: var(--color-card);
}
.th-dlg__kind { margin: 0 0 2px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-accent-text); }
.th-dlg__head h2 { margin: 0; font-size: clamp(1.2rem, 3.2vw, 1.55rem); line-height: 1.2; letter-spacing: -0.01em; }
.th-dlg__close {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 var(--space-3);
  border: 1px solid color-mix(in srgb, var(--color-ink) 30%, var(--color-border)); border-radius: var(--radius-sm);
  background: var(--color-card); color: var(--color-ink); font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.th-dlg__close:hover { background: var(--color-muted); border-color: var(--color-ink); }
.th-dlg__body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--space-4) var(--space-4) var(--space-5); color: var(--color-foreground);
}
.th-dlg__body:focus { outline: none; }
.th-dlg__body :is(button, a, input, [tabindex]):focus-visible { outline: 3px solid var(--color-ring); outline-offset: 2px; }
.th-dlg__body p { color: var(--color-foreground); }
.th-dlg__body h3 { font-size: 1.15rem; margin: var(--space-5) 0 var(--space-2); }
.th-dlg__body h3:first-of-type { margin-top: var(--space-3); }
.th-who { color: var(--color-muted-foreground) !important; font-size: 0.925rem; }
.th-steps { margin: 0; padding-left: 1.5em; }
.th-steps li { margin: 0 0 var(--space-3); padding-left: 4px; }
.th-steps li::marker { color: var(--color-accent-text); font-weight: 800; }
.th-list { margin: 0; padding-left: 1.3em; }
.th-list li { margin: 0 0 var(--space-2); }
.th-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); }
.th-actions .btn { min-width: 44px; }

/* practice test */
.th-qmeta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); margin: 0 0 var(--space-2); font-weight: 700; }
.th-qcount { color: var(--color-ink); }
.th-qkind { color: var(--color-accent-text); }
.th-bar { height: 6px; border-radius: 3px; background: var(--color-muted); margin-bottom: var(--space-4); overflow: hidden; }
.th-bar span { display: block; height: 100%; background: var(--color-ink); border-radius: 3px; }
.th-fs { border: 0; margin: 0; padding: 0; min-width: 0; }
.th-q { padding: 0; margin: 0 0 var(--space-3); font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; line-height: 1.35; color: var(--color-ink); }
.th-q:focus { outline: none; }
.th-opts { display: grid; gap: var(--space-2); }
.th-opt {
  display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-card); cursor: pointer;
  touch-action: manipulation;
}
.th-opt:hover { border-color: var(--color-ink); }
.th-opt input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--color-accent); }
.th-opt__text { flex: 1; min-width: 0; line-height: 1.4; }
.th-opt__tag { flex: none; font-size: 0.8rem; font-weight: 800; }
.th-opt:has(input:checked) { border-color: var(--color-ink); background: var(--color-muted); box-shadow: inset 3px 0 0 var(--color-ink); }
.th-opt:has(input:focus-visible) { outline: 3px solid var(--color-ring); outline-offset: 2px; }
.th-opt.is-right { border-color: var(--th-ok-line); background: var(--th-ok-bg); box-shadow: inset 3px 0 0 var(--th-ok); cursor: default; }
.th-opt.is-right .th-opt__tag { color: var(--th-ok); }
.th-opt.is-wrong { border-color: var(--th-bad-line); background: var(--th-bad-bg); box-shadow: inset 3px 0 0 var(--th-bad); cursor: default; }
.th-opt.is-wrong .th-opt__tag { color: var(--th-bad); }
.th-numwrap { max-width: 420px; }
.th-label { display: block; font-weight: 700; margin-bottom: 6px; color: var(--color-ink); }
.th-numrow { display: flex; align-items: center; gap: var(--space-2); }
.th-numrow .th-input { max-width: 220px; font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.th-numrow .th-input[readonly] { background: var(--color-muted); }
.th-unit { color: var(--color-muted-foreground); font-weight: 600; }
.th-hint { margin: 6px 0 0; font-size: 0.9rem; color: var(--color-muted-foreground) !important; }
.th-err { margin: 6px 0 0; min-height: 0; color: var(--th-bad) !important; font-weight: 600; font-size: 0.95rem; }
.th-err:empty { display: none; }
.th-fb { margin-top: var(--space-4); }
.th-fb:empty { display: none; }
.th-fb:focus { outline: none; }
.th-fb.is-right, .th-fb.is-wrong { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); border: 1px solid; border-left-width: 4px; }
.th-fb.is-right { background: var(--th-ok-bg); border-color: var(--th-ok-line); border-left-color: var(--th-ok); }
.th-fb.is-wrong { background: var(--th-bad-bg); border-color: var(--th-bad-line); border-left-color: var(--th-bad); }
.th-fb p { margin: 0 0 var(--space-2); }
.th-fb p:last-child { margin-bottom: 0; }
.th-fb__head { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.th-fb.is-right .th-fb__head { color: var(--th-ok); }
.th-fb.is-wrong .th-fb__head { color: var(--th-bad); }
.th-fb__right { font-weight: 700; }

/* score */
.th-score { padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-muted); }
.th-score h3 { margin: 0 0 var(--space-2) !important; font-size: 1.6rem; }
.th-score h3:focus { outline: none; }
.th-score__line { display: flex; align-items: center; gap: 8px; margin: 0; }
.th-score.is-pass { background: var(--th-ok-bg); border-color: var(--th-ok-line); }
.th-score.is-pass .th-score__line { color: var(--th-ok); }
.th-missed { margin: 0; padding-left: 1.4em; }
.th-missed li { margin: 0 0 var(--space-4); padding-left: 4px; }
.th-missed p { margin: 0 0 4px; }
.th-missed__q { font-weight: 700; color: var(--color-ink) !important; }
.th-missed__k { font-weight: 700; }
.th-missed__ok { color: var(--th-ok) !important; font-weight: 600; }
.th-missed__why { color: var(--color-muted-foreground) !important; font-size: 0.95rem; }

/* phones: the popup fills the screen */
@media (max-width: 640px) {
  .th-dlg { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; inset: 0; border: 0; border-radius: 0; }
  .th-dlg__body { padding: var(--space-3) var(--space-3) var(--space-5); }
  .th-dlg__head { padding-left: var(--space-3); }
  .th-hero { padding-top: var(--space-6); }
  .th-actions .btn { flex: 1 1 100%; }
}

/* ---------- print: only the results sheet ---------- */
.th-print { display: none; }
.th-print__h { font-size: 1.6rem; margin: 0 0 var(--space-3); }
.th-print__line { margin: 0 0 var(--space-2); color: inherit; max-width: none; }
.th-print__table { width: 100%; border-collapse: collapse; margin: var(--space-4) 0; }
.th-print__table th, .th-print__table td { text-align: left; padding: 8px 10px; border: 1px solid #999; font-size: 1rem; }
.th-print__fine { font-size: 0.9rem; color: inherit; max-width: none; }
@media print {
  .skip-link, .site-header, .site-footer, .th-hero, .th-lessons, .th-keep, .th-start, .th-preview, dialog, noscript { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .th-print { display: block !important; color: #000; padding: 0; }
  .th-print h2, .th-print p, .th-print th, .th-print td { color: #000 !important; }
}

/* ---------- on each lesson page: the "Practice this lesson" button and the link back ---------- */
.practice-box {
  margin-top: 22px; padding: 16px 20px; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between;
  background: var(--card, var(--color-card)); border: 1px solid var(--line, var(--color-border)); border-radius: 12px;
}
.practice-box p { margin: 0; color: var(--muted, var(--color-muted-foreground)); font-size: 15px; max-width: 52ch; }
.practice-box p b { color: var(--ink, var(--color-ink)); }
/* The text link next to the button ("Hands-on practice") had no colour and showed the browser default blue (1.83:1 on the dark page). Same ink as the headings: 15:1 light, 13:1 dark. */
.practice-box a:not(.practice-btn) { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink, var(--color-ink)); font-weight: 700; text-decoration: underline; text-decoration-color: var(--accent, var(--color-accent)); text-underline-offset: 4px; text-decoration-thickness: 2px; }
.practice-box a:not(.practice-btn):focus-visible { outline: 3px solid var(--accent, var(--color-accent)); outline-offset: 2px; }
.practice-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 22px;
  background: var(--accent, #C2410C); color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; border-radius: 8px;
}
.practice-btn:hover { filter: brightness(0.92); }
.practice-btn:focus-visible, .th-crumbs a:focus-visible { outline: 3px solid var(--accent, #C2410C); outline-offset: 2px; }
/* Dark: dark text needs the light orange. The fallback used to be #C2410C (3.63:1 with this text) on any page that does not set --accent. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .practice-btn { background: var(--accent, #FB923C); color: #1a0f08; } }
.th-crumbs { display: flex; flex-wrap: wrap; gap: 0 20px; margin: 0 0 8px; }
.th-crumbs a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted, #5b6785); font-size: 15px; }
