/* Lecteur audio officiel Emyjam — habillage custom (pas de contrôles natifs) */

.emyjam-audio-player {
  --audio-player-bg: linear-gradient(145deg, rgba(75, 0, 0, 0.55) 0%, rgba(24, 17, 17, 0.95) 48%, rgba(10, 10, 10, 0.98) 100%);
  --audio-player-border: rgba(139, 0, 0, 0.38);
  --audio-player-accent: var(--color-secondary, #D4AF37);
  --audio-player-play-bg: var(--color-scene-red, #8B0000);
  --audio-player-track: rgba(245, 245, 245, 0.12);
  --audio-player-fill: var(--color-secondary, #D4AF37);
  --audio-player-fill-soft: rgba(212, 175, 55, 0.55);
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 16px 18px;
  border-radius: var(--radius-lg, 14px);
  border: 1px solid var(--audio-player-border);
  background: var(--audio-player-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.emyjam-audio-player__media {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.emyjam-audio-player__layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px 16px;
}

.emyjam-audio-player__play {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--audio-player-play-bg);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(139, 0, 0, 0.35);
  transition:
    transform 0.22s ease,
    background 0.22s ease,
    box-shadow 0.28s ease;
}

.emyjam-audio-player__play:hover {
  background: #a00000;
  transform: scale(1.04);
}

.emyjam-audio-player__play:focus-visible,
.emyjam-audio-player__mute:focus-visible,
.emyjam-audio-player__seek:focus-visible,
.emyjam-audio-player__volume-slider:focus-visible {
  outline: 2px solid var(--audio-player-accent);
  outline-offset: 3px;
}

.emyjam-audio-player__play[aria-pressed="true"] {
  background: var(--color-bordeaux, #4B0000);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* Halo doré discret — lecture active uniquement (classe déjà gérée par JS) */
.emyjam-audio-player.is-playing .emyjam-audio-player__play,
.emyjam-audio-player.is-playing .emyjam-audio-player__play[aria-pressed="true"] {
  background: var(--color-bordeaux, #4B0000);
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.42),
    0 0 14px rgba(212, 175, 55, 0.22),
    0 0 28px rgba(212, 175, 55, 0.12),
    0 6px 16px rgba(0, 0, 0, 0.35);
}

.emyjam-audio-player__play-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition: opacity 0.18s ease;
}

/* display:inline-flex ci-dessus écrase le [hidden] UA — forcer le masquage */
.emyjam-audio-player__play-icon[hidden],
.emyjam-audio-player__mute-icon[hidden] {
  display: none !important;
}

.emyjam-audio-player__play-icon--play {
  margin-left: 1px;
}

.emyjam-audio-player__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.emyjam-audio-player__title {
  margin: 0;
  font-family: var(--font-display, Georgia, serif);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--color-text, #F5F5F5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emyjam-audio-player__timeline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.emyjam-audio-player__time {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted, #BDBDBD);
  min-width: 2.5rem;
}

.emyjam-audio-player__time--duration {
  text-align: right;
}

.emyjam-audio-player__seek,
.emyjam-audio-player__volume-slider {
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  accent-color: var(--audio-player-fill);
}

/* Progression visuelle : or rempli / piste sombre restante */
.emyjam-audio-player__seek {
  --seek-progress: 0%;
  background: linear-gradient(
    to right,
    var(--audio-player-fill) 0%,
    var(--audio-player-fill-soft) var(--seek-progress),
    var(--audio-player-track) var(--seek-progress),
    var(--audio-player-track) 100%
  );
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: background 0.12s linear;
}

.emyjam-audio-player__volume-slider {
  --volume-progress: 100%;
  background: linear-gradient(
    to right,
    var(--audio-player-fill) 0%,
    var(--audio-player-fill) var(--volume-progress),
    var(--audio-player-track) var(--volume-progress),
    var(--audio-player-track) 100%
  );
}

.emyjam-audio-player__seek::-webkit-slider-runnable-track,
.emyjam-audio-player__volume-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.emyjam-audio-player__seek::-moz-range-track,
.emyjam-audio-player__volume-slider::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.emyjam-audio-player__seek::-webkit-slider-thumb,
.emyjam-audio-player__volume-slider::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--audio-player-fill);
  border: 2px solid #1a1212;
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.45),
    0 1px 4px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.emyjam-audio-player__seek::-moz-range-thumb,
.emyjam-audio-player__volume-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--audio-player-fill);
  border: 2px solid #1a1212;
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.45),
    0 1px 4px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.emyjam-audio-player__seek:hover::-webkit-slider-thumb,
.emyjam-audio-player__volume-slider:hover::-webkit-slider-thumb {
  transform: scale(1.08);
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.65),
    0 0 10px rgba(212, 175, 55, 0.25);
}

.emyjam-audio-player__seek:hover::-moz-range-thumb,
.emyjam-audio-player__volume-slider:hover::-moz-range-thumb {
  transform: scale(1.08);
}

.emyjam-audio-player.is-playing .emyjam-audio-player__seek::-webkit-slider-thumb {
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.55),
    0 0 8px rgba(212, 175, 55, 0.2),
    0 1px 4px rgba(0, 0, 0, 0.45);
}

.emyjam-audio-player__volume {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 108px;
}

.emyjam-audio-player__mute {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(139, 0, 0, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-muted, #BDBDBD);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.emyjam-audio-player__mute:hover {
  color: var(--color-text, #F5F5F5);
  border-color: rgba(212, 175, 55, 0.45);
}

.emyjam-audio-player__volume-slider {
  width: 72px;
  flex-shrink: 0;
}

.emyjam-audio-player--compact {
  padding: 12px 14px;
}

.emyjam-audio-player--compact .emyjam-audio-player__play {
  width: 40px;
  height: 40px;
}

.emyjam-audio-player--compact .emyjam-audio-player__title {
  font-size: 0.9rem;
}

.emyjam-audio-player--compact .emyjam-audio-player__volume {
  display: none;
}

.activity-card__media--audio .activity-card__media-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: linear-gradient(165deg, rgba(139, 0, 0, 0.22), rgba(20, 20, 20, 0.08));
  min-height: 120px;
}

.activity-card__media--audio .emyjam-audio-player {
  max-width: 100%;
}

@media (max-width: 640px) {
  .emyjam-audio-player__layout {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .emyjam-audio-player__volume {
    grid-column: 1 / -1;
    justify-content: flex-end;
    min-width: 0;
  }

  .emyjam-audio-player__volume-slider {
    width: min(140px, 40vw);
  }
}

@media (prefers-reduced-motion: reduce) {
  .emyjam-audio-player__play,
  .emyjam-audio-player__seek,
  .emyjam-audio-player__play-icon,
  .emyjam-audio-player__mute,
  .emyjam-audio-player__seek::-webkit-slider-thumb,
  .emyjam-audio-player__volume-slider::-webkit-slider-thumb,
  .emyjam-audio-player__seek::-moz-range-thumb,
  .emyjam-audio-player__volume-slider::-moz-range-thumb {
    transition: none;
  }
}
