/* Commute Edition audio player — docs/AUDIO-COMMUTE-DESIGN.md.
 *
 * The mount is emitted on every in-scope lesson but starts collapsed: it only
 * takes up space once commute-audio.js confirms an episode exists (.is-ready).
 * A lesson without audio therefore looks exactly as it does today.
 */

.ed-audio {
  display: none;
}

.ed-audio.is-ready {
  display: block;
  margin: 0 0 var(--sp-5);
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.ed-audio.is-playing {
  border-color: var(--brand-soft);
  box-shadow: var(--shadow-1);
}

/* ---- header row -------------------------------------------------------- */

.ed-audio__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.ed-audio__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--brand);
}

.ed-audio__hint {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

/* ---- controls ---------------------------------------------------------- */

.ed-audio__controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.ed-audio__play,
.ed-audio__step,
.ed-audio__speed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  border-radius: var(--r-pill);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.ed-audio__play {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  background: var(--brand);
  border-color: transparent;
  color: var(--text-on-brand);
  font-size: 1rem;
}

.ed-audio__play:hover { background: var(--brand-strong); }

.ed-audio__step {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.ed-audio__step:hover,
.ed-audio__speed:hover {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand);
}

.ed-audio__speed {
  min-width: 48px;
  height: 34px;
  padding: 0 var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.ed-audio__play:focus-visible,
.ed-audio__step:focus-visible,
.ed-audio__speed:focus-visible,
.ed-audio__seek:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---- seek bar ---------------------------------------------------------- */

.ed-audio__seek {
  flex: 1 1 auto;
  min-width: 60px;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  cursor: pointer;
}

.ed-audio__seek::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand);
  border: none;
  cursor: pointer;
}

.ed-audio__seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand);
  border: none;
  cursor: pointer;
}

.ed-audio__time {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---- loading (prefetch) -------------------------------------------------
 * The episode is downloaded in full before playback (§4.8), which on a weak
 * mobile connection is ~24s. Without a visible state that reads as broken, so
 * the hint doubles as a progress readout and the play button shows it is busy.
 */

.ed-audio.is-loading .ed-audio__play {
  opacity: .65;
  cursor: progress;
}

.ed-audio.is-loading .ed-audio__hint {
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.ed-audio.is-loading .ed-audio__seek {
  opacity: .5;
  pointer-events: none;
}

/* ---- locked / error states --------------------------------------------- */

.ed-audio__locked {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.ed-audio__locked .fa-lock { color: var(--text-faint); }

.ed-audio.is-error .ed-audio__hint { color: var(--danger); }

/* ---- narrow screens ---------------------------------------------------- */

@media (max-width: 560px) {
  .ed-audio__controls { flex-wrap: wrap; }
  .ed-audio__seek { order: 10; flex-basis: 100%; min-width: 0; }
  .ed-audio__time { order: 11; }
}

@media (prefers-reduced-motion: reduce) {
  .ed-audio__play,
  .ed-audio__step,
  .ed-audio__speed { transition: none; }
}
