/* ---------------------------------------------------------------------------
   Champ `at_video` (attps-get-field) — lecteur (mode bloc) et calque de fond
   (mode background). Le couplage aux conteneurs (position relative, calque en
   z-index 0, enfants au-dessus) est à la charge du consommateur : cf.
   attps-builder/assets/css/video.css.

   Le fond vidéo reprend le principe du calque d'image de fond
   (.atb-*--bg-images::before) : un calque absolu en z-index 0, les enfants du
   conteneur au-dessus. Le poster est l'image de fond du calque ; la vidéo ou
   l'iframe vient par-dessus une fois chargée par video.js.
   --------------------------------------------------------------------------- */

/* --- Bloc ------------------------------------------------------------------ */

.atgf-video {
    --atgf-video-radius: var(--atb-radius, 0);
    --atgf-video-play-size: 4.5rem;
    --atgf-video-play-bg: var(--atb-primary, #0099DD);
    --atgf-video-play-color: var(--atb-light, #fff);

    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--atgf-video-radius);
    background: #000;
}

.atgf-video--aspect-16-9 { aspect-ratio: 16 / 9; }
.atgf-video--aspect-4-3  { aspect-ratio: 4 / 3; }
.atgf-video--aspect-1-1  { aspect-ratio: 1 / 1; }
.atgf-video--aspect-9-16 { aspect-ratio: 9 / 16; }
.atgf-video--aspect-21-9 { aspect-ratio: 21 / 9; }

.atgf-video__media,
.atgf-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.atgf-video__media {
    object-fit: cover;
}

/* Ratio auto : le média dicte sa hauteur (fichier local surtout). */
.atgf-video--aspect-auto .atgf-video__media {
    position: static;
    height: auto;
    object-fit: initial;
}

.atgf-video--aspect-auto .atgf-video__facade {
    position: relative;
    aspect-ratio: 16 / 9;
}

/* Fournisseur inconnu : l'HTML oEmbed n'est pas positionné par nos soins. */
.atgf-video--embed {
    aspect-ratio: auto;
    background: transparent;
}

.atgf-video--embed iframe {
    position: static;
    aspect-ratio: 16 / 9;
    height: auto;
}

/* --- Façade (clic pour charger) ------------------------------------------- */

.atgf-video__facade {
    appearance: none;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: #000;
    cursor: pointer;
    display: block;
}

.atgf-video__poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--atb-transition-slow, 0.3s ease), opacity var(--atb-transition, 0.2s ease);
}

.atgf-video__facade:hover .atgf-video__poster,
.atgf-video__facade:focus-visible .atgf-video__poster {
    transform: scale(1.03);
}

/* Effets (18/11/2026, outil image_fx de l'image) : variables de la règle scopée posée sur la racine, lues par le média
   (vidéo, iframe) et l'affiche — jamais par le bouton de lecture. Un filtre sur une iframe YouTube / Vimeo filtre
   aussi ses commandes. */
.atgf-video--fx :is(.atgf-video__media, .atgf-video__poster, iframe) {
    filter: var(--atgf-img-filter, none);
    opacity: var(--atgf-img-opacity, 1);
    mix-blend-mode: var(--atgf-img-blend, normal);
    transition: transform var(--atb-transition-slow, 0.3s ease), filter var(--atgf-img-dur, .35s) var(--atgf-img-ease, ease), opacity var(--atgf-img-dur, .35s) var(--atgf-img-ease, ease);
}

/* Voile (couleur ou dégradé, intensité par état) : entre l'affiche et le bouton de lecture (ordre du balisage). */
.atgf-video__veil {
    position: absolute;
    inset: 0;
    background: var(--atgf-img-veil, transparent);
    opacity: var(--atgf-img-veil-op, 1);
    pointer-events: none;
    transition: opacity var(--atgf-img-dur, .35s) var(--atgf-img-ease, ease);
}

.atgf-video__play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--atgf-video-play-size);
    height: var(--atgf-video-play-size);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--atgf-video-play-bg);
    color: var(--atgf-video-play-color);
    box-shadow: var(--atb-shadow-lg, 0 12px 32px rgba(0, 0, 0, 0.12));
    transition: transform var(--atb-transition, 0.2s ease);
}

.atgf-video__play::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 0.9rem 0 0.9rem 1.5rem;
    border-color: transparent transparent transparent currentColor; /* la couleur du bouton : l'Apparence (Typographie) la règle */
}

.atgf-video__facade:hover .atgf-video__play,
.atgf-video__facade:focus-visible .atgf-video__play {
    transform: translate(-50%, -50%) scale(1.08);
}

.atgf-video__facade:focus-visible {
    outline: 3px solid var(--atgf-video-play-bg);
    outline-offset: -3px;
}

/* --- Calque de fond (mode background) : le média dans son calque ------------ */

/* Le calque lui-même est positionné par le consommateur (ex. .atb-section--bg-video
   > .atgf-bg-video dans le builder) ; on ne fixe ici que son remplissage. */
.atgf-bg-video {
    overflow: hidden;
    background-size: cover;
    background-position: center;
    opacity: var(--atgf-video-opacity, 1);
    pointer-events: none;
}



.atgf-bg-video__media {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    border: 0;
    object-fit: cover;
    opacity: 0;
    transition: opacity var(--atb-transition-slow, 0.3s ease);
}

/* Une fois chargée (classe posée par video.js), la vidéo recouvre le poster. */
.atgf-bg-video.is-playing .atgf-bg-video__media {
    opacity: 1;
}

/* Une iframe n'a pas d'object-fit : video.js la dimensionne pour couvrir le
   calque (ratio 16:9), d'où width/height inline. */
iframe.atgf-bg-video__media {
    max-width: none;
    max-height: none;
}

/* Fond désactivé sur mobile : le poster reste, video.js ne charge rien. */
@media (max-width: 768px) {
    .atgf-bg-video--no-mobile .atgf-bg-video__media {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .atgf-bg-video .atgf-bg-video__media {
        display: none;
    }
}

/* Façade d'un fichier (17/11/2026) : posée sur la vidéo, même en ratio « auto » (la vidéo y garde sa hauteur propre) ;
   sans affiche, transparente : la première image de la vidéo se voit dessous. */
.atgf-video--aspect-auto .atgf-video__facade--file { position: absolute; inset: 0; aspect-ratio: auto; }
.atgf-video__facade--bare { background: transparent; }

/* Icône choisie (`play_icon`) : centrée, à la taille et à la couleur du texte du bouton ; le triangle dessiné s'efface. */
.atgf-video__play--icon { display: grid; place-items: center; font-size: 1.75rem; }
.atgf-video__play--icon::after { content: none; }
.atgf-video__play--icon :is(svg, img, i, .atb-icon) { width: 1em; height: 1em; }
