/* =============================================================
   SECCIÓN 04 — GALERÍA HORIZONTAL
   Navegación libre: drag (PC) · swipe (móvil) · trackpad
   Capricho del Mar by Z
============================================================= */

#galeria {
  padding: var(--sp-section) 0;
  background: rgba(8, 18, 32, 0.92);
}

/* ── CABECERA ────────────────────────────────────────────── */
.gallery-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 var(--sp-side) clamp(1.5rem, 3vh, 2.5rem);
}
.gallery-hd-title {
  font-family: var(--font-display);
  font-size: clamp(0.65rem, 1vw, 0.85rem);
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(245, 240, 232, 0.40);
}
.gallery-hd-title em {
  font-style: normal;
  color: var(--c-gold);
}
.gallery-hd-count {
  font-family: var(--font-display);
  font-size: clamp(0.6rem, 0.85vw, 0.72rem);
  letter-spacing: 0.16em;
  color: rgba(245, 240, 232, 0.28);
}
.gallery-count-cur {
  color: var(--c-gold);
  font-weight: 600;
}

/* ── PISTA HORIZONTAL ────────────────────────────────────── */
.gallery-track {
  display: flex;
  gap: clamp(1rem, 1.75vw, 1.75rem);
  /* padding lateral centra el primer y último slide */
  padding-inline: 19vw;
  overflow-x: scroll;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  user-select: none;
  /* ocultar scrollbar */
  scrollbar-width: none;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-track.is-dragging        { cursor: grabbing; }

/* ── DIAPOSITIVA ─────────────────────────────────────────── */
.gallery-slide {
  flex-shrink: 0;
  width: 62vw;
  height: 72vh;
  overflow: hidden;
  position: relative;
  scroll-snap-align: center;

  /* Efecto swap: comprimida e inset cuando inactiva */
  clip-path: inset(3% round 2px);
  transform: scale(0.91);
  transition:
    clip-path 0.55s var(--ease-luxury),
    transform  0.55s var(--ease-luxury);
}
.gallery-slide.is-active {
  clip-path: inset(0% round 0px);
  transform: scale(1);
}

/* ── IMAGEN ──────────────────────────────────────────────── */
.gallery-slide-img {
  width: 100%; height: 100%;
}
.gallery-slide-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none; /* no interfiere con el drag */
}

/* ── ETIQUETA ────────────────────────────────────────────── */
.gallery-slide-label {
  position: absolute;
  bottom: clamp(1rem, 2.5vh, 1.75rem);
  left: clamp(1.25rem, 2.5vw, 2rem);
  font-family: var(--font-display);
  font-size: clamp(0.55rem, 0.78vw, 0.7rem);
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(245, 240, 232, 0.50);
  z-index: 1;
}

/* ── BARRA DE PROGRESO ───────────────────────────────────── */
.gallery-progress {
  height: 1px;
  background: rgba(245, 240, 232, 0.07);
  margin-top: clamp(1.5rem, 3vh, 2.5rem);
  position: relative;
}
.gallery-progress-fill {
  position: absolute;
  inset: 0;
  background: var(--c-gold);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.35s var(--ease-luxury);
}

/* ── CONTROLES (escritorio y móvil) ─────────────────────────── */
.gallery-nav {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: clamp(1.5rem, 3vh, 2.25rem);
}
.gallery-arrow {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(245, 240, 232, 0.18);
  background: rgba(245, 240, 232, 0.06);
  color: rgba(245, 240, 232, 0.60);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .25s, color .25s, border-color .25s, opacity .25s;
}
.gallery-arrow svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.gallery-arrow:hover:not(:disabled) {
  background: rgba(201, 169, 110, 0.12);
  border-color: rgba(201, 169, 110, 0.30);
  color: var(--c-gold);
}
.gallery-arrow:disabled { opacity: 0.25; pointer-events: none; }

/* ── CURSOR ZOOM en slides ───────────────────────────────── */
.gallery-slide-img            { cursor: zoom-in; }
.gallery-track.is-dragging
  .gallery-slide-img          { cursor: grabbing; }

/* ── LIGHTBOX ────────────────────────────────────────────── */
.lb-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(5, 10, 18, 0.96);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.lb-overlay.is-open {
  opacity: 1; pointer-events: auto;
}
.lb-img-wrap {
  max-width: 90vw; max-height: 88vh;
  display: flex; align-items: center; justify-content: center;
}
.lb-img {
  max-width: 90vw; max-height: 88vh;
  object-fit: contain;
  border-radius: 2px;
  opacity: 1;
  transition: opacity 0.18s ease, transform 0.3s ease;
  transform: scale(0.96);
  user-select: none;
}
.lb-overlay.is-open .lb-img { transform: scale(1); }
.lb-img.is-fading            { opacity: 0; }

.lb-close {
  position: absolute; top: 1.5rem; right: 1.75rem;
  background: none; border: none; cursor: pointer;
  color: rgba(245, 240, 232, 0.5);
  padding: 0.5rem;
  transition: color 0.2s;
  z-index: 1;
}
.lb-close:hover { color: var(--c-gold); }

.lb-prev, .lb-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(245, 240, 232, 0.06);
  border: 1px solid rgba(245, 240, 232, 0.1);
  color: rgba(245, 240, 232, 0.6);
  cursor: pointer; border-radius: 50%;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  z-index: 1;
}
.lb-prev { left: 1.75rem; }
.lb-next { right: 1.75rem; }
.lb-prev:hover, .lb-next:hover {
  background: rgba(201, 169, 110, 0.12);
  border-color: rgba(201, 169, 110, 0.3);
  color: var(--c-gold);
}

.lb-caption {
  position: absolute; bottom: 2rem; left: 50%;
  transform: translateX(-50%);
  font-size: var(--sz-label);
  letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(245, 240, 232, 0.35);
  white-space: nowrap;
}

@media (max-width: 768px) {
  .lb-prev { left: 0.75rem; }
  .lb-next { right: 0.75rem; }
  .lb-prev, .lb-next { width: 40px; height: 40px; }
}

/* ── ACCESIBILIDAD ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .gallery-slide {
    clip-path: none;
    transform: none;
    transition: none;
  }
  .gallery-progress-fill { transition: none; }
  .lb-img { transition: opacity 0.18s ease; }
}
