.gallery-section-v2 {
    margin-top: 140px;
    background-color: #fff;
    position: relative;
    margin-bottom:60px;
}

.gallery-header-v2 {
    position: relative;   /* para que z-index funcione */
    z-index: 2;   
    text-align: center;
    max-width: 800px;
    margin: 0 auto 60px;
    border-radius: 12px;
}

.gallery-header-v2 h2 {
    z-index: 1; 
    font-size: 3rem;
    font-weight: 500;
    margin-bottom: 1.2rem;
    color: #0f0f0f;
}

.gallery-header-v2 p {
    font-size: 17px;
    z-index: 1; 
    color: #0f0f0f;
    line-height: 1.4;
    margin: 0 auto 0;
    font-weight:400;
    max-width: 500px;
    margin-bottom: -125px;
}

/* ================================================= */
/* GALERÍA DESKTOP - 3 IMÁGENES                     */
/* ================================================= */

/* Contenedor de galería con imágenes alineadas por la base */
.gallery-grid-v2 {
    position: relative;  /* Para posicionar el ::before */
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 30px;
    margin: 0 auto;
    flex-wrap: nowrap;
}

/* Barra gris delgada de fondo - POSICIONADA 80PX SOBRE EL H2 */
.gallery-section-v2::before {
    content: "";
    position: absolute;
    top: -50px; /* se ajustará según vista */
    left: 50%;
    transform: translateX(-50%);
    width: 65%;
    height: 750px;
    background-color: #FAFAFA;
    border-radius: 3px;
    z-index: 0;
    transition: height 0.3s ease, width 0.3s ease;
}

/* Imagen contenedor */
.gallery-item-v2 {
    position: relative;      /* Para que quede sobre la barra */
    z-index: 3;              /* encima del ::before */
    flex: 1;
    max-height: 800px;  /* Aumenté la altura máxima */
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
}

/* Wrapper para la imagen */
.img-wrapper {
    width: 100%;
    height: 100%;
}

/* Imagen: obligamos a cubrir el alto */
.gallery-item-v2 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ================================================= */
/* COLLAGE MÓVIL - INICIALMENTE OCULTO              */
/* ================================================= */
.gallery-collage-mobile {
    display: none; /* Oculto por defecto en desktop */
    position: relative;
    z-index: 3;
    max-width: 400px;
    margin: 0 auto;
    /* Animación de entrada */
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}

.gallery-collage-mobile.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.gallery-collage-mobile img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
}

/* ================================================= */
/* ANIMACIONES DE ENTRADA DESKTOP                    */
/* ================================================= */

/* Estado inicial de TODOS los items: invisibles */
.gallery-item-v2 {
    opacity: 0;
    /* Definimos las propiedades que se van a animar y el tipo de aceleración */
    transition-property: opacity, transform;
    transition-timing-function: ease-out;
}

/* Estado inicial específico para el item del medio: desplazado hacia abajo */
.gallery-item-v2:nth-child(2) {
    /* Mantenemos el margen de la versión anterior para el efecto escalonado */
    margin-top: 30px; 
    transform: translateY(50px);
}

/* Clase que se añadirá con JavaScript para hacerlos visibles */
.gallery-item-v2.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.gallery-item-v2:nth-child(1){
    transition-duration: 1.5s;
    transition-delay: 1s;
}

/* Velocidad para la imagen del medio (Slide Up) */
.gallery-item-v2:nth-child(2) {
    transition-duration: 0.8s; 
    transition-delay: 0.3s;
}

.gallery-item-v2:nth-child(3) {
    transition-duration: 1.5s; 
    transition-delay: 0.7s;
}

/* ================================================= */
/* RESPONSIVIDAD MEJORADA                            */
/* ================================================= */

/* Tablets - Ajustar para que el grid pueda hacer wrap y las imágenes un poco más chicas */
@media (max-width: 1024px) {
    .gallery-grid-v2 {
        flex-wrap: wrap; /* Permitimos que las imágenes bajen de línea */
        gap: 20px;
    }
        
    .gallery-item-v2 {
        flex-basis: calc(50% - 10px); /* 2 imágenes por fila */
        max-height: 500px;
    }
    .gallery-item-v2:nth-child(2) {
        margin-top: 0; /* En tablet ya no queremos el efecto escalonado */
    }
}
@media (max-width: 768px) {
    .gallery-section-v2::before {
        height: 450px;
        width: 90%;
        top: 50px; /* o ajusta según tu necesidad */
    }
}

@media (max-width: 768px) {
    /* OCULTAR GALERÍA DESKTOP COMPLETAMENTE */
    .gallery-grid-v2 {
        display: none !important;
    }
    .mobile-gray-bar {
        
        position: absolute;
        top: 50px;
        left: 10px;
        width: calc(100% - 20px);
        height: auto; /* permitimos que crezca con el contenido */
        background-color: #FAFAFA;
        z-index: 0;
        min-height: 750px; /* altura inicial base */

    }
    /* MOSTRAR COLLAGE MÓVIL */
    .gallery-collage-mobile {
        display: block !important;
    }
    .gallery-section-v2 {
        position: relative; /* para que la barra se posicione dentro */
        margin-bottom: 0px; /* Sin margen inferior */
    }
    /* BARRA GRIS VISIBLE EN MÓVIL - 50PX SOBRE EL TÍTULO */

    .gallery-header-v2 {
        margin-bottom: 50px;
        padding: 40px 20px;
    }
    .gallery-header-v2 h2 {
        font-size: 2rem;
        line-height: 1.1;
    }
    .gallery-header-v2 p {
        font-size: 1rem;
        margin-right: 40px;
        margin-bottom: -50px;
    }
}

/* Móviles pequeños - una columna, imágenes aún más pequeñas */
@media (max-width: 600px) {
    .gallery-section-v2 {
        padding: 60px 5vw;
        margin-top: 0px;
    }
    
    .gallery-collage-mobile {
        max-width: 95vw;
    }
    
    .gallery-header-v2 h2 {
        font-size: 33px;
       text-align: left; 
       margin-right: 50px;
    }
    .gallery-header-v2 p {
        font-size: 0.9rem;
        max-width: 100%;
        margin-bottom: -50px;
        text-align: left; 
    }
}

