/* ======================================================= */
/* ESTILOS AVANZADOS: PRODUCTOS DESTACADOS V2 */
/* VERSIÓN: Solo ANIMACIÓN ESCALONADA (JEARRG AOS-SCRIPTS) */
/* ======================================================= */

:root {
    --color-dark-bg: #1A1A1A;
    --color-overlay-bg: rgba(0, 0, 0, 0.85); 
    --color-text-light: #FFFFFF;
    --font-serif: 'Cormorant Garamond', serif;
    --font-sans: 'Inter', sans-serif;
    
    --color-accent: #B5734C; 
    --color-glow: rgba(181, 115, 76, 0.7); 
    
    --transition-duration: 0.4s;
    --shadow-intensity: 0.15;
    
    /* Variable CSS para el retraso escalonado (se inyecta con JS) */
  
}

/* --- SECCIÓN PRINCIPAL --- */
.featured-products-section {
    padding: clamp(60px, 10vw, 100px) 0; 
    background-color: var(--color-dark-bg);
    color: var(--color-text-light);
    text-align: center;
    overflow-x: hidden; 
}

/* Tipografía de la Sección */
.featured-products-section .pre-title {
    color: #888888; 
    font-size: 0.9rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.featured-products-section h2 {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 5vw, 3.5rem); 
    font-weight: 700;
    margin-top: 5px;
    position: relative;
    display: inline-block;
}

.featured-products-section .subtitle-featured {
    font-family: var(--font-sans);
    font-size: 1.05rem;
    color: #a0a0a0;
    max-width: 600px;
    margin: 15px auto 50px auto; 
    line-height: 1.6;
}

/* --- GRID DE LA GALERÍA --- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
    gap: clamp(20px, 4vw, 40px);
    margin-top: 50px;
}

/* --- ITEM DE LA GALERÍA (TARJETA) --- */
.gallery-item {
    position: relative;
    border-radius: 12px; 
    overflow: hidden;
    /* Sombra inicial sutil */
    box-shadow: 0 4px 15px rgba(0, 0, 0, var(--shadow-intensity)), 
                0 1px 3px rgba(0, 0, 0, calc(var(--shadow-intensity) + 0.1));
    
    /* Transición inicial SOLO para box-shadow y el hover */
    transition: box-shadow var(--transition-duration) ease;
    cursor: pointer;
    will-change: transform, box-shadow; /* Optimización de rendimiento */

    /* ESTADO INICIAL PARA LA ANIMACIÓN (Oculto y desplazado) */
    opacity: 0;
    transform: translateY(40px); 
}

/* ESTADO HOVER: Mantiene la elevación y el brillo */
.gallery-item:hover {
    transform: translateY(-8px); 
    box-shadow: 
        0 30px 60px rgba(0, 0, 0, 0.7),
        0 10px 20px rgba(0, 0, 0, 0.5),
        0 0 40px 12px var(--color-glow); 
    /* Transición de transform se habilita en .is-in-view y aquí la usamos */
    transition: transform var(--transition-duration) cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                box-shadow var(--transition-duration) ease;
}

/* --- ESTILOS DE IMAGEN --- */
.gallery-item img {
    width: 100%;
    height: 450px; 
    object-fit: cover;
    display: block;
    transition: transform var(--transition-duration) ease-out; /* Mantiene la transición del zoom en hover */
}

.gallery-item:hover img {
    transform: scale(1.05); /* Zoom sutil en la imagen al hacer hover */
}


/* --- TEXTO SUPERPUESTO (Overlay) --- */
.overlay {
    position: absolute;
    inset: 0; 
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 30px; 
    background: linear-gradient(to top, var(--color-overlay-bg) 0%, rgba(0, 0, 0, 0) 100%); 
    color: var(--color-text-light);
    text-align: left;
    opacity: 1; 
    transform: translateY(0); /* Posición normal (visible) */
    
    /* Prepara la animación para cuando se oculte */
    transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out;
}
/* 2. Ocultar al pasar el ratón (Hover) */
.gallery-item:hover .overlay {
    opacity: 0; /* Oculta completamente el overlay */
    transform: translateY(100%); /* Desplaza el overlay fuera de la vista hacia abajo */
}

/* 3. Ocultar al hacer clic (Focus/Clic) */
/* (Asegúrate de que .gallery-item tenga tabindex="0" en el HTML para que esto funcione) */
.gallery-item:focus .overlay {
    opacity: 0; /* Oculta completamente el overlay */
    transform: translateY(100%); /* Desplaza el overlay fuera de la vista hacia abajo */
}
.overlay h4 {
    font-family: var(--font-serif);
    font-size: 1.5rem; 
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.3;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8); 
}

.overlay p {
    font-family: var(--font-sans);
    font-size: 1rem; 
    font-weight: 300;
    color: #cccccc;
    margin: 0;
    max-width: 90%;
    opacity: 0.85; 
}

.gallery-item:hover .overlay p {
    opacity: 1;
}

/* --- CTA SECUNDARIO --- */
.cta-button.secondary {
    display: inline-block;
    background: transparent;
    color: var(--color-text-light);
    border: 2px solid var(--color-text-light); 
    padding: 12px 30px; 
    text-decoration: none;
    text-transform: uppercase;
    font-weight: 600; 
    letter-spacing: 1.5px;
    border-radius: 4px; 
    margin-top: 60px; 

}

.cta-button.secondary:hover {
    background: var(--color-accent); 
    color: var(--color-text-light);
    border-color: var(--color-accent);
    transform: scale(1.05); 
    box-shadow: 0 0 15px rgba(181, 115, 76, 0.5); 
}

/* ----------------------------------------------------------------- */
/* --- CÓDIGO DE ANIMACIÓN ESCALONADA (ACTIVACIÓN CON JAVASCRIPT) --- */
/* ----------------------------------------------------------------- */

/* 1. Definición del Keyframe */


/* 2. Estado Activo (La clase 'is-in-view' se añade con JavaScript) */
.gallery-item.is-in-view {
    /* Aplica la animación */
    animation: fadeInSlideUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    
    /* Usa la variable --delay inyectada por JS para el efecto escalonado */
    animation-delay: var(--delay); 
    
    /* ** IMPORTANTE: Habilita la transición de TRANSFORM después de la animación de entrada ** */
    /* Esto es clave para que el :hover funcione de forma fluida DESPUÉS de que la tarjeta ha entrado */
    transition: 
        transform var(--transition-duration) cubic-bezier(0.25, 0.46, 0.45, 0.94), 
        box-shadow var(--transition-duration) ease;
}

/* --- Preferencias de movimiento reducido (Accesibilidad) --- */
@media (prefers-reduced-motion: reduce) {
    /* Desactivar todas las transiciones y animaciones complejas */
    .gallery-item, 
    .cta-button.secondary,
    .gallery-item img {
        transition: none !important;
        animation: none !important;
    }
    
    /* Mantener el estado final estático (visible y en posición) */
    

    .gallery-item:hover {
        transform: none !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7); 
    }
}


/* --- RESPONSIVE ESPECÍFICO (Tablet y Móvil) --- */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr; 
    }
    
    .gallery-item img {
        height: 350px; 
    }
    
    .overlay {
        padding: 20px;
    }
    
    .overlay h4 {
        font-size: 1.3rem;
    }
    
    .cta-button.secondary {
        margin-top: 40px;
    }
}