/**
 * Amazon Clusters CSS - Versión UX/UI Optimizada v1.6 - MODIFICADO
 * Mejoras: Botón "Ver Reseña" con overlay y imagen aclarada en hover
 */

/* ==========================================================================
   CONTENEDOR PRINCIPAL DEL CLUSTER
   ========================================================================== */

.amazon-cluster-container {
    display: grid;
    gap: 20px;
    margin: 30px 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

/* Grid dinámico basado en data-attributes */
.amazon-cluster-container[data-columns-desktop="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.amazon-cluster-container[data-columns-desktop="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.amazon-cluster-container[data-columns-desktop="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.amazon-cluster-container[data-columns-desktop="6"] {
    grid-template-columns: repeat(6, 1fr);
}

/* ==========================================================================
   ITEM INDIVIDUAL DEL CLUSTER - ANIMACIONES SUAVES
   ========================================================================== */

.cluster-item {
    background: #fff;
    border: 2px solid transparent;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    /* 🌊 ANIMACIONES MÁS SUAVES - Múltiples propiedades */
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.07);
    cursor: pointer;
}

/* 🌊 HOVER CON ANIMACIONES EN CAPAS */
.cluster-item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.12);
    border-color: #0073aa;
    /* 👆 BORDE/OUTLINE SUTIL ACTIVADO */
}

/* ==========================================================================
   ENLACE COMPLETO (todo el item es clickeable)
   ========================================================================== */

.cluster-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
    position: relative;
}

.cluster-link:hover {
    text-decoration: none;
    color: inherit;
}

/* ==========================================================================
   IMAGEN DEL PRODUCTO - ANIMACIÓN SUAVE + OVERLAY
   ========================================================================== */

