/* =========================================================
   Audiobook Player — Shared Styles
   Self-contained player UI for narrated lesson companions.
   Loaded alongside micro.css on audiobook-enabled lessons.
   ========================================================= */

/* ── Hero "Listen" Button — mirrors .go-btn shape exactly ── */
.ab-hero-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, rgba(232,168,124,0.15) 0%, rgba(212,120,90,0.15) 100%);
  border: 1px solid rgba(232, 168, 124, 0.3);
  border-radius: 50px;
  padding: .9rem 2.5rem;
  color: var(--warm);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all .25s;
  margin-top: 0.75rem;
}
.ab-hero-btn:hover {
  background: linear-gradient(135deg, rgba(232,168,124,0.25) 0%, rgba(212,120,90,0.25) 100%);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(232, 168, 124, 0.15);
}
.ab-hero-btn svg {
  width: 16px;
  height: 16px;
  fill: var(--warm);
  flex-shrink: 0;
}
.ab-hero-duration {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text3);
  margin-left: 0.25rem;
}

/* ── Resume prompt ─────────────────────────────────────── */
.ab-resume {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text3);
  margin-top: 0.25rem;
  text-align: center;
}

/* ── Sticky Bottom Bar ─────────────────────────────────── */
.ab-float {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
  padding: 1.5rem 1.5rem 1rem;
  z-index: 9100;
  pointer-events: none;
  transform: translateY(100%);
  transition: transform 0.4s var(--ease-spring);
}
.ab-float.visible {
  display: block;
  transform: translateY(0);
  pointer-events: auto;
}

