/* Course player, "Margin" design.
   The interface is greys only. Colour appears only where it carries meaning:
   right and wrong answers (always with an icon and words), and premium colours in content.
   Fonts: Source Serif and Source Sans, SIL Open Font License 1.1, self-hosted in fonts/. */

@font-face { font-family: "Source Serif"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/SourceSerifPro-Regular.woff2) format("woff2"); }
@font-face { font-family: "Source Serif"; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/SourceSerifPro-Semibold.woff2) format("woff2"); }
@font-face { font-family: "Source Serif"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/SourceSerifPro-RegularIt.woff2) format("woff2"); }
@font-face { font-family: "Source Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/SourceSansPro-Regular.woff2) format("woff2"); }
@font-face { font-family: "Source Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/SourceSansPro-Semibold.woff2) format("woff2"); }

:root {
  /* greys */
  --ground: #ECEDEE;    /* page and sidebar */
  --sheet: #FFFFFF;     /* lesson sheet, password card, dialog */
  --quiet: #F1F2F3;     /* tiles: options, zones, key idea, secondary pill */
  --quiet-2: #E4E5E7;   /* hover, selected fill, progress track */
  --line: #DFE0E2;
  --outline: #7C7E83;   /* control outlines that must be seen (3:1) */
  --text: #303236;
  --text-2: #5F6166;
  --action: #4A4D52;    /* primary pill, selection, progress, switch thumb */
  --action-2: #35373B;
  --video: #222326;
  /* meaning */
  --ok: #006F5F; --ok-bg: #E0F1EC;
  --bad: #B01E68; --bad-bg: #F8E4EE;
  /* type */
  --serif: "Source Serif", Georgia, "Times New Roman", serif;
  --ui: "Source Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* grid and shape */
  --gutter: 152px; --measure: 640px;
  --r-s: 14px; --r: 22px; --r-l: 32px; --btn-h: 50px;
  --shadow: 0 1px 2px rgba(34,36,40,.04), 0 12px 32px rgba(34,36,40,.06);
  --shadow-2: 0 2px 4px rgba(34,36,40,.05), 0 24px 56px rgba(34,36,40,.12);
  --t: 240ms; --ease: cubic-bezier(.25,.1,.25,1);
  --ease-out: cubic-bezier(.22,.61,.36,1); /* things that appear: quick start, soft landing */
  --ico-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%235F6166' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2.5 4.5 3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
  --ico-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.3 5 8.8 9.6 3.6'/%3E%3C/svg%3E");
  --ico-bad: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='m3.2 3.2 5.6 5.6m0-5.6-5.6 5.6'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 96px; } /* keep focused controls clear of the comment button */
a { color: var(--text); }
::selection { background: #C9CBCF; color: var(--text); }
body { margin: 0; background: var(--ground); color: var(--text); font: 400 16px/1.5 var(--ui); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: rgba(48,50,54,.12); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
/* no double-tap zoom or tap delay on controls (iOS Safari); text fields stay at 16 px or more so Safari never zooms in on focus */
button, label.option, summary, .zone { touch-action: manipulation; }
.lock-card input, .textin, .comment-dialog input, .comment-dialog textarea { -webkit-appearance: none; appearance: none; }
button:disabled { cursor: default; opacity: .45; }
b, strong { font-weight: 600; }
/* a very long word (or title) breaks instead of pushing the page wider */
.lesson, .nav, .comment-dialog { overflow-wrap: break-word; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

/* == pills == */
.btn, .lock-card button[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--btn-h); padding: 0 28px;
  border: 0; border-radius: 999px; background: var(--action); color: #fff; font: 600 16.5px/1.15 var(--ui); text-align: center;
  transition: background var(--t) var(--ease), transform var(--t) var(--ease);
}
.btn:hover, .lock-card button[type="submit"]:hover { background: var(--action-2); }
.btn:active:not(:disabled) { transform: scale(.985); }
.btn:disabled:hover { background: var(--action); }
/* secondary pill: Cancel, Previous, Start over, Retry, Place here */
.btn.ghost, button.option { background: var(--quiet); color: var(--text); }
.btn.ghost:hover, button.option:hover { background: var(--quiet-2); }
button.option {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 22px;
  border: 0; border-radius: 999px; font: 600 15.5px/1.2 var(--ui); transition: background var(--t) var(--ease);
}
button.option:disabled:hover { background: var(--quiet); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* == FR | EN switch == */
.lang-switch {
  position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 999px;
  background: var(--sheet); box-shadow: inset 0 0 0 1px var(--line); font: 600 13.5px/1 var(--ui); letter-spacing: .05em;
}
.lang-switch button {
  position: relative; z-index: 1; min-width: 42px; min-height: 30px; padding: 0 12px; border: 0; border-radius: 999px;
  background: none; color: var(--text-2); transition: color var(--t) var(--ease);
}
.lang-switch button[aria-pressed="true"] { color: #fff; }
.lang-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px;
  background: var(--action); transition: transform var(--t) var(--ease);
}
.lang-switch[data-lang="en"] .lang-thumb { transform: translateX(100%); }

/* == password screen == */
.lock { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 72px 16px; }
.lock-card { width: min(420px, 100%); background: var(--sheet); border-radius: var(--r-l); box-shadow: var(--shadow); padding: 24px 36px 30px; }
.lock-top { display: flex; justify-content: flex-end; margin: 0 -14px 14px 0; }
.lock-card .lang-switch { background: var(--quiet); box-shadow: none; }
.lock-card h1 { margin: 0 0 28px; font: 600 30px/1.2 var(--serif); letter-spacing: -.01em; }
.lock-card label { display: block; font: 600 14.5px/1.3 var(--ui); margin: 0 0 8px 2px; }
.lock-card input {
  display: block; width: 100%; min-height: 52px; background: var(--quiet); border: 1.5px solid var(--outline); border-radius: 999px;
  padding: 0 22px; font: 400 18px/1 var(--ui); letter-spacing: .14em; transition: background var(--t) var(--ease), border-color var(--t) var(--ease);
}
.lock-card input:focus-visible { outline: 0; background: var(--sheet); border-color: var(--action); box-shadow: 0 0 0 4px var(--quiet-2); }
.lock-card button[type="submit"] { width: 100%; margin-top: 12px; }
/* while opening, the button stays readable (the generic disabled fade would drop white-on-grey below 4.5:1) */
.lock-card button[type="submit"]:disabled, .lock-card button[type="submit"]:disabled:hover { cursor: wait; opacity: 1; background: var(--text-2); }
#lock-msg { margin: 16px 0 0; min-height: 1.4em; font: 400 14.5px/1.4 var(--ui); color: var(--text-2); }
/* problems (wrong password, offline, file://) read as a soft tile with an icon, not as plain grey text */
#lock-msg:is([data-kind="wrong"], [data-kind="offline"], [data-kind="fileUrl"]) {
  display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; padding: 14px 18px; border-radius: var(--r-s);
  background: var(--quiet); color: var(--text); font-size: 15px;
}
#lock-msg:is([data-kind="wrong"], [data-kind="offline"], [data-kind="fileUrl"])::before {
  content: ""; width: 22px; height: 22px; border-radius: 50%; margin-top: 0; background: var(--action) var(--ico-bad) center / 12px no-repeat;
}
#lock-msg[data-kind="fileUrl"]::before, #lock-msg[data-kind="offline"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M6 2.5v4M6 9.4v.1'/%3E%3C/svg%3E");
}

/* == shell: the sidebar lies flat on the ground, the lesson is one sheet == */
.app { display: grid; grid-template-columns: 296px minmax(0, 1fr); gap: 8px; min-height: 100vh; min-height: 100dvh; padding: 24px 24px 24px 12px; align-items: start; }
.nav { position: sticky; top: 24px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow-y: auto; padding: 16px 0 24px; }
.nav-head { padding: 0 20px 22px; }
.nav-top { margin: 0 0 22px -4px; }
.nav .nav-title { margin: 0; font: 600 21px/1.25 var(--serif); letter-spacing: -.005em; }
.nav-sub, .nav-count { margin: 6px 0 0; font: 400 14.5px/1.45 var(--ui); color: var(--text-2); }
.nav-count { margin-top: 8px; }
.nav-progress { display: flex; gap: 2px; height: 4px; margin: 20px 0 0; border-radius: 2px; overflow: hidden; background: #D9DADC; }
.nav-progress span { flex: 1; transition: background var(--t) var(--ease); }
.nav-progress span.done { background: var(--action); }
.nav-progress span.now { background: linear-gradient(to right, var(--action) 40%, transparent 40%); }
.nav button[data-id] {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) 18px; gap: 6px; align-items: baseline; width: 100%; margin: 0;
  text-align: left; background: none; border: 0; border-radius: 999px; padding: 10px 16px 10px 20px;
  font: 400 16px/1.3 var(--ui); color: var(--text-2); transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.nav button[data-id]:hover { background: #E2E3E5; color: var(--text); }
.nav button[data-id] .num { font: 400 15px/1.3 var(--serif); }
/* The tick is drawn, not typed: the fonts have no check-mark glyph. The text stays for assistive technology and tests. */
.nav button[data-id] .tick { align-self: center; font-size: 0; color: var(--text-2); }
.nav button[data-id] .tick:not(:empty)::before { content: ""; display: inline-block; width: 14px; height: 14px; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.nav button[data-id][aria-current="page"] { background: var(--sheet); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(34,36,40,.06); border-radius: 22px; }
.nav button[data-id][aria-current="page"] .num { font-weight: 600; }

.lesson { background: var(--sheet); border-radius: var(--r-l); padding: 64px 72px 80px; max-width: calc(var(--gutter) + var(--measure) + 144px); width: 100%; outline: none; min-width: 0; }

/* == slide-like lesson header == */
.lesson-head { margin-bottom: 52px; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; }
.lesson h1 { flex: 1; min-width: 0; display: grid; grid-template-columns: var(--gutter) 1fr; align-items: baseline; margin: 0; font: 600 38px/1.14 var(--serif); letter-spacing: -.015em; text-wrap: balance; }
.lesson h1:focus { outline: none; }
.lesson h1 .num { font-size: .62em; font-weight: 400; color: var(--text-2); letter-spacing: 0; }
.count { flex: none; margin: 0; font: 600 30px/1 var(--serif); white-space: nowrap; }
.count span { font-size: .5em; font-weight: 400; color: var(--text-2); margin-left: 2px; }
.progress { height: 4px; border-radius: 2px; background: var(--quiet-2); margin-top: 18px; }
.progress span { display: block; height: 100%; border-radius: 2px; background: var(--action); transform-origin: left; animation: grow 480ms var(--ease-out) both; }
.meta { margin: 14px 0 0 var(--gutter); font: 400 14.5px/1.45 var(--ui); color: var(--text-2); }
.meta span:not(:last-child)::after { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--outline); margin: 0 10px; vertical-align: middle; }

/* == the grid: labels in the margin, content on the measure == */
.block { position: relative; margin: 0 0 52px var(--gutter); max-width: var(--measure); }
.block p { margin: 0; }
.label { font: 600 14px/1.3 var(--ui); color: var(--text-2); }
.block > .label, .question legend .label { position: absolute; left: calc(-1 * var(--gutter)); top: 4px; width: calc(var(--gutter) - 24px); }
.block-heading > .label { top: 19px; } /* level with the heading's own line */
.block-mcq > .label, .block-mrq > .label, .block-fillin > .label, .block-slider > .label, .question legend .label { top: 6px; }
.block-quiz .question { position: relative; }
.block-quiz .question + .question { margin-top: 44px; }
.block-text p { font: 400 19px/1.7 var(--ui); }
.block-heading { margin-bottom: 20px; }
.block-heading h2 { margin: 12px 0 0; font: 600 26px/1.25 var(--serif); letter-spacing: -.005em; }
.block-list ul { margin: 0; padding-left: 1.2em; font: 400 19px/1.7 var(--ui); }
.block-list li + li { margin-top: 4px; }
.hint, figcaption { font: 400 14.5px/1.45 var(--ui); color: var(--text-2); }
.block .hint { margin-top: 10px; }
.btn.continue { display: flex; margin: 0 0 52px var(--gutter); }

/* key idea */
.callout { background: var(--quiet); border-radius: var(--r); padding: 26px 30px 28px; font: italic 400 25px/1.36 var(--serif); }
.block-callout > .label { top: 30px; }
.callout.bad { background: var(--quiet-2); color: var(--text); font: 400 17px/1.5 var(--ui); padding: 16px 22px; } /* a notice, not a wrong answer: grey */
.callout.bad a { color: var(--text); font-weight: 600; }
/* A network problem is not a wrong answer: neutral tile, no berry. */
.callout.notice { background: var(--quiet-2); color: var(--text); font: 400 17px/1.5 var(--ui); padding: 22px 26px; }
.callout.notice a { color: var(--text); font-weight: 600; }

/* quote */
.quote { margin: 0; }
.quote blockquote { margin: 0; padding: 2px 0 2px 22px; box-shadow: inset 3px 0 0 var(--line); font: italic 400 24px/1.4 var(--serif); }
.quote figcaption { padding-left: 22px; }

/* figures */
figure { margin: 0; }
figure img { display: block; max-width: 100%; height: auto; border-radius: var(--r-s); background: #fff; }
figcaption { margin-top: 12px; }
audio { display: block; width: 100%; }

/* video */
.player { position: relative; border-radius: var(--r); overflow: hidden; background: var(--video); color: #fff; aspect-ratio: 16 / 9; } /* keeps its room while the video downloads */
.player video, .player iframe { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border: 0; }
.player > .callout.notice { border-radius: 0; }
.block-video > .callout { font: 400 17px/1.5 var(--ui); }
/* native captions: readable on the video, in the page and in full screen */
video::cue { background: rgba(0,0,0,.76); color: #fff; font-family: var(--ui); }

/* accordion, tabs, cards, process, timeline, table */
.acc { background: var(--quiet); border-radius: var(--r); margin: 0 0 8px; transition: background var(--t) var(--ease); }
.acc:hover { background: #EBECEE; }
.acc summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; list-style: none;
  padding: 14px 16px 14px 22px; font: 600 17px/1.35 var(--ui); border-radius: var(--r);
}
.acc summary::-webkit-details-marker { display: none; }
/* soft round chevron instead of the browser triangle; it turns when the panel opens */
.acc summary::after {
  content: ""; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--sheet) var(--ico-chev) center / 12px no-repeat;
  transition: transform var(--t) var(--ease);
}
.acc[open] summary::after { transform: rotate(180deg); }
.block .acc p { padding: 0 22px 18px; font: 400 17px/1.55 var(--ui); }
.tablist { display: flex; flex-wrap: wrap; gap: 6px; }
.tablist [role="tab"] {
  min-height: 42px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--quiet); color: var(--text-2);
  font: 600 15px/1.2 var(--ui); transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.tablist [role="tab"]:hover { background: var(--quiet-2); }
.tablist [role="tab"][aria-selected="true"] { background: var(--action); color: #fff; }
.tabpanel { margin-top: 10px; background: var(--quiet); border-radius: var(--r); padding: 18px 22px; font: 400 17px/1.55 var(--ui); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 10px; }
.card {
  min-width: 0; min-height: 150px; background: var(--quiet); border: 0; border-radius: var(--r); padding: 18px; display: flex; flex-direction: column;
  justify-content: center; gap: 8px; text-align: center; font: 400 17px/1.45 var(--ui); box-shadow: inset 0 0 0 1.5px var(--outline);
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.card:hover { background: var(--quiet-2); }
.card[aria-pressed="true"] { background: var(--action); color: #fff; box-shadow: none; }
.card-side { font: 600 12.5px/1 var(--ui); text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.step { background: var(--quiet); border-radius: var(--r); padding: 18px 24px 22px; min-height: 140px; }
.block .step .hint { margin: 0; }
.step h3 { margin: 6px 0; font: 600 21px/1.3 var(--serif); }
.step p:last-child { font: 400 17px/1.55 var(--ui); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; box-shadow: inset 2px 0 0 var(--line); }
.timeline li { position: relative; padding: 0 0 18px 16px; font: 400 17px/1.5 var(--ui); }
.timeline li::before { content: ""; position: absolute; left: -27px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--action); box-shadow: 0 0 0 4px var(--sheet); }
.timeline strong { font: 600 17px/1.4 var(--serif); }
.timeline li:last-child { padding-bottom: 0; }
.block .timeline p { margin-top: 2px; }
.table-wrap { overflow-x: auto; border-radius: var(--r-s); box-shadow: inset 0 0 0 1px var(--line); }
/* a table keeps its columns readable and scrolls sideways instead of crushing them */
table { border-collapse: collapse; width: 100%; overflow-wrap: normal; font: 400 16px/1.45 var(--ui); }
th, td { padding: 11px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
tbody tr:last-child > * { border-bottom: 0; }
thead th { background: var(--quiet-2); font-weight: 600; }
tbody th { font-weight: 600; }

/* labeled graphic and hotspot */
.graphic { position: relative; }
.graphic img { display: block; width: 100%; height: auto; border-radius: var(--r-s); box-shadow: 0 0 0 1px var(--line); }
.marker {
  position: absolute; transform: translate(-50%, -50%); width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; padding: 0;
  background: var(--action); color: #fff; font: 600 15px/1 var(--ui); box-shadow: 0 1px 6px rgba(34,36,40,.35); transition: background var(--t) var(--ease);
}
.marker:hover, .marker[aria-current="true"] { background: var(--text); }
.marker[aria-current="true"] { box-shadow: 0 0 0 3px var(--quiet-2), 0 1px 6px rgba(34,36,40,.35); }
.region { position: absolute; background: transparent; border: 2px dashed transparent; border-radius: 8px; padding: 0; cursor: pointer; transition: background var(--t) var(--ease), border-color var(--t) var(--ease); }
/* the white halo keeps the dashed outline readable on any picture */
.region:hover, .region:focus-visible { background: rgba(255,255,255,.28); border-color: var(--text); box-shadow: 0 0 0 2px #fff; }
.region.is-correct { border: 3px solid var(--ok); background: rgba(224,241,236,.45); box-shadow: 0 0 0 2px #fff; }
.region.is-wrong { border: 3px solid var(--bad); background: rgba(248,228,238,.45); box-shadow: 0 0 0 2px #fff; }

/* == questions == */
fieldset.question { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.question legend { float: left; width: 100%; padding: 0; }
fieldset.question legend + * { clear: both; }
.question legend, .block .qlabel, .block .instruction { display: block; margin: 0 0 20px; font: 600 23px/1.32 var(--serif); letter-spacing: -.005em; color: var(--text); }
.block .instruction { margin-bottom: 20px; }
/* every option as tall as the tallest one */
.options { display: grid; grid-auto-rows: 1fr; gap: 8px; }
.options > label.option { margin: 0; }
label.option {
  position: relative; display: grid; grid-template-columns: 28px 1fr auto; gap: 14px; align-items: center; width: 100%; margin: 0 0 8px;
  background: var(--quiet); border-radius: var(--r); padding: 14px 22px 14px 14px; font: 400 17.5px/1.4 var(--ui); color: var(--text);
  cursor: pointer; transition: background var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
/* the native radio or checkbox covers the whole tile: keyboard, screen readers and clicks work as usual */
label.option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
label.option input:disabled { cursor: default; }
label.option:hover { background: var(--quiet-2); }
/* after submitting, tiles are locked: no hover change, no pointer */
label.option:has(input:disabled) { cursor: default; }
label.option:has(input:disabled):not(.is-correct):not(.is-wrong):hover { background: var(--quiet); }
label.option:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 3px; }
.key {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--sheet);
  box-shadow: inset 0 0 0 1.5px var(--outline); font: 600 13px/1 var(--ui); color: var(--text-2);
  transition: background var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.option.multi .key { border-radius: 8px; }
label.option:has(input:checked) { background: var(--quiet-2); box-shadow: inset 0 0 0 2px var(--action); }
label.option:has(input:checked) .key { background: var(--action); box-shadow: none; color: #fff; }
/* once checked, right and wrong win over the selected look (the :has selectors match its weight) */
label.option.is-correct, label.option.is-correct:has(input:checked) { background: var(--ok-bg); box-shadow: inset 0 0 0 2px var(--ok); }
label.option.is-wrong, label.option.is-wrong:has(input:checked) { background: var(--bad-bg); box-shadow: inset 0 0 0 2px var(--bad); }
label.option.is-correct .key, label.option.is-correct:has(input:checked) .key { background: var(--ok); box-shadow: none; color: #fff; }
label.option.is-wrong .key, label.option.is-wrong:has(input:checked) .key { background: var(--bad); box-shadow: none; color: #fff; }
.mark { display: inline-grid; justify-items: start; font: 600 14px/1.2 var(--ui); white-space: nowrap; }
.mark > span { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 6px; visibility: hidden; }
.mark[data-show="ok"] > .m-ok, .mark[data-show="bad"] > .m-bad { visibility: visible; animation: soft-in var(--t) var(--ease-out) both; }
.m-ok { color: var(--ok); }
.m-bad { color: var(--bad); }
.mark > span::before { content: ""; display: inline-block; width: 14px; height: 14px; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.nav button[data-id] .tick, .m-ok { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.3 5 8.8 9.6 3.6'/%3E%3C/svg%3E"); }
.m-bad { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='m3.2 3.2 5.6 5.6m0-5.6-5.6 5.6'/%3E%3C/svg%3E"); }

.feedback { position: relative; margin: 12px 0 0; padding: 16px 22px; border-radius: var(--r); background: var(--quiet); font: 400 17px/1.5 var(--ui); }
.block .feedback { margin-top: 12px; }
.feedback.ok, .feedback.bad, .feedback.done, .result.ok, .result.bad { padding-left: 56px; }
.feedback.ok, .result.ok { background: var(--ok-bg); }
.feedback.bad, .result.bad { background: var(--bad-bg); }
.feedback.ok::before, .feedback.bad::before, .feedback.done::before, .result.ok::before, .result.bad::before {
  content: ""; position: absolute; left: 22px; top: 18px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ok) var(--ico-ok) center / 13px no-repeat;
}
.feedback.bad::before, .result.bad::before { background: var(--bad) var(--ico-bad) center / 13px no-repeat; }
/* end of course: neutral, it is not an answer */
.feedback.done::before { background: var(--action) var(--ico-ok) center / 13px no-repeat; }
.result { position: relative; margin-top: 16px; padding: 16px 22px; border-radius: var(--r); background: var(--quiet); font: 600 17px/1.5 var(--ui); }

.textin {
  display: block; width: 100%; max-width: 420px; min-height: 50px; padding: 0 22px; background: var(--quiet-2); border: 1.5px solid var(--outline);
  border-radius: 999px; font: 400 17px/1 var(--ui); transition: background var(--t) var(--ease), border-color var(--t) var(--ease);
}
.textin:hover { background: #DCDDE0; }
.textin:focus-visible { outline: 0; background: var(--sheet); border-color: var(--action); box-shadow: 0 0 0 4px var(--quiet-2); }
.textin.is-correct { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.textin[aria-invalid="true"] { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.slider { display: flex; gap: 16px; align-items: flex-start; }
.slider-track { flex: 1; min-width: 0; }
.slider input { display: block; width: 100%; height: 28px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.slider input::-webkit-slider-runnable-track { height: 10px; border-radius: 999px; background: var(--quiet-2); box-shadow: inset 0 0 0 1.5px var(--outline); }
.slider input::-moz-range-track { height: 10px; border-radius: 999px; background: var(--quiet-2); box-shadow: inset 0 0 0 1.5px var(--outline); }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px; border-radius: 50%; border: 3px solid #fff; background: var(--action); box-shadow: 0 0 0 1.5px var(--outline); }
.slider input::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; background: var(--action); box-shadow: 0 0 0 1.5px var(--outline); }
.slider input:hover::-webkit-slider-thumb { background: var(--action-2); }
.slider-ends { display: flex; justify-content: space-between; margin-top: 4px; font: 400 14px/1.2 var(--ui); color: var(--text-2); }
.slider-out { min-width: 4em; text-align: right; font: 600 22px/28px var(--serif); }

/* matching and sorting */
.bank { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 60px; margin: 0 0 10px; padding: 8px; border-radius: var(--r); background: var(--quiet); transition: background var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.bank.drop { background: var(--quiet-2); box-shadow: inset 0 0 0 2px var(--action); }
.bank button.option, .zone button.option { min-height: 38px; padding: 0 16px; font-size: 14.5px; background: var(--sheet); box-shadow: inset 0 0 0 1.5px var(--outline); }
.bank button.option:hover, .zone button.option:hover { background: var(--quiet-2); }
.chip:active { cursor: grabbing; }
.chip {
  display: inline-flex; align-items: center; background: var(--sheet); border: 0; border-radius: 999px; padding: 10px 18px;
  font: 600 16.5px/1.2 var(--ui); color: var(--text); text-align: left; box-shadow: inset 0 0 0 1.5px var(--outline);
  transition: box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}
button.chip { cursor: grab; }
.chip[aria-pressed="true"] { background: var(--quiet-2); box-shadow: inset 0 0 0 2.5px var(--action); }
.zones { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.zone {
  background: var(--quiet); border-radius: var(--r); padding: 16px 20px; min-height: 116px; width: 100%; text-align: left;
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; cursor: pointer; transition: background var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.zone-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; width: 100%; }
.zone small { font: 600 14px/1.3 var(--ui); color: var(--text); }
/* while an item is selected, every box shows where it can go */
.armed .zone:not(.is-correct):not(.is-wrong) { box-shadow: inset 0 0 0 1.5px var(--outline); background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(124,126,131,.08) 10px 20px); }
.zone.drop { background: var(--quiet-2); box-shadow: inset 0 0 0 2px var(--action); }
.zone.is-correct { background: var(--ok-bg); box-shadow: inset 0 0 0 2px var(--ok); }
.zone.is-wrong { background: var(--bad-bg); box-shadow: inset 0 0 0 2px var(--bad); }
.slot { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; min-height: 42px; } /* room for one chip: a box does not grow when its first chip lands */
/* "Place here" keeps its room while hidden, so the boxes do not grow when a chip is selected */
.zone > button.option { transition: opacity var(--t) var(--ease), visibility var(--t) var(--ease), background var(--t) var(--ease); }
.zone > button.option[hidden] { display: inline-flex !important; visibility: hidden; opacity: 0; }

/* ordering: numbered tiles with up and down pills */
.sequence { list-style: none; margin: 0; padding: 0; counter-reset: seq; }
.sequence li {
  counter-increment: seq; display: flex; align-items: center; gap: 14px; margin: 0 0 8px; padding: 10px 12px 10px 14px;
  background: var(--quiet); border-radius: var(--r); font: 400 17px/1.4 var(--ui);
}
.sequence li::before {
  content: counter(seq); flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--sheet); box-shadow: inset 0 0 0 1.5px var(--outline); font: 600 13px/1 var(--ui); color: var(--text-2);
}
.sequence li > span:first-child { flex: 1; min-width: 0; }
.sequence .mark { display: grid; margin-top: 4px; }
.sequence li.is-correct { background: var(--ok-bg); box-shadow: inset 0 0 0 2px var(--ok); }
.sequence li.is-wrong { background: var(--bad-bg); box-shadow: inset 0 0 0 2px var(--bad); }
.sequence li.is-correct::before { background: var(--ok); box-shadow: none; color: #fff; }
.sequence li.is-wrong::before { background: var(--bad); box-shadow: none; color: #fff; }
.seq-btns { display: inline-flex; gap: 6px; flex: none; }
.seq-btns button.option { width: 40px; min-height: 40px; padding: 0; background: var(--sheet); box-shadow: inset 0 0 0 1.5px var(--outline); font-size: 17px; }

/* scenario */
.block .scenario .speaker { font: 600 14px/1.3 var(--ui); color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.scenario blockquote { margin: 8px 0 18px; font: 400 22px/1.45 var(--serif); }
.block .scenario .feedback { margin: 0 0 16px; }
.choices { display: grid; gap: 8px; }
.choices button.option {
  display: block; width: 100%; min-height: 0; text-align: left; border-radius: var(--r); padding: 14px 22px;
  font: 400 17.5px/1.4 var(--ui); background: var(--quiet);
}
.choices button.option:hover { background: var(--quiet-2); }

/* end of lesson */
.lesson-end { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin: 0 0 0 var(--gutter); max-width: var(--measure); }
.lesson-end .feedback { flex: 0 0 100%; }

/* == comments == */
.comment-btn {
  position: fixed; right: 24px; bottom: 24px; z-index: 5; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px;
  background: var(--quiet); border: 0; border-radius: 999px; font: 600 14.5px/1 var(--ui); color: var(--text-2);
  box-shadow: 0 1px 2px rgba(34,36,40,.06), 0 6px 18px rgba(34,36,40,.08); transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.comment-btn::before {
  content: ""; width: 14px; height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%235F6166' stroke-width='1.3' stroke-linejoin='round'%3E%3Cpath d='M1.5 2.5h9v6h-5l-2.5 2v-2h-1.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.comment-btn:hover { background: var(--quiet-2); color: var(--text); }
.comment-dialog { width: min(520px, calc(100vw - 32px)); border: 0; border-radius: var(--r-l); background: var(--sheet); color: var(--text); box-shadow: var(--shadow-2); padding: 32px 32px 28px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; } /* stays reachable when the iPhone keyboard is up */
.comment-dialog::backdrop { background: rgba(48,50,54,.35); }
.comment-dialog h2 { margin: 0 0 20px; font: 600 23px/1.3 var(--serif); }
.comment-dialog label { display: block; font: 600 14.5px/1.3 var(--ui); margin: 16px 0 8px; }
.comment-dialog textarea, .comment-dialog input {
  display: block; width: 100%; border: 1.5px solid var(--outline); background: var(--quiet); padding: 12px 18px; font: 400 17px/1.5 var(--ui);
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease);
}
.comment-dialog input { min-height: 48px; border-radius: 999px; padding: 0 20px; }
.comment-dialog textarea { border-radius: 20px; resize: vertical; }
.comment-dialog textarea:focus-visible, .comment-dialog input:focus-visible { outline: 0; background: var(--sheet); border-color: var(--action); box-shadow: 0 0 0 4px var(--quiet-2); }
.consent { font: 400 14px/1.5 var(--ui); color: var(--text-2); margin: 16px 0 0; }
.comment-dialog .hint { margin: 16px 0 0; font-weight: 600; }
.comment-dialog .hint:empty { display: none; }
.comment-dialog .hint.ok, .comment-dialog .hint.bad { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--r-s); }
.comment-dialog .hint.ok { background: var(--ok-bg); color: var(--ok); }
.comment-dialog .hint.bad { background: var(--bad-bg); color: var(--bad); }
.comment-dialog .hint.ok::before, .comment-dialog .hint.bad::before { content: ""; flex: none; width: 16px; height: 16px; margin-top: 2px; background: center / contain no-repeat; }
.comment-dialog .hint.ok::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23006F5F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.2 3.2L13 5'/%3E%3C/svg%3E"); }
.comment-dialog .hint.bad::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23B01E68' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 4l8 8M12 4l-8 8'/%3E%3C/svg%3E"); }
.comment-dialog .actions { margin-top: 20px; }

/* == narrower screens: labels move above the blocks == */
@media (max-width: 1140px) {
  :root { --gutter: 0px; }
  .lesson { padding: 48px 44px 88px; }
  .lesson h1 { display: block; }
  .lesson h1 .num { display: block; margin-bottom: 4px; }
  .block > .label, .question legend .label { position: static; display: block; width: auto; margin-bottom: 10px; }
  .block-callout > .label { position: absolute; top: 20px; left: 26px; }
  .block-callout .callout { padding-top: 46px; }
}

/* == tablet and phone: the sidebar becomes a compact header above the lesson ==
   Kept as a sidebar, it would leave the lesson column about 430 px wide at 768 px. */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 8px 12px 12px; }
  .lesson { max-width: none; }
  .nav { position: static; max-height: none; overflow: visible; padding: 12px 4px 8px; display: flex; flex-wrap: wrap; gap: 6px; }
  /* many lessons: one strip that scrolls sideways, not a wall of pills */
  .nav-list { flex: 0 0 100%; display: flex; gap: 6px; overflow-x: auto; padding: 5px 5px 8px; margin: -5px; scrollbar-width: thin; }
  .nav-head { flex: 0 0 100%; padding: 0 4px 6px; display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: start; }
  .nav-top { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
  .nav .nav-title { grid-column: 1; padding-top: 4px; font-size: 19px; }
  .nav-sub { grid-column: 1; }
  .nav-progress, .nav-count { grid-column: 1 / -1; }
  .nav button[data-id] { position: relative; flex: 1 0 52px; width: auto; margin: 0; display: flex; justify-content: center; padding: 10px 0; background: #E2E3E5; border-radius: 999px; }
  .nav button[data-id] .t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .nav button[data-id] .tick { display: none; }
  .nav button[data-id].done .num { color: var(--text); font-weight: 600; }
  .nav button[data-id][aria-current="page"] { background: var(--action); box-shadow: none; }
  .nav button[data-id][aria-current="page"] .num { color: #fff; }
}

/* == phone == */
@media (max-width: 760px) {
  .lock { padding: 40px 16px; }
  .lock-card { padding: 18px 22px 24px; }
  .lock-top { margin-right: -4px; }
  .lesson { padding: 28px 20px 96px; border-radius: 26px; }
  .lesson-head { margin-bottom: 30px; }
  .lesson h1 { font-size: 29px; }
  .count { font-size: 24px; }
  .block { margin-bottom: 36px; }
  .block-text p, .block-list ul { font-size: 18px; }
  .callout { padding: 18px 22px 22px; font-size: 22px; }
  .block-callout > .label { top: 18px; left: 22px; }
  .block-callout .callout { padding-top: 42px; }
  .question legend, .block .qlabel, .block .instruction { font-size: 21px; }
  label.option { grid-template-columns: 28px 1fr; padding: 12px 16px 12px 12px; }
  label.option .mark { grid-column: 2; }
  .zones { grid-template-columns: minmax(0, 1fr); }
  .btn.continue { width: 100%; }
  .lesson-end .btn { flex: 1 1 auto; }
  .comment-btn { right: 16px; bottom: 16px; }
  .comment-dialog { padding: 24px 20px 22px; }
  /* touch targets: at least 44 px on a phone */
  .lang-switch button { min-height: 44px; }
  .nav button[data-id] { min-height: 44px; }
  .tablist [role="tab"], .chip, .zone button.option { min-height: 44px; }
  .seq-btns button.option { width: 44px; min-height: 44px; }
  .marker { width: 44px; height: 44px; }
  .region::after { content: ""; position: absolute; inset: -10px; }
  .slider input { height: 44px; }
}

/* == Windows high-contrast mode: fills and box-shadow rings disappear there, so give every control and tile a real border == */
@media (forced-colors: active) {
  .btn, .lock-card button[type="submit"], button.option, .tablist [role="tab"], .comment-btn, .chip, .card, .lang-switch,
  label.option, .acc, .zone, .bank, .feedback, .result, .callout, .step, .tabpanel, .sequence li { border: 1px solid ButtonText; }
  .key, .sequence li::before { border: 1px solid ButtonText; }
  .nav button[data-id][aria-current="page"] { border: 1px solid ButtonText; }
  /* the selected or pressed state is a thicker border, never colour alone */
  label.option:has(input:checked), .chip[aria-pressed="true"], .card[aria-pressed="true"], .tablist [role="tab"][aria-selected="true"] { border: 3px solid Highlight; }
  .progress, .nav-progress { border: 1px solid ButtonText; }
  .progress span, .nav-progress span.done, .lang-thumb, .timeline li::before, .marker { forced-color-adjust: none; background: Highlight; }
  .lang-switch button[aria-pressed="true"] { forced-color-adjust: none; color: HighlightText; }
  .feedback::before, .result::before { forced-color-adjust: none; }
}

/* == appearing things: a soft fade, never a jump == */
@keyframes soft-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.lesson > *, .feedback:not([hidden]), .result:not([hidden]), .tabpanel:not([hidden]), .step > *, .card > span, .acc[open] > :not(summary), .comment-dialog[open], .comment-dialog[open]::backdrop {
  animation: soft-in var(--t) var(--ease-out) both;
}

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

/* text for screen readers only */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* == no jumps: a stack lays its children in one cell, the tallest sets the height;
   phantoms are invisible copies that only hold the room == */
.stack { display: grid; }
.stack > * { grid-area: 1 / 1; min-width: 0; }
.stack > .phantom { display: block; visibility: hidden; }
.stack > [role="tabpanel"][hidden] { display: block !important; visibility: hidden; }
.stack > .feedback, .stack > .result { align-self: start; }
.stack > .phantom.slot, .stack > .phantom.bank { display: flex; }

/* blank to fill in: one solid line */
.blank { display: inline-block; width: 4.6em; height: 1em; margin: 0 .12em; border-bottom: 2px solid currentColor; vertical-align: -.12em; }

/* formulas (MathML) */
math { font-size: 1.08em; }
math[display="block"] { margin: 12px 0; }
