/* ==================================================================
   Audiolibro: ventana flotante con el vídeo de YouTube del libro
   (assets/js/ui/audio-player.js) y chip «Escuchar» del lector.
   ================================================================== */

.audio-player {
  --ap-w: 236px;
  --ap-gap: 18px;
  --ap-bottom: calc(var(--ap-gap) + var(--safe-b));
  position: fixed;
  z-index: 90;
  width: var(--ap-w);
  border-radius: 16px;
  overflow: hidden;
  background: color-mix(in oklab, var(--ink) 92%, var(--bg));
  color: var(--bg);
  box-shadow: 0 1px 0 rgb(255 255 255 / .06) inset, 0 18px 40px -16px rgb(0 0 0 / .55), 0 2px 6px rgb(0 0 0 / .18);
  opacity: 0;
  scale: .92;
  transition: opacity var(--dur-3) var(--ease-out), scale var(--dur-3) var(--ease-spring), width var(--dur-3) var(--ease-out),
              inset var(--dur-3) var(--ease-out);
}
.audio-player.is-open { opacity: 1; scale: 1; }
.audio-player.is-big { --ap-w: min(420px, calc(100vw - 2 * var(--ap-gap))); }
.audio-player.is-dragging { transition: none; opacity: .92; cursor: grabbing; }

/* Esquinas */
.audio-player[data-corner="br"] { right: var(--ap-gap); bottom: var(--ap-bottom); transform-origin: bottom right; }
.audio-player[data-corner="bl"] { left: calc(var(--rail-w, 0px) + var(--ap-gap)); bottom: var(--ap-bottom); transform-origin: bottom left; }
.audio-player[data-corner="tr"] { right: var(--ap-gap); top: calc(var(--ap-gap) + var(--safe-t, 0px)); transform-origin: top right; }
.audio-player[data-corner="tl"] { left: calc(var(--rail-w, 0px) + var(--ap-gap)); top: calc(var(--ap-gap) + var(--safe-t, 0px)); transform-origin: top left; }

.ap-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 4px 5px 10px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.ap-title {
  flex: 1;
  min-width: 0;
  display: grid;
  text-align: left;
  padding: 2px 4px;
  border-radius: 8px;
  color: inherit;
  line-height: 1.2;
}
.ap-title:hover { background: rgb(255 255 255 / .08); }
.ap-title b {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ap-title b::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 7px 2px 0;
  border-radius: 50%;
  background: color-mix(in oklab, var(--bg) 45%, transparent);
  vertical-align: middle;
}
.is-playing .ap-title b::before { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 30%, transparent); animation: ap-pulse 1.6s var(--ease-in-out) infinite; }
@keyframes ap-pulse { 50% { box-shadow: 0 0 0 5px color-mix(in oklab, var(--accent) 0%, transparent); } }
.ap-title small {
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
  opacity: .7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ap-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  color: inherit;
  opacity: .75;
}
.ap-btn:hover { opacity: 1; background: rgb(255 255 255 / .1); }
.ap-btn .icon { width: 16px; height: 16px; }

.ap-video { aspect-ratio: 16 / 9; background: #000; }
.ap-video iframe { display: block; width: 100%; height: 100%; border: 0; }
.is-dragging .ap-video iframe { pointer-events: none; }

/* Móvil: por encima de la barra inferior (y de la barra de versículos si está abierta) */
@media (max-width: 760px) {
  .audio-player { --ap-w: 200px; --ap-gap: 10px; --ap-bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); }
  .audio-player.is-big { --ap-w: calc(100vw - 20px); }
  .audio-player[data-corner="bl"], .audio-player[data-corner="tl"] { left: var(--ap-gap); }
  .has-dock .audio-player[data-corner^="b"] { --ap-bottom: calc(var(--tabbar-h) + var(--safe-b) + 140px); }
  .is-immersive .audio-player[data-corner^="b"] { --ap-bottom: calc(var(--safe-b) + 10px); }
}
@media (min-width: 761px) {
  .has-dock .audio-player[data-corner^="b"] { --ap-bottom: calc(var(--ap-gap) + var(--safe-b) + 64px); }
}
@media (prefers-reduced-motion: reduce) { .audio-player { transition: opacity var(--dur-2); scale: 1; } }

/* Chip del capítulo */
.audio-chip { display: contents; }
.chip-audio { color: var(--accent); border-color: var(--accent-line); gap: .4em; }
.chip-audio:hover { background: var(--accent-soft); }
.chip-audio small { opacity: .7; font-size: .92em; }
.chip-audio.is-on { background: var(--accent-soft); }
.ap-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; margin-left: 2px; }
.ap-eq i { width: 2px; height: 100%; border-radius: 1px; background: currentColor; animation: ap-eq 1s var(--ease-in-out) infinite; }
.ap-eq i:nth-child(2) { animation-delay: -.3s; }
.ap-eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes ap-eq { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
.ap-eq i { transform-origin: bottom; }
.btn-listen small { opacity: .65; font-size: .85em; margin-left: .15em; }
