/* ==========================================================================
   PRESTIGE · Galería editorial de propiedad
   Hero cinemascope 2.35:1 + tira de 3 thumbnails + lightbox masonry.
   ========================================================================== */

/* ---------- Galería principal ---------- */

.gallery {
  background: var(--anthracite, #2D302F);
}

.gallery-hero {
  position: relative;
  width: 100%;
  /* Cinemascope 2.35:1 — formato cinematográfico real */
  aspect-ratio: 2.35 / 1;
  background-color: #1a1c1b;
  background-size: cover;
  background-position: center;
  cursor: zoom-in;
  overflow: hidden;
}

.gallery-hero::after {
  /* Borde dorado superior delgado, da el toque editorial */
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0,0,0,0.05) 0%,
    rgba(0,0,0,0) 30%,
    rgba(0,0,0,0) 70%,
    rgba(0,0,0,0.25) 100%
  );
  pointer-events: none;
}

.gallery-hero-label {
  position: absolute;
  left: 2rem;
  bottom: 1.5rem;
  color: var(--timberwolf-soft, #EFEAE0);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  z-index: 2;
  text-shadow: 0 1px 12px rgba(0,0,0,0.45);
}

/* Tira de thumbnails curados */
.gallery-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  background: var(--anthracite, #2D302F);
}

.gallery-strip-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  background-color: #1a1c1b;
  background-size: cover;
  background-position: center;
  cursor: zoom-in;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.gallery-strip-tile:hover { opacity: 0.85; }

/* Tarjeta "+N fotos" — la última, en dorado */
.gallery-more {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--gold, #B89968);
  color: var(--anthracite, #2D302F);
  display: grid;
  place-items: center;
  cursor: pointer;
  text-align: center;
  border: none;
  font-family: inherit;
  padding: 0;
  transition: background 0.25s ease;
}

.gallery-more:hover { background: #c8a578; }

.gallery-more .num {
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 400;
  line-height: 1;
  display: block;
}

.gallery-more .lbl {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-top: 0.4rem;
  font-weight: 500;
}

/* Placeholder cuando aún no hay imágenes */
.gallery-empty {
  aspect-ratio: 2.35 / 1;
  display: grid;
  place-items: center;
  color: var(--gold, #B89968);
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-size: 2rem;
  font-style: italic;
  background: var(--anthracite, #2D302F);
}

/* ---------- Carrusel horizontal cinemático ---------- */
/* Hilera de tiles con scroll-snap-x, drag con mouse en desktop,
   swipe nativo en móvil, captions en cursiva debajo.            */

.gallery-rail-wrap {
  position: relative;
  background: var(--anthracite, #2D302F);
  padding: 2rem 0 2rem;
}

.gallery-rail {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 0 max(2rem, calc((100% - 1600px) / 2 + 2rem));
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  user-select: none;
}

.gallery-rail::-webkit-scrollbar { display: none; }
.gallery-rail.is-dragging       { cursor: grabbing; scroll-behavior: auto; }

.gallery-rail-tile {
  flex: 0 0 auto;
  width: clamp(280px, 38vw, 460px);
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  cursor: zoom-in;
  background: transparent;
  border: none;
  padding: 0;
  text-align: left;
  font-family: inherit;
  color: inherit;
}

.gallery-rail-tile .frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #1a1c1b;
  background-size: cover;
  background-position: center;
  overflow: hidden;
  transition: transform 0.6s ease;
  position: relative;
}

.gallery-rail-tile:hover .frame {
  transform: scale(1.015);
}

.gallery-rail-tile .frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 70%, rgba(0,0,0,0.35) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-rail-tile:hover .frame::after { opacity: 1; }

.gallery-rail-tile .cap {
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
  min-height: 1.6rem;
  padding: 0 0.2rem;
}

.gallery-rail-tile .cap-num {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold, #B89968);
  font-weight: 500;
  flex: none;
  opacity: 0.85;
}

.gallery-rail-tile .cap-text {
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--timberwolf-soft, #EFEAE0);
  line-height: 1.4;
  opacity: 0.85;
}

/* Flechas de navegación */
.gallery-rail-arrows {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.2rem;
}

.gallery-rail-arrow {
  pointer-events: auto;
  background: rgba(45, 48, 47, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(184, 153, 104, 0.4);
  color: var(--timberwolf-soft, #EFEAE0);
  width: 48px;
  height: 48px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.25s ease, border-color 0.25s ease, opacity 0.3s ease;
  padding: 0;
}

.gallery-rail-arrow:hover {
  background: var(--gold, #B89968);
  color: var(--anthracite, #2D302F);
  border-color: var(--gold, #B89968);
}

.gallery-rail-arrow[disabled] {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

.gallery-rail-arrow svg { width: 22px; height: 22px; }

/* Pie del carrusel: contador + botón "Ver mosaico" */
.gallery-rail-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem 2rem 0;
  flex-wrap: wrap;
}

.gallery-rail-progress {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold, #B89968);
  font-weight: 500;
  min-width: 70px;
  text-align: center;
}

.gallery-rail-mosaic {
  background: transparent;
  border: 1px solid var(--gold, #B89968);
  color: var(--gold, #B89968);
  padding: 0.8rem 1.8rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  transition: background 0.25s ease, color 0.25s ease;
}

.gallery-rail-mosaic:hover {
  background: var(--gold, #B89968);
  color: var(--anthracite, #2D302F);
}

/* ---------- Lightbox ---------- */

.lb {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 21, 0.97);
  z-index: 9999;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lb.is-open {
  display: flex;
  opacity: 1;
}

.lb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.8rem;
  color: var(--timberwolf-soft, #EFEAE0);
  flex: none;
}

.lb-counter {
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--gold, #B89968);
}

.lb-caption {
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--timberwolf-soft, #EFEAE0);
  flex: 1;
  text-align: center;
  padding: 0 1rem;
  opacity: 0.85;
}

.lb-close {
  background: transparent;
  border: 1px solid rgba(239, 234, 224, 0.3);
  color: var(--timberwolf-soft, #EFEAE0);
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.2s ease, background 0.2s ease;
  padding: 0;
}

.lb-close:hover {
  border-color: var(--gold, #B89968);
  background: rgba(184, 153, 104, 0.1);
}

.lb-close svg { width: 18px; height: 18px; }

/* Modo "single image" (vista uno-a-uno) */
.lb-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 4rem 1rem;
  min-height: 0;
}

.lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 1px solid rgba(239, 234, 224, 0.3);
  color: var(--timberwolf-soft, #EFEAE0);
  width: 48px;
  height: 48px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.2s ease, background 0.2s ease;
  padding: 0;
}

.lb-nav:hover {
  border-color: var(--gold, #B89968);
  background: rgba(184, 153, 104, 0.1);
}

.lb-nav.prev { left: 1.2rem; }
.lb-nav.next { right: 1.2rem; }
.lb-nav svg { width: 22px; height: 22px; }
.lb-nav[disabled] { opacity: 0.25; cursor: not-allowed; }

/* Modo "grid" (masonry editorial — vista todas las fotos) */
.lb-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 2rem 2rem;
}

.lb-grid {
  column-count: 3;
  column-gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
}

.lb-grid-tile {
  break-inside: avoid;
  margin: 0 0 12px;
  cursor: zoom-in;
  display: block;
  border: none;
  padding: 0;
  background: transparent;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.lb-grid-tile img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.3s ease, transform 0.5s ease;
  opacity: 0.92;
}

.lb-grid-tile:hover img {
  opacity: 1;
  transform: scale(1.015);
}

/* Tabs entre "Recorrido" (single) y "Mosaico" (grid) */
.lb-tabs {
  display: flex;
  gap: 0;
  border: 1px solid rgba(239, 234, 224, 0.3);
}

.lb-tab {
  background: transparent;
  border: none;
  color: var(--timberwolf-soft, #EFEAE0);
  padding: 8px 18px;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  font-family: inherit;
}

.lb-tab + .lb-tab { border-left: 1px solid rgba(239, 234, 224, 0.3); }

.lb-tab.is-active {
  background: var(--gold, #B89968);
  color: var(--anthracite, #2D302F);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .gallery-rail { padding: 0 1.2rem; }
  .gallery-rail-tile { width: 80vw; max-width: 380px; }
  .gallery-rail-arrows { display: none; }
  .gallery-rail-foot { padding: 1.4rem 1.2rem 0; gap: 1.2rem; }
  .gallery-rail-wrap { padding: 1.4rem 0 1.4rem; }

  .gallery-hero { aspect-ratio: 16 / 9; }
  .gallery-hero-label { left: 1.2rem; bottom: 1rem; font-size: 0.7rem; }

  .gallery-strip { grid-template-columns: repeat(2, 1fr); }
  .gallery-strip-tile:nth-child(n+3) { display: none; }
  /* Mostramos: 2 thumbs + el botón "+N" en la 2ª fila */
  .gallery-strip-tile:nth-child(1),
  .gallery-strip-tile:nth-child(2) { display: block; }

  .lb-topbar { padding: 0.9rem 1rem; }
  .lb-caption { display: none; }
  .lb-stage { padding: 0 0.5rem 0.5rem; }
  .lb-nav { width: 40px; height: 40px; }
  .lb-nav.prev { left: 0.4rem; }
  .lb-nav.next { right: 0.4rem; }
  .lb-grid { column-count: 2; column-gap: 8px; }
  .lb-grid-tile { margin-bottom: 8px; }
  .lb-grid-wrap { padding: 0 0.8rem 1.2rem; }
}

@media (max-width: 520px) {
  .gallery-hero { aspect-ratio: 4 / 3; }
  .lb-grid { column-count: 1; }
  .lb-tab { padding: 6px 12px; font-size: 0.66rem; }
}

/* ---------- Body lock cuando lightbox abierto ---------- */
body.lb-open { overflow: hidden; }
