/* MDP · Gallery modal full-bleed masonry · estilo The Agency / luxury real estate
 * Reemplaza el lightbox one-image por un grid editorial scroll-vertical sobre fondo carbón.
 * UI minimal: Close arriba-izq, counter arriba-der, sin prev/next (es un scroll feed).
 */

@import url("./tokens.css");

/* ============ MODAL CONTAINER ============ */
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--carbon);
  color: var(--paper-on-dark);
  opacity: 0;
  visibility: hidden;
  transition: opacity 600ms var(--ease-cinematic),
              visibility 0s linear 600ms;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.gallery-modal.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 600ms var(--ease-cinematic),
              visibility 0s linear 0s;
}

/* ============ CHROME TOP · sticky over scroll ============ */
.gallery-chrome {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 22px clamp(20px, 3vw, 40px);
  background: linear-gradient(180deg, rgba(10,10,10,0.85) 0%, rgba(10,10,10,0.55) 60%, rgba(10,10,10,0) 100%);
  backdrop-filter: blur(8px) saturate(110%);
  -webkit-backdrop-filter: blur(8px) saturate(110%);
  pointer-events: none;
}
.gallery-chrome > * { pointer-events: auto; }

.gallery-close {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: 0;
  color: var(--paper-on-dark);
  cursor: pointer;
  padding: 4px 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  justify-self: start;
  transition: opacity var(--dur-base) var(--ease-out-expo);
}
.gallery-close:hover { opacity: 0.7; }
.gallery-close .gc-x {
  font-family: var(--sans-display);
  font-size: 26px;
  line-height: 0.8;
  font-weight: 400;
}

.gallery-title {
  justify-self: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--paper-on-dark);
  opacity: 0.85;
  text-align: center;
}

.gallery-actions {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 24px;
}
.gallery-counter {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--paper-on-dark);
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  .gallery-chrome { padding: 14px 16px; }
  .gallery-close .gc-label { display: none; }
  .gallery-title { font-size: 9px; letter-spacing: 0.24em; }
  .gallery-counter { font-size: 9px; letter-spacing: 0.24em; }
}

/* ============ GRID MASONRY · estilo editorial ============ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;                                /* hairline gap · cinema feel */
  padding: 2px;
  margin-top: -68px;                       /* compensa el chrome sticky height */
}

.gallery-cell {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 900ms var(--ease-cinematic),
              transform 1200ms var(--ease-cinematic);
}
.gallery-modal.is-open .gallery-cell { opacity: 1; transform: none; }

/* stagger per-cell (hasta 24) */
.gallery-modal.is-open .gallery-cell:nth-child(1)  { transition-delay: 80ms; }
.gallery-modal.is-open .gallery-cell:nth-child(2)  { transition-delay: 140ms; }
.gallery-modal.is-open .gallery-cell:nth-child(3)  { transition-delay: 200ms; }
.gallery-modal.is-open .gallery-cell:nth-child(4)  { transition-delay: 260ms; }
.gallery-modal.is-open .gallery-cell:nth-child(5)  { transition-delay: 320ms; }
.gallery-modal.is-open .gallery-cell:nth-child(6)  { transition-delay: 380ms; }
.gallery-modal.is-open .gallery-cell:nth-child(7)  { transition-delay: 440ms; }
.gallery-modal.is-open .gallery-cell:nth-child(8)  { transition-delay: 500ms; }
.gallery-modal.is-open .gallery-cell:nth-child(n+9) { transition-delay: 560ms; }

.gallery-cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1800ms var(--ease-cinematic),
              filter 600ms var(--ease-out-expo);
  filter: saturate(0.95);
}
.gallery-cell:hover img {
  transform: scale(1.04);
  filter: saturate(1.05) brightness(1.04);
}

/* ============ LAYOUT PATTERNS · cada cell define span + aspect ============
   Los patterns se asignan en JS via clase .gc-pattern-{n}. */
.gc-hero    { grid-column: span 12; aspect-ratio: 21 / 9; }   /* panorámica gigante */
.gc-half    { grid-column: span 6;  aspect-ratio: 4 / 3; }    /* 50/50 row */
.gc-third   { grid-column: span 4;  aspect-ratio: 1 / 1; }    /* trio square */
.gc-two-thirds { grid-column: span 8; aspect-ratio: 16 / 10; }
.gc-portrait{ grid-column: span 4;  aspect-ratio: 3 / 4; }
.gc-wide    { grid-column: span 12; aspect-ratio: 16 / 7; }

@media (max-width: 900px) {
  .gallery-grid { grid-template-columns: repeat(6, 1fr); }
  .gc-half, .gc-third, .gc-portrait, .gc-two-thirds { grid-column: span 6; aspect-ratio: 4 / 3; }
  .gc-hero, .gc-wide { grid-column: span 6; aspect-ratio: 16 / 9; }
}
@media (max-width: 560px) {
  .gallery-grid { grid-template-columns: 1fr; gap: 1px; padding: 1px; }
  .gallery-cell { grid-column: 1 !important; aspect-ratio: 4 / 3 !important; }
  .gc-hero, .gc-wide { aspect-ratio: 16 / 9 !important; }
  .gc-portrait { aspect-ratio: 3 / 4 !important; }
}

/* ============ BODY LOCK · al abrir gallery ============ */
body.gallery-open { overflow: hidden; }
