/* ----- ESTILOS GENERALES ----- */
body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    margin: 0;
    padding: 20px 10px;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
}

/* ----- GALERÍA ----- */
.galeria {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.galeria img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background-color: #ffffff;
    cursor: pointer;
    border-radius: 6px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.galeria img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* ----- VISOR PANTALLA COMPLETA ----- */
.visor {
    display: none;  /* CORREGIDO: Esta es la única propiedad 'display' que debe estar aquí */
    position: fixed;
    inset: 0;
    z-index: 100;
    background-color: #000000;
    overflow: hidden;
    /* NUEVO: Centra el contenido (el wrapper de imagen y texto) */
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
}

/* NUEVO: Contenedor de imagen y texto */
.imagen-y-texto-wrapper {
    display: flex;
    flex-direction: column; /* Apila los elementos verticalmente */
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.visor img {
    /* La imagen se encogerá para dejar espacio al texto */
    flex-shrink: 1;
    min-height: 0; /* Soluciona problemas de desbordamiento en flexbox */
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ----- BOTONES DEL VISOR ----- */
.btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 12px 18px;
    cursor: pointer;
    font-size: 24px;
    border-radius: 50%;
    z-index: 120;
    user-select: none;
    transition: background-color 0.2s;
}

.btn:hover { 
    background-color: rgba(255, 255, 255, 0.4); 
}

.prev { left: 20px; }
.next { right: 20px; }

.close {
    position: fixed;
    top: 15px;
    right: 25px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    z-index: 130;
    user-select: none;
    line-height: 1;
}

/* ----- TEXTO DEL VISOR ----- */
.visor-texto {
    /* ELIMINADO: position: fixed y otras propiedades de posicionamiento */
    flex-shrink: 0; /* Evita que el texto se encoja */
    color: white;
    padding: 15px 0 5px 0; /* Añade espacio arriba y abajo */
    max-width: 90%;
    text-align: center;
    transition: opacity 0.4s ease-in-out; /* <-- AÑADE ESTA LÍNEA */
}

.visor-texto h2 {
    margin: 0 0 5px 0;
    font-size: 1.2rem;
}

.visor-texto p {
    margin: 0;
    font-size: 1rem;
    color: #f0f0f0;
}


/* ===== BOTÓN FLOTANTE PARA VOLVER A INICIO ===== */
.btn-flotante-inicio {
  /* Posición fija en la pantalla */
  position: fixed;
  bottom: 25px;
  right: 25px;
  z-index: 50; /* Lo ponemos por encima del contenido pero por debajo del visor de imágenes */

  /* Apariencia */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 55px;
  height: 55px;
  background-color: #333;
  color: white;
  font-size: 26px; /* Tamaño del emoji */
  text-decoration: none;
  border-radius: 50%; /* Para que sea circular */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: background-color 0.3s, transform 0.3s;
}

.btn-flotante-inicio:hover {
  background-color: #555;
  transform: scale(1.1); /* Efecto al pasar el ratón por encima */
}

/* ----- ESTILO PARA EL SPINNER DE CARGA ----- */
.spinner {
    /* Por defecto estará oculto */
    display: none; 
    
    /* Apariencia del círculo giratorio */
    width: 60px;
    height: 60px;
    border: 8px solid rgba(255, 255, 255, 0.3); /* Círculo base */
    border-top-color: #ffffff; /* Color de la parte que gira */
    border-radius: 50%;
    
    /* Posición (centrado en el visor) */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 110; /* Por encima de la imagen pero debajo de los botones */

    /* Animación */
    animation: spin 1s infinite linear;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}


/* ----- TRANSICIÓN PARA LA IMAGEN DEL VISOR ----- */
.visor img {
    /* ... tus estilos existentes como max-width, max-height, etc. ... */

    /* AÑADIR ESTA LÍNEA para la transición suave */
    transition: opacity 0.4s ease-in-out;
}