.lightbox {
    opacity: 0.01;
    transition: opacity 0.4s ease;
    will-change: opacity;
    font-style: inherit;
}

.lightbox[data-visible] {
    opacity: 1;
}

.lightbox>button {
    --size: 2rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: var(--size);
    height: var(--size);
    background: black;
    color: white;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.4s ease;
    will-change: opacity;
    pointer-events: none;
}

.lightbox>button:focus {
    outline: none;
}

.lightbox>button:first-of-type {
    left: 3rem;
}

.lightbox>button:last-of-type {
    right: 3rem;
}

.lightbox[data-has-prev]>button:first-of-type,
.lightbox[data-has-next]>button:last-of-type {
    opacity: 1;
    pointer-events: all;
}

.lightbox>div {
    --px: 3rem;
    --py: 1rem;
    position: absolute;
    top: var(--py);
    bottom: var(--py);
    right: var(--px);
    left: var(--px);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.9);
    transition: transform 0.4s ease;
    will-change: transform;
    z-index: 1;
}

.lightbox[data-visible]>div {
    transform: scale(1);
}

.lightbox img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
}

@media screen and (min-width: 60rem) {
    .lightbox>div {
        --px: 4.5rem;
        --py: 1.5rem;
    }
    .lightbox>button {
        --size: 3rem;
    }
}