html:has(.project-lightbox[open]) {
    overflow: hidden;
}

.project-lightbox {
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: #000;
    color: #fff;
    touch-action: pinch-zoom;
    container-type: inline-size;
}

.project-lightbox[open] {
    display: grid;
    place-items: center;
}

.project-lightbox__photo {
    position: relative;
    width: min(90vw, 90vh * var(--photo-ratio, 1));
    width: min(90vw, 90dvh * var(--photo-ratio, 1));
    aspect-ratio: var(--photo-ratio, 1);
}

@media (max-width: 760px), (pointer: coarse) {
    .project-lightbox__photo {
        width: min(100vw, 100vh * var(--photo-ratio, 1));
        width: min(100vw, 100dvh * var(--photo-ratio, 1));
    }
}

.project-lightbox__photo img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
    user-select: none;
}

.project-lightbox button {
    position: absolute;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgb(0 0 0 / 65%);
    color: #fff;
    font: 32px/1 system-ui, sans-serif;
    cursor: pointer;
}

.project-lightbox button[hidden] {
    display: none;
}

.project-lightbox button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -3px;
}

.project-lightbox__close {
    z-index: 1;
    top: max(4px, env(safe-area-inset-top));
    right: max(4px, env(safe-area-inset-right));
}

.project-lightbox__prev,
.project-lightbox__next {
    top: 50%;
    transform: translateY(-50%);
}

/* Subtract the space outside the centered photo from the viewport safe inset. */
.project-lightbox__prev {
    left: env(safe-area-inset-left, 0px);
    left: max(0px, env(safe-area-inset-left, 0px) - (100cqw - 100%) / 2);
}

.project-lightbox__next {
    right: env(safe-area-inset-right, 0px);
    right: max(0px, env(safe-area-inset-right, 0px) - (100cqw - 100%) / 2);
}

.aramake-project-gallery .fotorama__stage__frame {
    cursor: zoom-in;
}
