.product-parameters {
    margin-top: 0;
    margin-bottom: 1.6rem;
    pointer-events: auto;
    opacity: 0;
    transition: opacity var(--duration-default);
}

.card-wrapper:hover .product-parameters {
    opacity: 1;
}

.product-parameters label.color-swatch {
    margin: 0;
}

/* Disabled color swatches */
.product-parameters input.disabled+label.color-swatch,
.product-parameters input[disabled]+label.color-swatch,
.product-parameters label.color-swatch.disabled {
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

p.color-count {
    display: none;
    font-size: 1.5rem;
    margin: 0;
}

/* Desktop behavior - show max 4 swatches */
@media screen and (min-width: 1201px) {
    .desktop-hidden-swatch {
        display: none !important;
    }

    .desktop-color-count {
        display: inline !important;
    }

    .mobile-color-count {
        display: none !important;
    }

    /* Show all swatches when hovering over the color count on desktop */
    .product-parameters:hover .desktop-hidden-swatch {
        display: inline-block !important;
    }

    .product-parameters:hover .desktop-color-count {
        display: none !important;
    }
}

@media screen and (max-width: 1200px) {
    .card-wrapper .product-parameters {
        opacity: 1;

        .product-form__controls-group {
            height: 3rem !important;
        }
    }

    /* Hide all swatches except the first one on mobile/tablet */
    .product-form__controls-group input:not(:first-of-type),
    .product-form__controls-group label:not(:first-of-type) {
        display: none;
    }

    /* Also hide desktop-hidden swatches on mobile */
    .desktop-hidden-swatch {
        display: none !important;
    }

    /* Show only mobile count, hide desktop count on mobile */
    .desktop-color-count {
        display: none !important;
    }

    .mobile-color-count {
        display: inline !important;
    }
}

/* Ensure color swatches are always visible on touch devices */
@media (hover: none) and (pointer: coarse) {
    .product-parameters {
        opacity: 1 !important;
    }

    .card-wrapper .product-parameters {
        opacity: 1 !important;
    }
}

/* Additional mobile-specific rule for devices that don't support hover */
@media (max-width: 768px) {
    .product-parameters {
        opacity: 1 !important;
    }

    .card-wrapper .product-parameters {
        opacity: 1 !important;
    }
}

/* Swiper */
.card--product {
    position: relative;
}

.swiper-button {
    all: unset;
    z-index: 100;
    padding: 1rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3.2rem;
    height: 3.2rem;
    background-color: transparent;
    border-radius: 50%;
    cursor: pointer;
}

/* Desktop: hide buttons by default, show on hover */
@media screen and (min-width: 769px) {
    .card-wrapper:hover .swiper-button {
        display: block;
    }
}

/* Mobile: always show buttons */
@media screen and (max-width: 768px) {
    .swiper-button {
        display: block;
        width: 2.4rem;
        height: 2.4rem;
    }

    .chevron {
        width: 1.8rem;
        height: 1.8rem;
    }
}

.swiper-button-left {
    left: .5rem;
}

.swiper-button-right {
    right: .5rem;
}

.chevron {
    color: white;
}

/* Allow the overlay link to receive clicks/taps so the whole card is clickable.
   Interactive children inside the card (hearts, swatches, quick add, arrows)
   either sit above this overlay via z-index or stop propagation themselves,
   so they won't trigger navigation unintentionally. */
.card-wrapper__link--overlay {
    pointer-events: auto !important;
}

.card--product .media>img {
    top: 50% !important;
    left: 50% !important;
    translate: -50% -50% !important;
}


/* Ensure smooth hover fade mirrors theme behavior */
@media screen and (min-width: 990px) {

    .card-wrapper .media.media--hover-effect>img,
    .card .media.media--hover-effect>img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        opacity: 0 !important;
        transition: transform var(--duration-long) ease, opacity var(--duration-long) ease;
    }

    /* Ensure proper stacking context */
    .card-wrapper .media.media--hover-effect {
        position: relative;
    }

    /* Class-based visibility to avoid DOM-order races */
    .card-wrapper .media.media--hover-effect>img.is-primary {
        z-index: 1;
        opacity: 1 !important;
    }

    .card-wrapper .media.media--hover-effect>img.is-secondary {
        z-index: 2;
        opacity: 0 !important;
    }

    /* On desktop hover (before activation), fade first-out and second-in */
    .card-wrapper:not(.swiper-active):hover .media.media--hover-effect>img.is-primary:not(:only-of-type) {
        opacity: 0 !important;
    }

    .card-wrapper:not(.swiper-active):hover .media.media--hover-effect>img.is-secondary {
        opacity: 1 !important;
    }

    /* When only one image is available for current color, zoom instead of swap */
    .card-wrapper:not(.swiper-active):hover .media.media--hover-effect.hover-zoom>img.is-primary {
        transform: scale(1.06);
        opacity: 1 !important;
    }
}