/* ------------------------------
   GIF – STYLE GLOBAL
------------------------------ */

/* Cible large : figures marquées et toutes les images .gif */
figure[data-wf-figure="1"],
figure img[src$=".gif"],
figure img[src*=".gif"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: 1rem auto;
}

/* Taille responsive par défaut */
figure[data-wf-figure="1"] img,
figure img[src$=".gif"],
figure img[src*=".gif"] {
    display: block;
    width: 100%;
    height: auto;
    max-width: 270px;
    max-height: 235px;

    border-radius: 12px;
    border: 1px solid #ccc;

    transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
    will-change: transform, box-shadow;
}

/* ------------------------------
   ZOOM AU SURVOL (DESKTOP)
------------------------------ */
@media (hover: hover) and (pointer: fine) {
    figure[data-wf-figure="1"] img:hover,
    figure img[src$=".gif"]:hover,
    figure img[src*=".gif"]:hover {
        transform: scale(1.40);
        box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    }
}

/* ------------------------------
   EFFET KEN BURNS (zoom progressif)
------------------------------ */
figure[data-wf-figure="1"] img,
figure img[src$=".gif"],
figure img[src*=".gif"] {
    animation: kenburns 8s ease-in-out infinite alternate;
}

@keyframes kenburns {
    0%   { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.12) translate(2%, 2%); }
}

/* ------------------------------
   CADRE ANIMÉ (GLOW + PULSATION)
------------------------------ */
figure[data-wf-figure="1"] img,
figure img[src$=".gif"],
figure img[src*=".gif"] {
    box-shadow: 0 0 8px rgba(255,255,255,0.18);
    animation: glowpulse 3s ease-in-out infinite;
}

@keyframes glowpulse {
    0%   { box-shadow: 0 0 6px rgba(255,255,255,0.18); filter: saturate(1); }
    50%  { box-shadow: 0 0 14px rgba(255,255,255,0.36); filter: saturate(1.05); }
    100% { box-shadow: 0 0 6px rgba(255,255,255,0.18); filter: saturate(1); }
}

/* ------------------------------
   LÉGENDES STYLÉES
------------------------------ */
figure[data-wf-figure="1"] figcaption,
figure img[src$=".gif"] + figcaption,
figure img[src*=".gif"] + figcaption {
    margin-top: .5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #222;
    background: rgba(255,255,255,0.85);
    padding: .35rem .7rem;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    display: inline-block;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Petite variante sombre si le thème du site est sombre */
body.theme-dark figure[data-wf-figure="1"] figcaption,
body.theme-dark figure img[src$=".gif"] + figcaption,
body.theme-dark figure img[src*=".gif"] + figcaption {
    background: rgba(20,20,20,0.6);
    color: #eee;
}

/* ------------------------------
   GESTION DES TAILLES
------------------------------ */

/* Desktop : garder 270×235 */
@media (min-width: 1024px) {
    figure[data-wf-figure="1"] img,
    figure img[src$=".gif"],
    figure img[src*=".gif"] {
        width: 270px !important;
        height: 235px !important;
        object-fit: cover;
    }
}

/* Smartphone paysage : garder 270×235 */
@media (max-width: 1023px) and (orientation: landscape) {
    figure[data-wf-figure="1"] img,
    figure img[src$=".gif"],
    figure img[src*=".gif"] {
        width: 270px !important;
        height: 235px !important;
        object-fit: cover;
    }
}

/* Smartphone portrait : GIF responsive et plus petit */
@media (max-width: 1023px) and (orientation: portrait) {
    figure[data-wf-figure="1"] img,
    figure img[src$=".gif"],
    figure img[src*=".gif"] {
        width: 70%;
        height: auto;
        max-width: 270px;
        max-height: 235px;
    }
}

/* ------------------------------
   RETINA SUPPORT (utilisation de data-retina si fournie)
   Note: CSS ne peut pas remplacer src ; utilisez data-retina + JS pour swap si besoin.
------------------------------ */
@media only screen and (-webkit-min-device-pixel-ratio: 2),
       only screen and (min-resolution: 192dpi) {
    /* Visuel : augmenter netteté via transform subtle (CSS ne swap pas src) */
    figure[data-wf-figure="1"] img,
    figure img[src$=".gif"],
    figure img[src*=".gif"] {
        image-rendering: auto;
    }
}

/* ------------------------------
   GALERIE HORIZONTALE
------------------------------ */
.gif-gallery {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: .5rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    align-items: center;
}

.gif-gallery figure {
    scroll-snap-align: center;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Indicateur visuel pour l'élément actif */
.gif-gallery figure.active {
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}

/* ------------------------------
   MODE CINÉMA (agrandissement dans la page)
------------------------------ */

/* Conteneur agrandi, fond sombre et centrage */
.video-block.video-cinema {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(1100px, 95%);
    max-width: 1100px;
    height: auto;
    z-index: 99999;
    background: rgba(0,0,0,0.92);
    padding: 0.6rem;
    border-radius: 10px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.7);
    transition: all .28s ease;
    display: block;
}

/* Assure que la frame occupe toute la largeur du conteneur cinéma */
.video-block.video-cinema .video-frame,
.video-block.video-cinema .video-frame iframe,
.video-block.video-cinema .video-frame video {
    width: 100% !important;
    height: auto !important;
    display: block;
}

/* Toolbar repositionnée dans le mode cinéma */
.video-block.video-cinema .video-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-bottom: .5rem;
}

/* Overlay pour assombrir le reste de la page (créé via pseudo-element) */
.video-block.video-cinema::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: -1;
    border-radius: 0;
}

/* Small screens : limiter la taille et désactiver fixed pour UX */
@media (max-width: 767px) {
    .video-block.video-cinema {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        width: 100%;
        padding: .3rem;
        border-radius: 6px;
    }
}

/* ------------------------------
   VIDEO TOOLBAR (boutons)
------------------------------ */
.video-toolbar {
    display: flex;
    gap: .5rem;
    margin-bottom: .5rem;
    flex-wrap: wrap;
}

.video-toolbar button {
    font-size: .9rem;
    padding: .28rem .5rem;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.95);
    cursor: pointer;
    transition: transform .12s ease, background .12s ease;
}

.video-toolbar button:active { transform: translateY(1px); }
.video-toolbar button[disabled] { opacity: .5; cursor: not-allowed; }

/* Dark theme variant for toolbar */
body.theme-dark .video-toolbar button {
    background: rgba(30,30,30,0.9);
    color: #eee;
    border: 1px solid rgba(255,255,255,0.04);
}

/* ------------------------------
   ACCESSIBILITY & SMALL TWEAKS
------------------------------ */
.video-block { margin-bottom: 1rem; }
.video-frame { width: 100%; overflow: hidden; border-radius: 8px; }

/* Ensure iframes and videos are responsive inside blocks */
.video-frame iframe,
.video-frame video,
.video-frame embed,
.video-frame object {
    width: 100%;
    height: auto;
    display: block;
}

/* Prevent animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
