/* The listening player and the speaking screen (STORY-04.20; the owner-approved mock-up
   docs/mockups/2026-11-19-04.20-player-and-speaking/, every choice as recommended). Colours, spacing and type from
   tokens.css; light theme only. */

/* ---------- The player (audio.js) ----------
   One row of at most 56 px: play or pause (44 x 44), the bar, the time and the status as badges inside the row
   (principle 6); in practice back 5 seconds and the speed, 44 x 44 each. The row never wraps: the bar gives way. The
   section's clock stays in the exam bar, so the player has no clock of its own. */
.audio { display: grid; gap: var(--s2); min-width: 0; font-size: var(--fs-base); line-height: 1.4; }
.audio-row {
  display: flex; align-items: center; gap: 6px; min-width: 0; height: 56px; padding: 6px var(--s2);
  border-radius: var(--r-s); background: var(--exam-pane); box-shadow: inset 0 0 0 1px var(--exam-line);
}
.questions .block-audio .audio-row { background: var(--exam-bg); }
.audio-btn, .audio-back, .audio-speed {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px;
  background: var(--exam-bg); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong);
}
.audio-btn .i, .audio-back .i { width: 20px; height: 20px; }
.audio-btn:disabled { opacity: 0.5; }
.audio-speed { font: 700 var(--fs-s)/1 var(--text); font-variant-numeric: tabular-nums; }
.audio-track { flex: 1 1 48px; min-width: 24px; height: 8px; border-radius: 4px; background: var(--exam-fill); overflow: hidden; }
.audio-track.seekable { cursor: pointer; height: 12px; border-radius: 6px; }
.audio-track span { display: block; height: 100%; width: 0; background: var(--ink); border-radius: inherit; }
.audio-badge {
  display: inline-flex; align-items: center; gap: 4px; flex: none; min-height: 26px; padding: 1px 8px; border-radius: 13px;
  background: var(--exam-bg); box-shadow: inset 0 0 0 1px var(--exam-line); color: var(--ink);
  font: 700 var(--fs-s)/1.2 var(--text); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.audio-badge .i { width: 14px; height: 14px; }
.audio-badge--ink { background: var(--ink); color: var(--surface); box-shadow: none; }
.audio-badge--coral { background: var(--coral-tint); color: var(--coral-deep); box-shadow: none; }
.audio-badge--line { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); }
.audio-time:empty { display: none; }
/* The "i": a 22 px circle in a 44 px tap area; its sentence opens under the row, never over the questions. */
.audio-i { display: grid; place-items: center; flex: none; width: 44px; height: 44px; margin: 0 -8px 0 -6px; padding: 0; border: 0; background: none; color: var(--teal); }
.audio-i .i { width: 20px; height: 20px; }
.audio-bubble { padding: var(--s3) var(--s4); border-radius: var(--r-m); background: var(--ink); color: var(--surface); font-size: var(--fs-m); line-height: 1.5; }
.audio-replay .callout { padding: var(--s2) var(--s3); }
/* The speed (STORY-04.70). In practice the row's speed button opens the speed menu under the row, never over the
   questions: "− 1.00× +" (0.05× steps; the value goes back to 1.00×) and "Audio made with AI voices". As in the test the
   player shows its fixed speed under the row, off. The vocabulary card uses the same control (.flash__speed). */
.audio-menu { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); padding: var(--s1) var(--s2); border-radius: var(--r-s); box-shadow: inset 0 0 0 1px var(--exam-line); }
.audio-menu[hidden] { display: none; }
.audio-menu__note, .flash__speed-note { margin: 0; font-size: var(--fs-s); color: var(--ink-2); }
.speed { display: inline-flex; align-items: center; gap: 4px; }
.speed__step, .speed__value {
  display: grid; place-items: center; flex: none; min-width: 44px; height: 44px; padding: 0 var(--s2); border: 0; border-radius: 12px;
  background: var(--exam-bg); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); font: 700 var(--fs-base)/1 var(--text);
}
.speed__step { font-size: 1.25rem; }
.speed__value { min-width: 64px; font-variant-numeric: tabular-nums; }
.speed__step:disabled { opacity: 0.4; }
.audio-fixed { margin: 0; }
.audio-fixed__speed {
  min-height: 28px; padding: 2px 10px; border: 0; border-radius: 14px; background: transparent; color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--exam-line); font: 600 var(--fs-s)/1.2 var(--text); font-variant-numeric: tabular-nums; cursor: not-allowed;
}

/* ---------- Speaking (run-speaking.js, speak-band.js) ----------
   Two raised cards (principles 5 and 7): the task, with its size button, and the answer. The answer card holds a status
   band and the notes box, neither a card of its own (no card inside a card). The band: one row of the step ("Prepare",
   "Speak", "Listen", "Choose an option", "Time is up"), the time and its button; a second line under it (the
   preparation's bar, "Recording" and the level meter, "Nothing is being recorded.", or the examiner's player). */
