/* Hero v4 — "The stack, made visible".
   A six-frame focus bracket fans out behind the laptop like the walls of a corridor,
   each frame focused a little deeper (01 far → 06 near), all converging on the screen,
   which holds the single sharp result.
   On scroll (js/hero-v4.js sets --c 0→1) the frames fold into the screen. */

.hero--v4 {
  /* Device width: as wide as the first screen allows, leaving room for the heading and buttons. */
  --dw: clamp(300px, min(90vw, (100svh - 440px) * 1.64), 780px);
  --c: 0;
  padding-top: clamp(14px, 2.6vh, 32px);
  padding-bottom: clamp(40px, 6vw, 80px);
  /* The fanned frames are wider than the viewport on small screens; clip them, never scroll. */
  overflow-x: clip;
  max-width: none;
  margin: 0 calc(var(--gutter) * -1);
}
.hero--v4::before {
  top: 64%;
  background: radial-gradient(closest-side, rgba(89, 214, 160, 0.14), rgba(89, 214, 160, 0.04) 55%, transparent);
}

/* ---------- Heading ---------- */

.v4-head {
  display: grid; justify-items: center;
  padding: 0 var(--gutter);
  position: relative; z-index: 2;
}

.v4-title {
  margin-top: clamp(14px, 2.2vh, 22px);
  font-family: "SF Pro Display", "SF Pro", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(60px, 9.4vw, 124px);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1;
  padding: 0 0.04em 0.06em;
}
.v4-title__word {
  display: block;
  background: linear-gradient(180deg, #ffffff 20%, #b9c4bf 95%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.v4-actions { margin-top: clamp(16px, 2.6vh, 26px); }

/* ---------- Stage: frames + laptop ---------- */

.v4-stage {
  position: relative;
  width: var(--dw);
  margin: clamp(22px, 3.6vh, 40px) auto 0;
  perspective: calc(var(--dw) * 1.9);
  perspective-origin: 50% 40%;
}

.v4-device {
  width: 100%;
  margin: 0;
  z-index: 1;
  animation-delay: 0s;
}
.v4-device::after { left: 3%; right: 3%; }

/* The frames share the screen's centre (x 50%, y 45.5% of the device image). */
.v4-frames {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  pointer-events: none;
}

.v4-frame {
  /* --s: side (-1 left, 1 right) · --d: distance from the laptop (1 nearest … 3 outermost). */
  --s: -1; --d: 1;
  --x: calc(var(--s) * var(--dw) * (0.42 + 0.13 * var(--d)));
  --z: calc(var(--dw) * (-0.06 - 0.13 * var(--d)));
  --ry: calc(var(--s) * -1 * (30deg + 3deg * var(--d)));
  --y: 0px;
  --sc: 1;
  position: absolute;
  left: 50%; top: 45.5%;
  width: calc(var(--dw) * 0.5);
  aspect-ratio: 3 / 2;
  margin: calc(var(--dw) * -0.5 / 3) 0 0 calc(var(--dw) * -0.25);
  border-radius: calc(var(--dw) * 0.012);
  overflow: hidden;
  background: #0c1512;
  box-shadow:
    0 0 0 1px rgba(199, 255, 227, 0.14),
    0 24px 60px rgba(0, 0, 0, 0.55);
  transform:
    translate3d(calc(var(--x) * (1 - var(--c))), calc(var(--y) * (1 - var(--c))), calc(var(--z) * (1 - var(--c)) - var(--dw) * 0.2 * var(--c)))
    rotateY(calc(var(--ry) * (1 - var(--c))))
    scale(var(--sc));
  opacity: calc((1.15 - 0.2 * var(--d)) * (1 - var(--c)));
  /* Farther frames sit deeper in the dark. */
  filter: brightness(calc(1.02 - 0.16 * var(--d)));
  animation: v4-frame-in 1.2s cubic-bezier(0.2, 0.75, 0.2, 1) calc(0.25s + 0.09s * var(--d)) backwards;
}
.v4-frame:nth-child(1) { --s: -1; --d: 3; }
.v4-frame:nth-child(2) { --s: -1; --d: 2; }
.v4-frame:nth-child(3) { --s: -1; --d: 1; }
.v4-frame:nth-child(4) { --s: 1;  --d: 1; }
.v4-frame:nth-child(5) { --s: 1;  --d: 2; }
.v4-frame:nth-child(6) { --s: 1;  --d: 3; }

.v4-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Glass sheen across each print. */
.v4-frame::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.04));
  border-radius: inherit;
}

.v4-frame__tag {
  position: absolute; top: 8px; left: 10px;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.12em;
  color: rgba(199, 255, 227, 0.7);
}
.v4-frame:nth-child(n+4) .v4-frame__tag { left: auto; right: 10px; }

/* Frames rise out from behind the screen into the fan. */
@keyframes v4-frame-in {
  from {
    opacity: 0;
    transform: translate3d(0, 0, calc(var(--dw) * -0.3)) rotateY(0deg) scale(var(--sc));
  }
}

/* ---------- Below the laptop ---------- */

.v4-foot {
  display: grid; justify-items: center; gap: 12px;
  margin-top: clamp(28px, 4vw, 44px);
  padding: 0 var(--gutter);
}
.v4-foot .hero__lede { max-width: 32em; }

/* ---------- Smaller screens ---------- */

@media (max-width: 1100px) {
  .hero--v4 { --dw: clamp(300px, min(64vw, (100svh - 440px) * 1.64), 780px); }
  .v4-frame { --x: calc(var(--s) * var(--dw) * (0.40 + 0.12 * var(--d))); }
}

/* Too narrow for the fan: the bracket becomes a deck standing behind the laptop,
   each frame's top edge peeking above the lid, farther frames higher and smaller. */
@media (max-width: 900px) {
  .hero--v4 { --dw: min(86vw, 640px); }
  .v4-stage { margin-top: calc(var(--dw) * 0.2 + 30px); perspective: none; }
  .v4-frame {
    --x: 0px; --z: 0px; --ry: 0deg;
    --y: calc(var(--dw) * -0.068 * var(--d));
    --sc: calc(1 - 0.06 * var(--d));
    width: calc(var(--dw) * 0.8);
    aspect-ratio: 1.55;
    margin: calc(var(--dw) * -0.8 / 3.1) 0 0 calc(var(--dw) * -0.4);
    transform-origin: 50% 0;
    box-shadow: 0 0 0 1px rgba(199, 255, 227, 0.16), 0 -6px 24px rgba(0, 0, 0, 0.5);
    filter: brightness(calc(1.25 - 0.15 * var(--d)));
    opacity: calc(1 - var(--c));
  }
  .v4-frame:nth-child(n+4) { display: none; }
  .v4-frame:nth-child(1) { --d: 3; }
  .v4-frame:nth-child(2) { --d: 2; }
  .v4-frame:nth-child(3) { --d: 1; }
  .v4-frame img { object-position: 50% 35%; }
  .v4-frame__tag { top: calc(var(--dw) * 0.014); font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .v4-frame { animation: none; }
  .hero--v4 { --c: 0 !important; }
}
