/* ======= GALERÍA ======= */
main {
    padding-top: 120px;
    padding-bottom: 80px;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px; /* Un poco más de espacio */
    padding: 15px;
    max-width: 1400px; /* Ancho máximo para pantallas muy grandes */
    margin: 0 auto;
}

/* Item-collage (Ahora es tarjeta individual) */
.gallery-item {
    position: relative;
    aspect-ratio: 1/1; /* Mantiene el cuadrado perfecto */
    overflow: hidden;
    border-radius: 4px; /* Un toque más suave */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    background-color: #f0f0f0;
    cursor: pointer;
}

/* Imágenes internas */
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

/* Efecto Hover en la imagen */
.gallery-item:hover img {
    transform: scale(1.05);
}

/* --- TEXTO SOBRE LA IMAGEN (Overlay) --- */
/* Agrupamos los textos para darles fondo y posición */
.gallery-item .texto-galery {
    position: absolute;
    left: 0;
    width: 100%;
    padding: 5px 15px;
    color: #ffffff;
    z-index: 10;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    pointer-events: none; /* Para que el click pase a la imagen/div */
    font-size: 14px;
    line-height: 1.3;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}

/* El título (primer p) un poco más arriba */
.gallery-item .texto-galery:first-of-type {
    bottom: 35px; /* Deja espacio para la fecha */
    font-weight: 600;
    padding-bottom: 0;
    background: none; /* El fondo lo pone el segundo p o un contenedor padre si quisieramos */
}

/* La fecha (segundo p) pegada al fondo */
.gallery-item .texto-galery:last-of-type {
    bottom: 0;
    font-size: 12px;
    font-style: italic;
    padding-top: 2px;
    padding-bottom: 10px;
    opacity: 0.9;
    /* Fondo degradado más fuerte abajo para garantizar lectura */
    background: linear-gradient(to top, rgba(0,0,0,0.9) 10%, rgba(0,0,0,0) 100%); 
    height: 80px; /* Altura del degradado */
    display: flex;
    align-items: flex-end; /* Texto abajo */
}


/* ======= MODAL (Estilos mantenidos y limpiados) ======= */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: saturate(0.9) blur(2px);
    justify-content: center;
    align-items: center;
}

.modal[open] {
    display: flex
}

.modal-content {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    width: clamp(340px, 84vw, 980px);
    height: clamp(460px, 86vh, 880px);
    background: #f5f5f5;
    border: 1px solid #d6d6d6;
    border-radius: 1px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}

.modal-image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    background: transparent;
}

.modal-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.modal-comment-container {
    padding: 14px 16px;
    background: #ececec;
    border-top: 1px solid #d6d6d6;
    color: #2b2b2b;
    text-align: center;
    font-size: 16px;
    line-height: 1.45;
    min-height: 110px;
    max-height: 40%;
    overflow: auto;
}

.close {
    position: fixed;
    top: 22px;
    right: 20px;
    z-index: 1100;
    color: #ffffff;
    font-size: 42px;
    line-height: 1;
    cursor: pointer;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .5);
    user-select: none;
}

.arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    cursor: pointer;
    user-select: none;
    color: #e6e6e6;
    font-size: 40px;
    line-height: 1;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}

.modal .arrow.left { left: 10px; }
.modal .arrow.right { right: 10px; }
.modal .arrow:hover { color: #ffffff; }

/* ======= RESPONSIVE ======= */
@media (max-width: 900px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .gallery {
        grid-template-columns: 1fr; /* 1 columna en móviles */
    }
    .gallery-item .texto-galery {
        font-size: 16px; /* Texto más grande en móvil */
    }
    main {
        padding-top: 100px;
    }
}