.gallery-wrap {
    padding: var(--offset-biggest) var(--offset-usual);
    max-width: 1400px;
    margin: 0 auto;
}

.gallery-grid {
    column-count: 4;
    column-gap: var(--offset-usual);
}

@media (max-width: 1200px) {
    .gallery-grid {
        column-count: 3;
    }
}

@media (max-width: 800px) {
    .gallery-grid {
        column-count: 2;
    }
}

@media (max-width: 500px) {
    .gallery-grid {
        column-count: 2;
    }
}

.gallery-item {
    position: relative;
    cursor: pointer;
    border-radius: var(--offset-smallest);
    overflow: hidden;
    margin: 0 0 var(--offset-small);
    /* важно: запрет разрыва элемента между колонками */
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    transition: transform .3s ease;
    will-change: transform;
    display: block;
    line-height: 0;
}

.gallery-item img {
    width: 100%;
    height: auto;
    /* реальные пропорции */
    display: block;
    filter: grayscale(1) contrast(1.3) brightness(0.93) sepia(0.11);
    transition: filter .4s ease;
}

.gallery-item:hover {
    transform: scale(1.02);

}

.gallery-item:hover img {

    filter: grayscale(0) contrast(1) brightness(1) sepia(0);
    transition: filter .4s;
}

.gallery-item.flying {
    opacity: 0;
    pointer-events: none;
}

/* ---------- лайтбокс ---------- */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .72);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity .35s ease, visibility .35s ease;
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-stage {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
}

.lightbox-card {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-radius: var(--offset-smallest);
    overflow: hidden;
    pointer-events: auto;
    transform-origin: 50% 50%;
    will-change: transform, width, height;
}

.lightbox-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    filter: grayscale(1);
    transition: filter .5s ease;
}

.lightbox-card.open img {
    filter: grayscale(0);
}

.lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: var(--offset-smallest);
    background: var(--color-black);
    color: var(--color-white);
    border: none;
    font-size: var(--fontsize-big);
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(.5);
    transition: opacity .25s ease .2s, transform .3s ease .2s, background .2s ease;
    font-weight: 900;
    z-index: 2;
    transition: color .1s;
}
.lightbox-close:hover {
    background: var(--color-red-active);
    color: var(--color-white);
    transition: color .1s;
}



.lightbox-card.open .lightbox-close {
    opacity: 1;
    transform: scale(1);
}

body.lightbox-open {
    overflow: hidden;
}