#snap-gallery {
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100vw; /* Límite estricto de ancho */
  background-color: #1d2e28;
  display: grid;
  grid-template-rows: 1fr auto;
  position: relative;
  overflow: hidden; /* Evita que nada salga del contenedor padre */
}

/* --- CABECERA FLOTANTE --- */
.gallery-header {
  position: absolute;
  top: 20px;
  left: 0;
  width: 100%;
  text-align: center;
  z-index: 10;
  pointer-events: none; /* Para poder hacer click a través del texto */
}

.gallery-title {
  font-size: 1.5rem;
  color: #f5da95;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  letter-spacing: 2px;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.3);
  display: inline-block;
  padding: 5px 20px;
  border-radius: 50px;
  backdrop-filter: blur(5px);
}

/* --- 1. ESCENARIO PRINCIPAL (MAIN STAGE) --- */
.main-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  min-height: 0; /* TRUCO CLAVE: Evita que el grid explote en móviles reales */
  min-width: 0;
}
/* La imagen de fondo grande */
#mainBg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center; /* Fuerza a que el recorte sea exactamente en el medio */
  transition:
    opacity 0.4s ease-in-out,
    transform 5s ease;
}

/* Efecto Ken Burns deshabilitado */
.main-stage:hover #mainBg {
  /* transform: scale(1.05); */
}

/* Capa oscura para que se lea el texto */
.overlay-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70%;
  background: linear-gradient(to top, #1d413d 5%, transparent);
  z-index: 1;
}

/* Contenido de texto principal */
.main-content {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 2;
  width: 90%;
  max-width: 600px;
  color: white;
}

.main-content h3 {
  font-size: 3rem;
  margin: 10px 0;
  color: #f5da95;
  line-height: 1.1;
}

.main-content p {
  font-size: 1.1rem;
  color: #ddd;
  margin-bottom: 20px;
}

.card-year {
  background: #f5da95;
  color: #1d413d;
  padding: 5px 15px;
  font-weight: bold;
  border-radius: 20px;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.card-btn {
  color: #f5da95;
  text-decoration: none;
  border-bottom: 1px solid #f5da95;
  padding-bottom: 3px;
  font-size: 0.9rem;
  transition: color 0.3s;
}

/* --- 2. CINTA DE MINIATURAS (SECUNDARIAS) --- */
.thumbs-wrapper {
  background: #1d413d;
  padding: 20px 0 30px 0;
  width: 100%;
  z-index: 5;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
}

.thumbs-scroll {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  padding: 0 20px;
  scroll-snap-type: x mandatory;
  justify-content: flex-start;
}

/* Scrollbar invisible */
.thumbs-scroll::-webkit-scrollbar {
  display: none;
}
.thumbs-scroll {
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}

.thumb-card {
  flex: 0 0 140px;
  height: 90px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.5;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  scroll-snap-align: center;
}

.thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Estado Activo y Hover */
.thumb-card:hover {
  opacity: 0.8;
  transform: translateY(-3px);
}

.thumb-card.active {
  opacity: 1;
  border-color: #f5da95;
  box-shadow: 0 0 15px rgba(245, 218, 149, 0.4);
  transform: scale(1.05);
}

/* --- MEDIA QUERY: MÓVIL (hasta 768px) --- */
@media screen and (max-width: 768px) {
  /* Ajustes para que el contenido no choque con los bordes en pantallas chicas */
  .gallery-header {
    top: 10px;
  }

  .gallery-title {
    font-size: 1.1rem;
    padding: 5px 15px;
    letter-spacing: 1px;
  }

  /* Ajustar contenido principal para que no se salga del viewport */
  .main-content {
    bottom: 130px; /* Espacio para las miniaturas */
    width: 90%;
    padding: 15px;
    max-width: calc(100vw - 30px);
  }

  .main-content h3 {
    font-size: 1.5rem;
    margin: 5px 0;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .main-content p {
    font-size: 0.9rem;
    margin-bottom: 10px;
    line-height: 1.3;
    display: none; /* Ocultar descripción en móvil para ahorrar espacio */
  }

  .card-year {
    font-size: 0.7rem;
    padding: 4px 12px;
  }

  .card-btn {
    font-size: 0.8rem;
    display: block;
    margin-top: 8px;
  }

  /* Reducir el tamaño de las miniaturas para asegurar que el scroll lateral sea obvio */
  .thumbs-wrapper {
    padding: 12px 0 15px 0;
    height: auto;
    flex-shrink: 0;
  }

  .thumbs-scroll {
    gap: 10px;
    padding: 0 15px;
    /* Permitir que el scroll funcione correctamente */
    -webkit-overflow-scrolling: touch;
  }

  .thumb-card {
    flex: 0 0 80px;
    height: 60px;
    min-width: 80px;
    min-height: 60px;
  }

  .thumb-card.active {
    transform: scale(1.08);
  }
}

/* --- MEDIA QUERY: Tablets (768px - 1024px) --- */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .gallery-title {
    font-size: 1.3rem;
  }

  .main-content {
    bottom: 120px;
    width: 85%;
  }

  .main-content h3 {
    font-size: 2rem;
  }

  .main-content p {
    font-size: 0.95rem;
  }

  .thumbs-wrapper {
    padding: 15px 0 25px 0;
  }

  .thumb-card {
    flex: 0 0 110px;
    height: 75px;
  }
}

/* --- MEDIA QUERY: Desktop Normales (1025px - 1799px) --- */
@media screen and (min-width: 1025px) and (max-width: 1799px) {
  /* Mantener estilos por defecto */
}

/* --- MEDIA QUERY: Pantallas Gigantes (1800px+) --- */
@media screen and (min-width: 1800px) {
  .gallery-title {
    font-size: 1.8rem;
    padding: 8px 30px;
  }

  .main-content {
    bottom: 50px;
    max-width: 800px;
  }

  .main-content h3 {
    font-size: 3.5rem;
  }

  .main-content p {
    font-size: 1.2rem;
  }

  .thumbs-wrapper {
    padding: 30px 0 40px 0;
  }

  .thumb-card {
    flex: 0 0 160px;
    height: 110px;
  }
}
