/* ==========================================================================
   Lecteur audio a2prl.fr — direction « Halo » (maquette M, sur la base de H)
   Surcouche sur le lecteur WordPress (MediaElement, thème legacy). Le balisage
   est celui de WordPress ; les réglages (hauteur 52 px, pas de volume, format
   m:ss) sont passés par le filtre mejs_settings dans a2prl-habillage.php.
   Tant qu'on n'a jamais lancé le son : seul le bouton est visible, entouré
   d'un halo qui respire, avec le mot « Écouter ». Au premier appui (classe
   a2prl-lecteur--demarre posée par le script) : le mot s'efface, le trait se
   déploie depuis le bouton, puis le temps restant apparaît. En pause, tout
   reste. Trait de 3 px cerné de blanc, point cerclé, temps en gras.
   Le script a2prl/lecteur.js pose la variante (--sombre, --magenta) d'après le
   fond réel, affiche le temps restant et pilote le glisser.

   Les sélecteurs du trait sont longs à dessein : wp-mediaelement.css pose
   « .mejs-controls .mejs-time-rail .mejs-time-current { background:#0073aa } »
   et « .mejs-controls .mejs-time-rail span { border-radius:0 } », il faut passer
   au-dessus (0,4,0).
   ========================================================================== */

/* ── Conteneur : rien ─────────────────────────────────────────────────── */
.mejs-container.wp-audio-shortcode {
    background: transparent !important;
    border: 0;
    box-sizing: border-box;
    height: 52px !important;
    min-height: 52px;
    margin: 0;
    padding: 0;
    overflow: visible;
}
.mejs-container.wp-audio-shortcode * {
    font-family: -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}
.wp-audio-shortcode .mejs-inner,
.wp-audio-shortcode .mejs-layers {
    background: transparent;
}
.wp-audio-shortcode .mejs-controls {
    background: transparent !important;
    position: absolute;
    inset: 0;
    height: 100%;
    padding: 0 4px 0 0;
    align-items: center;
    box-sizing: border-box;
    overflow: visible;
}

/* ── Bouton lecture ───────────────────────────────────────────────────── */
.wp-audio-shortcode .mejs-playpause-button {
    flex: none;
    width: 44px;
    height: 44px;
    margin: 0;
}
.wp-audio-shortcode .mejs-playpause-button > button {
    position: relative;
    isolation: isolate;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: #17161a;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M8 5v14l11-7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 22px 22px;
    box-shadow: 0 8px 18px -8px rgba(23, 22, 26, 0.7);
    transition: background-color .2s ease, transform .15s ease, box-shadow .2s ease;
}
.wp-audio-shortcode .mejs-playpause-button > button:hover {
    transform: scale(1.06);
}
.wp-audio-shortcode .mejs-playpause-button > button:focus-visible {
    outline: 2px solid #b51f69;
    outline-offset: 3px;
}
.wp-audio-shortcode .mejs-playpause-button.mejs-pause > button,
.wp-audio-shortcode .mejs-playpause-button.mejs-replay > button {
    background-color: #b51f69;
    box-shadow: 0 8px 18px -8px rgba(181, 31, 105, 0.8);
}
.wp-audio-shortcode .mejs-playpause-button.mejs-pause > button {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='5' width='4' height='14' rx='1' fill='%23ffffff'/%3E%3Crect x='14' y='5' width='4' height='14' rx='1' fill='%23ffffff'/%3E%3C/svg%3E");
}

