:root {
    --arrow-button-size: 1.7em;
}

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background-color: rgba(50, 50, 50, 0.8);
    z-index: 4;
    pointer-events: none;
    -webkit-backdrop-filter: blur(0);
            backdrop-filter: blur(0);
    opacity: 0;
}

.lightbox.active {
    transition: opacity 0.3s ease-in-out, -webkit-backdrop-filter 0.3s ease-in-out;
    transition: backdrop-filter 0.3s ease-in-out, opacity 0.3s ease-in-out;
    transition: backdrop-filter 0.3s ease-in-out, opacity 0.3s ease-in-out, -webkit-backdrop-filter 0.3s ease-in-out;
    pointer-events: all;
    opacity: 1;
    -webkit-backdrop-filter: blur(15px);
            backdrop-filter: blur(15px);
}

.lightbox .header {
    display: flex;
    padding: 2vw 3vw;
    justify-content: space-between;
    align-items: center;
}

.lightbox .header h2 {
    margin-bottom: 0;
    color: var(--white);
}

.lightbox-close {
    font-size: max(2.25em, 3vw);
    color: var(--white);
    cursor: pointer;
    margin-top: -0.75vw;
}

.lightbox-galleries {
    position: relative;
}

@media (orientation: portrait) {
    .lightbox-galleries {
        margin-top: 15vh;
    }
}

.lightbox-gallery {
    display: none;
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    margin: 0 auto 5vh;
    max-width: 80vw;
    max-height: calc(93vh - calc(8vw + 2.3em));
}

.lightbox-gallery:has(.lightbox-slide-caption),
/* .has-caption can be removed once :has is well-supported */
.lightbox-gallery.has-caption {
    margin-bottom: 6vh;
}

.lightbox-gallery.active {
    display: block;
}

.lightbox-slide {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    -webkit-filter: blur(0.6em);
            filter: blur(0.6em);
    transition: opacity 0.35s, -webkit-filter 0.2s;
    transition: opacity 0.35s, filter 0.2s;
    transition: opacity 0.35s, filter 0.2s, -webkit-filter 0.2s;
}

.lightbox-slide.active {
    opacity: 1;
    -webkit-filter: blur(0);
            filter: blur(0);
    z-index: 1;
}

.lightbox-slide > div,
.lightbox-slide img {
    width: 100%;
    height: 100%;
}

.lightbox-slide img {
    object-fit: contain;
}

.lightbox-slide-caption {
    /*position: absolute;
    bottom: -2.5em;*/
    color: var(--white);
    /*width: calc(calc(93vh - calc(8vw + 2.3em)) * 1.77);
    max-width: 80vw;*/
}

.arrows {
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    position: absolute;
    top: calc(50% - calc(var(--arrow-button-size) / 2));
    width: 100%;
    padding: 0 0.8em;
    z-index: 2;
}

.arrows button {
    background-color: rgba(0, 0, 0, 0.4);
    width: var(--arrow-button-size);
    height: var(--arrow-button-size);
    padding: 0.6em;
    border: none;
    border-radius: 50%;
    text-align: center;
    transition: background-color 0.2s;
    cursor: pointer;
    line-height: 0;
}

.arrows button:hover {
    background-color: rgba(45, 181, 193, 0.5);
}

.arrows button img {
    height: 100%;
}

.slide-counter {
    margin: 0 auto;
    width: 4em;
    display: flex;
    justify-content: center;
    color: var(--white);
    font-size: calc(2vh + 0.2em);
    padding: 0.5em 1em 0.4em;
    border-radius: 1em;
    background-color: rgba(0, 0, 0, 0.4);
}

.slide-counter span {
    margin: 0 0.1em;
}

.slide-counter span:first-child {
    flex: 1 1 100%;
    text-align: right;
}

.slide-counter span:last-child {
    flex: 1 1 100%;
}

@media (max-width: 740px), (max-height: 536px) {
    .lightbox-slide-caption {
        font-size: 0.8em;
        /*width: calc(calc(93vh - calc(8vw + 2.8em)) * 1.77);*/
    }
}

@media (max-height: 536px) {
    .lightbox .header {
        font-size: 0.8em;
    }
}

@media (orientation: portrait) {
    .lightbox-galleries {
        margin-top: 0;
    }

    .lightbox-gallery {
        aspect-ratio: 9/16;
        max-height: calc(89vh - calc(8vw + 2.3em));
    }
}

@media (max-width: 536px) and (orientation: portrait) {
    .lightbox-galleries {
        display: flex;
        flex-direction: column-reverse;
    }

    .lightbox-gallery {
        max-height: calc(83vh - calc(8vw + 2.3em));
        margin-bottom: 3vh;
    }

    .arrows {
        position: relative;
        justify-content: center;
        margin-bottom: 0.5em;
        padding-left: 5vh;
        padding-right: 5vh;
    }

    .arrows button {
        margin: 0 3.5vh;
    }
}
