/* document_reader.css — reproductor de voz unificado al sistema Apple
 * del sitio (pill + border + glow azul). Inspirado en el reproductor
 * minimalista de iOS/Samsung (iconos circulares, animacion de pulso
 * al reproducir, boton stop separado con estado destructivo).
 *
 * Usado por el macro `partials/_document_reader.html` en paginas
 * /legal/* y /faq/*. Las clases JS (`.js-document-reader`,
 * `.js-document-reader-stop`, `.reader-icon`, `.reader-label`,
 * `is-idle`, `is-playing`, `is-paused`) se preservan del sistema
 * anterior para no romper `app/static/js/document_reader.js`.
 */

.document-reader {
  align-items: center;
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

/* Base de ambos botones — look pill unificado con el resto del sitio. */
.document-reader-btn {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--bs-border-radius-pill);
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-weight: 600;
  gap: 0.55rem;
  justify-content: center;
  line-height: 1;
  text-decoration: none;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.2s ease,
    transform 0.15s ease;
  box-shadow: 0 0 0 rgba(0, 122, 255, 0);
  user-select: none;
}

.document-reader-btn:active {
  transform: scale(0.97);
}

.document-reader-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), 0.55);
}

/* ==============================================================
 * PLAY / PAUSE button (ancho, pill con icono circular embebido)
 * ============================================================== */
.document-reader-btn--play {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #ffffff;
  font-size: 0.95rem;
  min-height: 2.5rem;
  padding: 0.35rem 1rem 0.35rem 0.4rem;
}

.document-reader-btn--play .reader-icon {
  align-items: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: inline-flex;
  font-size: 0.95rem;
  height: 1.75rem;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  width: 1.75rem;
}

/* Ancho reservado para el label para que al alternar entre
 * "Escuchar" / "Pausar" / "Reanudar" el boton no cambie de tamanyo.
 * 5rem cubre "Reanudar" (palabra mas larga) con Geist Sans 0.95rem
 * weight 600 con margen de holgura. */
.document-reader-btn--play .reader-label {
  display: inline-block;
  min-width: 5rem;
  padding-right: 0.15rem;
  text-align: center;
}

.document-reader-btn--play:hover {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #ffffff;
  filter: brightness(1.08);
  box-shadow: 0 10px 28px rgba(var(--bs-primary-rgb), 0.45);
}

.document-reader-btn--play:hover .reader-icon {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.05);
}

/* Estado playing: pulso azul alrededor + animacion del icono (onda). */
.document-reader-btn--play.is-playing {
  animation: reader-pulse 1.8s ease-in-out infinite;
}

.document-reader-btn--play.is-playing .reader-icon {
  background: rgba(255, 255, 255, 0.32);
}

.document-reader-btn--play.is-playing .reader-icon i {
  animation: reader-sound 1s ease-in-out infinite;
  display: inline-block;
}

/* Estado paused: icono mas tenue, sin animacion. */
.document-reader-btn--play.is-paused .reader-icon {
  background: rgba(255, 255, 255, 0.24);
}

@keyframes reader-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(var(--bs-primary-rgb), 0.50);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(var(--bs-primary-rgb), 0);
  }
}

@keyframes reader-sound {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  .document-reader-btn--play.is-playing {
    animation: none;
  }
  .document-reader-btn--play.is-playing .reader-icon i {
    animation: none;
  }
}

/* ==============================================================
 * STOP button (circular icon-only, look "ghost" con acento rojo)
 * ============================================================== */
.document-reader-btn--stop {
  background: var(--bs-body-bg);
  border: 1px solid rgba(var(--bs-body-color-rgb), 0.18);
  color: var(--bs-body-color);
  font-size: 1rem;
  height: 2.5rem;
  padding: 0;
  width: 2.5rem;
}

.document-reader-btn--stop:hover {
  background: rgba(var(--bs-danger-rgb), 0.08);
  border-color: var(--bs-danger);
  color: var(--bs-danger);
  box-shadow: 0 0 16px rgba(var(--bs-danger-rgb), 0.35);
}

.document-reader-btn--stop:focus-visible {
  box-shadow: 0 0 0 2px rgba(var(--bs-danger-rgb), 0.55);
}

[data-bs-theme="dark"] .document-reader-btn--stop {
  border-color: rgba(255, 255, 255, 0.14);
}

[data-bs-theme="dark"] .document-reader-btn--stop:hover {
  background: rgba(var(--bs-danger-rgb), 0.14);
  box-shadow: 0 0 20px rgba(var(--bs-danger-rgb), 0.5);
}

/* ==============================================================
 * RESPONSIVE — en pantallas muy estrechas el label puede estorbar.
 * Mantenemos solo el icono circular del play para preservar la
 * altura y dejar aire al titulo de la pagina.
 * ============================================================== */
@media (max-width: 380px) {
  .document-reader-btn--play {
    padding-right: 0.4rem;
  }
  .document-reader-btn--play .reader-label {
    display: none;
  }
}