/* ── Avant la première lecture : bouton seul, halo, « Écouter » ─────────── */
@keyframes a2prl-halo {
    0%, 100% { transform: scale(0.9); opacity: 0.35; }
    50%      { transform: scale(1.3); opacity: 0; }
}
.wp-audio-shortcode .mejs-playpause-button > button::before {
    content: "";
    position: absolute;
    inset: -5px;
    z-index: -1;
    border-radius: 50%;
    background: #b51f69;
    opacity: 0.35;
    animation: a2prl-halo 2.4s ease-in-out infinite;
    transition: opacity .3s ease;
}
.wp-audio-shortcode.a2prl-lecteur--demarre .mejs-playpause-button > button::before {
    animation: none;
    opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
    .wp-audio-shortcode .mejs-playpause-button > button::before { animation: none; opacity: 0.25; }
}
/* Le mot « Écouter » (posé par lecteur.js), qui se replie au premier appui */
.wp-audio-shortcode .a2prl-ecouter {
    flex: none;
    max-width: 140px;
    margin-left: 16px;
    overflow: hidden;
    color: #17161a;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1;
    white-space: nowrap;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
    cursor: pointer;
    user-select: none;
    transition: opacity .25s ease, max-width .4s cubic-bezier(.2,.7,.2,1), margin-left .4s cubic-bezier(.2,.7,.2,1);
}
.wp-audio-shortcode.a2prl-lecteur--demarre .a2prl-ecouter {
    opacity: 0;
    max-width: 0;
    margin-left: 0;
    pointer-events: none;
}
/* Le trait et le temps : cachés, puis révélés en cascade au premier appui
   (le trait glisse et se déploie depuis le bouton, le temps suit) */
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail {
    opacity: 0;
    transform: translateX(-14px);
    pointer-events: none;
    transition: opacity .45s cubic-bezier(.2,.7,.2,1) .1s, transform .45s cubic-bezier(.2,.7,.2,1) .1s;
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--demarre .mejs-controls .mejs-time-rail {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-total {
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform .55s cubic-bezier(.2,.7,.2,1) .15s;
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--demarre .mejs-controls .mejs-time-rail .mejs-time-total {
    transform: scaleX(1);
}
.wp-audio-shortcode .mejs-duration-container {
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity .4s ease .45s, transform .4s ease .45s;
}
.wp-audio-shortcode.a2prl-lecteur--demarre .mejs-duration-container {
    opacity: 1;
    transform: none;
}

/* ── Trait ────────────────────────────────────────────────────────────── */
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail {
    display: flex;
    align-items: center;
    height: 100%;
    margin: 0 16px;
    padding: 0;
}
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-total {
    position: relative;
    width: 100%;
    height: 3px;
    margin: 0;
    border-radius: 2px;
    background: rgba(23, 22, 26, 0.28);
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.75); /* liseré blanc : le trait se lit sur une photo */
    cursor: pointer;
    touch-action: none;
}
/* Zone de prise de 32 px de haut autour du trait : on l'attrape sans viser */
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-total::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -15px;
    bottom: -15px;
}
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-buffering,
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-loaded,
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-hovered,
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-current {
    height: 3px;
    border-radius: 2px;
    transition: none;
    animation: none;
}
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-buffering,
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-loaded {
    background: rgba(23, 22, 26, 0.1);
}
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-hovered {
    background: rgba(181, 31, 105, 0.3);
}
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-current {
    background: #b51f69;
}

/* ── Point ────────────────────────────────────────────────────────────── */
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-handle {
    top: 0;
    width: 0;
    height: 0;
    border: 0;
    transition: none;
}
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-handle-content {
    width: 14px;
    height: 14px;
    left: -7px;
    top: -5.5px;
    box-sizing: border-box;
    border: 2.5px solid #ffffff;
    border-radius: 50%;
    background: #b51f69;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transform: scale(0);
    transition: transform .15s ease;
}
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail:hover .mejs-time-handle-content,
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-handle-content:active,
.mejs-container.wp-audio-shortcode .mejs-controls .mejs-time-rail .mejs-time-handle-content:focus,
.mejs-container.wp-audio-shortcode.a2prl-lecteur--en-cours .mejs-controls .mejs-time-rail .mejs-time-handle-content {
    transform: scale(1);
}

/* ── Bulle de temps (au survol du trait) ──────────────────────────────── */
.wp-audio-shortcode .mejs-time-float {
    height: auto;
    width: auto;
    margin-bottom: 12px;
    padding: 3px 8px;
    border: 0;
    border-radius: 6px;
    background: #17161a;
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
    white-space: nowrap;
}
.wp-audio-shortcode .mejs-time-float-current {
    position: static;
    display: block;
    width: auto;
    height: auto;
    margin: 0;
}
.wp-audio-shortcode .mejs-time-float-corner {
    border-width: 4px;
    border-color: #17161a transparent transparent;
}

/* ── Durée / temps restant ────────────────────────────────────────────── */
.wp-audio-shortcode .mejs-time {
    flex: none;
    height: auto;
    min-width: 44px;
    padding: 0;
    color: #17161a;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    line-height: 1;
    text-align: right;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.9); /* lisible sur une photo */
    overflow: visible;
}
.wp-audio-shortcode .mejs-currenttime-container,
.wp-audio-shortcode .mejs-volume-button,
.wp-audio-shortcode .mejs-horizontal-volume-slider,
.wp-audio-shortcode .mejs-duration-container .mejs-duration {
    display: none !important;
}
/* Le temps affiché est le nôtre (.a2prl-temps, posé par lecteur.js) : MediaElement
   réécrit le sien à chaque tick, on le masque et on garde la main. */
