/* Questions and the material they refer to (passages, tables, charts, audio). Used in the test
   runner, in lesson quizzes and in the answer review. A chosen answer takes --pick: ink in the
   exam, teal on study screens. Correct / wrong marks appear only after an answer is checked and
   always carry an icon and words as well as colour. */

/* ---------- Question frame ---------- */
.q {
  display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: var(--s3); row-gap: var(--s3);
  align-items: start; border: 0; padding: 0; margin: 0; min-width: 0;
}
.q:focus { outline: none; }
.q > .qn { grid-column: 1; grid-row: 1; }
.q > .q-stimulus, .q > .q__text, .q > .q__ctl { grid-column: 2; min-width: 0; }
.q--block > * { grid-column: 1 / -1 !important; }
.qn {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; flex: none;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-family: var(--display); font-weight: 700; font-size: var(--fs-m); font-variant-numeric: tabular-nums;
}
.q__range { font-size: var(--fs-l); font-variant-numeric: tabular-nums; }
.q__text { padding-top: 3px; font-size: var(--fs-l); line-height: 1.5; }
.q__text p + p { margin-top: var(--s2); }
.q__ctl { display: grid; gap: var(--s3); }
.q.is-current { margin: calc(var(--s3) * -1); padding: var(--s3); background: var(--exam-bg); border-radius: 12px; box-shadow: inset 3px 0 0 var(--pick); }
.q.is-current > .qn { background: var(--pick); color: var(--pick-ink); box-shadow: none; }

/* ---------- Options ---------- */
.opts { display: grid; gap: var(--s2); }
.opt {
  position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--s3); align-items: center;
  min-height: 48px; padding: var(--s2) var(--s4) var(--s2) var(--s3);
  background: var(--exam-bg); border-radius: var(--r-s); box-shadow: inset 0 0 0 1px var(--exam-line);
  cursor: pointer; line-height: 1.45;
}
.opt input, .seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt__key {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-family: var(--display); font-weight: 700; font-size: var(--fs-s);
}
.opt--multi .opt__key { border-radius: 8px; }
.opt:has(input:checked) { box-shadow: inset 0 0 0 2px var(--pick); }
.opt input:checked + .opt__key { background: var(--pick); color: var(--pick-ink); box-shadow: none; }
.opt:has(input:focus-visible), .seg label:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.opt:has(input:disabled) { cursor: default; }
.opt:has(input:disabled:not(:checked)):not(.is-correct) { color: var(--ink-2); }
.opts .opt.is-correct, .opts .opt.is-correct:has(input:checked) { background: var(--teal-tint); box-shadow: inset 0 0 0 2px var(--teal); }
.opt.is-correct .opt__key, .opt.is-correct input:checked + .opt__key { background: var(--teal); color: var(--on-fill); box-shadow: none; }
.opts .opt.is-wrong, .opts .opt.is-wrong:has(input:checked) { background: var(--coral-tint); box-shadow: inset 0 0 0 2px var(--coral-deep); }
.opt.is-wrong .opt__key, .opt.is-wrong input:checked + .opt__key { background: var(--coral-deep); color: var(--on-fill); box-shadow: none; }

/* Two or three short options side by side (True / False / Not Given). */
.seg {
  display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); max-width: calc(var(--n, 3) * 130px);
  border-radius: var(--r-s); box-shadow: inset 0 0 0 1px var(--line-strong); background: var(--exam-bg);
}
.seg label {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 var(--s2); font-weight: 500; font-size: var(--fs-m); cursor: pointer;
  border-inline-start: 1px solid var(--line-strong); white-space: nowrap;
}
.seg label:first-child { border-inline-start: 0; border-radius: var(--r-s) 0 0 var(--r-s); }
.seg label:last-child { border-radius: 0 var(--r-s) var(--r-s) 0; }
.seg label .i { display: none; }
.seg label:has(input:checked) { background: var(--pick); color: var(--pick-ink); font-weight: 700; }
.seg label:has(input:checked) .i, .seg label.is-correct .i, .seg label.is-wrong .i { display: block; }
.seg label:has(input:disabled) { cursor: default; }
.seg label.is-correct { background: var(--teal); color: var(--on-fill); font-weight: 700; }
.seg label.is-wrong { background: var(--coral-deep); color: var(--on-fill); font-weight: 700; }

