/**
 * Video lightbox sizing.
 *
 * GLightbox hands Plyr a hardcoded 16:9 ratio, so a portrait video ends up
 * letterboxed inside a 16:9 black box: wide empty bars beside it on desktop
 * and a postage-stamp player floating in the middle of the screen on mobile.
 * We size the slide from the video's real ratio instead, which the init
 * script writes to --nq-video-ar once the metadata is available. 16:9 stays
 * the fallback for the moment before that (and for anything non-local).
 */

.glightbox-container .gslide-video {
    --nq-lb-height: 100vh;
    --nq-lb-max-width: 100vw;

    width: min(var(--nq-lb-max-width), calc(var(--nq-lb-height) * var(--nq-video-ar, 1.7778))) !important;
    max-width: var(--nq-lb-max-width) !important;
    max-height: var(--nq-lb-height);
}

/* Desktop keeps a little breathing room for the close / arrow buttons. */
@media (min-width: 769px) {
    .glightbox-container .gslide-video {
        --nq-lb-height: 92vh;
        --nq-lb-max-width: min(94vw, 1000px);
    }
}

.glightbox-container .gslide-video .gvideo-wrapper {
    width: 100%;
    max-width: 100%;
}

/* Plyr's fixed ratio box, set both in its stylesheet and inline by its JS. */
.glightbox-container .gvideo-container .plyr__video-wrapper {
    aspect-ratio: var(--nq-video-ar, 1.7778) !important;
    height: auto !important;
    padding-bottom: 0 !important;
}

.glightbox-container .gvideo-container video {
    max-width: 100% !important; /* GLightbox writes max-width:960px inline */
    min-height: 0; /* its stylesheet floors every video at 165px */
    object-fit: contain;
}

/* Native fullscreen sizes itself - keep the ratio box out of its way. */
.plyr--fullscreen-active .plyr__video-wrapper,
.plyr--fullscreen-fallback .plyr__video-wrapper {
    aspect-ratio: auto !important;
    height: 100% !important;
}