.wp-audio-shortcode .a2prl-temps {
    display: block;
}

/* ── Sur fond sombre (détecté par le script) ──────────────────────────── */
.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-playpause-button > button::before,
.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-playpause-button > button::before {
    background: #ffffff;
}
.wp-audio-shortcode.a2prl-lecteur--sombre .a2prl-ecouter,
.wp-audio-shortcode.a2prl-lecteur--magenta .a2prl-ecouter {
    color: #ffffff;
    text-shadow: none;
}
.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-playpause-button > button {
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2317161a' d='M8 5v14l11-7z'/%3E%3C/svg%3E");
    box-shadow: none;
}
.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-playpause-button.mejs-pause > button {
    background-color: #b51f69;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='5' width='4' height='14' rx='1' fill='%23ffffff'/%3E%3Crect x='14' y='5' width='4' height='14' rx='1' fill='%23ffffff'/%3E%3C/svg%3E");
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-controls .mejs-time-rail .mejs-time-total {
    background: rgba(255, 255, 255, 0.28);
    box-shadow: none;
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-controls .mejs-time-rail .mejs-time-buffering,
.mejs-container.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-controls .mejs-time-rail .mejs-time-loaded {
    background: rgba(255, 255, 255, 0.1);
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-controls .mejs-time-rail .mejs-time-handle-content {
    border-color: #1a191d;
}
.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-time {
    color: #ffffff;
    text-shadow: none;
}
.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-time-float {
    background: #ffffff;
    color: #17161a;
}
.wp-audio-shortcode.a2prl-lecteur--sombre .mejs-time-float-corner {
    border-color: #ffffff transparent transparent;
}

/* ── Sur fond magenta ─────────────────────────────────────────────────── */
.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-playpause-button > button {
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23b51f69' d='M8 5v14l11-7z'/%3E%3C/svg%3E");
    box-shadow: none;
}
.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-playpause-button.mejs-pause > button {
    background-color: #17161a;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='5' width='4' height='14' rx='1' fill='%23ffffff'/%3E%3Crect x='14' y='5' width='4' height='14' rx='1' fill='%23ffffff'/%3E%3C/svg%3E");
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-controls .mejs-time-rail .mejs-time-total {
    background: rgba(255, 255, 255, 0.35);
    box-shadow: none;
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-controls .mejs-time-rail .mejs-time-buffering,
.mejs-container.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-controls .mejs-time-rail .mejs-time-loaded {
    background: rgba(255, 255, 255, 0.12);
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-controls .mejs-time-rail .mejs-time-hovered {
    background: rgba(255, 255, 255, 0.45);
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-controls .mejs-time-rail .mejs-time-current {
    background: #ffffff;
}
.mejs-container.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-controls .mejs-time-rail .mejs-time-handle-content {
    background: #ffffff;
    border-color: #b51f69;
}
.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-time {
    color: #ffffff;
    text-shadow: none;
}
.wp-audio-shortcode.a2prl-lecteur--magenta .mejs-time-float {
    background: #17161a;
    color: #ffffff;
}
