/**
 * Commercify Banner Video Controls CSS
 * Namespace: .cf-banner-video-*
 * Optimisé pour performances GPU, support RTL/LTR
 *
 * États (classes posées par commercify_banner_video_controls.js) :
 *  - vidéo à l'arrêt  : overlay sans classe            → bouton lecture en filigrane,
 *                                                         pleinement visible au survol
 *  - vidéo en lecture : .cf-banner-video-overlay-hidden → aucun contrôle visible,
 *                                                         bouton pause visible au survol
 *  - écrans tactiles (hover: none) : le bouton pause reste en filigrane pendant la lecture
 */

/* Overlay pour les contrôles vidéo (laisse passer le clic vers le lien de la vignette) */
.cf-banner-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    z-index: 10;
    pointer-events: none;
    transition: background-color 0.25s ease;
    animation: cf-banner-video-overlay-fade-in 0.3s ease;
}

/* Bouton play/pause - état par défaut (vidéo à l'arrêt) : filigrane discret */
.cf-banner-video-play-btn {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.55);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    z-index: 11;
    outline: none;
    box-shadow: none;
    opacity: 0.45;
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease,
                box-shadow 0.2s ease, opacity 0.25s ease, visibility 0s linear 0s;
    will-change: transform, opacity;
}

/* Survol de la vignette, vidéo à l'arrêt : voile léger + bouton lecture pleinement visible */
.vignette-ad:hover .cf-banner-video-overlay:not(.cf-banner-video-overlay-hidden) {
    background: rgba(0, 0, 0, 0.25);
}

.vignette-ad:hover .cf-banner-video-play-btn {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.75);
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease,
                box-shadow 0.2s ease, opacity 0.25s ease, visibility 0s linear 0s;
}

/* Vidéo en lecture : aucun contrôle visible hors survol */
.cf-banner-video-overlay.cf-banner-video-overlay-hidden .cf-banner-video-play-btn {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

/* Vidéo en lecture + survol : bouton pause pleinement visible (sans voile sur la vidéo) */
.vignette-ad:hover .cf-banner-video-overlay.cf-banner-video-overlay-hidden .cf-banner-video-play-btn {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease,
                box-shadow 0.2s ease, opacity 0.25s ease, visibility 0s linear 0s;
}

/* Navigation clavier : mêmes règles que le survol, uniquement sur focus clavier
   (:focus-visible — un clic souris ne laisse pas le bouton affiché).
   Règles séparées : un navigateur sans :has() n'invalide pas les règles :hover. */
.vignette-ad:has(:focus-visible) .cf-banner-video-overlay:not(.cf-banner-video-overlay-hidden) {
    background: rgba(0, 0, 0, 0.25);
}

.vignette-ad:has(:focus-visible) .cf-banner-video-play-btn,
.vignette-ad:has(:focus-visible) .cf-banner-video-overlay.cf-banner-video-overlay-hidden .cf-banner-video-play-btn {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.75);
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: opacity 0.25s ease, visibility 0s linear 0s;
}

/* Écrans tactiles (pas de survol) : le bouton pause reste en filigrane pendant la lecture */
@media (hover: none) {
    .cf-banner-video-overlay.cf-banner-video-overlay-hidden .cf-banner-video-play-btn {
        opacity: 0.45;
        visibility: visible;
        pointer-events: auto;
    }
}

/* Hover sur le bouton lui-même (spécificité > règles de survol de la vignette) */
.vignette-ad .cf-banner-video-play-btn:hover,
.cf-banner-video-play-btn:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.85);
    border-color: rgba(255, 255, 255, 1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.cf-banner-video-play-btn:active {
    transform: scale(0.95);
}

/* Focus clavier pour accessibilité (couleur du thème actif) */
.cf-banner-video-play-btn:focus-visible {
    opacity: 1;
    visibility: visible;
    outline: 2px solid var(--cfy-t-accent, currentColor);
    outline-offset: 2px;
}

/* Icône play */
.cf-banner-video-play-icon {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transform: translateX(2px); /* Ajustement visuel pour centrer le triangle */
    transition: transform 0.2s ease;
    will-change: transform;
}

/* Support RTL pour l'icône */
html[dir="rtl"] .cf-banner-video-play-icon {
    transform: translateX(-2px); /* Inverser l'ajustement en RTL */
}

/* État pause (quand la vidéo joue) : icône deux barres injectée par JS, pas de décalage */
.cf-banner-video-play-btn.cf-banner-video-pause-state .cf-banner-video-play-icon {
    transform: translateX(0);
}

/* Responsive : petits écrans */
@media (max-width: 576px) {
    .cf-banner-video-play-btn {
        width: 48px;
        height: 48px;
    }

    .cf-banner-video-play-icon {
        width: 20px;
        height: 20px;
    }
}

/* Responsive : très petits écrans */
@media (max-width: 400px) {
    .cf-banner-video-play-btn {
        width: 40px;
        height: 40px;
    }

    .cf-banner-video-play-icon {
        width: 16px;
        height: 16px;
    }
}

/* Optimisation pour les bannières 2x1 (plus larges) et 1x2 (plus hautes) */
.vignette-ad-2x1 .cf-banner-video-play-btn,
.vignette-ad-1x2 .cf-banner-video-play-btn {
    width: 72px;
    height: 72px;
}

.vignette-ad-2x1 .cf-banner-video-play-icon,
.vignette-ad-1x2 .cf-banner-video-play-icon {
    width: 32px;
    height: 32px;
}

/* Animation d'apparition pour l'overlay */
@keyframes cf-banner-video-overlay-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Optimisation GPU */
.cf-banner-video-overlay,
.cf-banner-video-play-btn {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