.ab-bar {
  background: var(--surface, #161a26) !important;
  border: 1px solid var(--border, #232939) !important;
  border-radius: 14px !important;
  padding: 0.75rem 1rem !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -4px 30px rgba(0,0,0,0.4);
  cursor: pointer;
}

/* ── Play/Pause Button ─────────────────────────────────── */
.ab-play {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #e8a87c, #d4785a) !important;
  border: none !important;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  transition: transform 0.2s;
  padding: 0 !important;
  margin: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.ab-play:hover { transform: scale(1.08); }
.ab-play:active { transform: scale(0.95); }
.ab-play svg {
  fill: #0b0d14 !important;
  width: 16px !important;
  height: 16px !important;
}
.ab-play .play-icon { margin-left: 2px; }

/* ── Track Info ────────────────────────────────────────── */
.ab-info {
  flex: 1;
  min-width: 0;
}
.ab-chapter {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.ab-time {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text3);
  margin-top: 2px;
}

/* ── Waveform (desktop only) ───────────────────────────── */
.ab-wave {
  flex: 1;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 1.5px;
  cursor: pointer;
  min-width: 80px;
}
.ab-wave-bar {
  flex: 1;
  background: var(--border2);
  border-radius: 1px;
  min-width: 2px;
  transition: background 0.15s;
}
.ab-wave-bar.played { background: var(--warm); }
.ab-wave-bar.current {
  background: var(--warm);
  box-shadow: 0 0 6px rgba(232, 168, 124, 0.4);
}

/* ── Speed Toggle ──────────────────────────────────────── */
.ab-speed {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
}
.ab-speed:hover {
  color: var(--text);
  border-color: var(--border2);
}

/* ── Lock (tab-sync toggle) ────────────────────────────── */
.ab-lock {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text4);
  flex-shrink: 0;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.ab-lock:hover { color: var(--text2); background: rgba(255,255,255,0.05); }
.ab-lock.locked { color: var(--warm); }
.ab-lock svg { width: 14px; height: 14px; fill: currentColor; }

/* ── Close Button ──────────────────────────────────────── */
.ab-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text4);
  flex-shrink: 0;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.ab-close:hover { color: var(--text2); background: rgba(255,255,255,0.05); }
.ab-close svg { width: 14px; height: 14px; }

/* ── Notes FAB shift when player is active ─────────────── */
.ab-playing .nb-floating-btn {
  bottom: 80px !important;
  transition: bottom 0.3s var(--ease-spring);
}

/* ── Expanded View ─────────────────────────────────────── */
.ab-expanded {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  z-index: 9200;
  transform: translateY(100%);
  transition: transform 0.4s var(--ease-spring);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.ab-expanded.visible {
  transform: translateY(0);
}

.ab-expanded-handle {
  width: 36px;
  height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 8px auto;
  flex-shrink: 0;
}

.ab-expanded-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ab-expanded-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ab-expanded-title svg { width: 16px; height: 16px; fill: var(--warm); }
.ab-expanded-close {
  color: var(--text3);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.ab-expanded-close:hover { color: var(--text); background: var(--surface); }

/* ── Chapter List ──────────────────────────────────────── */
.ab-chapters {
  padding: 0.5rem 0;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.ab-ch-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  transition: background 0.15s;
}
.ab-ch-item:hover { background: rgba(232, 168, 124, 0.04); }
.ab-ch-item.active { background: rgba(232, 168, 124, 0.06); }
.ab-ch-item.played { opacity: 0.5; }

.ab-ch-num {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text4);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}
.ab-ch-item.active .ab-ch-num { color: var(--warm); }

.ab-ch-name {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--text2);
  flex: 1;
}
.ab-ch-item.active .ab-ch-name { color: var(--text); font-weight: 500; }

.ab-ch-dur {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text4);
  flex-shrink: 0;
}

/* Equalizer animation */
.ab-ch-eq {
  display: none;
  gap: 2px;
  align-items: flex-end;
  height: 12px;
  flex-shrink: 0;
}
.ab-ch-item.active .ab-ch-eq { display: flex; }
.ab-ch-eq span {
  width: 2px;
  background: var(--warm);
  border-radius: 1px;
  animation: ab-eq 0.8s ease-in-out infinite alternate;
}
.ab-ch-eq span:nth-child(1) { height: 4px; animation-delay: 0s; }
.ab-ch-eq span:nth-child(2) { height: 8px; animation-delay: 0.15s; }
.ab-ch-eq span:nth-child(3) { height: 5px; animation-delay: 0.3s; }
.ab-ch-eq span:nth-child(4) { height: 10px; animation-delay: 0.1s; }
@keyframes ab-eq {
  0% { transform: scaleY(0.4); }
  100% { transform: scaleY(1); }
}

/* ── Full Transport Controls ───────────────────────────── */
.ab-progress-wrap {
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ab-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 0.25rem 0 0.5rem;
}
.ab-ctrl-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.ab-ctrl-btn:hover { color: var(--text); }
.ab-ctrl-btn svg { width: 18px; height: 18px; fill: currentColor; }

.ab-ctrl-play {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--warm), var(--warm2));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s var(--ease-spring);
}
.ab-ctrl-play:hover { transform: scale(1.06); }
.ab-ctrl-play:active { transform: scale(0.95); }
.ab-ctrl-play svg {
  width: 20px;
  height: 20px;
  fill: var(--bg);
}
.ab-ctrl-play .play-icon { margin-left: 2px; }

/* ── Progress Bar ──────────────────────────────────────── */
.ab-progress-track {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  margin-bottom: 0.5rem;
}
.ab-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--warm), var(--warm2));
  border-radius: 2px;
  position: relative;
  transition: width 0.3s linear;
}
.ab-progress-fill::after {
  content: '';
  position: absolute;
  right: -5px;
  top: -4px;
  width: 12px;
  height: 12px;
  background: var(--warm);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(232, 168, 124, 0.4);
  opacity: 0;
  transition: opacity 0.15s;
}
.ab-progress-track:hover .ab-progress-fill::after { opacity: 1; }

.ab-progress-times {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text3);
}

/* ── Backdrop ──────────────────────────────────────────── */
.ab-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.ab-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 600px) {
  .ab-wave { display: none; }
  .ab-float { padding: 0.75rem 0.75rem 0.5rem; }
  .ab-bar { padding: 0.5rem 0.75rem; gap: 0.5rem; }
  .ab-play { width: 32px; height: 32px; }
  .ab-play svg { width: 12px; height: 12px; }
  .ab-chapter { font-size: 0.65rem; }
  .ab-time { font-size: 0.55rem; }
  .ab-expanded { max-height: 85vh; }
  .ab-hero-btn { justify-content: center; }
}

/* ── Light theme ───────────────────────────────────────── */
[data-theme="light"] .ab-bar {
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .ab-backdrop {
  background: rgba(0, 0, 0, 0.3);
}
