/* BT — Video Player (Plyr) */

/* ── Elementor flex container ─────────────────────────────────
   Exact same rules as widget-video.min.css */
.e-con .elementor-widget-bt-video-player {
    width: 100%;
    min-width: 100%;
}
.e-con-inner > .elementor-widget-bt-video-player,
.e-con > .elementor-widget-bt-video-player {
    width: var(--container-widget-width, 100%);
    --flex-grow: var(--container-widget-flex-grow);
}

/* Overflow + GPU layer like Elementor widget-video */
.elementor-widget-bt-video-player .elementor-widget-container {
    overflow: hidden;
    transform: translateZ(0);
}

/* ── Root ─────────────────────────────────────────────────────── */
.bt-video-player {
    width: 100%;
}

/* ── Wrap: dimensions via aspect-ratio or fixed height ────────── */
.bt-video-player__wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #000;
    border-radius: 12px;
}

.bt-video-player__wrap--16-9 { aspect-ratio: 16 / 9; }
.bt-video-player__wrap--21-9 { aspect-ratio: 21 / 9; }
.bt-video-player__wrap--4-3  { aspect-ratio: 4 / 3; }
.bt-video-player__wrap--1-1  { aspect-ratio: 1 / 1; }
.bt-video-player__wrap--9-16 { aspect-ratio: 9 / 16; }
.bt-video-player__wrap--fixed { aspect-ratio: unset; }

/* ── Raw <video> (PHP-rendered, before Plyr init) ─────────────── */
.bt-video-player__wrap > .bt-video-player__video {
    display: flex;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    border: none;
}

/* ── Plyr: absolute fill, kill all Plyr sizing ────────────────── */
.bt-video-player__wrap .plyr {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    max-width: none !important;
    min-width: 0 !important;
}

.bt-video-player__wrap .plyr__video-wrapper,
.bt-video-player__wrap .plyr__video-wrapper--fixed-ratio {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    padding-bottom: 0 !important;
    aspect-ratio: unset !important;
}

.bt-video-player__wrap .plyr__video-wrapper video {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

/* iframe (YouTube/Vimeo) : fill simple — le wrapper porte déjà le bon
   aspect-ratio, pas besoin de cover/zoom. */
.bt-video-player__wrap .plyr__video-wrapper iframe {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: unset !important;
    min-height: unset !important;
    aspect-ratio: unset !important;
    transform: none !important;
}

.bt-video-player__wrap .plyr__poster {
    background-size: cover;
    background-position: center;
}

.bt-video-player__wrap .plyr__controls {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 5 !important;
}

.bt-video-player__wrap .plyr__control--overlaid {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 6;
}

/* Masque le gros bouton play de Plyr quand notre poster custom est présent —
   évite deux boutons play visibles simultanément. */
.bt-video-player:not(.bt-video-player--active) .plyr__control--overlaid {
    display: none !important;
}

/* ── Poster overlay ───────────────────────────────────────────── */
.bt-video-player__poster {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.4s ease;
}

.bt-video-player__poster img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bt-video-player__poster--empty {
    background: #111;
}

.bt-video-player__poster::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(0,0,0,.4) 0%, transparent 40%, transparent 60%, rgba(0,0,0,.15) 100%);
    pointer-events: none;
}

.bt-video-player--active .bt-video-player__poster {
    opacity: 0;
    pointer-events: none;
}

/* ── Play button (poster) ─────────────────────────────────────── */
.bt-video-player__play {
    position: relative;
    z-index: 4;
    width: 68px;
    height: 68px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,.6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform .2s ease, background .2s ease;
    box-shadow: 0 4px 24px rgba(0,0,0,.3);
}

.bt-video-player__play svg {
    width: 28px;
    height: 28px;
    margin-left: 3px;
}

.bt-video-player__play:hover {
    transform: scale(1.08);
    background: rgba(0,0,0,.75);
}

.bt-video-player__play:active {
    transform: scale(.97);
}

.bt-video-player__play:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* ── Tap-to-play overlay (autoplay bloqué sur mobile/Low Power Mode) ── */
.bt-video-player__tap-play {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.35);
    cursor: pointer;
    animation: bt-video-fadein .3s ease;
}

.bt-video-player__tap-play button {
    width: 68px;
    height: 68px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.92);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(0,0,0,.3);
    pointer-events: none; /* le click remonte au div parent */
}

.bt-video-player__tap-play button svg {
    width: 28px;
    height: 28px;
    margin-left: 3px;
}

@keyframes bt-video-fadein { from { opacity: 0; } to { opacity: 1; } }

/* ── Loading ──────────────────────────────────────────────────── */
.bt-video-player--loading .bt-video-player__poster::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 40px; height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: bt-video-spin .8s linear infinite;
    z-index: 5;
}

.bt-video-player--loading .bt-video-player__play { display: none; }

@keyframes bt-video-spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    .bt-video-player__play { width: 56px; height: 56px; }
    .bt-video-player__play svg { width: 22px; height: 22px; }

    /* Barre de contrôles Plyr : empêche le débordement horizontal
       (cause du "widget sort de l'écran" dans l'éditeur mobile) */
    .bt-video-player__wrap .plyr__controls {
        flex-wrap: nowrap;
        overflow: hidden;
        padding: 8px !important;
        gap: 2px !important;
    }

    /* Tous les boutons de contrôle : taille explicite, ne pas réduire à 0 */
    .bt-video-player__wrap .plyr__controls .plyr__controls__item {
        flex-shrink: 0;
    }

    /* Boutons icônes (play, mute, settings, pip…) : taille fixe */
    .bt-video-player__wrap .plyr__control {
        width: 32px !important;
        height: 32px !important;
        padding: 4px !important;
        flex-shrink: 0 !important;
    }

    /* SVG dans les boutons : taille explicite (remplace --plyr-control-icon-size) */
    .bt-video-player__wrap .plyr__control svg {
        width: 16px !important;
        height: 16px !important;
    }

    /* Volume : ne pas s'effondrer à 0 une fois le range caché */
    .bt-video-player__wrap .plyr__volume {
        min-width: 32px;
        flex-shrink: 0;
    }

    /* Slider volume caché sur mobile — seul le bouton mute reste */
    .bt-video-player__wrap .plyr__volume input[type="range"] {
        display: none !important;
    }

    /* Réduire la taille du texte de temps */
    .bt-video-player__wrap .plyr__time {
        font-size: 0.7rem;
        min-width: 0;
    }

    /* Settings + PiP : réduire la largeur du menu pour qu'il reste dans le viewport */
    .bt-video-player__wrap .plyr__menu__container {
        max-width: calc(100vw - 32px);
    }
}

@media (max-width: 480px) {
    .bt-video-player__play { width: 48px; height: 48px; }
    .bt-video-player__play svg { width: 18px; height: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .bt-video-player__play, .bt-video-player__poster { transition: none; }
    .bt-video-player--loading .bt-video-player__poster::before { animation: none; }
}
