/* ---------------------------------------------------------
   GALERÍA · recorrido en profundidad (escena fija + scroll)
   --------------------------------------------------------- */
.gl { position: relative; background: var(--night); }
.gl-scene { position: relative; height: 310vh; height: 310svh; }
.gl-stage {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; overflow: clip;
  background:
    radial-gradient(46% 34% at 50% 48%, rgba(18, 62, 112, .5) 0, rgba(4, 20, 39, 0) 100%),
    linear-gradient(180deg, var(--night) 0, #031a33 58%, #020f1e 100%);
}

/* Palabra de fondo: vive en el mundo 3D a profundidad fija y se estira (eje wdth) */
.gl-word { position: absolute; left: 0; top: 0; width: 0; height: 0; margin: 0; pointer-events: none; user-select: none; }
.gl-word span {
  position: absolute; left: -50vw; width: 100vw; top: -.54em; text-align: center;
  font-family: var(--font-display); font-weight: 820; font-stretch: 62%;
  font-size: clamp(6rem, 19vw, 22rem); line-height: 1; letter-spacing: -.03em; white-space: nowrap;
  color: #0a2645; -webkit-text-stroke: 1.5px rgba(160, 196, 232, .3); opacity: 0;
}

/* Piso: rieles y marcas de medición (canvas) */
.gl-floor { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Mundo 3D: la cámara avanza moviendo el mundo en Z */
.gl-view { position: absolute; inset: 0; perspective: var(--gl-p, 1000px); perspective-origin: 50% var(--gl-oy, 48%); }
.gl-world {
  position: absolute; left: 50%; top: var(--gl-oy, 48%); width: 0; height: 0;
  transform-style: preserve-3d; will-change: transform;
}
.gl-list { position: absolute; left: 0; top: 0; width: 0; height: 0; margin: 0; padding: 0; list-style: none; transform-style: preserve-3d; }
.gl-world li { position: absolute; left: 0; top: 0; visibility: hidden; opacity: 0; }
.gl-world button {
  position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 2px;
  background: #0a2747; cursor: zoom-in; overflow: hidden;
}
.gl-world img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 2px; }
.gl-world button:focus-visible { outline: 2px solid var(--hivis); outline-offset: 6px; }
/* Marcas de encuadre en la foto del plano focal: "entra en tolerancia" */
.gl-world li::after {
  content: ""; position: absolute; inset: -14px; pointer-events: none; opacity: 0; transform: scale(1.06);
  --c: var(--hivis); --l: 22px; --t: 2px;
  background:
    linear-gradient(var(--c), var(--c)) 0 0 / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) 0 0 / var(--t) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) 100% 0 / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) 100% 0 / var(--t) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) 0 100% / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) 0 100% / var(--t) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) 100% 100% / var(--l) var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) 100% 100% / var(--t) var(--l) no-repeat;
  transition: opacity .16s ease-out, transform .42s var(--ease-out);
}
.gl-world li.is-focus::after { opacity: 1; transform: none; }

/* Titular: presente al entrar, se retira cuando la cámara arranca */
.gl-head { position: absolute; left: 0; right: 0; top: calc(var(--header-h) + clamp(20px, 6vh, 64px)); z-index: 2; pointer-events: none; }
.gl-head .sec-title { max-width: 12ch; font-size: clamp(2.4rem, 1.1rem + 3.6vw, 4.9rem); font-stretch: 100%; line-height: .96; }
.gl-head .sec-lead { max-width: 34ch; }

/* Lectura inferior: pie de la foto enfocada + regla del recorrido */
.gl-hud {
  position: absolute; left: 0; right: 0; bottom: clamp(26px, 5.5vh, 56px); z-index: 2;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; pointer-events: none;
}
.gl-now { position: relative; flex: 1 1 auto; max-width: 40ch; min-height: 2.8em; margin: 0; overflow: hidden; }
.gl-now > span {
  position: absolute; left: 0; bottom: 0; right: 0;
  font-size: clamp(1rem, .95rem + .25vw, 1.15rem); line-height: 1.35; color: #fff; text-wrap: balance;
  opacity: 0; transform: translate3d(0, 100%, 0);
  transition: opacity .2s ease-out, transform .5s var(--ease-out);
}
.gl-now > span.is-in { opacity: 1; transform: none; }
.gl-now > span.is-out { opacity: 0; transform: translate3d(0, -100%, 0); transition-duration: .16s, .3s; }
.gl-ruler { position: relative; flex: none; width: clamp(200px, 26vw, 380px); height: 40px; }
.gl-ruler::before { content: ""; position: absolute; left: 0; right: 0; top: 18px; height: 1px; background: rgba(241, 244, 246, .26); }
.gl-ruler i { position: absolute; top: 12px; width: 1px; height: 6px; margin-left: -.5px; background: rgba(241, 244, 246, .4); }
.gl-ruler i.is-grp { top: 4px; height: 14px; background: rgba(241, 244, 246, .75); }
.gl-ruler span { position: absolute; top: 24px; font-size: .78rem; line-height: 1; color: var(--zinc-300); white-space: nowrap; }
.gl-ruler .gl-play { left: 0; top: 0; width: 2px; height: 19px; margin-left: -1px; background: var(--hivis); will-change: transform; }

