/* =============================================================
   GALLERY — CSS Grid (desktop/tablet) + Carousel (mobile)
   The Mosaic School
   ============================================================= */

/* ── Wrapper de sección ── */
.gallery-section-wrapper {
  padding-bottom: 48px;
}

/* ─────────────────────────────────────────────────────────────
   DESKTOP / TABLET  —  CSS Grid 5 × 7
   ───────────────────────────────────────────────────────────── */

.parent {
  column-count: 4;
  column-gap: 12px;
  width: 100%;
  padding: 0 12px;
  box-sizing: border-box;
}

.gallery-item {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 12px;
  position: relative;
  background: #e8e6f0;
}

.gallery-item:nth-child(odd) {
  aspect-ratio: 4 / 3;
}

.gallery-item:nth-child(even) {
  aspect-ratio: 3 / 4;
}

.gallery-item:nth-child(3n) {
  aspect-ratio: 1 / 1;
}

.gallery-item:nth-child(5n) {
  aspect-ratio: 9 / 16;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.gallery-item:hover img {
  transform: scale(1.05);
}



/* ── Ocultar controles del carrusel en desktop ── */
.gallery-carousel-controls {
  display: none;
}

/* =============================================================
   ANIMACIÓN DE ENTRADA — carrusel móvil
   Una sola animación para todas las imágenes.
   Se usa opacity + filter para no interferir con el translateX.
   ============================================================= */

@keyframes mosaicCarouselEnter {
  0% {
    opacity: 0;
    filter: blur(14px) brightness(1.4);
    transform: translateX(0%) scale(0.93);
  }

  45% {
    opacity: 0.7;
    filter: blur(4px) brightness(1.12);
    transform: translateX(0%) scale(0.97);
  }

  100% {
    opacity: 1;
    filter: blur(0px) brightness(1);
    transform: translateX(0%) scale(1);
  }
}

/* =============================================================
   MOBILE  ≤ 767px  —  Carrusel
   ============================================================= */

@media (max-width: 767px) {

  /* ── Wrapper del carrusel ── */
  .gallery-section-wrapper {
    padding-bottom: 32px;
  }

  /* ── El .parent se convierte en track del carrusel ── */
  .parent {
    display: block;
    overflow: hidden;
    width: 100%;
    height: 72vw;
    max-height: 380px;
    min-height: 220px;
    padding: 0;
    position: relative;
    touch-action: pan-y;
  }

  /* ── Cada item ocupa exactamente el ancho del contenedor ── */
  .gallery-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    /* Resetear posiciones del grid ── */
    grid-column: unset !important;
    grid-row: unset !important;
    grid-column-start: unset !important;
    grid-row-start: unset !important;
    /* Transición de carrusel ── */
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }

  /* ── Animación de entrada para la imagen activa ── */
  .gallery-item.carousel-entering {
    animation: mosaicCarouselEnter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
    /* Desactiva la transición durante la animación para evitar conflicto */
    transition: none;
  }


  .gallery-item img {
    transition: none;
  }

  .gallery-item:hover img {
    transform: none;
  }

  /* ── Mostrar controles del carrusel en móvil ── */
  .gallery-carousel-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-top: 16px;
    padding: 0 16px;
    position: relative;
  }

  /* Botones prev / next */
  .carousel-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #111a73;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(17, 26, 115, 0.35);
    transition: background 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .carousel-btn:hover,
  .carousel-btn:focus-visible {
    background: #1e28a0;
    transform: scale(1.08);
    outline: 2px solid rgba(17, 26, 115, 0.4);
    outline-offset: 2px;
  }

  .carousel-btn:active {
    transform: scale(0.95);
  }

  /* Indicadores de posición */
  .carousel-dots {
    display: flex;
    gap: 7px;
    align-items: center;
    justify-content: center;
    flex: 1;
  }

  .carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    padding: 0;
    background: rgba(17, 26, 115, 0.22);
    transition: background 0.2s ease, transform 0.2s ease, width 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .carousel-dot.is-active {
    background: #111a73;
    transform: scale(1.25);
    border-radius: 4px;
    width: 18px;
  }

  .carousel-dot:focus-visible {
    outline: 2px solid #111a73;
    outline-offset: 2px;
  }

  /* Contador de posición */
  .carousel-counter {
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: rgba(17, 26, 115, 0.6);
    min-width: 44px;
    text-align: center;
    flex-shrink: 0;
  }

}