/* Audio player bar and transcript panel for training narration */

/* ── Audio Player Bar ────────────────────────────────────────── */

.audio-player-bar {
  position: sticky;
  top: 6rem;
  z-index: 2;
  height: 2.75rem;
  background-color: #fafafa;
  border-bottom: 1px solid #e1e1e1;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  padding: 0 0.75rem;
  gap: 0.5rem;
  font-family: Roboto, sans-serif;
  font-size: 0.83333rem;
  color: #333;
}

/* Adjust TOC sidebar sticky offset when audio bar is present */

body.has-audio-player .toc.sidebar .toc-menu {
  top: 8.75rem;
}

body.has-audio-player .toc.sidebar .toc-menu ul {
  max-height: calc(100vh - 11.25rem);
}

/* ── Buttons ─────────────────────────────────────────────────── */

.audio-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #333;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  line-height: 1;
  font-family: inherit;
}

.audio-btn:hover {
  background: #e1e1e1;
}

.audio-btn:focus-visible {
  outline: 2px solid #1565c0;
  outline-offset: 2px;
}

.audio-icon {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
  display: block;
}

.audio-play-pause .audio-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.audio-speed-select {
  font-family: Roboto, sans-serif;
  font-weight: 500;
  font-size: 0.77778rem;
  color: #333;
  background: #fff;
  border: 1px solid #e1e1e1;
  border-radius: 0.25rem;
  padding: 0.125rem 0.25rem;
  height: 1.75rem;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23333' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.375rem center;
  padding-right: 1.25rem;
}

.audio-speed-select:hover {
  border-color: #c1c1c1;
}

.audio-speed-select:focus-visible {
  outline: 2px solid #1565c0;
  outline-offset: 2px;
}

/* ── Progress Bar ────────────────────────────────────────────── */

.audio-progress-wrap {
  -webkit-box-flex: 1;
  -ms-flex: 1 1;
  flex: 1 1;
  height: 2.75rem;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  cursor: pointer;
  padding: 0 0.25rem;
}

.audio-progress-track {
  width: 100%;
  height: 4px;
  background: #e1e1e1;
  border-radius: 2px;
  position: relative;
}

.audio-progress-fill {
  height: 100%;
  background: #1565c0;
  border-radius: 2px;
  width: 0%;
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.audio-progress-handle {
  width: 12px;
  height: 12px;
  background: #1565c0;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 0%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.audio-progress-wrap:hover .audio-progress-track {
  height: 6px;
}

.audio-progress-wrap:focus-visible {
  outline: 2px solid #1565c0;
  outline-offset: 2px;
}

/* ── Time Display ────────────────────────────────────────────── */

.audio-time {
  font-variant-numeric: tabular-nums;
  font-size: 0.77778rem;
  color: #5d5d5d;
  white-space: nowrap;
  min-width: 2.5rem;
  text-align: center;
}

/* ── Loading / Error ─────────────────────────────────────────── */

.audio-loading {
  font-size: 0.77778rem;
  color: #8e8e8e;
  font-style: italic;
}

.audio-error {
  font-size: 0.77778rem;
  color: #d32f2f;
}

/* ── Transcript Panel ────────────────────────────────────────── */

.transcript-panel {
  display: none;
}

.transcript-header {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e1e1e1;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.transcript-title {
  font-size: 0.83333rem;
  font-weight: 500;
  color: #333;
  margin: 0;
  line-height: 1.3;
}

.transcript-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #5d5d5d;
  padding: 0 0.25rem;
  line-height: 1;
}

.transcript-close:hover {
  color: #333;
}

.transcript-close:focus-visible {
  outline: 2px solid #1565c0;
  outline-offset: 2px;
}

.transcript-body {
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  font-size: 0.83333rem;
  line-height: 1.5;
  color: #5d5d5d;
  -webkit-box-flex: 1;
  -ms-flex: 1 1;
  flex: 1 1;
}

.transcript-segment {
  margin: 0;
  padding: 0.25rem 0.375rem;
  border-radius: 0.25rem;
  cursor: pointer;
  -webkit-transition: background-color 150ms ease;
  transition: background-color 150ms ease;
}

.transcript-segment + .transcript-segment {
  margin-top: 0.25rem;
}

.transcript-segment:hover {
  background: #f0f0f0;
}

.transcript-segment.is-active {
  background: #e8f0fe;
  color: #333;
}

.transcript-text {
  margin: 0;
  padding: 0.25rem 0;
}

.transcript-text + .transcript-text {
  margin-top: 0.5rem;
}

.transcript-empty {
  color: #8e8e8e;
  font-style: italic;
  padding: 0.5rem 0;
}

/* ── Desktop Layout ──────────────────────────────────────────── */

@media screen and (min-width: 1024px) {
  .transcript-panel.is-visible {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-flex: 0;
    -ms-flex: 0 0 16rem;
    flex: 0 0 16rem;
    -webkit-box-ordinal-group: 3;
    -ms-flex-order: 2;
    order: 2;
    position: sticky;
    top: 8.75rem;
    max-height: calc(100vh - 8.75rem);
  }

  body:not(.has-audio-player) .transcript-panel.is-visible {
    top: 6rem;
    max-height: calc(100vh - 6rem);
  }
}

/* ── Mobile ──────────────────────────────────────────────────── */

@media screen and (max-width: 1023.5px) {
  .audio-player-bar {
    padding: 0 0.5rem;
    gap: 0.375rem;
  }

  .audio-time-duration {
    display: none;
  }

  .audio-transcript-toggle {
    display: none;
  }

  .transcript-panel {
    display: none !important;
  }
}

/* ── Print ───────────────────────────────────────────────────── */

@media print {
  .audio-player-bar,
  .transcript-panel {
    display: none !important;
  }
}

/* ── Reduced Motion ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .transcript-segment {
    -webkit-transition: none;
    transition: none;
  }
}