/* ---------- Gaps, drop-downs, matching ---------- */
.gapline { line-height: 2.4; padding-top: 0; margin-top: -6px; }
input.gap {
  width: 12.5em; max-width: 100%; min-height: 44px; height: 44px; padding: 0 var(--s3); margin-inline: 2px;
  border-radius: 8px; background: var(--exam-bg);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: var(--fs-base); vertical-align: middle; display: inline-block;
}
input.gap:focus-visible, .gp:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 8px; }
input.gap.is-ok { box-shadow: inset 0 0 0 2px var(--teal); background-color: var(--teal-tint); }
input.gap.is-bad { box-shadow: inset 0 0 0 2px var(--coral-deep); background-color: var(--coral-tint); text-decoration: line-through; text-decoration-color: var(--coral-deep); }
.cloze { font-size: var(--fs-l); }
/* A grid item, so it may be narrower than its widest gap; the gap's max-width then holds it to the line. */
.cloze > p { line-height: 2.6; min-width: 0; }
.cloze-slot { display: inline-block; max-width: 100%; vertical-align: middle; white-space: nowrap; }
.cloze-n, .fb__n {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; margin-inline-end: 6px; border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--line-strong); vertical-align: middle;
  font-family: var(--display); font-weight: 700; font-size: var(--fs-xs); line-height: 1; font-variant-numeric: tabular-nums;
}
.match { gap: var(--s4); }
.match-options { display: grid; gap: var(--s2); padding: var(--s4); border-radius: var(--r-s); background: var(--exam-bg); box-shadow: inset 0 0 0 1px var(--exam-line); }
.match-options li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--s3); align-items: start; }
.match-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; column-gap: var(--s3); row-gap: var(--s2); align-items: start; }
.match-row .match-text { padding-top: 3px; }
.match--seg .match-row { grid-template-columns: 32px minmax(0, 1fr); row-gap: var(--s3); }
.match--seg .match-row .seg, .match--seg .match-row .fb { grid-column: 2; }
.match-row .gp { min-width: 104px; margin: 0; justify-self: end; }
.match-row .fb { grid-column: 2 / -1; }
.match-text { font-size: var(--fs-l); line-height: 1.5; }

