/* =========================
   3. Galería
   ========================= */
.gallery-section__header { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-8); }
.gallery-section__title  { font-size: var(--text-xl); font-weight: 800; }
.gallery-section__sub    { max-width: 50ch; }

/* ── MOSAIC GRID (tablet/desktop) ── */
.collage {
  display: none; /* oculto en móvil */
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  overflow: hidden;
}

.collage__item {
  position: relative;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--color-dark);
  aspect-ratio: 1 / 1;
}

.collage__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Overlay oscuro al hover */
.collage__item::before {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Borde primario al hover */
.collage__item::after {
  content: '';
  position: absolute; inset: 0; z-index: 2;
  border: 3px solid var(--color-primary);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* Label con data-label */
.collage__item [data-label]::before,
.collage__item::before {
  /* solo el overlay, el label va aparte */
}

.collage__label {
  position: absolute;
  bottom: var(--space-4);
  left: 0;
  right: 0;
  z-index: 3;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

/* Estado hover */
.collage__item:hover img      { transform: scale(1.07); }
.collage__item:hover::before  { opacity: 1; }
.collage__item:hover::after   { opacity: 1; }
.collage__item:hover .collage__label {
  opacity: 1;
  transform: translateY(0);
}

/* ── FLIPBOOK (solo móvil) ── */
.flipbook {
  display: block;
  position: relative;
  overflow: hidden;
  background: var(--color-dark);
  touch-action: pan-y;
}

.flipbook__track {
  position: relative;
  height: 360px;
}

.flipbook__item {
  position: absolute; inset: 0;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.55s ease, transform 0.55s ease;
  pointer-events: none;
}

.flipbook__item.is-active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.flipbook__item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.flipbook__label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: var(--space-8) var(--space-5) var(--space-4);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, transparent 100%);
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 800;
  letter-spacing: 0.04em;
}

/* Controles flipbook */
.flipbook__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--color-dark);
}

.flipbook__btn {
  width: 40px; height: 40px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.flipbook__btn:hover  { background: rgba(255, 255, 255, 0.2); }
.flipbook__btn:active { transform: scale(0.93); }

.flipbook__dots {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: center;
  max-width: 200px;
}
.flipbook__dot {
  width: 7px; height: 7px;
  background: rgba(255, 255, 255, 0.25);
  border: none; padding: 0; cursor: pointer;
  transition: background var(--transition), transform var(--transition), width var(--transition);
  min-height: unset;
}
.flipbook__dot.is-active { background: var(--color-primary); width: 20px; }

/* Barra de progreso */
.flipbook__progress {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
}
.flipbook__progress-bar {
  height: 100%;
  background: var(--color-primary);
  width: 0%;
}
.flipbook__progress-bar.is-animating {
  transition: width linear;
}

/* =========================
   Lightbox
   ========================= */
.lightbox__backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 200;
  backdrop-filter: blur(6px);
}
.lightbox__backdrop[hidden] { display: none; }

.lightbox {
  position: fixed; inset: 0;
  z-index: 201;
  display: flex; align-items: center; justify-content: center;
}
.lightbox[hidden] { display: none; }

.lightbox__img-wrap {
  max-width: 90vw; max-height: 88vh;
  display: flex; align-items: center; justify-content: center;
}
.lightbox__img {
  max-width: 90vw; max-height: 88vh;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  object-fit: contain;
  animation: lbFadeIn 0.25s ease;
}
@keyframes lbFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.lightbox__close {
  position: fixed; top: var(--space-4); right: var(--space-4);
  width: 44px; height: 44px;
  background: rgba(255, 255, 255, 0.12); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition); z-index: 202;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.22); }

.lightbox__arrow {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px;
  background: rgba(255, 255, 255, 0.10); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), transform var(--transition); z-index: 202;
}
.lightbox__arrow:hover  { background: rgba(255, 255, 255, 0.22); }
.lightbox__arrow:active { transform: translateY(-50%) scale(0.93); }
.lightbox__arrow--prev  { left: var(--space-4); }
.lightbox__arrow--next  { right: var(--space-4); }

.lightbox__counter {
  position: fixed; bottom: var(--space-5); left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.5); color: rgba(255, 255, 255, 0.75);
  font-size: var(--text-xs); font-weight: 700;
  padding: var(--space-2) var(--space-4);
  letter-spacing: 0.08em; backdrop-filter: blur(4px); z-index: 202;
}

/* =========================
   Media Queries — Galería
   ========================= */
@media only screen and (min-width: 481px) and (max-width: 768px) {
  .flipbook__track { height: 400px; }
}

@media only screen and (min-width: 769px) and (max-width: 1279px) and (orientation: portrait) {
  .collage {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
  .flipbook { display: none; }
}

@media only screen and (min-width: 769px) and (max-width: 1279px) and (orientation: landscape) {
  .collage {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
  }
  .flipbook { display: none; }
}

@media only screen and (min-width: 1280px) {
  .collage {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
  }
  .flipbook { display: none; }
}