html.sth-image-lightbox-open {
    overflow: hidden;
}

html.sth-image-lightbox-gutter {
    scrollbar-gutter: stable;
}

.sth-image-lightbox {
    --sth-lightbox-left: max(12px, env(safe-area-inset-left));
    --sth-lightbox-right: max(12px, env(safe-area-inset-right));
    --sth-lightbox-top: max(12px, env(safe-area-inset-top));
    --sth-lightbox-image-inset: max(
        calc(var(--sth-lightbox-top) + 54px),
        calc(env(safe-area-inset-bottom) + 12px)
    );
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    overflow: hidden;
}

.sth-image-lightbox::backdrop {
    background: rgb(0 0 0 / 88%);
}

.sth-image-lightbox__controls {
    position: absolute;
    z-index: 1;
    top: var(--sth-lightbox-top);
    right: var(--sth-lightbox-right);
    display: flex;
    gap: 8px;
}

.sth-image-lightbox__controls a,
.sth-image-lightbox__controls button {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid rgb(255 255 255 / 24%);
    border-radius: 50%;
    background: #262626;
    color: #fff;
    cursor: pointer;
}

.sth-image-lightbox__controls a:hover,
.sth-image-lightbox__controls button:hover {
    background: #414141;
    color: #fff;
}

.sth-image-lightbox__controls svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.sth-image-lightbox__controls :focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.sth-image-lightbox__viewport,
.sth-image-lightbox__status {
    position: absolute;
    inset: var(--sth-lightbox-image-inset) var(--sth-lightbox-right)
        var(--sth-lightbox-image-inset) var(--sth-lightbox-left);
    display: grid;
    place-items: center;
    margin: 0;
    pointer-events: none;
}

.sth-image-lightbox__viewport {
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}

.sth-image-lightbox__viewport img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: auto;
}

.sth-image-lightbox__viewport img[hidden],
.sth-image-lightbox__status[hidden] {
    display: none;
}

.sth-image-lightbox__status {
    padding: 0 12px;
    color: #fff;
    text-align: center;
}

@media (prefers-reduced-motion: no-preference) {
    .sth-image-lightbox[open],
    .sth-image-lightbox[open]::backdrop {
        animation: sth-lightbox-enter 240ms ease-out both;
    }

    .sth-image-lightbox__viewport img:not([hidden]) {
        animation: sth-lightbox-image-enter 240ms ease-out both;
    }

    .sth-image-lightbox.is-closing,
    .sth-image-lightbox.is-closing::backdrop {
        animation: sth-lightbox-exit 160ms ease-in both;
    }
}

@keyframes sth-lightbox-enter {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes sth-lightbox-image-enter {
    from { opacity: 0; transform: scale(0.99); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes sth-lightbox-exit {
    from { opacity: var(--sth-lightbox-close-opacity, 1); }
    to { opacity: 0; }
}