.exam-body--speaking > .task-card .passage__in > * + * { margin-top: var(--s3); }
.answer-card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.stage { display: grid; gap: var(--s1); padding: var(--s1) var(--s4) var(--s2); border-bottom: 1px solid var(--exam-line); }
.stage__row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s3); min-height: 44px; min-width: 0; }
/* The step's word; a lesson's try (step-try-parts.js) shows it as a line of its own. */
.stage__label { display: flex; align-items: center; gap: var(--s2); font-weight: 700; font-size: var(--fs-l); min-height: 28px; }
.stage .stage__label { min-height: 0; font: 700 var(--fs-xl)/1.2 var(--display); white-space: nowrap; }
.stage__clock { font: 800 1.75rem/1 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stage__clock:empty { display: none; }
.speak.is-prep .stage__clock, .stage.is-waiting .stage__clock { color: var(--ink-2); }
.stage__controls { display: flex; align-items: center; gap: var(--s2); margin-inline-start: auto; }
.stage__controls:empty { display: none; }
/* After the answer: "Record again" and "Next task" on their own line, one at each end. */
.stage.is-after .stage__controls { flex: 1 1 100%; justify-content: space-between; }
/* The band's buttons are slim: a 44 px tap area with a 32 px face, as the exam bar's (principle 4). */
.stage__controls .btn--exam {
  position: relative; isolation: isolate; min-height: 44px; padding: 0 var(--s3); background: none; box-shadow: none;
  color: var(--on); font-size: var(--fs-s); font-weight: 700; white-space: nowrap;
}
.stage__controls .btn--exam::before { content: ""; position: absolute; inset: 6px 0; z-index: -1; border-radius: var(--r-s); background: var(--face); }
.stage__controls .btn--exam-plain::before { box-shadow: inset 0 0 0 1px var(--line-strong); }
.stage__line:empty { display: none; }
.stage__bar { height: 8px; margin-bottom: var(--s1); border-radius: 4px; background: var(--exam-fill); overflow: hidden; }
.stage__bar span { display: block; height: 100%; background: var(--ink-2); border-radius: inherit; }
.stage__rec { display: flex; align-items: center; gap: var(--s3); min-height: 28px; }
.stage__rec-label { display: flex; align-items: center; gap: var(--s2); flex: none; font-weight: 700; font-size: var(--fs-s); }
.stage__text { display: flex; align-items: center; gap: var(--s2); min-height: 28px; font-size: var(--fs-s); color: var(--ink-2); }
.rec-dot { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); animation: rec 1.2s ease-in-out infinite; }
@keyframes rec { 50% { opacity: 0.25; } }
/* The level meter: 24 bars whose heights follow the microphone (speak-band.js), flat at 4 px in silence. */
.meter.lvl { display: flex; flex: 1 1 auto; align-items: center; justify-content: space-between; gap: 3px; height: 28px; min-width: 0; }
.lvl i { flex: 1 1 0; min-width: 3px; max-width: 10px; height: 4px; border-radius: 2px; background: var(--ink); }
/* Reduce motion: the dot and "Recording", still; no bars. */
@media (prefers-reduced-motion: reduce) {
  .rec-dot { animation: none; }
  .meter.lvl { display: none; }
}
/* The microphone check's bar. */
.mic-check .meter { width: 100%; height: 10px; border-radius: 5px; background: var(--exam-fill); overflow: hidden; }
.mic-check .meter span { display: block; height: 100%; width: 0; border-radius: 5px; background: var(--ink); transition: width 80ms linear; }
/* The notes box: the box pattern (STORY-04.13), no outline of its own; "Notes · not scored" along its bottom edge and
   the handle in its corner. */
.notes { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.prep-notes {
  flex: 1 1 auto; min-height: 88px; height: 100%; padding: var(--s3) var(--s4) var(--s2); border: 0; border-radius: 0;
  background: none; box-shadow: none; resize: none; font-size: var(--fs-l); line-height: 1.6;
}
.prep-notes:focus-visible { outline: none; }
.notes:has(.prep-notes:focus-visible) { box-shadow: inset 0 0 0 2px var(--ink); }
.notes .box-label { margin-top: auto; }
/* While the student picks an option (a staged task) nothing is prepared yet: the notes box comes with the preparation. */
.is-choosing .notes { display: none; }
.notes .box-grip { margin-inline-start: auto; }
.answer-card > .choices-below:not(:empty) { padding: var(--s3) var(--s4); }
/* After the answer the card scrolls as one: the recording and the model answers under the band, then the notes if any
   were written (an empty notes box is not shown, as in the mock-up). */
.is-after > .answer-card { overflow-y: auto; overscroll-behavior: contain; }
.is-after > .answer-card > * { flex: none; }
.is-after > .answer-card > .after-task { order: 1; }
.is-after > .answer-card > .notes { order: 2; }
.is-after > .answer-card > .notes:has(.prep-notes:placeholder-shown) { display: none; }
.after-task { display: grid; gap: var(--s3); padding: var(--s3) var(--s4); }
.after-task:empty { display: none; }
.after-task h3 { font-size: var(--fs-base); }
.playback { display: grid; gap: var(--s2); }
.playback audio { width: 100%; height: 44px; }

@media (max-width: 860px) {
  /* The task as tall as its words, the answer card at least its band and a few lines of notes. */
  .exam-body--speaking { grid-template-rows: minmax(0, max-content) minmax(min-content, 1fr); }
  .exam-body--speaking.is-after { grid-template-rows: fit-content(50%) minmax(0, 1fr); }
  /* A task with no preparation has no notes box: the answer card is as tall as its band, with no empty card under it. */
  .exam-body--speaking:not(.is-after):not(:has(.notes)) { grid-template-rows: minmax(0, max-content) max-content; align-content: start; }
  .exam-body--speaking > .task-card > .passage { padding-top: var(--s5); }
}
/* The task's size button: the task takes the whole screen, the answer folded to its band. */
.exam-body--speaking.is-task { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.exam-body--speaking.is-task > .answer-card > :not(.stage) { display: none; }
