.product-gallery {
    min-width: 0;
}

.product-gallery__stage {
    position: relative;
    overflow: hidden;
    border-radius: var(--rd-radius-lg, 24px);
}

.product-gallery__main {
    overflow: hidden;
    border-radius: inherit;
}

.product-gallery__main .swiper-slide {
    aspect-ratio: 4 / 3;
    background: var(--bg-tint);
}

.product-gallery__lightbox {
    display: block;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
}

.product-gallery__main img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.product-gallery__thumbs {
    margin-top: 12px;
    padding: 1px;
}

.product-gallery__thumbs .swiper-slide {
    box-sizing: border-box;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--bg-tint);
    cursor: pointer;
    opacity: 0.6;
    transition: border-color .15s ease, opacity .15s ease;
}

.product-gallery__thumbs .swiper-slide:hover,
.product-gallery__thumbs .swiper-slide-thumb-active {
    border-color: var(--accent);
    opacity: 1;
}

.product-gallery__thumbs img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

/* Product badge: keep "Новинка" inside the gallery image area. */
.product-gallery__stage > .tab.tag-pill {
    position: absolute;
    top: 5px;
    left: 5px;
    right: auto;
    bottom: auto;
    margin: 0;
    padding: 8px 14px;
    border-radius: 999px;
    transform: none;
    z-index: 5;
}

/* Local product lightbox. Uses the Swiper bundle already shipped with the theme. */
/*
 * Reserve the vertical scrollbar space before the lightbox opens.
 * The page width therefore never changes when scrolling is locked.
 */
@supports (scrollbar-gutter: stable) {
    html {
        scrollbar-gutter: stable;
    }
}

@supports not (scrollbar-gutter: stable) {
    html {
        overflow-y: scroll;
    }
}

body.product-lightbox-open {
    overflow: hidden;
}

.product-lightbox[hidden] {
    display: none;
}

.product-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(0, 0, 0, 0.76);
    opacity: 0;
    transition: opacity .28s ease;
}

.product-lightbox.is-open {
    opacity: 1;
    transition-duration: .38s;
}

.product-lightbox__backdrop {
    position: absolute;
    inset: 0;
}

.product-lightbox__dialog,
.product-lightbox__swiper,
.product-lightbox__swiper .swiper-wrapper,
.product-lightbox__swiper .swiper-slide,
.product-lightbox__swiper .swiper-zoom-container {
    width: 100%;
    height: 100%;
}

.product-lightbox__dialog {
    position: relative;
}

.product-lightbox__swiper {
    opacity: 0;
    transform: scale(.97);
    transform-origin: center center;
    transition: transform .28s cubic-bezier(.4, 0, .22, 1), opacity .28s ease;
}

.product-lightbox.is-open .product-lightbox__swiper {
    opacity: 1;
    transform: scale(1);
    transition-duration: .38s, .38s;
}

.product-lightbox__swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-lightbox__swiper .swiper-zoom-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-lightbox__swiper img {
    display: block;
    max-width: calc(100% - 24px);
    max-height: calc(100% - 96px);
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.product-lightbox__close,
.product-lightbox__nav {
    position: absolute;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #111;
    cursor: pointer;
    line-height: 1;
}

.product-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    font-size: 0;
}

/* Swiper watchOverflow: hide navigation when there is nothing to slide. */
.product-lightbox__nav.swiper-button-lock {
    display: none;
}

.product-lightbox__counter[hidden] {
    display: none;
}

.portfolio-detail__lightbox {
    display: block;
    cursor: zoom-in;
}

.product-lightbox__nav::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    box-sizing: border-box;
    width: 9px;
    height: 9px;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform-origin: center;
}

.product-lightbox__nav--prev::before {
    transform: translate(-50%, -50%) rotate(135deg);
}

.product-lightbox__nav--next::before {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.product-lightbox__close {
    top: 12px;
    right: 12px;
    font-size: 28px;
    font-weight: 300;
}

.product-lightbox__nav--prev {
    left: 12px;
}

.product-lightbox__nav--next {
    right: 12px;
}

.product-lightbox__counter {
    position: absolute;
    z-index: 4;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 13px;
    line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
    .product-lightbox,
    .product-lightbox__swiper {
        transition: none;
    }
}

@media (max-width: 767.98px) {
    .product-lightbox__nav {
        display: none;
    }

    .product-lightbox__swiper img {
        max-width: 100%;
        max-height: calc(100% - 72px);
    }
}
