/* ==== Сетка миниатюр ==== */
.jgallery {
    display: grid;
    grid-template-columns: repeat(var(--jgallery-columns, 5), 1fr);
    gap: 8px;
    margin: 1em 0;
}

@media (max-width: 768px) {
    .jgallery {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .jgallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

.jgallery__item {
    position: relative;
    display: block;
    padding-bottom: 100%;
    overflow: hidden;
    border-radius: 6px;
    background: #eee;
    cursor: zoom-in;
}

.jgallery__item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s ease;
}

.jgallery__item:hover img,
.jgallery__item:focus img {
    transform: scale(1.06);
}

/* ==== Полноэкранный просмотр ==== */
.jgallery-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .92);
}

.jgallery-overlay.is-open {
    display: flex;
}

.jgallery-overlay__stage {
    max-width: 100vw;
    max-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Изображение не увеличивается сверх своего реального размера
   и не выходит за пределы окна просмотра. */
.jgallery-overlay__img {
    display: block;
    width: auto;
    height: auto;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    user-select: none;
}

.jgallery-overlay__close,
.jgallery-overlay__prev,
.jgallery-overlay__next {
    position: absolute;
    border: 0;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    cursor: pointer;
    line-height: 1;
    border-radius: 6px;
    transition: background .15s ease;
}

.jgallery-overlay__close:hover,
.jgallery-overlay__prev:hover,
.jgallery-overlay__next:hover {
    background: rgba(255, 255, 255, .25);
}

.jgallery-overlay__close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 26px;
}

.jgallery-overlay__prev,
.jgallery-overlay__next {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 64px;
    font-size: 22px;
}

.jgallery-overlay__prev {
    left: 16px;
}

.jgallery-overlay__next {
    right: 16px;
}

.jgallery-overlay__counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    opacity: .8;
}

body.jgallery-lock {
    overflow: hidden;
}
