/* ==========================================================================
   Scene four — the project universe.
   The reference image is rebuilt as living layers: the room is the extracted
   plate on canvas, the twelve screens are DOM buttons wearing sprites cut
   from that same image, the creator is its matted centre. This sheet carries
   the layer stack, the hover life and the caption typography; the entrance
   choreography itself is driven per-frame from boot4.js.
   ========================================================================== */

.gallery {
  position: relative;
  height: 260svh;
  background: #000;
}

.gallery__pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  background: #000;
}

#galleryStage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* the 3D room the cards live in */
.gallery__world {
  position: absolute;
  inset: 0;
  perspective: 1200px;
  perspective-origin: 50% 42%;
}

.gallery__deck {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   Cards. The sprite carries the reference's own bezel, rim light and glow,
   so the button is chrome-free: no border, no background — just the pixels,
   an easing inner shell for hover/float, and a tinted shadow when lifted.
   -------------------------------------------------------------------------- */

.g-card {
  position: absolute;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0;
  will-change: transform, opacity;
  transform-style: preserve-3d;
  -webkit-tap-highlight-color: transparent;
}

.g-card__in {
  position: relative;
  display: block;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              filter 0.5s ease;
  animation: gFloat calc(7s + var(--i, 0) * 0.7s) ease-in-out
             calc(var(--i, 0) * -1.27s) infinite alternate paused;
}
/* a slow light sweep across each screen's face, one screen after another;
   the inset keeps it off the rim glow (14 / 368 and 14 / 240.5 of the sprite) */
.g-card__in::after {
  content: '';
  position: absolute;
  inset: 5.8% 3.8%;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 236, 222, 0.14) 50%, transparent 58%)
              no-repeat 150% 0 / 250% 100%;
  mix-blend-mode: screen;
  animation: gSheen 10s ease-in-out calc(var(--i, 0) * 1.4s) infinite paused;
}
.gallery.is-live .g-card__in,
.gallery.is-live .g-card__in::after { animation-play-state: running; }

.g-card img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
}

/* hover: toward the camera, a touch brighter, its glow deepened — and the
   rest of the room eases back a breath so the depth reads */
.g-card:hover .g-card__in,
.g-card:focus-visible .g-card__in {
  transform: translateZ(30px) scale(1.022);
  filter: brightness(1.12) drop-shadow(0 10px 34px var(--tint, rgba(255, 140, 60, 0.4)));
}
.g-card:focus-visible {
  outline: none;
}
.gallery__deck.is-hot .g-card:not(:hover):not(:focus-visible) .g-card__in {
  transform: translateZ(-12px) scale(0.992);
  filter: brightness(0.9);
}

/* each screen drifts on its own slow path and sways a little in 3D, side
   screens turning toward the figure (--side: 1 left, -1 right, 0 centre) */
@keyframes gFloat {
  0% { translate: 0 0; rotate: 0 1 0 calc(var(--side, 0) * 2.4deg); }
  50% { translate: 4px -10px; rotate: 1 0.3 0 1.5deg; }
  100% { translate: -3px -5px; rotate: 0 1 0 calc(var(--side, 0) * -1.2deg - 0.6deg); }
}
@keyframes gSheen {
  0%, 65% { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}

.gallery__person {
  position: absolute;
  display: block;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  will-change: transform, opacity;
}

/* --------------------------------------------------------------------------
   Corner captions — the reference's HUD. Letterspaced hairline sans, amber
   headline, dashes as punctuation. They type themselves in on .is-labels.
   -------------------------------------------------------------------------- */

.g-label {
  position: absolute;
  margin: 0;
  font-family: var(--ui);
  font-size: clamp(8px, 0.72vw, 12px);
  font-weight: 400;
  line-height: 2.05;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(212, 208, 205, 0.6);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.9s ease calc(var(--li, 0) * 0.14s),
              transform 1.1s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--li, 0) * 0.14s);
  pointer-events: none;
}
.gallery.is-labels .g-label { opacity: 1; transform: none; }

.g-label--projects {
  top: clamp(18px, 3.8vh, 40px);
  left: clamp(20px, 3vw, 52px);
  font-size: clamp(10px, 0.92vw, 15px);
  font-weight: 500;
  letter-spacing: 0.52em;
  color: #d8b183;
}
.g-label--projects::after,
.g-label--ideas::after,
.g-label--scroll::after,
.g-label--tomorrow::after {
  content: '';
  display: block;
  width: 1.6em;
  height: 1px;
  margin-top: 1.1em;
  background: currentColor;
  opacity: 0.55;
}
.g-label--ideas {
  top: clamp(90px, 15.5vh, 150px);
  left: clamp(20px, 3vw, 52px);
}
.g-label--ideas b { font-weight: 500; color: rgba(232, 226, 220, 0.82); }
.g-label--scroll {
  top: clamp(18px, 4vh, 42px);
  right: clamp(20px, 3vw, 52px);
}
.g-label--real {
  bottom: clamp(20px, 6vh, 60px);
  left: clamp(20px, 3vw, 52px);
}
.g-label--tomorrow {
  bottom: clamp(20px, 6vh, 60px);
  right: clamp(20px, 3vw, 52px);
}


/* --------------------------------------------------------------------------
   Portrait: recomposition (layout4.PORTRAIT places the survivors); the rest
   of the deck sits this orientation out. Captions tighten into two rows.
   -------------------------------------------------------------------------- */

.gallery.is-portrait .g-label--ideas { top: clamp(64px, 9vh, 110px); }
.gallery.is-portrait .g-label--real,
.gallery.is-portrait .g-label--tomorrow { bottom: clamp(14px, 3vh, 30px); }

/* --------------------------------------------------------------------------
   Fallbacks
   -------------------------------------------------------------------------- */

.gallery.is-fallback #galleryStage { display: none; }
.gallery.is-fallback .gallery__pin {
  background: #000 url('../../public/projects/plate.jpg') center / cover no-repeat;
}
.gallery.is-set .g-card,
.gallery.is-set .gallery__person { opacity: 1; }
.gallery.is-set .g-label { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .g-card__in, .g-card__in::after { animation: none; }
  .g-label { transition-duration: 0.01ms; transition-delay: 0s; }
}
