/* AFFICHES VIVANTES ET LIGHTBOX — HTML/CSS UNIQUEMENT.
   Fichier séparé pour étudier ces ajouts après les exercices de base. */

/* 1. Une image et son calque de paupières partagent le même cadre.
   Les proportions de l’image déterminent la position des yeux. */
.ouvrir-affiche {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: #151515;
    cursor: zoom-in;
    font: inherit;
}

.poster {
    display: block;
    position: relative;
    width: 100%;
    line-height: 0;
}

.affiche .poster img, .lightbox .poster img,
.armoiries .poster img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.yeux-animes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Au repos, la paupière est aplatie : l’œil original reste visible. */
.paupiere {
    transform-box: fill-box;
    transform-origin: center;
    transform: scaleY(0);
}

/* Deux clignements brefs pendant une séquence de quatre secondes. */
.ouvrir-affiche:hover .paupiere,
.ouvrir-affiche:focus-visible .paupiere,
.lightbox:popover-open .paupiere {
    animation: cligner 4s 1;
}

@keyframes cligner {
    0%, 18%, 24%, 72%, 78%, 100% { transform: scaleY(0); }
    21%, 75% { transform: scaleY(1); }
}

/* 2. Le héros assis laisse échapper un petit ronflement. */
.sommeil {
    position: absolute;
    top: 19%;
    left: 60%;
    color: #fff5df;
    font-family: 'Roboto Condensed', Arial, sans-serif;
    font-weight: 900;
    font-size: 32px;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
}

.ouvrir-affiche:hover .sommeil,
.ouvrir-affiche:focus-visible .sommeil,
.lightbox:popover-open .sommeil {
    animation: ronflement 2s 2;
}

@keyframes ronflement {
    0% { opacity: 0; transform: translateY(8px) rotate(-8deg); }
    35% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-20px) rotate(4deg); }
}

/* 3. Lightbox native : popover et popovertarget sont des attributs HTML.
   Pas de JavaScript ni de changement de page pour ouvrir une affiche.
   L’arrière-plan est assombri par ::backdrop. */
.lightbox {
    position: fixed;
    margin: auto;
    padding: 52px 12px 12px;
    border: 4px solid #151515;
    background: #151515;
    color: #fff5df;
    width: max-content;
    max-width: 92vw;
    max-height: 96vh;
    overflow: auto;
    box-shadow: 8px 8px 0 #ffdf00;
}

.lightbox::backdrop {
    background: rgba(0, 0, 0, 0.88);
}

.lightbox .poster {
    width: min(52vh, 78vw);
    margin: 0 auto;
}

.fermer-lightbox {
    position: absolute;
    right: 10px;
    top: 9px;
    border: 2px solid #151515;
    background: #ffdf00;
    color: #151515;
    padding: 7px 12px;
    font-family: Arial, sans-serif;
    font-weight: bold;
    cursor: pointer;
}

.ouvrir-affiche:focus-visible, .fermer-lightbox:focus-visible {
    outline: 4px solid #ffdf00;
    outline-offset: 3px;
}

.fermer-lightbox:hover {
    background: #f12c1b;
    color: white;
}

.titre-lightbox {
    font-size: 21px;
    text-align: center;
    margin: 12px 0 5px;
}

.aide-lightbox {
    font-size: 11px;
    text-align: center;
    line-height: 1.4;
}

/* Seule la lightbox s’adapte à la fenêtre : la page reste fixe à 1200 px. */
@media (prefers-reduced-motion: reduce) {
    .ouvrir-affiche:hover .paupiere,
    .ouvrir-affiche:focus-visible .paupiere,
    .lightbox:popover-open .paupiere,
    .ouvrir-affiche:hover .sommeil,
    .ouvrir-affiche:focus-visible .sommeil,
    .lightbox:popover-open .sommeil {
        animation: none;
    }
}
