/* ==========================================================================
   Lesson voiceovers (components/lesson-voiceover.js)

   A quiet "Listen" button at the top of each lesson opens an inline player
   with a seek bar, skips, speed and a transcript that follows the voice. A
   small floating player appears while audio plays out of view.
   ========================================================================== */

.vo { margin: 0 0 1rem; }

.vo-listen {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 40px;
  padding: 0.35rem 0.9rem 0.35rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-color);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.vo-listen:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent-color) 45%, var(--border-color)); }
.vo-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.vo-listen .vo-icon { color: var(--accent-color); }
.vo-play .vo-icon, .vo-mini-play .vo-icon { width: 20px; height: 20px; }
.vo-skip { display: inline-flex !important; gap: 0.2rem; font-variant-numeric: tabular-nums; }
.vo-skip span { font-size: 0.72rem; }
.vo-listen-len {
  color: var(--text-secondary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.vo-listen-len::before { content: "·"; margin-right: 0.45rem; }
.vo-listen[hidden], .vo-player[hidden], .vo-transcript[hidden], .vo-mini[hidden] { display: none !important; }

.vo-player {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--surface-1);
  box-shadow: 0 1px 2px rgba(35, 29, 46, 0.06);
}
.vo.has-transcript .vo-player { border-radius: 22px 22px 0 0; border-bottom-color: transparent; }

.vo-player button, .vo-mini button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 36px;
  height: 36px;
  padding: 0 0.55rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-color);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
}
.vo-player button:hover, .vo-mini button:hover { background: var(--surface-2); }
.vo-player button:focus-visible, .vo-listen:focus-visible, .vo-seek:focus-visible, .vo-para:focus-visible, .vo-mini button:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}
.vo-player .vo-play, .vo-mini .vo-mini-play {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  background: var(--accent-color);
  color: #fff;
}
.vo-player .vo-play:hover, .vo-mini .vo-mini-play:hover { background: var(--accent-hover, var(--accent-color)); }
body.dark .vo-player .vo-play, body.dark .vo-mini .vo-mini-play { color: #2b2140; }
.vo-tx { display: inline-flex !important; gap: 0.35rem; }
.vo-tx[aria-expanded="true"] { background: var(--surface-2) !important; }
.vo-rate { min-width: 46px !important; font-variant-numeric: tabular-nums; }

.vo-seek {
  --vo-p: 0%;
  flex: 1 1 auto;
  min-width: 60px;
  height: 36px;
  margin: 0 0.25rem;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.vo-seek::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent-color) var(--vo-p), var(--surface-3, #e6e1ec) var(--vo-p));
}
.vo-seek::-moz-range-track { height: 5px; border-radius: 999px; background: var(--surface-3, #e6e1ec); }
.vo-seek::-moz-range-progress { height: 5px; border-radius: 999px; background: var(--accent-color); }
.vo-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--accent-color);
  border: 2px solid var(--surface-1);
  box-shadow: 0 0 0 1px var(--accent-color);
}
.vo-seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-color);
  border: 2px solid var(--surface-1);
}
.vo-time {
  flex: 0 0 auto;
  min-width: 5.8rem;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.vo-transcript {
  max-height: 16rem;
  overflow-y: auto;
  margin: 0 !important;
  padding: 0.35rem 0.45rem 0.5rem !important;
  border: 1px solid var(--border-color);
  border-top: 1px dashed var(--border-color);
  border-radius: 0 0 22px 22px;
  background: var(--surface-1);
  list-style: none;
  overscroll-behavior: contain;
}
.vo-transcript li { margin: 0 !important; padding: 0 !important; }
.vo-transcript li::before { content: none !important; }
.vo-para {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: left;
  cursor: pointer;
}
.vo-para:hover { background: var(--surface-2); color: var(--text-color); }
.vo-para.is-current { background: color-mix(in srgb, var(--accent-color) 9%, transparent); color: var(--text-color); }
.vo-para-time { flex: 0 0 2.6rem; font-size: 0.78rem; line-height: 1.95; font-variant-numeric: tabular-nums; opacity: 0.8; }

/* Floating player while the lesson player is out of view. */
.vo-mini {
  position: fixed;
  right: 96px;
  bottom: 22px;
  z-index: 1400;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem;
  width: min(360px, calc(100vw - 110px));
  padding: 0.45rem 0.45rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-1) 96%, transparent);
  box-shadow: 0 10px 30px rgba(35, 29, 46, 0.16);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.vo-mini .vo-mini-title {
  display: grid !important;
  place-items: start !important;
  justify-content: stretch;
  height: auto !important;
  min-height: 40px;
  padding: 0.15rem 0.4rem !important;
  border-radius: 10px !important;
  text-align: left;
  overflow: hidden;
}
.vo-mini-kicker { color: var(--text-secondary); font-size: 0.68rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.vo-mini-label { display: block; width: 100%; overflow: hidden; font-size: 0.85rem; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.vo-mini-track {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 6px;
  height: 3px;
  border-radius: 999px;
  background: var(--surface-3, #e6e1ec);
  overflow: hidden;
}
.vo-mini-progress { display: block; width: 0; height: 100%; background: var(--accent-color); }

@media (max-width: 640px) {
  .vo-player { flex-wrap: wrap; border-radius: 20px; row-gap: 0.1rem; }
  .vo-seek { order: 10; flex-basis: 100%; margin: 0; }
  .vo-time { min-width: 0; margin-left: auto; }
  .vo-skip { display: none !important; }
  .vo-tx span { display: none; }
  .vo.has-transcript .vo-player { border-radius: 20px 20px 0 0; }
  .vo-mini { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); width: auto; }
}

@media print { .vo, .vo-mini { display: none !important; } }
