/* Players keep accessible names without repeating dotted visual headings. */
.speaking-cards-page .recording-player__label {
  display: none;
}

.speaking-cards-page .recording-player {
  display: grid;
  grid-template-columns: 62px auto minmax(0, 1fr);
  column-gap: 18px;
  /* Tight enough that the time readout and the bar below it read as one
     unit, not two rows with air between them. */
  row-gap: 3px;
  align-items: center;
}

.speaking-cards-page .recording-player > .controls-row {
  display: contents;
}

.speaking-cards-page .recording-player .play-btn {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.speaking-cards-page .recording-player > .scrub-wrap {
  grid-column: 2 / -1;
  grid-row: 2;
  width: 100%;
  margin-top: 0;
}

.speaking-cards-page .recording-player .time {
  grid-column: 2;
  grid-row: 1;
  margin-right: 0;
}

.speaking-cards-page .recording-player .speaking-player-status {
  grid-column: 3;
  grid-row: 1;
  min-height: 34px;
  margin: 0;
  padding: 4px 14px;
  align-self: center;
}

/* The prompt player is laid out like the Listening player (css/audio-player.css):
     row 1:  (play 44)  ...  [ Transcript ]  ...  [Skip]
     row 2:  ===================== bar =====================
     row 3:  0:04                                      0:41
   Five tracks, the middle three alike either side of the toggle, and the last
   one floors at 44px, so with no Skip pill the toggle still sits on the
   player's middle and does not jump when the pill goes. The saved-answer
   player keeps the three-column grid above. The row-3 split is the
   `.time-row` recording-player.js builds; `.time` stays for screen readers. */
.speaking-cards-page .speaking-question-audio .recording-player {
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) minmax(44px, auto);
  column-gap: 0;
  row-gap: 8px;
}

.speaking-cards-page .speaking-question-audio .recording-player .play-btn {
  grid-column: 1;
  grid-row: 1;
  width: 44px;
  height: 44px;
}

/* Size the icon box, not the svg: .pp holds both icons absolutely (inset: 0),
   so a smaller svg alone would pin to its top-left. The 3px optical nudge
   scales with it (2px at 24px). */
.speaking-cards-page .speaking-question-audio .recording-player .pp {
  width: 24px;
  height: 24px;
}

.speaking-cards-page .speaking-question-audio .recording-player .pp-play {
  transform: translateX(2px);
}

.speaking-cards-page .speaking-question-audio .recording-player .play-btn .count {
  width: 23px;
  height: 24px;
  font-size: 12px;
  transform: translateX(2px);
}

/* The Skip pill takes the Transcript toggle's height and type so the two sit
   on one midline; the grey wash, colour and 10px radius stay. At about 41px it
   is under the last track's 44px floor, so it never moves the toggle. */
.speaking-cards-page .speaking-question-audio .recording-player .speaking-player-status {
  grid-column: 5;
  grid-row: 1;
  justify-self: end;
  height: 34px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  max-width: none;
}

.speaking-cards-page .speaking-question-audio .recording-player .speaking-player-status--skip {
  font-size: 12px;
  font-weight: 600;
  padding: 0 8px;
}

.speaking-cards-page .speaking-question-audio .recording-player > .scrub-wrap {
  grid-column: 1 / -1;
  grid-row: 2;
}

