/**
 * AF Video — front styles
 *
 * The poster sits in the flow and gives the block its size (so there is no
 * layout shift), the video is laid over it and fades in once it can play.
 * @author At first Sarl <team@atfirst.io>
 */

.afvideo {
    position: relative;
    overflow: hidden;
    line-height: 0;
}

.afvideo__poster,
.afvideo__poster img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.afvideo__poster {
    transition: opacity .4s ease;
}

.afvideo__media {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity .4s ease;
}

/* With a poster present, the video overlays it. */
.afvideo:not(.afvideo--noposter) .afvideo__media {
    position: absolute;
    top: 0;
    left: 0;
}

.afvideo.is-ready .afvideo__media {
    opacity: 1;
}

/* Keep the poster underneath: it covers the gap if the video is ever removed
   from the compositor, and it is what remains visible when autoplay is denied. */
.afvideo.is-ready:not(.is-autoplay-blocked) .afvideo__poster {
    opacity: 0;
}

.afvideo.is-autoplay-blocked .afvideo__media {
    opacity: 0;
}

/* No poster: the video is the flow element. */
.afvideo--noposter .afvideo__media {
    position: relative;
    opacity: 1;
}

/* Controls mode is a real player, never hide it behind the poster. */
.afvideo--controls .afvideo__media {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .afvideo__media,
    .afvideo__poster {
        transition: none;
    }
}
