/* --- Gallery --- */
.gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    grid-auto-rows: 260px; /* Altura base para cada fila de la cuadrícula */
    gap: 10px;
    padding: 10px;
    max-width: 1200px;
    margin: 0 auto;
}

.gallery-item {
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative; /* Necesario para el overlay */
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* MUY IMPORTANTE para que las imágenes llenen el espacio sin deformarse */
    cursor: pointer;
    display: block;
}

/* Clases para expandir los elementos en la cuadrícula */
.gallery-item.wide {
    grid-column: span 2; /* Ocupa 2 columnas */
}

.gallery-item.tall {
    grid-row: span 2; /* Ocupa 2 filas */
}
/* ------------------------------------------- */


/* Overlay (sin cambios) */
.overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0));
    color: white;
    padding: 15px;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
    opacity: 0;
    pointer-events: none;
}

.gallery-item:hover .overlay {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.overlay h3 { margin: 0 0 5px 0; }
.overlay p { margin: 0; font-size: 0.9em; }


/* Estilos del Modal (sin cambios, no afectan el layout de la galería) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 900px;
    animation-name: zoom;
    animation-duration: 0.6s;
    object-fit: contain;
    max-height: 90vh;
}

@keyframes zoom {
    from {transform:scale(0)}
    to {transform:scale(1)}
}

.close-button {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.prev-button, .next-button {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px;
    color: white;
    font-weight: bold;
    font-size: 20px;
    user-select: none;
}

.next-button { right: 0; }
.prev-button { left: 0; }


/* Media Query para responsividad (ahora sin desactivar el collage) */
@media screen and (max-width: 768px) {
    .gallery-container {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        grid-auto-rows: 150px;
    }
}