.jww-lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 3.5rem 0.5rem 1rem;
    border: 0;
    background: rgb(18 25 30 / 96%);
    color: #fff;
}

.jww-lightbox[open] {
    display: grid;
    grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem;
    align-items: center;
    gap: 0.25rem;
}

.jww-lightbox__figure {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 100%;
    min-height: 0;
    margin: 0;
    overflow: auto;
    text-align: center;
    touch-action: pan-y pinch-zoom;
}

.jww-lightbox__figure img {
    min-height: 0;
    max-width: 100%;
    max-height: calc(100dvh - 7rem);
    object-fit: contain;
}

.jww-lightbox figcaption {
    margin-top: 0.5rem;
}

.jww-lightbox button {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid #aaa;
    border-radius: 50%;
    background: #202930;
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
}

.jww-lightbox__prev { grid-column: 1; }
.jww-lightbox__next { grid-column: 3; }
.jww-lightbox__prev,
.jww-lightbox__figure,
.jww-lightbox__next { grid-row: 1; }

.jww-lightbox .jww-lightbox__close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.jww-lightbox__count {
    position: absolute;
    top: 0.5rem;
    left: 1rem;
    margin: 0;
    line-height: 2.75rem;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 47.99rem) {
    .jww-lightbox[open] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: minmax(0, 1fr) auto;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .jww-lightbox__figure {
        grid-column: 1 / -1;
    }

    .jww-lightbox__figure img {
        max-height: calc(100dvh - 9rem);
    }

    .jww-lightbox__prev,
    .jww-lightbox__next {
        grid-row: 2;
        margin-top: 0.5rem;
    }

    .jww-lightbox__prev { justify-self: end; margin-right: 0.75rem; }
    .jww-lightbox__next { grid-column: 2; justify-self: start; margin-left: 0.75rem; }
}

.jww-lightbox button:focus-visible,
.jww-lightbox-trigger:focus-visible {
    outline: 3px solid #91aa4e;
    outline-offset: 2px;
}

.jww-lightbox-trigger {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}

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