/* Visor de la galería: carrusel a pantalla completa con apertura animada.
   El JS (js/gallery.js) agrega .visible para animar la entrada y la saca para la salida. */

dialog.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; overflow: hidden;
  background: transparent; color: #fff;
}
dialog.lightbox::backdrop {
  background: rgba(8,12,18,.94);
  opacity: 0; transition: opacity .35s ease;
}
dialog.lightbox.visible::backdrop { opacity: 1; }
/* Mientras está abierto, la página de atrás no scrollea */
html.lb-abierto { overflow: hidden; }

/* --- Carrusel: una foto por pantalla, se desliza con el dedo --- */
.lb-track {
  display: flex; height: 100%;
  overflow-x: auto; overscroll-behavior: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.lb-track::-webkit-scrollbar { display: none; }
.lb-slide {
  flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always;
  margin: 0; padding: 72px 16px 112px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.lb-slide img {
  /* Las fotos son ~4:5 (240×298). El ancho manda: entra en pantalla a lo ancho
     y a lo alto (53vh de ancho ≈ 66vh de alto) sin pasar de 435px (≈540px de alto). */
  width: min(100%, 435px, 53vh); height: auto;
  aspect-ratio: 240 / 298;
  object-fit: contain; border-radius: var(--radio);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .25s ease;
  will-change: transform;
}
.lb-slide figcaption {
  font-family: "Bebas Neue", sans-serif; font-size: 28px; letter-spacing: .05em; text-align: center;
}

/* --- Controles: aparecen con un fundido al abrir --- */
.lb-cerrar, .lb-nav, .lb-slide figcaption { opacity: 0; transition: opacity .3s ease .1s; }
.lightbox.visible .lb-cerrar,
.lightbox.visible .lb-nav,
.lightbox.visible .lb-slide figcaption { opacity: 1; }

.lb-cerrar {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px;
  width: 48px; height: 48px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; cursor: pointer;
}
.lb-cerrar svg { width: 24px; height: 24px; }
.lb-cerrar:hover { background: rgba(255,255,255,.2); }

.lb-nav {
  position: absolute; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 18px;
}
.lb-flecha {
  width: 48px; height: 48px; display: grid; place-items: center; padding: 0; cursor: pointer;
  border: 1px solid rgba(255,255,255,.55); border-radius: 50%; background: transparent; color: #fff;
  transition: background .2s, color .2s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.lb-flecha svg { width: 20px; height: 20px; }
.lb-flecha:hover, .lb-flecha:active { background: #fff; color: var(--oscuro); border-color: #fff; }
.lb-cerrar:focus-visible, .lb-flecha:focus-visible { outline: 2px solid #6cb8f0; outline-offset: 3px; }
.lb-contador {
  min-width: 72px; text-align: center;
  font-family: "Bebas Neue", sans-serif; font-size: 22px; letter-spacing: .06em; color: rgba(255,255,255,.85);
}

@media (prefers-reduced-motion: reduce) {
  dialog.lightbox::backdrop, .lb-slide img, .lb-cerrar, .lb-nav, .lb-slide figcaption { transition: none; }
}
