/* =========================================
   REPRODUCTOR DE AUDIO

   IMPORTANTE: el comportamiento "fijo abajo + se ancla al footer"
   se consigue con position: sticky en lugar de fixed + JS.
   Esto elimina el bug de salto al hacer scroll rápido.

   Estructura HTML necesaria:
     <div class="player-stage">
       <div class="audio-player">...</div>
     </div>
     <footer>...</footer>

   El .player-stage envuelve toda la zona donde queremos que el
   player esté visible (desde el final del hero hasta antes del
   footer). El .audio-player con sticky se queda pegado abajo
   mientras estemos dentro de .player-stage.
   ========================================= */

.player-stage {
  position: relative;
  /* El stage no necesita altura fija: ya la aporta el contenido (main).
     Solo nos aseguramos de que el sticky tenga contexto. */
}

.audio-player {
  position: sticky;
  bottom: 0;
  height: var(--player-h);
  z-index: 999;
  background: linear-gradient(135deg, rgba(15, 73, 81, 0.85) 0%, rgba(30, 118, 130, 0.85) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(68, 220, 241, 0.22);
  box-shadow: 0 -8px 32px rgba(15, 73, 81, 0.25);
  /* Nota: NO transition en bottom/position. Sticky se mueve solo. */
}

.player-inner {
  max-width: var(--max-w);
  height: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  color: var(--blanco);
}

/* === Botón play/pause === */
.play-btn {
  flex-shrink: 0;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--lima);
  color: var(--teal-muy-oscuro);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.3s var(--ease);
  position: relative;
}
.play-btn:hover {
  background: var(--lima-suave);
  transform: scale(1.08);
  box-shadow: var(--sombra-lima);
}
.play-btn svg { width: 22px; height: 22px; }
.play-btn .icon-pause { display: none; }
.play-btn.playing .icon-play { display: none; }
.play-btn.playing .icon-pause { display: block; }

/* Pulso cuando reproduce */
.play-btn.playing::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--lima);
  animation: pulse-ring 1.5s ease-out infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Estado cargando */
.play-btn.loading { pointer-events: none; }
.play-btn.loading::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--teal-muy-oscuro);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.play-btn.loading svg { opacity: 0.3; }

/* === Info === */
.player-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.live-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(220, 53, 69, 0.18);
  border: 1px solid rgba(220, 53, 69, 0.4);
  color: #ff7080;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1px;
}
.live-badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ff4757;
  animation: live-blink 1.5s ease-in-out infinite;
}
@keyframes live-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.player-text {
  min-width: 0;
  flex: 1;
}
.player-text .titulo {
  font-family: var(--fuente-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--blanco);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-text .subtitulo {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Ondas === */
.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
}
.waveform span {
  display: block;
  width: 3px;
  background: var(--cian);
  border-radius: 2px;
  height: 30%;
  transition: height 0.2s ease;
}
.audio-player.is-playing .waveform span {
  animation: wave 1.2s ease-in-out infinite;
}
.waveform span:nth-child(1) { animation-delay: 0s; }
.waveform span:nth-child(2) { animation-delay: 0.15s; }
.waveform span:nth-child(3) { animation-delay: 0.3s; }
.waveform span:nth-child(4) { animation-delay: 0.45s; }
.waveform span:nth-child(5) { animation-delay: 0.6s; }
@keyframes wave {
  0%, 100% { height: 25%; }
  50% { height: 90%; }
}

/* === Volumen === */
.volume-control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
.volume-control svg {
  width: 20px; height: 20px;
  color: rgba(255, 255, 255, 0.7);
}
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--cian);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, background 0.2s ease;
}
.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--lima);
}
.volume-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--cian);
  border: none;
  cursor: pointer;
}
/* === Info de la canción en directo === */
#player-info {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
}

#player-info > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#titulo {
  font-family: var(--fuente-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--blanco);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#artista {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Responsive === */
@media (max-width: 640px) {
  :root { --player-h: 68px; }
  .player-inner { padding: 0 0.8rem; gap: 0.8rem; }
  .volume-control, .waveform { display: none; }
  .play-btn { width: 44px; height: 44px; }
  .player-text .titulo { font-size: 0.9rem; }
  .player-text .subtitulo { font-size: 0.7rem; }
  #titulo { font-size: 0.85rem; }
  #artista { font-size: 0.72rem; }
}
