/* Corva hero: live 3D dots (from sketch B), as the page's first section.
   Everything is scoped to #hero and prefixed h3- so it cannot collide with the page's own styles.

   Layout modes
   - default (scripting on): one pinned stage. hero.js adds .h3-on to <html> once the scene runs,
     which turns the section into the 450vh scroll track.
   - flowing: .h3-static (no WebGL, or the scene failed), .h3-rm (reduced motion stills),
     and @media (scripting: none). The three acts are stacked as ordinary content.
   - .h3-lost: the WebGL context was lost mid-scroll. The track and the text keep working,
     the canvas is replaced by the CSS logo mark.

   One layout breakpoint, used identically in hero.js: (max-aspect-ratio: 1/1) is "portrait",
   where the text sits at the bottom of the screen instead of the left. */

#hero {
  --h3-night: #05070A;
  --h3-text: #E9EEF0;
  --h3-teal: #35D0BE;
  --h3-dim: #7F8D98;
  --h3-soft: #B9C4CB;
  --h3-line: #1C242C;
  --h3-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --h3-gutter: clamp(20px, 4vw, 56px);
  --h3-display: "Archivo", system-ui, sans-serif;
  --h3-body: "Hanken Grotesk", system-ui, sans-serif;
  --h3-mark: "Unbounded", system-ui, sans-serif;
  /* distance from the stage's bottom edge to the bottom of the visible screen (iPhone bars) */
  --h3-bars: calc(100lvh - 100svh);

  position: relative;
  height: 100vh; height: 100svh;
  background: var(--h3-night);
  color: var(--h3-text);
  font-family: var(--h3-body);
}
#hero *, #hero *::before, #hero *::after { box-sizing: border-box; }
:where(#hero) :where(p, h2, ul) { margin: 0; }
.h3-on #hero { height: 450vh; }

.h3-vh {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.h3-stage {
  position: sticky; top: 0;
  height: 100vh;
  height: 100lvh; /* lvh, not svh: see the Motion Library gotcha on iPhone bars and sticky stages */
  overflow: clip;
  background: var(--h3-night);
}

.h3-scene {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; opacity: 0;
  touch-action: pan-y; /* a vertical swipe still scrolls the page; the script only listens */
}
.h3-on .h3-scene { opacity: 1; transition: opacity 900ms var(--h3-ease-out); }
.h3-lost .h3-scene { opacity: 0; transition: none; }

/* ---------- the logo mark: three dots in the logo's triangle, sized in em ---------- */
.h3-tri { position: relative; display: inline-block; width: .74em; height: .68em; flex: none; }
.h3-tri b { position: absolute; width: .27em; height: .27em; border-radius: 50%; background: var(--h3-text); }
.h3-tri b:nth-child(1) { left: 0; bottom: 0; }
.h3-tri b:nth-child(2) { right: 0; bottom: 0; }
.h3-tri b:nth-child(3) { left: 50%; top: 0; transform: translateX(-50%); background: var(--h3-teal); }

.h3-word, .h3-endword { font-family: var(--h3-mark); font-weight: 700; letter-spacing: -0.02em; }
.h3-word i, .h3-endword i { font-style: normal; color: var(--h3-teal); }

.h3-brand {
  position: absolute; z-index: 4; top: var(--h3-gutter); left: var(--h3-gutter);
  display: flex; align-items: center; gap: .42em;
  font-size: 22px; line-height: 1;
}
.h3-brand .h3-word { font-size: .92em; }

/* CSS mark: hidden while the scene is loading or running */
.h3-mark { display: none; }
.h3-lost .h3-mark {
  display: grid; place-items: center;
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  font-size: clamp(88px, 14vw, 180px);
}

/* ---------- contact: a quiet text link, top right (second line under the brand on portrait) ---------- */
.h3-contact {
  position: absolute; z-index: 4; top: var(--h3-gutter); right: var(--h3-gutter);
  display: inline-block; padding: 3px 0; margin-top: -3px;
  font: 500 .875rem/1 var(--h3-body); letter-spacing: .005em; color: var(--h3-soft);
  text-decoration: none; text-underline-offset: 4px; text-decoration-thickness: 1px;
  transform-origin: 100% 50%;
  transition: transform 140ms ease-out, opacity 300ms ease;
}
.h3-contact:focus-visible { outline: 2px solid var(--h3-text); outline-offset: 5px; border-radius: 2px; }
.h3-contact:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) {
  .h3-contact:hover { color: var(--h3-text); text-decoration-line: underline; }
}

/* ---------- the captions ---------- */
/* One short line per act, set like a caption under the scene: the paper, the app and the spheres
   are the subject. All three share one place (a one-cell grid) and swap with the scroll. */
.h3-acts {
  position: absolute; z-index: 3;
  left: var(--h3-gutter); bottom: clamp(40px, 9vh, 88px);
  display: grid;
  pointer-events: none;
}
.h3-act {
  grid-area: 1 / 1; align-self: end; margin: 0;
  max-width: 15ch;
  font-family: var(--h3-display); font-weight: 800; font-stretch: 125%;
  font-size: clamp(1.625rem, 2.5vw, 2.625rem); line-height: 1.02; letter-spacing: -0.03em;
  text-wrap: balance;
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  /* leaving is quicker than arriving */
  transition: opacity 200ms ease-out, transform 260ms ease-out;
}
.h3-act[data-state="past"] { transform: translate3d(0, -14px, 0); }
.h3-act[data-state="on"] {
  opacity: 1; transform: none;
  transition: opacity 480ms var(--h3-ease-out) 90ms, transform 620ms var(--h3-ease-out) 90ms;
}
.h3-act[data-n="3"] { color: var(--h3-teal); }

/* ---------- hint ---------- */
.h3-hint {
  position: absolute; z-index: 3; right: var(--h3-gutter); bottom: clamp(40px, 10vh, 96px);
  font: 500 .875rem/1.3 var(--h3-body); color: var(--h3-dim); letter-spacing: .01em;
  opacity: 0; transform: translate3d(0, 6px, 0);
  transition: opacity 300ms var(--h3-ease-out), transform 300ms var(--h3-ease-out);
  pointer-events: none;
}
.h3-hint[data-on="true"] { opacity: 1; transform: none; }
.h3-hint-touch { display: none; }
@media (pointer: coarse) {
  .h3-hint-fine { display: none; }
  .h3-hint-touch { display: inline; }
}

/* ---------- closing wordmark, placed under the three spheres by the script ---------- */
.h3-endword {
  position: absolute; z-index: 3; left: 0; top: 0; /* above the portrait text fade */
  font-size: 100px; line-height: 1; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transform-origin: 0 0;
  will-change: transform, opacity;
}
.h3-lost .h3-endword { visibility: hidden; }

/* ---------- hand-off anchors: never visible ---------- */
#heroMark { position: absolute; inset: 0; z-index: 0; opacity: 0; pointer-events: none; }
#heroMark b { position: absolute; left: 0; top: 0; width: 0; height: 0; border-radius: 50%; }

/* ---------- portrait: the caption at the bottom of the visible screen ---------- */
@media (max-aspect-ratio: 1/1) {
  .h3-brand { font-size: 18px; }
  .h3-contact { right: auto; left: var(--h3-gutter); top: calc(var(--h3-gutter) + 30px); font-size: .8125rem; transform-origin: 0 50%; }
  .h3-acts {
    right: var(--h3-gutter);
    bottom: calc(var(--h3-bars) + clamp(28px, 5vh, 44px));
  }
  .h3-act { font-size: clamp(1.625rem, 7.2vw, 2.375rem); max-width: 14ch; }
  /* the floor's reflections run under the caption: a short fade keeps it readable */
  .h3-stage::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; pointer-events: none;
    height: calc(var(--h3-bars) + 40%);
    background: linear-gradient(to top, var(--h3-night) 0, var(--h3-night) calc(var(--h3-bars) + 16%), rgb(5 7 10 / .8) calc(var(--h3-bars) + 24%), rgb(5 7 10 / 0) 100%);
    transition: opacity 400ms ease;
  }
  /* no caption during the logo ending, so no fade over the dots */
  #hero[data-act="0"] .h3-stage::after { opacity: 0; }
  .h3-hint { left: var(--h3-gutter); right: auto; bottom: auto; top: calc(var(--h3-gutter) + 58px); }
}