/* Visor */
.gl-box { width: min(1200px, 94vw, 100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 16px); max-height: 92vh; max-height: 92dvh; overscroll-behavior: contain; padding: 0; border: 0; border-radius: 6px; background: #020d1b; color: #fff; overflow: visible; }
.gl-box::backdrop { background: rgba(2, 10, 22, .9); }
.gl-box[open] { animation: gl-boxin .3s var(--ease-out); }
@keyframes gl-boxin { from { opacity: 0; transform: scale(.97); } }
.gl-box img { display: block; width: 100%; max-height: 82vh; max-height: 80dvh; object-fit: contain; border-radius: 6px 6px 0 0; background: #000; }
.gl-cap { margin: 0; padding: 12px 16px; font-size: .95rem; color: var(--zinc-200); }
.gl-box button { position: absolute; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--hair); background: rgba(4, 20, 39, .8); cursor: pointer; }
.gl-box button svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gl-box button:focus-visible { outline: 2px solid var(--hivis); outline-offset: 2px; }
.gl-prev { left: -22px; top: 45%; } .gl-next { right: -22px; top: 45%; } .gl-close { right: 10px; top: 10px; }

/* Responsive */
@media (max-width: 900px) {
  .gl-box button.gl-prev { left: 6px; } .gl-box button.gl-next { right: 6px; }
  .gl-ruler span { font-size: .875rem; }
}
@media (max-width: 699.98px) {
  .gl-scene { height: 270vh; height: 270svh; }
  .gl-word span { font-size: 22vw; }
  .gl-head .sec-title { font-size: clamp(2.2rem, 1.2rem + 5vw, 2.8rem); }
  .gl-head .sec-lead { font-size: .98rem; max-width: 30ch; }
  .gl-hud { flex-direction: column; align-items: stretch; gap: 10px; bottom: max(18px, env(safe-area-inset-bottom)); }
  .gl-now { min-height: 2.8em; }
  .gl-now > span { font-size: 1rem; }
  .gl-ruler { width: 100%; }
  .gl-world li::after { inset: -9px; --l: 14px; }
}

/* Movimiento reducido: rejilla estática */
.gl.is-static .gl-scene { height: auto; }
.gl.is-static .gl-stage { position: static; display: flex; flex-direction: column; height: auto; overflow: visible; padding: clamp(72px, 10vh, 120px) 0; background: var(--night); }
.gl.is-static .gl-word, .gl.is-static .gl-floor, .gl.is-static .gl-hud { display: none; }
.gl.is-static .gl-head { position: static; order: -1; margin-bottom: 32px; }
.gl.is-static .gl-head .sec-title { max-width: none; }
.gl.is-static .gl-view { position: static; perspective: none; }
.gl.is-static .gl-world { position: static; width: auto; height: auto; transform: none; will-change: auto; }
.gl.is-static .gl-list {
  position: static; width: min(1400px, calc(100% - 2 * var(--gutter))); height: auto; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 44vw), 1fr)); gap: 10px;
  transform: none; will-change: auto;
}
.gl.is-static .gl-world li { position: static; visibility: visible; opacity: 1; }
.gl.is-static .gl-world li::after { display: none; }
.gl.is-static .gl-world img { aspect-ratio: 4 / 3; height: auto; }
@media (prefers-reduced-motion: reduce) {
  .gl-box[open] { animation: none; }
}

/* Visor abierto: el fondo no se desplaza con el dedo (Lenis solo detiene la rueda) */
html:has(.gl-box[open]) { overflow: hidden; scrollbar-gutter: stable; }
