/*******************************************************
 * 🖼️ ESTILOS GENERALES Y LAYOUT
 *******************************************************/

.gallery-title {
    /* Título: san serif azul oscuro */
    font-family: sans-serif, Arial, Helvetica;
    color: #1a4d85;
    /* Azul oscuro */
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.gallery {
    /* Usa CSS Grid para la rejilla de miniaturas */
    display: grid;
    /* Define columnas: auto-fit para ocupar el espacio, minmax(250px, 1fr) para el ancho */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.gallery__item {
    cursor: pointer;
    overflow: hidden;
    /* Bordes redondeados de 15px para las miniaturas */
    border-radius: 15px;
    border: 2px solid black;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    /* Asegura que la miniatura sea cuadrada */
    aspect-ratio: 1 / 1;
}

.gallery__img {
    width: 100%;
    height: 100%;
    /* Asegura que la imagen cubra el área sin deformarse */
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery__img:hover {
    /* Efecto de zoom ligero al pasar el mouse */
    transform: scale(1.05);
}

/*******************************************************
 * 📱 ESTILOS RESPONSIVE (Móviles y Tablets)
 *******************************************************/

/* Tablets */
@media (max-width: 900px) {
    .gallery {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Móviles */
@media (max-width: 600px) {
    .gallery {
        justify-content: center;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
}


/*******************************************************
 * 💡 ESTILOS LIGHTBOX (Modal de Imagen Ampliada)
 *******************************************************/

.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;

    /* 💥 CORRECCIÓN CLAVE: ESTADO INICIAL OCULTO 💥 */
    opacity: 0;
    pointer-events: none;
    /* Deshabilita clics cuando es invisible */
    visibility: hidden;

    transition: opacity 0.3s ease, visibility 0s 0.3s;
    /* La visibilidad cambia al final de la transición */
}

/* Clase que JS agregará para mostrar el lightbox */
.gallery-lightbox.visible {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transition-delay: 0s;
    /* Inicia la transición inmediatamente */
}

.gallery-lightbox__modal {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox__img-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    border: 2px solid #000;
}

.gallery-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

/* Controles de Navegación (Flechas) */
.gallery-lightbox__control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 3em;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    padding: 0 15px;
    opacity: 0.6;
    transition: opacity 0.2s;
    text-shadow: 0 0 5px black;
}

.gallery-lightbox__control:hover {
    opacity: 1;
}

.icon-back {
    left: 0;
}

.icon-next {
    right: 0;
}

/* Botón de cierre superior (la X) */
.gallery-lightbox__close {
    /* Lo posicionamos fuera de la imagen ampliada, arriba a la derecha */
    position: absolute;
    top: -30px;
    right: -10px;
    font-size: 3em;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
    /* Asegura que esté por encima de la imagen */
    opacity: 0.8;
}

.gallery-lightbox__close:hover {
    opacity: 1;
}


/* Estilos para las flechas en móvil: Un poco más grandes */
@media (max-width: 600px) {
    .gallery-lightbox__control {
        font-size: 2.5em;
        padding: 0 10px;
    }
}