.item-image {
    position: relative;
    width: 100%;
    height: 220px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* 🌊 ANIMACIÓN SUAVE DE IMAGEN */
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 🌊 HOVER: Imagen aclarada (opacity reducida) */
.cluster-item:hover .item-image img {
    opacity: 0.3;
    transform: scale(1.05);
}

/* ==========================================================================
   OVERLAY OSCURO PARA MEJOR CONTRASTE DEL BOTÓN
   ========================================================================== */

.item-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.cluster-item:hover .item-image::before {
    opacity: 1;
}

/* ==========================================================================
   BOTÓN "VER RESEÑA" - LLAMADA A LA ACCIÓN
   ========================================================================== */

.cluster-item::before {
    content: "Ver Reseña →";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: #0073aa;
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    z-index: 10;
    /* 👆 INICIALMENTE INVISIBLE */
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    box-shadow: 0 8px 25px rgba(0, 115, 170, 0.3);
    white-space: nowrap;
    letter-spacing: 0.5px;
}

/* 👆 APARECER EN HOVER */
.cluster-item:hover::before {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ==========================================================================
   ELIMINAR EL ::after ANTERIOR
   ========================================================================== */

.cluster-item::after {
    display: none;
}

/* ==========================================================================
   CONTENIDO DEL ITEM - MEJOR TIPOGRAFÍA
   ========================================================================== */

.item-content {
    padding: 20px 18px;
    text-align: center;
    background: #fff;
    position: relative;
}

/* ✨ MEJOR TIPOGRAFÍA PARA TÍTULOS */
.item-title {
    margin: 0;
    /* Tamaños responsivos más grandes */
    font-size: clamp(15px, 2.5vw, 18px);
    font-weight: 600;
    /* Interlineado optimizado */
    line-height: 1.4;
    /* Colores más contrastados */
    color: #1a1a1a;
    word-wrap: break-word;
    /* Espaciado entre letras para mejor legibilidad */
    letter-spacing: -0.01em;
    /* Transición suave para cambio de color */
    transition: color 0.3s ease;
    /* Truncado inteligente - máximo 3 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Altura mínima para consistencia */
    min-height: 3.6em;
}

/* ✨ HOVER: Color más vibrante */
.cluster-link:hover .item-title {
    color: #0073aa;
    /* Micro-animación en el título */
    transform: translateY(-1px);
}

/* ==========================================================================
   RESPONSIVE DESIGN - TIPOGRAFÍA ADAPTATIVA
   ========================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    .amazon-cluster-container {
        gap: 16px;
        margin: 25px 0;
    }
    
    .amazon-cluster-container[data-columns-tablet="1"] {
        grid-template-columns: 1fr;
    }
    
    .amazon-cluster-container[data-columns-tablet="2"] {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .amazon-cluster-container[data-columns-tablet="3"] {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .item-image {
        height: 200px;
    }
    
    .item-content {
        padding: 16px 14px;
    }
    
    /* ✨ Tipografía adaptativa tablet */
    .item-title {
        font-size: clamp(14px, 2.2vw, 16px);
        line-height: 1.35;
        min-height: 3.2em;
    }
    
    /* Botón más pequeño en tablet */
    .cluster-item::before {
        font-size: 12px;
        padding: 10px 20px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .amazon-cluster-container {
        gap: 14px;
        margin: 20px 0;
    }
    
    .amazon-cluster-container[data-columns-mobile="1"] {
        grid-template-columns: 1fr;
    }
    
    .amazon-cluster-container[data-columns-mobile="2"] {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .item-image {
        height: 180px;
    }
    
    .item-content {
        padding: 14px 12px;
    }
    
    /* ✨ Tipografía optimizada mobile */
    .item-title {
        font-size: clamp(13px, 3vw, 15px);
        font-weight: 600;
        line-height: 1.3;
        letter-spacing: -0.005em;
        min-height: 2.8em;
        -webkit-line-clamp: 2;
    }
    
    /* 🌊 Animaciones reducidas en mobile */
    .cluster-item:hover {
        transform: translateY(-4px) scale(1.01);
        box-shadow: 0 12px 24px rgba(0,0,0,0.1);
    }
    
    /* Botón adaptado para mobile */
    .cluster-item::before {
        font-size: 11px;
        padding: 8px 16px;
        border-radius: 20px;
    }
}

/* Mobile muy pequeño */
@media (max-width: 480px) {
    .amazon-cluster-container {
        gap: 12px;
        margin: 15px 0;
    }
    
    .item-image {
        height: 160px;
    }
    
    .item-content {
        padding: 12px 10px;
    }
    
    /* ✨ Tipografía compacta móvil pequeño */
    .item-title {
        font-size: clamp(12px, 3.5vw, 14px);
        line-height: 1.25;
        min-height: 2.5em;
    }
    
    /* Hover muy sutil en móviles pequeños */
    .cluster-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 16px rgba(0,0,0,0.08);
    }
    
    /* Botón compacto para móviles pequeños */
    .cluster-item::before {
        content: "Ver →";
        font-size: 10px;
        padding: 6px 12px;
    }
}

/* ==========================================================================
   PLACEHOLDER PARA IMÁGENES SIN CARGAR
   ========================================================================== */

.item-image img[src*="placeholder"] {
    opacity: 0.7;
    filter: grayscale(20%);
    transition: all 0.3s ease;
}

.cluster-item:hover .item-image img[src*="placeholder"] {
    opacity: 0.3;
    filter: grayscale(0%);
}

/* ==========================================================================
   ACCESIBILIDAD Y ESTADOS DE FOCUS
   ========================================================================== */

.cluster-link:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
    border-radius: 12px;
}

.cluster-link:focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

/* ==========================================================================
   COMPATIBILIDAD CON TEMAS Y RESETS
   ========================================================================== */

/* Reset de estilos que pueden interferir */
.amazon-cluster-container * {
    box-sizing: border-box;
}

.amazon-cluster-container .cluster-item {
    list-style: none;
    margin: 0;
}

/* Evitar que otros estilos afecten las imágenes */
.amazon-cluster-container .item-image img {
    border: none !important;
    box-shadow: none !important;
    max-width: none !important;
    margin: 0 !important;
}

/* Asegurar que el título no herede estilos no deseados */
.amazon-cluster-container .item-title {
    margin: 0 !important;
    text-transform: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
}

/* ==========================================================================
   MEJORAS DE PERFORMANCE
   ========================================================================== */

.cluster-item {
    /* Optimización de rendimiento para animaciones */
    will-change: transform, box-shadow;
    backface-visibility: hidden;
    perspective: 1000px;
}

.item-image img {
    /* Optimización para transforms de imagen */
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* Reducir animaciones si el usuario prefiere movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    .cluster-item,
    .item-image img,
    .item-title,
    .cluster-item::before,
    .item-image::before {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
    
    .cluster-item:hover {
        transform: none !important;
    }
    
    .cluster-item:hover .item-image img {
        opacity: 0.3 !important;
        transform: none !important;
    }
}