/* Home · Hero (from variants/hero-a, integrated 2026-11-10) — "Centred stage".
   Logo, one line and the download button centred above the laptop; the six-frame bracket
   stands in a shallow arc behind it. hero-a.js drives:
     --c            0 = arc open, 1 = folded into the screen (on scroll)
     data-sweep     "on" while the focus sweep runs; .is-active on the one sharp frame
   Layered over site.css (tokens, .button, .hero__device). Uses its own ha-* classes only. */

.ha {
  /* Device width: what the first screen leaves after the top bar and the centred copy block
     (which shrinks a little with the screen's height). 2378 × 1452 device image → width = height × 1.64. */
  --dw: clamp(300px, min(60vw, (75svh - var(--topbar-h) - 105px) * 1.64), 1040px);
  --c: 0;
  position: relative;
  isolation: isolate;
  /* .page adds side gutters; the arc runs edge to edge, clipped at the screen, never scrolled. */
  margin: 0 calc(var(--gutter) * -1);
  padding: clamp(16px, 3vh, 40px) 0 clamp(40px, 6vh, 72px);
  overflow-x: clip;
  text-align: center;
}

/* Low, wide light the laptop sits in. */
.ha::before {
  content: ""; position: absolute; z-index: -2;
  left: 50%; top: 66%;
  width: min(1500px, 150vw); aspect-ratio: 2.2 / 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(120, 150, 60, 0.11), rgba(120, 150, 60, 0.03) 60%, transparent);
  pointer-events: none;
}

/* ---------- Copy block ---------- */

