/* Галерея товара — минималистичная карусель без внешних библиотек */

.product-gallery {
    --gallery-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --gallery-duration: 0.45s;
    width: 100%;
}

.product-gallery__main {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.product-gallery__viewport {
    flex: 1;
    overflow: hidden;
    border-radius: 0.375rem;
    touch-action: pan-y pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
}

.product-gallery__track {
    display: flex;
    transition: transform var(--gallery-duration) var(--gallery-ease);
    will-change: transform;
}

.product-gallery__slide {
    flex: 0 0 100%;
    margin: 0;
    min-height: min(420px, 55vw);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0.375rem;
    background: linear-gradient(145deg, #f8f6f0 0%, #f0ede4 100%);
}

.product-gallery__img {
    width: 100%;
    max-height: min(480px, 62vw);
    object-fit: contain;
    transition: transform 0.5s var(--gallery-ease);
    transform-origin: center center;
}

.product-gallery__slide.is-active .product-gallery__img:hover {
    transform: scale(1.03);
}

.product-gallery__fallback {
    min-height: min(400px, 55vw);
    width: 100%;
}

.product-gallery__nav {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid rgba(95, 106, 78, 0.2);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--dark-color, #3d3d33);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        background 0.25s ease,
        border-color 0.25s ease,
        transform 0.25s var(--gallery-ease),
        box-shadow 0.25s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 2;
}

.product-gallery__nav:hover {
    background: #fff;
    border-color: var(--primary-color, #c08a82);
    box-shadow: 0 4px 14px rgba(192, 138, 130, 0.2);
}

.product-gallery__nav:active {
    transform: scale(0.96);
}

.product-gallery__nav:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.product-gallery__thumbs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.85rem;
    padding-bottom: 0.15rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.product-gallery__thumb {
    flex: 0 0 auto;
    width: 4.25rem;
    height: 4.25rem;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #f5f3ed;
    cursor: pointer;
    scroll-snap-align: start;
    transition:
        border-color 0.3s var(--gallery-ease),
        opacity 0.3s ease,
        transform 0.3s var(--gallery-ease);
    opacity: 0.72;
}

.product-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.product-gallery__thumb:hover {
    opacity: 0.95;
    transform: translateY(-2px);
}

.product-gallery__thumb.is-active {
    border-color: var(--primary-color, #c08a82);
    opacity: 1;
    box-shadow: 0 4px 12px rgba(192, 138, 130, 0.22);
}

.product-gallery.is-fading .product-gallery__track {
    transition: opacity 0.35s var(--gallery-ease), transform var(--gallery-duration) var(--gallery-ease);
}

@media (max-width: 768px) {
    .product-gallery__nav {
        width: 2rem;
        height: 2rem;
        font-size: 0.85rem;
    }

    .product-gallery__slide {
        min-height: min(320px, 68vw);
    }

    .product-gallery__img {
        max-height: min(360px, 68vw);
    }

    .product-gallery__thumb {
        width: 3.75rem;
        height: 3.75rem;
    }

    .product-gallery__slide.is-active .product-gallery__img:hover {
        transform: none;
    }
}

/* ── Мини-карусель в карточке каталога ─────────────────────────── */

.product-card-gallery {
    position: relative;
    overflow: hidden;
    /* Высота как у обычной card-img-top */
    height: 220px;
}

.product-card-gallery .product-gallery__viewport {
    border-radius: 0;
    height: 100%;
}

.product-card-gallery .product-gallery__track {
    height: 100%;
}

.product-card-gallery .product-gallery__slide {
    min-height: 0;
    height: 220px;
    border-radius: 0;
    background: #f8f6f0;
}

.product-card-gallery__img {
    width: 100%;
    height: 220px;
    max-height: none;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.product-card-gallery .product-gallery__slide.is-active .product-card-gallery__img:hover {
    transform: scale(1.04);
}

/* Прозрачная ссылка поверх каждого слайда → переход на страницу товара */
.product-card-gallery__slide-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
}

/* Стрелки — плавают внутри изображения, скрыты до hover */
.product-card-gallery__nav--prev,
.product-card-gallery__nav--next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    margin: 0;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.25s ease, transform 0.2s ease;
}

.product-card-gallery__nav--prev {
    left: 0.5rem;
}

.product-card-gallery__nav--next {
    right: 0.5rem;
}

.product-card-gallery:hover .product-card-gallery__nav--prev,
.product-card-gallery:hover .product-card-gallery__nav--next,
.product-card-gallery:focus-within .product-card-gallery__nav--prev,
.product-card-gallery:focus-within .product-card-gallery__nav--next {
    opacity: 1;
}

/* Точки-индикаторы внизу изображения */
.product-card-gallery__dots {
    position: absolute;
    bottom: 0.5625rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.3125rem;
    z-index: 2;
}

.product-card-gallery__dot {
    width: 0.4375rem;
    height: 0.4375rem;
    padding: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.product-card-gallery__dot.is-active {
    background: #fff;
    transform: scale(1.3);
    border-color: #fff;
}

/* На мобильных стрелки всегда видны (нет hover) */
@media (hover: none) {
    .product-card-gallery__nav--prev,
    .product-card-gallery__nav--next {
        opacity: 0.85;
        width: 1.875rem;
        height: 1.875rem;
    }
}

@media (max-width: 767.98px) {
    .product-card-gallery,
    .product-card-gallery .product-gallery__slide,
    .product-card-gallery__img {
        height: 200px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .product-gallery__track,
    .product-gallery__img,
    .product-gallery__thumb,
    .product-gallery__nav {
        transition: none !important;
    }

    .product-gallery__slide.is-active .product-gallery__img:hover {
        transform: none;
    }
}
