/* ==========================================================================
   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 {
  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(5.6s + var(--i, 0) * 0.63s) ease-in-out
             calc(var(--i, 0) * -1.27s) infinite alternate paused;
}
.gallery.is-live .g-card__in { 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);
}

@keyframes gFloat {
  from { translate: 0 0; rotate: 0.001deg; }
  to { translate: 0 -7px; rotate: -0.35deg; }
}

.gallery__person {
  position: absolute;
  display: block;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  will-change: transform, opacity;
}

/* --------------------------------------------------------------------------
   The heading, top-left where the reference puts its mark: the site's
   title voice, cream with the key word in the logo's red
   -------------------------------------------------------------------------- */

.g-title {
  position: absolute;
  z-index: 60;
  left: clamp(20px, 2vw, 36px);
  top: clamp(18px, 2.6vh, 30px);
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(20px, 2.1vw, 38px);
  font-weight: 700;
  font-stretch: 90%;
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: 0 2px 18px rgba(0, 0, 0, .6);
  pointer-events: none;
  clip-path: inset(0 100% 0 0);
  opacity: 0;
}
.g-title em { font-style: normal; color: var(--gold); }
.g-title::after {                         /* a red hairline under it */
  content: '';
  display: block;
  width: 2.2em;
  height: 2px;
  margin-top: .35em;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
}
.gallery.is-labels .g-title {
  opacity: 1;
  clip-path: inset(0 -10% -30% 0);
  transition: clip-path 1.1s var(--ease-expo), opacity .4s ease;
}
.gallery.is-labels .g-title::after { transform: none; transition: transform 1s var(--ease-expo) .5s; }

/* --------------------------------------------------------------------------
   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; }

@media (prefers-reduced-motion: reduce) {
  .g-card__in { animation: none; }
}