/* The gap picker (picker.js, STORY-04.22): the button where a drop-down stood, and its list. */
.gp {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; max-width: 100%; padding: 0 var(--s2) 0 6px; margin-inline: 2px;
  border: 0; border-radius: 8px; background: var(--exam-bg); box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2);
  font: 500 var(--fs-base)/1.2 var(--text); vertical-align: middle; white-space: nowrap; text-align: start;
}
.gp--nonum { padding-inline-start: var(--s3); }
.gp__n {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px; flex: none;
  box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink);
  font-family: var(--display); font-weight: 700; font-size: var(--fs-xs); line-height: 1; font-variant-numeric: tabular-nums;
}
/* A long choice takes the line and shows up to two lines of itself. */
.gp__v { min-width: 0; padding-block: 2px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; line-height: 1.25; }
.gp .i { flex: none; color: var(--ink-2); }
.gp.is-set { background: var(--exam-fill); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 2px var(--ink); }
.gp[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--ink), 0 0 0 4px var(--exam-fill); }
.gp.is-up { position: relative; z-index: 61; }
.gp:disabled { opacity: 1; }
.gp.is-ok { box-shadow: inset 0 0 0 2px var(--teal); background: var(--teal-tint); color: var(--ink); font-weight: 700; }
.gp.is-bad { box-shadow: inset 0 0 0 2px var(--coral-deep); background: var(--coral-tint); color: var(--ink); font-weight: 700; text-decoration: line-through; text-decoration-color: var(--coral-deep); }
.gp.is-bad.is-empty { color: var(--ink-2); font-weight: 500; text-decoration: none; }
.gp.is-bad.is-empty .gp__n { text-decoration: none; }
/* The list: a bottom sheet on a phone, a popover under the gap on a wide screen (placed by picker.js). Options are 44 px or more. */
.pk-back { position: fixed; inset: 0; z-index: 59; background: var(--scrim-deep); animation: pk-fade 160ms ease-out; }
.pk {
  position: fixed; z-index: 60; inset: auto 0 0 0; display: flex; flex-direction: column; max-height: 74vh; max-height: 74dvh; padding-bottom: env(safe-area-inset-bottom);
  border-radius: var(--r-l) var(--r-l) 0 0; background: var(--exam-bg); color: var(--ink); box-shadow: 0 0 0 1px var(--exam-line), var(--float);
  font-weight: 400; white-space: normal; animation: pk-up 180ms ease-out;
}
.pk__grip { position: relative; flex: none; display: grid; place-items: center; height: 24px; }
.pk__grip::before { content: ""; width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); }
.pk__head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 44px; padding: 0 var(--s1) 0 var(--s4); font-family: var(--display); font-weight: 700; font-size: var(--fs-l); }
.pk__x { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--r-s); background: none; color: var(--ink-2); }
.pk__ctx { flex: none; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; margin: 0; padding: 0 var(--s4) var(--s2); color: var(--ink-2); font-size: var(--fs-m); line-height: 1.4; }
.pk__list { display: grid; gap: 2px; min-height: 0; margin: 0; padding: 0 var(--s2) var(--s3); overflow-y: auto; overscroll-behavior: contain; }
.pk__list:focus-visible { outline: none; }
.pk__opt { display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: var(--s2) var(--s3); border-radius: var(--r-s); font-size: var(--fs-l); line-height: 1.35; cursor: pointer; }
.pk__opt b { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line-strong); font: 700 var(--fs-s)/1 var(--display); }
.pk__opt span { flex: 1; min-width: 0; }
.pk__opt .i { flex: none; width: 18px; height: 18px; stroke-width: 2.75; }
.pk__opt.is-on { background: var(--exam-fill); font-weight: 700; }
.pk__opt.is-focus { outline: 3px solid var(--ink); outline-offset: -3px; }
.pk__opt--none { color: var(--ink-2); }
.pk__opt--none.is-on { color: var(--ink); }
@keyframes pk-up { from { transform: translateY(24px); opacity: 0; } }
@keyframes pk-fade { from { opacity: 0; } }
@media (min-width: 861px) {
  .pk-back { background: transparent; animation: none; }
  .pk { inset: auto; width: max-content; max-width: min(440px, 70vw); max-height: 312px; padding-bottom: 0; border-radius: var(--r-m); box-shadow: 0 0 0 1px var(--line-strong), var(--float); animation: pk-fade 120ms ease-out; }
  .pk--wide { max-width: min(520px, 70vw); }
  .pk__grip, .pk__head, .pk__ctx { display: none; }
  .pk__list { padding: var(--s2); }
  .pk__opt { min-height: 44px; }
}
@media (hover: hover) and (pointer: fine) { .pk__opt:not(.is-on):hover { background: var(--exam-pane); } }
/* With Reduce Motion the list and its dimming appear at once (the app's global rule still leaves 0.01 ms). */
@media (prefers-reduced-motion: reduce) {
  .pk, .pk-back { animation: none !important; transition: none !important; }
}

/* ---------- Ordering, dictation, highlight ---------- */
.order { display: grid; gap: var(--s2); }
.order-item {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: var(--s3); align-items: center;
  padding: var(--s2) var(--s2) var(--s2) var(--s3); min-height: 60px;
  background: var(--exam-bg); border-radius: var(--r-s); box-shadow: inset 0 0 0 1px var(--exam-line);
}
.order-n { font-family: var(--display); font-weight: 700; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }
.order-btns { display: flex; gap: var(--s1); }
.order-solution { margin-top: var(--s2); }
textarea.dictation { min-height: 88px; background: var(--exam-bg); box-shadow: inset 0 0 0 1px var(--line-strong); border-radius: var(--r-s); font-size: var(--fs-l); }
.highlight { font-size: var(--fs-xl); line-height: 2.3; }
.word {
  min-height: 36px; padding: 2px 5px; border: 0; border-radius: 6px; background: none; font-size: inherit; line-height: 1.3;
}
.word.on { background: var(--pick); color: var(--pick-ink); }
.word.is-correct { background: var(--teal-tint); box-shadow: inset 0 -3px 0 var(--teal); color: var(--ink); }
.word.is-wrong { background: var(--coral-tint); box-shadow: inset 0 -3px 0 var(--coral-deep); color: var(--ink); text-decoration: line-through; }
@media (hover: hover) and (pointer: fine) {
  .word:not(:disabled):not(.on):hover, .opt:not(:has(input:disabled)):hover { background-color: var(--exam-fill); }
  .seg label:not(:has(input:checked)):not(:has(input:disabled)):hover { background: var(--exam-fill); }
}