.speaking-cards-page .speaking-question-audio .recording-player .time {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.speaking-cards-page .speaking-question-audio .recording-player > .time-row {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  justify-content: space-between;
  margin-top: -4px;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

/* Retell Lecture: a hairline between the image card and the player, with equal
   air each side. Respond to a Situation keeps the same 29px (14 + 1 + 14) but
   no rule. The surface hop is needed to outrank the chrome reset above. */
.speaking-cards-page [data-task-surface] .lecture-prompt > .speaking-question-audio {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.speaking-cards-page [data-task-surface] .situation-prompt > .speaking-question-audio {
  margin-top: 29px;
}

/* Submit/Retry pills for a manually-stopped take: same right-hand slot Skip
   uses on question players — the two never coexist on this player. */
.speaking-cards-page .recording-player .recorder-review-actions {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  gap: 8px;
  justify-self: end;
}

/* The recorder adopts the playback grid's arrangement: the orb keeps its
   full size in the left column, the time/bar pair sits to its right, the
   status sits below them, and one action slot holds the current phase's pills. */
.speaking-cards-page .recording-box--circle {
  grid-template-columns: 100px auto minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  row-gap: 3px;
  column-gap: 18px;
}

.speaking-cards-page .recording-box--circle .recording-orb {
  grid-column: 1;
  grid-row: 1 / span 3;
}

.speaking-cards-page .recording-box--circle .recorder-timer-info {
  grid-column: 2;
  grid-row: 1;
}

.speaking-cards-page .recording-box--circle .progress-bar {
  grid-column: 2 / -1;
  grid-row: 2;
  margin: 0;
}

.speaking-cards-page .recording-box--circle .recorder-actions {
  grid-column: 3;
  grid-row: 1;
}

.speaking-cards-page .recording-box--circle .recorder-status {
  grid-column: 2 / -1;
  grid-row: 3;
  margin: 0;
  color: var(--ink-tertiary);
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
}

/* The Speaking score panel used to be a direct child of the page and had its
   own reserved slot and entrance here. Under the Frame it is mounted inside
   the Outcome Surface or a Task Surface, so those `>` rules matched nothing
   and were removed; the shared `.score-panel` in css/main.css and the generic
   `.ai-feedback` entrance in css/ai-feedback.css carry it now. */

/* The Gatekeeper's notice, under the orbs it explains (issue #381). Off-script
   reuses the no-speech diagnosis-and-recovery band. Too-short is a gap in the
   evidence rather than a learner failure, so it stays neutral. */
.speaking-cards-page .score-panel .speaking-gate-notice {
  margin: 12px auto 0;
  max-width: 46em;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.speaking-cards-page .score-panel .speaking-gate-notice--off-script {
  margin: 0;
  color: var(--ink-secondary);
  text-align: left;
  white-space: pre-line;
}

.speaking-cards-page .score-panel .speaking-gate-notice--too-short {
  color: var(--ink-muted);
}

.speaking-cards-page .score-panel .improve-score {
  display: block;
  min-height: 42px;
  margin: 12px auto 0;
  padding: 9px 22px;
  border: 1px solid color-mix(in srgb, var(--rubric) 38%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--rubric) 8%, var(--surface));
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.speaking-cards-page .score-panel .improve-score:hover {
  background: color-mix(in srgb, var(--rubric) 14%, var(--surface));
}

.speaking-cards-page .speaking-question-audio,
.speaking-cards-page .recording-box--circle {
  box-sizing: border-box;
  width: 100%;
  padding: 16px 20px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 96%, var(--control-hover));
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.055);
  margin-bottom: 8px;
}

@media (max-width: 768px) {
  .speaking-cards-page .speaking-question-audio,
  .speaking-cards-page .recording-box--circle {
    padding: 14px 10px;
  }
}

/*
    A Task Surface is already a card, so a widget inside it is not a second one.
    The `.speaking-cards-page` prefix above gives these widgets card chrome at
    two classes; matching that here and adding the surface hop outranks it, so
    inside a surface they sit flush and let the surface be the card. Mounted
    bare — outside any surface — the chrome above still applies.

    Every page that mounts the recorder loads this stylesheet and carries the
    page class, so this is the only rule that strips card chrome inside a Task
    Surface; main.css carried a duplicate for Personal Introduction until that
    page joined the standard shape (#998).
*/
.speaking-cards-page [data-task-surface] .speaking-question-audio,
.speaking-cards-page [data-task-surface] .recording-box--circle {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  margin-bottom: 0;
}

/* ── The recorder on a phone (#618) ───────────────────────────────────────
   The desktop arrangement puts a 100px orb in a column of its own and the
   controls beside it. On a phone neither half gets enough width: the ring
   crowds a column of unequal outline pills, and the sentence that says what
   the recorder is doing ends up orphaned beneath both, describing a ring it
   is no longer next to.

   Stacked, each part gets the full width and the reading order is the order
   things happen in: the ring, the time, then the sentence about them, then
   the controls. The query is on the Task Surface rather than the viewport
   because the surface's own width is what the box has to fit inside. */
@container task-surface (max-width: 480px) {
  .speaking-cards-page .recording-box--circle {
    justify-items: center;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 10px;
  }

  .speaking-cards-page .recording-box--circle .recording-orb {
    grid-column: 1;
    grid-row: 1;
  }

  .speaking-cards-page .recording-box--circle .recorder-timer-info {
    grid-column: 1;
    grid-row: 2;
  }

  /* The status is the ring's caption, so it sits under it and reads centred
     with it rather than ranged left under a column that is no longer there. */
  .speaking-cards-page .recording-box--circle .recorder-status {
    grid-column: 1;
    grid-row: 3;
    text-align: center;
  }

  .speaking-cards-page .recording-box--circle .progress-bar {
    grid-column: 1;
    grid-row: 4;
    justify-self: stretch;
  }

  /* The saved-take player is mounted after the box's own pieces and inherits
     this tier's centring; it must stretch like the bar it replaces. */
  .speaking-cards-page .recording-box--circle.recording-box--saved .recording-player {
    width: 100%;
    justify-self: stretch;
  }

  /* One action is the one the learner is being asked to take and the others
     are ways of not taking it yet, so they stop being three pills of unequal
     width in a row: the primary spans the box and the secondary pair splits
     it. Two columns hold whichever phase's pair is showing — Pause/Restart
     while preparing, Stop/Restart while recording. */
  .speaking-cards-page .recording-box--circle .recorder-actions {
    display: grid;
    width: 100%;
    grid-column: 1;
    grid-row: 5;
    grid-template-columns: 1fr 1fr;
    justify-self: stretch;
    gap: 8px;
  }

  .speaking-cards-page .recording-box--circle .recorder-action-btn {
    box-sizing: border-box;
    min-height: 44px;
    padding: 6px 12px;
  }

  .speaking-cards-page .recording-box--circle .start-recording-btn {
    box-sizing: border-box;
    order: -1;
    width: 100%;
    max-width: none;
    min-height: 44px;
    grid-column: 1 / -1;
    padding: 12px 16px;
    border: 0;
    border-radius: var(--pill);
    margin: 0;
    /* --chrome-accent, not --brand-purple: this button was grey before this
       tier existed, so it is new chrome rather than furniture already
       wearing the old purple (docs/STYLE_GUIDE.md's rule for the two). */
    background-color: var(--chrome-accent);
    color: var(--surface);
    font-size: 15px;
    font-weight: 700;
  }

  .speaking-cards-page .recording-box--circle .start-recording-btn:hover {
    background-color: var(--chrome-accent-deep);
  }
}