.ha-head {
  position: relative; z-index: 3;
  display: grid; justify-items: center;
  padding: 0 var(--gutter);
}
.ha-head > * { animation: ha-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
.ha-head > :nth-child(2) { animation-delay: 0.06s; }
.ha-head > :nth-child(3) { animation-delay: 0.12s; }
.ha-head > :nth-child(4) { animation-delay: 0.18s; }
@keyframes ha-rise { from { opacity: 0; transform: translateY(12px); } }

.ha-logo { margin: 0; line-height: 0; }
.ha-logo img { display: block; width: auto; height: clamp(40px, min(3.8vw, 6.2vh), 60px); max-width: 100%; }

.ha-title {
  margin-top: clamp(14px, 2.2vh, 24px);
  font-family: "SF Pro Display", "SF Pro", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(28px, min(3.1vw, 5vh), 46px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
  padding-bottom: 0.06em;
  background: linear-gradient(180deg, #ffffff 25%, #b9c4bf 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  text-wrap: balance;
}

.ha-sub {
  margin-top: 8px;
  max-width: 52em;
  color: var(--muted);
  font-size: clamp(15px, 1.15vw, 18px);
  line-height: 1.45;
  text-wrap: balance;
}

.ha-cta {
  margin-top: clamp(18px, 2.6vh, 26px);
  display: grid; justify-items: center; gap: 10px;
}

/* The one action on the page: the only accent on the screen. */
.ha-download {
  gap: 10px;
  min-height: 48px;
  padding: 0 24px 0 20px;
  font-size: 16px;
  letter-spacing: -0.01em;
  box-shadow: 0 10px 30px rgba(89, 214, 160, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.ha-download:hover { box-shadow: 0 12px 34px rgba(89, 214, 160, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.ha-download:active { transform: scale(0.98); }
.ha-download svg { flex: none; }

.ha-note { color: var(--faint); font-size: 13px; letter-spacing: 0.01em; }

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

.ha-stage {
  position: relative;
  width: var(--dw);
  margin: clamp(24px, 3.6vh, 44px) auto 0;
  perspective: calc(var(--dw) * 2.1);
  perspective-origin: 50% 42%;
}

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

/* A blurred copy of the screen spilling light around the laptop; brighter as the frames fold in,
   and at the end of each sweep (when the screen holds the result). */
.ha-glow {
  position: absolute; z-index: -1;
  left: 50%; top: 52%;
  width: calc(var(--dw) * 1.5);
  aspect-ratio: 3 / 2;
  transform: translate(-50%, -50%);
  background: url("../assets/mushroom-glow.webp") center / cover no-repeat;
  filter: blur(calc(var(--dw) * 0.08)) saturate(1.05);
  -webkit-mask-image: radial-gradient(closest-side, #000 35%, transparent);
  mask-image: radial-gradient(closest-side, #000 35%, transparent);
  opacity: calc(0.36 + 0.34 * var(--c));
  pointer-events: none;
  transition: opacity 1.2s ease;
  animation: ha-fade 1.6s ease-out 0.2s backwards;
}
.ha[data-sweep="rest"] .ha-glow { opacity: calc(0.5 + 0.2 * var(--c)); }
@keyframes ha-fade { from { opacity: 0; } }

.ha-cards {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  pointer-events: none;
}

/* The arc: three frames a side on a shallow curve behind the lid, all facing the viewer's axis.
   --s side (-1 left, 1 right) · --d step out from the laptop (1 nearest … 3 outermost).
   Steps are even (same x and angle increment), so the arc reads as one bracket, not a corridor. */
.ha-card {
  --s: -1; --d: 1;
  --w: 0.44;                                                       /* card width, × device */
  --x: calc(var(--s) * var(--dw) * (0.3 + 0.15 * var(--d)));
  --z: calc(var(--dw) * (-0.04 - 0.1 * var(--d)));
  --ry: calc(var(--s) * -1 * (14deg + 7deg * var(--d)));
  position: absolute;
  left: 50%; top: 45.5%;                                           /* the screen's centre */
  width: calc(var(--dw) * var(--w));
  aspect-ratio: 3 / 2;
  margin: calc(var(--dw) * var(--w) / -3) 0 0 calc(var(--dw) * var(--w) / -2);
  transform:
    translate3d(calc(var(--x) * (1 - var(--c))), 0, calc(var(--z) * (1 - var(--c)) - var(--dw) * 0.2 * var(--c)))
    rotateY(calc(var(--ry) * (1 - var(--c))))
    scale(calc(1 - 0.2 * var(--c)));
  opacity: calc((1.08 - 0.1 * var(--d)) * (1 - var(--c)));
  transform-style: preserve-3d;
  animation: ha-card-in 1.2s cubic-bezier(0.2, 0.75, 0.2, 1) calc(0.3s + 0.1s * var(--d)) backwards;
}
.ha-card:nth-child(1) { --s: -1; --d: 3; }
.ha-card:nth-child(2) { --s: -1; --d: 2; }
.ha-card:nth-child(3) { --s: -1; --d: 1; }
.ha-card:nth-child(4) { --s: 1;  --d: 1; }
.ha-card:nth-child(5) { --s: 1;  --d: 2; }
.ha-card:nth-child(6) { --s: 1;  --d: 3; }

@keyframes ha-card-in {
  from { opacity: 0; transform: translate3d(0, 0, calc(var(--dw) * -0.3)) rotateY(0deg); }
}

/* Inner layer carries the focus state, so its transition never lags the scroll-driven transform. */
.ha-card__in {
  position: relative;
  width: 100%; height: 100%;
  border-radius: calc(var(--dw) * 0.011);
  overflow: hidden;
  background: #0c1512;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 24px 60px rgba(0, 0, 0, 0.6);
  /* At rest: the farther out, the deeper in the dark. */
  filter: brightness(calc(1.02 - 0.12 * var(--d))) blur(0px);
  transition: filter 0.75s ease, box-shadow 0.75s ease, transform 0.75s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ha-card__in img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Glass sheen across each print. */
.ha-card__in::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.04));
}

.ha-card__tag {
  position: absolute; top: 8px; left: 10px;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: color 0.75s ease;
}
.ha-card:nth-child(n+4) .ha-card__tag { left: auto; right: 10px; }

/* Focus sweep: while it runs, the bracket softens and one frame at a time comes sharp. */
.ha[data-sweep="on"] .ha-card__in {
  filter: brightness(calc(0.72 - 0.1 * var(--d))) blur(1.8px);
}
.ha[data-sweep="on"] .ha-card.is-active .ha-card__in {
  transform: translateZ(calc(var(--dw) * 0.05));
  filter: brightness(1.12) blur(0px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.34), 0 28px 70px rgba(0, 0, 0, 0.65);
}
.ha[data-sweep="on"] .ha-card__tag { color: rgba(255, 255, 255, 0.45); }
.ha[data-sweep="on"] .ha-card.is-active .ha-card__tag { color: #fff; }

/* ---------- Mid widths ---------- */

@media (max-width: 1100px) {
  .ha { --dw: clamp(300px, min(60vw, (75svh - var(--topbar-h) - 105px) * 1.64), 780px); }
  .ha-card { --x: calc(var(--s) * var(--dw) * (0.3 + 0.115 * var(--d))); }
}

/* ---------- Phones and small tablets ---------- */

/* Too narrow for the side arc: the bracket becomes a hand of six prints fanned above the lid,
   pivoting on a point below the laptop, the middle two in front. The sweep lifts one at a time. */
@media (max-width: 900px) {
  .ha { --dw: min(calc(100vw - 2 * var(--gutter)), 620px); }
  .ha-sub { max-width: 26em; }
  .ha-stage { margin-top: calc(var(--dw) * 0.2 + 30px); perspective: none; }

  .ha-card {
    --w: 0.56;
    --a: calc((var(--i) - 3.5) * 5.2deg);
    transform-origin: 50% 230%;
    transform:
      translateY(calc(var(--dw) * -0.215 * (1 - var(--c))))
      rotate(calc(var(--a) * (1 - var(--c))))
      scale(calc(1 - 0.2 * var(--c)));
    opacity: calc(1 - var(--c));
  }
  .ha-card:nth-child(1), .ha-card:nth-child(6) { z-index: 1; }
  .ha-card:nth-child(2), .ha-card:nth-child(5) { z-index: 2; }
  .ha-card:nth-child(3), .ha-card:nth-child(4) { z-index: 3; }
  @keyframes ha-card-in { from { opacity: 0; transform: translateY(0) rotate(0deg); } }

  .ha-card__in {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 -6px 22px rgba(0, 0, 0, 0.55);
    filter: brightness(calc(1.1 - 0.1 * var(--d)));
  }
  .ha-card__in img { object-position: 50% 30%; }
  .ha-card__tag, .ha-card:nth-child(n+4) .ha-card__tag {
    top: calc(var(--dw) * 0.016); left: 50%; right: auto;
    transform: translateX(-50%);
    font-size: 9px;
  }
  .ha[data-sweep="on"] .ha-card__in { filter: brightness(calc(0.82 - 0.08 * var(--d))) blur(1px); }
  .ha[data-sweep="on"] .ha-card.is-active .ha-card__in { transform: translateY(-7%); filter: brightness(1.1) blur(0px); }
}

@media (max-width: 520px) {
  .ha-download { width: 100%; max-width: 340px; }
}

/* ---------- Reduced motion: still arc, no sweep, no fold ---------- */

@media (prefers-reduced-motion: reduce) {
  .ha { --c: 0 !important; }
  .ha-head > *, .ha-card, .ha-glow, .ha-device { animation: none; }
  .ha-card__in, .ha-glow, .ha-card__tag { transition: none; }
}

/* ---------- On the home page: the hero is the first sheet (css/sep-b.css) ----------
   The slot already bleeds to the edges, so the hero must not; the Stacking sheet's rounded top
   overlaps it by --sb-r, so give that back under the laptop. */
.sb-slot > .ha { margin: 0; background: var(--bg); }
#page-home .sb-slot > .ha { padding-bottom: calc(var(--sb-r) + clamp(40px, 6vh, 72px)); }