/* ---------- stacked layout: no WebGL, reduced motion, or no scripting ---------- */
/* The three lines read top to bottom, then the logo mark. */
.h3-static #hero, .h3-rm #hero { height: auto; }
.h3-static .h3-stage, .h3-rm .h3-stage {
  position: relative; height: auto; overflow: visible;
  display: flex; flex-direction: column; gap: clamp(48px, 9vh, 104px);
  padding: calc(var(--h3-gutter) + 88px) var(--h3-gutter) clamp(56px, 10vh, 112px);
}
.h3-static .h3-scene, .h3-rm .h3-scene, .h3-static .h3-hint, .h3-rm .h3-hint,
.h3-static .h3-endword, .h3-rm .h3-endword { display: none; }
.h3-static .h3-stage::after, .h3-rm .h3-stage::after { content: none; }
.h3-static .h3-acts, .h3-rm .h3-acts { position: static; pointer-events: auto; gap: .18em; font-size: clamp(2rem, 5.4vw, 4.6rem); }
.h3-static .h3-act, .h3-rm .h3-act {
  grid-area: auto; font-size: 1em; max-width: none; opacity: 1; transform: none; transition: none;
}
.h3-static .h3-mark, .h3-rm .h3-mark {
  display: block; order: 2; font-size: clamp(88px, 14vw, 180px); line-height: 0;
}

