/* Where to Buy Module - Styles v1.1 */

/* ============================================================
   MÓDULO BASE
   ============================================================ */

.wheretobuys-module {
    padding: 50px 0;
    overflow: hidden;
}

.wheretobuys-header {
    text-align: center;
    margin-bottom: 40px;
}

.wheretobuys-title {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ============================================================
   CAROUSEL WRAPPER — con padding para las flechas
   ============================================================ */

.wheretobuys-carousel-wrapper {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 70px;      /* espacio para flechas */
}

/* Sin flechas → sin padding lateral */
.wheretobuys-carousel-wrapper.no-arrows {
    padding: 0 20px;
}

/* ============================================================
   CAROUSEL
   ============================================================ */

.wheretobuys-carousel {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 20px 0;

    /* DISTRIBUCIÓN AUTOMÁTICA:
       Cuando hay 4 o menos ítems caben exactamente en el ancho
       disponible, gracias a flex-wrap: nowrap + justify-content.
       Cuando hay más de 4 se activa el scroll. */
    justify-content: center;   /* centra cuando hay pocos ítems   */
    flex-wrap: nowrap;
}

.wheretobuys-carousel::-webkit-scrollbar {
    display: none;
}

/* ============================================================
   ITEMS — DESKTOP (≥ 992px)
   Se definen 4 columnas máximo. Si hay 1, 2 o 3 ítems,
   la distribución queda centrada gracias al justify-content.
   ============================================================ */

.wheretobuys-item {
    /* Tamaño fijo basado en cuartos del espacio disponible */
    flex: 0 0 calc(25% - 16px);   /* 4 columnas con gap 20px */
    min-width: 180px;
    max-width: 280px;

    aspect-ratio: 4 / 3;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.wheretobuys-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.wheretobuys-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.wheretobuys-image {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.wheretobuys-item:hover .wheretobuys-image {
    transform: scale(1.07);
}

/* ============================================================
   CLASES DE DISTRIBUCIÓN — generadas por JS según cantidad
   de ítems activos (1, 2, 3 o ≥4)
   ============================================================ */

/* 1 solo ítem: centrado y ancho generoso */
.wheretobuys-carousel.items-1 .wheretobuys-item {
    flex: 0 0 40%;
    max-width: 360px;
}

/* 2 ítems: mitad del espacio cada uno */
.wheretobuys-carousel.items-2 .wheretobuys-item {
    flex: 0 0 calc(50% - 10px);
    max-width: 400px;
}

/* 3 ítems: un tercio cada uno */
.wheretobuys-carousel.items-3 .wheretobuys-item {
    flex: 0 0 calc(33.333% - 14px);
    max-width: 340px;
}

/* 4+ ítems: cuarto del espacio; scroll horizontal si hay más */
.wheretobuys-carousel.items-4plus .wheretobuys-item {
    flex: 0 0 calc(25% - 16px);
    max-width: 280px;
}

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

.wheretobuys-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid currentColor;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0;
}

.wheretobuys-arrow:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.12);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.wheretobuys-arrow-prev { left: 0; }
.wheretobuys-arrow-next { right: 0; }
.wheretobuys-arrow svg  { pointer-events: none; }

/* ============================================================
   MODAL
   ============================================================ */

.wheretobuys-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: wtb-fadeIn 0.3s ease;
}

@keyframes wtb-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.wheretobuys-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: wtb-slideDown 0.3s ease;
}

@keyframes wtb-slideDown {
    from { opacity: 0; transform: translateY(-50px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wheretobuys-modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid #e9ecef;
}

.wheretobuys-modal-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: #333;
}

.wheretobuys-modal-body {
    padding: 30px;
}

.wheretobuys-modal-body p {
    margin: 0 0 15px 0;
    color: #555;
    line-height: 1.6;
}

.wheretobuys-modal-body #wheretobuys-modal-url {
    color: #2196f3;
    font-size: 14px;
    word-break: break-all;
}

.wheretobuys-modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.wheretobuys-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wheretobuys-btn-cancel {
    background: #f5f5f5;
    color: #666;
}

