/* ------------------------------------------------------------
   DEPTH — a ring of photos in real 3D space (CSS perspective +
   rotateY + translateZ), with the viewer standing at the center.
   Scrolling turns the whole ring around the viewer, so it reads
   as standing inside a room hung with photos and turning to face
   each one — not photos flying toward a fixed camera. No cursor
   involvement at all; depth and rotation come only from scroll.
------------------------------------------------------------- */

:root {
  --scroll-factor: 3.5;
}

.depth {
  position: relative;
  height: calc(var(--frames, 4) * 100vh * var(--scroll-factor));
  background: #000;
}

.depth__pin {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  perspective: 1000px;
}

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

.depth__layer {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(46vw, 560px);
  aspect-ratio: 3 / 2;
  background: #000;
  transform-style: preserve-3d;
  will-change: transform, opacity;
  opacity: 0;
}

.depth__layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 50px 120px rgba(0, 0, 0, 0.65);
}

/* Portrait photos: instead of letterboxing a vertical photo inside
   this landscape-shaped layer (object-fit: contain leaves black bars
   top/bottom), resize the layer itself to the photo's own 2:3
   ratio — same rendered height as a landscape layer at this
   breakpoint, narrower width computed from that ratio — so
   object-fit: cover fills the layer edge-to-edge with zero internal
   letterboxing. JS only ever sets this element's transform (rotateY /
   translateZ), never its width, so resizing it here is safe. */
.depth__layer:has(img.is-portrait) {
  width: auto;
  height: calc(min(46vw, 560px) * 2 / 3);
  aspect-ratio: 2 / 3;
}

.depth__vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.8) 100%),
    linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, transparent 30%);
}

.depth__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: 0 clamp(24px, 6vw, 72px) clamp(64px, 10vh, 120px);
  max-width: 620px;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}

.depth__caption.is-visible {
  opacity: 1;
}

.scene__caption-index {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin-bottom: 12px;
}

.scene__caption-text {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--fg-dim);
  font-weight: 300;
}

.depth__hint {
  position: absolute;
  bottom: clamp(30px, 6vh, 60px);
  right: clamp(24px, 6vw, 72px);
  z-index: 3;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

@media (max-width: 720px) {
  .depth__layer { width: min(74vw, 460px); }
  .depth__layer:has(img.is-portrait) { height: calc(min(74vw, 460px) * 2 / 3); }
}

@media (prefers-reduced-motion: reduce) {
  .depth { height: auto; }
  .depth__pin { position: relative; height: 70vh; }
  .depth__layer { opacity: 1 !important; transform: translate(-50%, -50%) !important; }
}