/* ---------- Feedback after a check ---------- */
.fb {
  display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--s3); align-items: start;
  padding: var(--s3) var(--s4) var(--s3) var(--s3); border-radius: var(--r-s);
  background: var(--exam-bg); box-shadow: inset 3px 0 0 var(--teal), inset 0 0 0 1px var(--exam-line);
  font-size: var(--fs-base); line-height: 1.5;
}
.fb--bad { box-shadow: inset 3px 0 0 var(--coral-deep), inset 0 0 0 1px var(--exam-line); }
.fb__mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--teal-tint); color: var(--teal); }
.fb--bad .fb__mark { background: var(--coral-tint); color: var(--coral-deep); }
.fb__mark .i { stroke-width: 2.5; }
.fb__body > * + * { margin-top: var(--s1); }
.fb__why { color: var(--ink-2); }
.fb__why p + p { margin-top: var(--s2); }
.fb-list { display: grid; gap: var(--s2); font-size: var(--fs-base); }

/* ---------- "Not sure" (STORY-03.23, REVIEW-2 §3) ---------- */
/* Under the answer, left-aligned with it, 16 px below (the row gap and its margin); 44 px tall. Off: an outline
   and an empty square. On: the sun tint and a ticked square. */
.ns-chip {
  position: relative; grid-column: 2; justify-self: start; display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 44px; margin-top: var(--s1); padding: 0 var(--s4) 0 var(--s3); border-radius: var(--r-s);
  background: var(--exam-bg); box-shadow: inset 0 0 0 1px var(--line-strong);
  font-weight: 500; font-size: var(--fs-base); line-height: 1.2; cursor: pointer;
}
.ns-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ns-chip__box { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.ns-chip__box .i { visibility: hidden; stroke-width: 3; }
.ns-chip:has(input:checked) { background: var(--sun-tint); color: var(--sun-ink); box-shadow: inset 0 0 0 1px var(--sun-deep); }
.ns-chip:has(input:checked) .ns-chip__box { background: var(--sun-ink); color: var(--sun-tint); box-shadow: none; }
.ns-chip:has(input:checked) .ns-chip__box .i { visibility: visible; }
.ns-chip:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---------- Material: passages, tables, cards, notes ---------- */
.block + .block { margin-top: var(--s5); }
.block-title { font-family: var(--display); font-size: 1.25rem; line-height: 1.25; margin-bottom: var(--s3); }
.block-text .para-row + .para-row { margin-top: var(--s4); }
.para-row.is-labelled { position: relative; padding-inline-start: 36px; }
.para { position: absolute; inset-inline-start: 0; top: 0.1em; font-family: var(--display); font-weight: 700; font-size: var(--fs-base); color: var(--ink-2); }
.block-text p + p { margin-top: var(--s3); }
.block-table .table--grid { font-size: var(--fs-m); line-height: 1.45; background: var(--exam-bg); }
.block-table .table--grid thead th { background: var(--exam-fill); }
.mini-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s3); }
.mini-card { padding: var(--s4); border-radius: var(--r-s); background: var(--exam-bg); box-shadow: inset 0 0 0 1px var(--exam-line); font-size: var(--fs-m); line-height: 1.5; }
.mini-card h5 { font-family: var(--display); font-size: var(--fs-l); margin-bottom: var(--s2); }
.block-note { padding: var(--s4) var(--s5); border-radius: var(--r-s); background: var(--exam-pane); box-shadow: inset 3px 0 0 var(--line-strong); font-size: var(--fs-base); line-height: 1.6; }
.block-note p + p { margin-top: var(--s2); }
.questions .block-note, .questions .block-audio .audio { background: var(--exam-bg); }
.q-stimulus { font-size: var(--fs-base); }

