#gallery {
    position: relative;
    width: 100%;
    height: 100vh;

    margin: 2rem 0;
}

#gallery div {
    position: absolute;
    background-color: lightgray;
    overflow: hidden;
    
    border-radius: 0.5rem;
}

#gallery div::before {
    z-index: 0;
    content: "";
    position: absolute;
    inset: calc(-2 * var(--gallery-blur));
    background: inherit;
    background-size: cover;
    background-position: center;
    filter: blur(var(--gallery-blur));
}

.gallery img:hover {
    transform: scale(1.05);
}

#gallery div img {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: auto;

    opacity: 0;
    transition: none;
    will-change: opacity;
}



.gallery-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 9999;

    touch-action: none;

    transition: opacity 0.3s ease-in-out;
    opacity: 0;
}

.gallery-overlay.gallery-active {
    opacity: 1;
}

.gallery-overlay-previous,
.gallery-overlay-next,
.gallery-overlay-back {
    position: absolute;
    background: #0000;
    width: 3.5rem;
    height: 3.5rem;

    border-radius: 9999px;
    padding: 1rem;

    z-index: 2;
}

.gallery-overlay-previous img,
.gallery-overlay-next img,
.gallery-overlay-back img {
    width: 100%;
}

@media (hover: hover) and (pointer: fine) {

    .gallery-overlay-previous:hover,
    .gallery-overlay-next:hover,
    .gallery-overlay-back:hover {
        transform: scale(1.1);
        background: #888888aa;
    }
}

.gallery-overlay-previous {
    left: 20px;
}

.gallery-overlay-next {
    right: 20px;
}

.gallery-overlay-back {
    left: 20px;
    top: 20px;
}


.gallery-overlay-preview {
    position: relative;
    overflow: hidden;

    will-change: transform;
    transform: translate3d(0, 0, 0);

    transition: none;
}

.gallery-overlay-preview-hide {
    transition: transform .35s ease-in !important;
    transform: translateY(8rem) !important;
}

.gallery-overlay-preview.gallery-overlay-zoom-transition {
    transition: transform .35s ease-in-out;
}

.gallery-overlay-preview::before {
    z-index: 0;
    content: "";
    position: absolute;
    inset: calc(-4 * var(--gallery-blur));
    background: inherit;
    background-size: cover;
    background-position: center;
    filter: blur(calc(var(--gallery-blur) * 2));
}

.gallery-overlay-img {
    position: relative;
    z-index: 1;
    display: block;
    border-radius: 0 !important;

    max-width: 90vw !important;
    max-height: 90vh !important;
    width: auto;
    height: auto;

    opacity: 0;
    transition: none;
    will-change: opacity;
}

.gallery-image-loaded {
    opacity: 1 !important;
    transition: opacity .35s ease-in-out !important;
}