.wheretobuys-btn-cancel:hover { background: #e0e0e0; }

.wheretobuys-btn-confirm {
    background: #2196f3;
    color: white;
}

.wheretobuys-btn-confirm:hover {
    background: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

/* ============================================================
   TABLET  (768 – 991 px)
   ============================================================ */

@media (max-width: 991px) {
    .wheretobuys-carousel-wrapper {
        padding: 0 60px;
    }

    /* Redistribución en tablet */
    .wheretobuys-carousel.items-1 .wheretobuys-item {
        flex: 0 0 60%;
        max-width: 400px;
    }

    .wheretobuys-carousel.items-2 .wheretobuys-item {
        flex: 0 0 calc(50% - 10px);
        max-width: 360px;
    }

    .wheretobuys-carousel.items-3 .wheretobuys-item,
    .wheretobuys-carousel.items-4plus .wheretobuys-item {
        flex: 0 0 calc(33.333% - 14px);
        max-width: 300px;
    }
}

/* ============================================================
   MÓVIL  (< 768 px)
   — 3 ítems HORIZONTALES simultáneos, nunca vertical —
   — Iconos grandes y usables                          —
   ============================================================ */

@media (max-width: 767px) {
    .wheretobuys-module {
        padding: 36px 0;
    }

    .wheretobuys-title {
        font-size: 20px;
    }

    /* Wrapper más estrecho para dar espacio a las flechas */
    .wheretobuys-carousel-wrapper {
        padding: 0 46px;
    }

    .wheretobuys-carousel-wrapper.no-arrows {
        padding: 0 12px;
    }

    /* Flechas más pequeñas pero aún tocables (mín 44 × 44 px) */
    .wheretobuys-arrow {
        width: 44px;
        height: 44px;
    }

    .wheretobuys-arrow svg {
        width: 22px;
        height: 22px;
    }

    /* ── TAMAÑO DE ÍTEM EN MÓVIL ──────────────────────────────
       Ocupan exactamente 1/3 del ancho visible.
       calc() descuenta el padding del wrapper (46px × 2 = 92px)
       y el gap entre los 3 ítems (20px × 2 = 40px).
       Esto hace que los iconos llenen la pantalla correctamente.
    ────────────────────────────────────────────────────────── */

    /* Todos los ítems: 3 columnas horizontales */
    .wheretobuys-carousel .wheretobuys-item,
    .wheretobuys-carousel.items-1 .wheretobuys-item,
    .wheretobuys-carousel.items-2 .wheretobuys-item,
    .wheretobuys-carousel.items-3 .wheretobuys-item,
    .wheretobuys-carousel.items-4plus .wheretobuys-item {
        flex: 0 0 calc(33.333vw - 50px);
        min-width: calc(33.333vw - 50px);
        max-width: none;
        padding: 14px;
        aspect-ratio: 1 / 1;      /* cuadrado → icono más grande */
    }

    /* Scroll snap para desplazamiento suave */
    .wheretobuys-carousel {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;   /* en móvil siempre al inicio */
    }

    .wheretobuys-item {
        scroll-snap-align: start;
    }

    /* Modal en móvil */
    .wheretobuys-modal-content   { width: 95%; }
    .wheretobuys-modal-header    { padding: 20px; }
    .wheretobuys-modal-header h3 { font-size: 18px; }
    .wheretobuys-modal-body      { padding: 20px; }
    .wheretobuys-modal-footer {
        padding: 15px 20px;
        flex-direction: column;
    }
    .wheretobuys-btn {
        width: 100%;
        padding: 14px;
    }
}

/* ============================================================
   EXTRA SMALL  (< 420 px)
   ============================================================ */

@media (max-width: 420px) {
    .wheretobuys-carousel-wrapper {
        padding: 0 40px;
    }

    .wheretobuys-carousel .wheretobuys-item,
    .wheretobuys-carousel.items-1 .wheretobuys-item,
    .wheretobuys-carousel.items-2 .wheretobuys-item,
    .wheretobuys-carousel.items-3 .wheretobuys-item,
    .wheretobuys-carousel.items-4plus .wheretobuys-item {
        flex: 0 0 calc(33.333vw - 44px);
        min-width: calc(33.333vw - 44px);
        padding: 10px;
    }

    .wheretobuys-arrow {
        width: 38px;
        height: 38px;
    }
}

/* ============================================================
   ACCESIBILIDAD
   ============================================================ */

.wheretobuys-arrow:focus {
    outline: 3px solid #2196f3;
    outline-offset: 3px;
}

.wheretobuys-link:focus {
    outline: 2px solid #2196f3;
    outline-offset: 2px;
}

/* ============================================================
   ESTADOS
   ============================================================ */

.wheretobuys-carousel.loading {
    opacity: 0.6;
    pointer-events: none;
}

.wheretobuys-carousel.animating {
    scroll-behavior: smooth;
}

/* ============================================================
   IMPRESIÓN
   ============================================================ */

@media print {
    .wheretobuys-arrow,
    .wheretobuys-modal {
        display: none;
    }
}