.chart-svg { width: 100%; height: auto; max-width: 640px; }
.chart-svg.pie { max-width: 260px; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis { stroke: var(--line-strong); stroke-width: 1.5; }
.chart-svg .tick, .chart-svg .value, .chart-svg .axis-label { fill: var(--ink-2); font-size: 11px; font-family: var(--text); font-variant-numeric: tabular-nums; }
.chart-svg .value { fill: var(--ink); font-weight: 700; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin-top: var(--s2); font-size: var(--fs-s); line-height: 1.4; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; flex: none; }

.scene { position: relative; aspect-ratio: 100 / 60; width: 100%; max-width: 640px; border-radius: 12px; border: 1px solid var(--exam-line); overflow: hidden; container-type: inline-size; }
.scene-item { position: absolute; transform: translate(-50%, -50%); line-height: 1; display: flex; flex-direction: column; align-items: center; }
.scene-item small { font-size: 1.9cqw; font-family: var(--text); background: var(--scene-label); color: var(--scene-ink); padding: 0 0.4em; border-radius: 4px; margin-top: 2px; white-space: nowrap; }
/* Illustrations are drawn at 3:2; a file of another shape is fitted inside, never cropped. */
.scene-picture { aspect-ratio: 3 / 2; width: 100%; max-width: 800px; border-radius: 12px; border: 1px solid var(--exam-line); overflow: hidden; background: var(--exam-bg); }
.scene-picture img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* The audio player: player.css (STORY-04.20). */
details.transcript { font-size: var(--fs-base); line-height: 1.6; }
.transcript-body { display: grid; gap: var(--s2); }

@media (max-width: 860px) {
  .q { grid-template-columns: 28px minmax(0, 1fr); }
  .qn { width: 28px; height: 28px; font-size: var(--fs-s); }
  .q__text { padding-top: 1px; font-size: var(--fs-base); }
  .q > .q__ctl:not(.q__ctl--inline), .q > .ns-chip { grid-column: 1 / -1; }
  .q > .q__ctl--inline ~ .ns-chip { grid-column: 2; }
  .seg { max-width: none; }
  input.gap { width: 10em; }
  .match-row { grid-template-columns: 28px minmax(0, 1fr); }
  .match-row .gp { grid-column: 2; justify-self: start; }
  .match-row .fb, .match--seg .match-row .seg, .match--seg .match-row .fb { grid-column: 1 / -1; }
  .match-row .match-text { padding-top: 1px; }
  .match-text, .cloze { font-size: var(--fs-base); }
  .highlight { font-size: var(--fs-l); line-height: 2.8; }
  .word { min-height: 44px; padding-block: 8px; }
  .block-title { font-size: var(--fs-xl); }
}

/* ---------- A reading or listening answer on a result: a raised card for each question (STORY-04.39, choice 8) ---------- */
/* The question's own node becomes the card (its id and classes stay): the number, the verdict, "Not sure" and "Review
   later" in its head; the question, its options and the answer lines in a raised body. */
.q.q-card { display: block; background: var(--paper-2); border: 1px solid var(--line-2); border-radius: 20px; }
.review-questions:has(> .q-card) { gap: var(--s3); }
.q-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s2); min-height: 48px; padding: 6px 10px 4px var(--s4); }
.q-card__head .qn { background: var(--surface); }
.q-card__ctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: auto; }
.q-card__ctl > * { margin: 0; }
.q-card__ctl .rl-in { font-size: var(--fs-s); }
.q-card__body { display: grid; gap: var(--s3); margin: 0 10px 10px; padding: var(--s3) var(--s4) 14px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-m); box-shadow: 0 1px 0 var(--line-2), 0 8px 16px -10px var(--shade-30); min-width: 0; }
@media (max-width: 860px) {
  .q-card__head { padding-left: var(--s3); }
  .q-card__body { margin: 0 var(--s2) var(--s2); padding: 10px var(--s3) var(--s3); }
}