/* reduced motion: each caption gets a still frame of the scene above it, rendered once by the script */
.h3-rm .h3-acts { gap: clamp(14px, 2vh, 22px); }
.h3-still { display: block; width: 100%; height: auto; border-radius: 4px; }
.h3-rm .h3-still:not(:first-child) { margin-top: clamp(36px, 7vh, 88px); }
@media (min-aspect-ratio: 1/1) {
  /* still on the left, its caption beside it, sitting on the image's bottom edge */
  .h3-rm .h3-acts { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); column-gap: clamp(32px, 4vw, 64px); row-gap: clamp(36px, 7vh, 88px); align-items: end; font-size: clamp(2rem, 3.6vw, 3.4rem); }
  .h3-rm .h3-still:not(:first-child) { margin-top: 0; }
}

@media (scripting: none) {
  #hero { height: auto; }
  .h3-stage {
    position: relative; height: auto; overflow: visible;
    display: flex; flex-direction: column; gap: clamp(48px, 9vh, 104px);
    padding: calc(var(--h3-gutter) + 88px) var(--h3-gutter) clamp(56px, 10vh, 112px);
  }
  .h3-scene, .h3-hint, .h3-endword { display: none; }
  .h3-stage::after { content: none; }
  .h3-acts { position: static; gap: .18em; font-size: clamp(2rem, 5.4vw, 4.6rem); }
  .h3-act { grid-area: auto; font-size: 1em; max-width: none; opacity: 1; transform: none; }
  .h3-mark { display: block; order: 2; font-size: clamp(88px, 14vw, 180px); line-height: 0; }
}

/* reduced motion: gentler, not nothing. Captions cross-fade in place, no travel. */
@media (prefers-reduced-motion: reduce) {
  .h3-act, .h3-act[data-state="past"], .h3-act[data-state="on"], .h3-hint, .h3-hint[data-on="true"] {
    transform: none; transition: opacity 200ms ease;
  }
}
