/* Карточки каталога: сетка, фото, свотчи, избранное (общий компонент) */

.products-grid-category {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    padding: 0;
    margin-bottom: 2rem;
}

.product-card-category {
    position: relative;
    overflow: hidden;
    background: #fff;
    transition: all 0.3s ease;
}

.product-card-category:hover {
    box-shadow: none;
}

.product-link-category {
    text-decoration: none;
    color: inherit;
    display: block;
}

.product-image-container-category {
    position: relative;
    overflow: hidden;
    aspect-ratio: 3/4;
    background: #f8f8f8;
}

.product-image-category {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    transition: opacity 0.25s ease, transform 0.4s ease;
}

/* Poster-img до старта mp4: LCP = картинка, не video frame */
.product-card-video-poster {
    z-index: 2;
}
.product-card-video-el.is-poster-pending {
    opacity: 0;
    z-index: 1;
    pointer-events: none;
}
.product-card-video-el:not(.is-poster-pending) {
    z-index: 2;
}
.product-image-container-category:has(.product-card-video-el:not(.is-poster-pending)) .product-card-video-poster {
    opacity: 0;
    pointer-events: none;
}

.product-image-container-category video.product-image-category,
.product-image-container-category img.product-image-category {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Скрытие слоёв при свотче (в т.ч. когда снаружи display:block!important) */
.product-image-container-category .product-image-category.is-media-hidden,
.product-image-container-category .product-image-category[hidden] {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: 0 !important;
}

.product-image-category.additional-image {
    opacity: 0;
    transform: scale(1.05);
    z-index: 1;
}

/* color-switched — только пока курсор не на карточке; иначе hover-видео/фото не показывались */
@media (hover: hover) and (pointer: fine) {
    .product-card-category.color-switched:not(:hover) .product-image-category.main-image {
        opacity: 1 !important;
    }

    .product-card-category.color-switched:not(:hover) .product-image-category.additional-image {
        opacity: 0 !important;
    }

    [data-hover-swap]:hover .product-image-category.main-image {
        opacity: 0 !important;
    }

    [data-hover-swap]:hover .product-image-category.additional-image {
        opacity: 1 !important;
        transform: scale(1);
        z-index: 3;
    }
}

/* Touch / coarse: tap/swipe через .is-showing-second (product-card-video-loop.js) */
[data-hover-swap].is-showing-second .product-image-category.main-image:not(.is-media-hidden) {
    opacity: 0 !important;
}
[data-hover-swap].is-showing-second .product-image-category.additional-image {
    opacity: 1 !important;
    transform: scale(1);
    z-index: 3;
}

.product-info-category {
    padding: 8px 10px 0 34px;
    background: transparent;
    margin-left: 16px;
    margin-right: 16px;
}

.product-info-category--swatches-only {
    padding: 0 10px 10px 34px;
    background: transparent;
    margin-left: 0;
    margin-right: 16px;
}

.product-title-category {
    font-size: 12px;
    line-height: 1.4;
    margin: 0 5px 4px -16px;
    color: rgba(0, 0, 0, 1);
    font-weight: 500;
}

.product-price-category {
    font-size: 12px;
    font-weight: 600;
    color: #000;
    margin-left: 0;
    margin-right: 0;
}

.product-info-category .d-flex.align-items-center.justify-content-between.mb-2 {
    padding-left: 0;
    padding-right: 0;
    margin-left: -16px;
}

.product-category-row {
    margin: 0 5px 6px -16px;
}

.product-category-thumb {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid #e5e5e5;
    flex-shrink: 0;
}

.product-category-name {
    font-size: 11px;
    line-height: 1.2;
}

.color-options-category {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.product-card-category:hover .color-options-category {
    opacity: 1;
    transform: translateY(0);
}

.color-swatches-category {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 0;
    padding-right: 0;
    width: auto;
    max-width: 100%;
    min-height: 26px;
    height: auto;
}

.color-swatch-category {
    width: 28px;
    height: 28px;
    border-radius: 10%;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-swatch-category:hover,
.color-swatch-category.active {
    border-color: #000;
}

.color-swatch-category.out-of-stock-swatch {
    opacity: 0.6;
    position: relative;
}

.color-swatch-category.out-of-stock-swatch::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #666;
    transform: rotate(-45deg);
    z-index: 1;
}

.color-more-category {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #f8f9fa;
    border-radius: 10%;
    border: 1px solid #e9ecef;
    font-size: 0.7rem;
    color: #666;
}

.add-to-cart-btn-category {
    display: none !important;
}

/* Кнопка избранного — всегда поверх hover-фото/видео (у них z-index до 3–4) */
.favorite-btn-category,
.product-card-category > .favorite-btn-category.fav-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.favorite-btn-category svg {
    color: #000;
    width: 16px;
    height: 16px;
}

.favorite-btn-category.active svg path {
    fill: #000;
}

#favorites-products-grid .product-item-favorites {
    display: contents;
}

@media (max-width: 991.98px) {
    .products-grid-category {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1px;
        padding: 0;
    }

    .product-card-category:hover {
        transform: none;
    }

    .color-options-category {
        opacity: 1;
        transform: translateY(0);
    }

    .product-info-category {
        padding: 8px 10px 10px 16px;
    }

    .product-info-category--swatches-only {
        padding: 0 10px 10px 16px;
    }

    .color-options-category {
        margin-top: 0 !important;
    }

    #favorites-products-grid.products-grid-category {
        grid-template-columns: 1fr;
    }

    #favorites-products-grid .product-info-category {
        padding: 8px 10px 0 34px;
    }
}
