/* =========================================================
   CARRUSEL DE PRODUCTOS (motor comun)
   ========================================================= */

.superop-carousel {
    --so-desktop: 3;
    --so-tablet: 2;
    --so-mobile: 1;
    --so-gap: 20px;
    --so-visible: var(--so-desktop);
    --so-arrow: 40px;

    position: relative;
    clear: both;
}

/* Si no hay relacionados, WooCommerce no pinta nada dentro. */
.superop-carousel:empty,
.superop-carousel.is-empty {
    display: none;
}

.superop-carousel > .products,
.superop-carousel > section {
    position: relative;
}

/* La lista pasa a ser la pista del carrusel. */
.superop-carousel ul.products {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: var(--so-gap);
    margin: 0 !important;
    padding: 0 0 6px !important;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    list-style: none !important;
}

.superop-carousel ul.products::-webkit-scrollbar {
    display: none;
}

.superop-carousel ul.products::before,
.superop-carousel ul.products::after {
    display: none !important;
    content: none !important;
}

.superop-carousel ul.products > li,
.superop-carousel ul.products > li.product {
    flex: 0 0 calc(
        (100% - (var(--so-visible) - 1) * var(--so-gap)) / var(--so-visible)
    );
    width: auto !important;
    min-width: 0;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    clear: none !important;
    scroll-snap-align: start;
}

.superop-carousel ul.products > li.product::before,
.superop-carousel ul.products > li.product::after {
    display: none !important;
    content: none !important;
}

.superop-carousel ul.products > li.product img {
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* Hueco cuadrado y la imagen entera dentro: si el tamaño elegido no está
   recortado, las tarjetas siguen teniendo todas la misma altura. */
.superop-carousel.superop-square ul.products > li.product img {
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #fff;
}

/* =========================================================
   FLECHAS
   ========================================================= */

.superop-carousel .superop-arrow {
    position: absolute;
    z-index: 5;
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--so-arrow);
    height: var(--so-arrow);
    margin: 0;
    padding: 0;
    transform: translateY(-50%);
    border: 1px solid #e0e0e0 !important;
    border-radius: 50%;
    background: #fff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    color: #222 !important;
    line-height: 0;
    cursor: pointer;
    transition: opacity 150ms ease, box-shadow 150ms ease;
}

.superop-carousel .superop-arrow:hover,
.superop-carousel .superop-arrow:focus {
    background: #fff !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
    color: #000 !important;
}

.superop-carousel .superop-arrow svg {
    display: block;
    width: 12px;
    height: 12px;
}

.superop-carousel .superop-prev {
    left: calc(var(--so-arrow) / -2);
}

.superop-carousel .superop-next {
    right: calc(var(--so-arrow) / -2);
}

.superop-carousel .superop-arrow[disabled] {
    opacity: 0.35;
    box-shadow: none;
    cursor: default;
}

/* Cuando caben todos, no hace falta carrusel. */
.superop-carousel.is-static .superop-arrow {
    display: none;
}

.superop-carousel.is-static ul.products {
    justify-content: flex-start;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 991px) {
    .superop-carousel {
        --so-visible: var(--so-tablet);
    }
}

@media (max-width: 575px) {
    .superop-carousel {
        --so-visible: var(--so-mobile);
        --so-arrow: 34px;
    }

    /* Sin espacio a los lados, las flechas se meten dentro. */
    .superop-carousel .superop-prev {
        left: 2px;
    }

    .superop-carousel .superop-next {
        right: 2px;
    }
}
