/* ==========================================================================
   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: 265svh;
  background: #000;
}

.gallery--projects {
  height: 235svh;
}

.gallery__pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  background: #000;
  transform: scale(calc(0.955 + var(--enter, 1) * 0.045));
  border-radius: calc((1 - var(--enter, 1)) * 18px);
  transform-origin: 50% 45%;
}

.gallery__pin::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  z-index: 40;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(246, 154, 97, .85), rgba(200, 56, 43, .85), transparent);
  opacity: calc(sin(var(--enter, 1) * 180deg));
}

.gallery canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

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

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

/* --------------------------------------------------------------------------
   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.
   Keep non-hovered cards at non-negative Z so preserve-3d hit-testing never
   pushes cards behind the deck/canvas plane. */
.g-card {
  pointer-events: auto;
  touch-action: manipulation;
}

.g-card:hover,
.g-card:focus-visible {
  z-index: 45 !important;
}

.g-card:hover .g-card__in,
.g-card:focus-visible .g-card__in {
  transform: translateZ(36px) scale(1.045);
  filter: brightness(1.16) drop-shadow(0 14px 40px var(--tint, rgba(255, 140, 60, 0.52)));
}

.g-card:focus-visible {
  outline: none;
}

.gallery__deck.is-hot .g-card:not(:hover):not(:focus-visible) .g-card__in {
  transform: scale(0.985);
  filter: brightness(0.84);
}

@keyframes gFloat {
  from {
    transform: translate3d(0, 0, 0) rotateY(0.4deg);
  }

  to {
    transform: translate3d(0, -10px, 6px) rotateY(-0.6deg);
  }
}

.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);
  text-shadow: 0 1px 12px rgba(0, 0, 0, .92);
  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;
}

.gallery.is-clearing .g-label {
  transition: 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);
}

/* the red index over the hero screen — placed by boot4 from frame coords */
.g-label--num {
  font-family: var(--ui);
  font-weight: 500;
  letter-spacing: 0.14em;
  color: #c8382b;
  transition-delay: 0.5s;
}

/* --------------------------------------------------------------------------
   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 {
  font-size: clamp(7.5px, 2vw, 10px);
  line-height: 1.5;
}

.gallery.is-portrait .g-label--ideas {
  top: clamp(62px, 7.6vh, 84px);
}

.gallery.is-portrait .g-label--real,
.gallery.is-portrait .g-label--tomorrow {
  bottom: clamp(10px, 1.8vh, 20px);
}

.gallery.is-portrait .g-label--num {
  display: none;
}

.gallery.is-portrait {
  height: 220svh;
}

.gallery--projects.is-portrait {
  height: 205svh;
}

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

.gallery.is-fallback canvas {
  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 {
    animation: none;
  }

  .g-label {
    transition-duration: 0.01ms;
    transition-delay: 0s;
  }
}