/* HERO — layout, stage geometry, depth layers, entrance sequence.
   Depth: 1 page-bg  ·  2 glow + glass panel  ·  3 figure  ·  4 bbox + chip  ·  5 text
   Stage geometry is driven by the figure size (container query units), so the
   full figure (head → sneakers → stool) always fits and never gets cropped. */

.hero {
  position: relative;
  height: 100vh; height: 100svh;
  min-height: 620px;
  padding: var(--nav-h) var(--pad-x) 0;
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  grid-template-rows: minmax(0, 1fr);
  column-gap: clamp(16px, 3vw, 56px);
  overflow: clip;
}

/* ---- Copy (layer 5) ---- */
.hero__copy { position: relative; z-index: 5; align-self: center; padding-bottom: 7svh; }
.hero__role { display: flex; align-items: center; gap: 14px; margin-bottom: clamp(18px, 3.2svh, 30px); }
.hero__role::before { content: ""; width: 28px; height: 1px; background: var(--c-gold); }
.hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-h1);
  line-height: 1;
  letter-spacing: -.018em;
  color: var(--c-ivory);
}
.hero__title .line { display: block; }
.hero__title em { font-style: italic; font-weight: 400; }
.hero__title .dot { color: var(--c-gold); }
.hero__services {
  margin-top: clamp(22px, 4svh, 38px);
  display: flex; flex-wrap: wrap; gap: 6px 0;
  font-size: var(--fs-lead); font-weight: 300; letter-spacing: .01em; color: var(--c-ivory-muted);
}
.hero__services li:not(:last-child)::after { content: "·" / ""; margin-inline: .7em; color: var(--c-gold-light); }
.hero__scroll {
  position: absolute; z-index: 5;
  left: var(--pad-x); bottom: clamp(18px, 4svh, 40px);
  display: flex; align-items: center; gap: 12px;
}
.hero__scroll .arrow { color: var(--c-gold-light); letter-spacing: 0; }

/* ---- Stage (figure + glass composition) ---- */
.stage {
  position: relative;
  container-type: size;
  --fig-ratio: .423;                         /* 846 / 2000, the cut-out image */
  --fig-top: clamp(6px, 1.6cqh, 18px);
  --fig-bottom: clamp(34px, 6.5cqh, 70px);
  --fig-h: min(calc(100cqh - var(--fig-top) - var(--fig-bottom)), 118cqw, 980px);
  --fig-w: calc(var(--fig-h) * var(--fig-ratio));
  --fig-cx: 36cqw;                           /* horizontal centre of the figure */
  --fig-left: calc(var(--fig-cx) - var(--fig-w) / 2);
  --fig-top-y: calc(100cqh - var(--fig-bottom) - var(--fig-h));
  --bleed: calc(var(--pad-x) + 2px);         /* panel runs off the right edge */
}

/* glow behind head/shoulders (layer 2) — also acts as soft rim light on hair */
.stage__glow {
  position: absolute; z-index: 0; pointer-events: none;
  left: calc(var(--fig-cx) - var(--fig-h) * .55);
  top: calc(var(--fig-top-y) - var(--fig-h) * .3);
  width: calc(var(--fig-h) * 1.1); height: calc(var(--fig-h) * 1.1);
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--c-gold-glow), rgba(156, 123, 60, .07) 55%, transparent 100%);
}
.stage__glow::after { /* second, slower layer: luminosity drift only */
  content: ""; position: absolute; inset: 18%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(196, 164, 104, .10), transparent);
}

/* big smoked-glass panel (layer 2) */
.stage__panel {
  position: absolute; z-index: 1;
  left: calc(var(--fig-cx) - var(--fig-w) * .08);
  right: calc(-1 * var(--bleed));
  top: calc(var(--fig-top-y) + var(--fig-h) * .19);
  height: calc(var(--fig-h) * .62);
  border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0;
  /* playhead x inside the panel: 35% of the way between figure edge and stage edge */
  --ph: calc(var(--fig-w) * .58 + (100cqw - var(--fig-cx) - var(--fig-w) * .5) * .35);
  --content-x: calc(var(--fig-w) * .62);     /* where visible content starts (right of figure) */
  display: grid; grid-template-rows: auto 1fr auto;
}
.panel__bar {
  display: flex; justify-content: flex-start; align-items: center; gap: 28px;
  white-space: nowrap; overflow: hidden;
  padding: 14px calc(var(--bleed) + 18px) 0 var(--content-x);
  font-size: var(--fs-nano); letter-spacing: var(--track-mid);
}
.panel__viewer { position: relative; }
.panel__viewer .waveform,
.panel__viewer .wf-canvas {
  position: absolute; left: 0; right: 0; top: 50%;
  width: 100%; height: 34%; transform: translateY(-50%);
  color: rgba(217, 178, 106, .3);
}
.panel__viewer .waveform--played { color: #F0C75E; opacity: .85; clip-path: inset(0 calc(100% - var(--ph)) 0 0); filter: drop-shadow(0 0 4px rgba(240, 170, 70, .45)); }
/* centre of the timeline in gold: the clips on the two tracks above the audio.
   Only the two audio strips (.clip--audio) stay blue. */
.stage__panel .clip:not(.clip--audio) {
  background: linear-gradient(180deg, rgba(240, 199, 94, .16), rgba(217, 178, 106, .07));
  border-color: rgba(217, 178, 106, .34);
}
.stage__panel .clip--warm { background: linear-gradient(180deg, rgba(240, 199, 94, .24), rgba(217, 178, 106, .1)); border-color: rgba(240, 199, 94, .5); }
.stage__panel .clip--active {
  background: linear-gradient(180deg, rgba(240, 199, 94, .3), rgba(217, 178, 106, .14));
  border-color: rgba(240, 199, 94, .75);
  box-shadow: 0 0 10px rgba(240, 170, 70, .28), inset 0 0 8px rgba(240, 199, 94, .14);
}
.stage__panel .timeline { padding: 0 0 16px; }
/* playhead: the mover carries the loop translation (transform only);
   the inner .playhead keeps its own entrance "draw" animation */
.stage__panel .ph-mover { position: absolute; left: var(--ph); top: 44px; bottom: 0; width: 1px; z-index: 2; }
.stage__panel .ph-mover .playhead { left: 0; }
.wf-live .ph-mover { will-change: transform, opacity; }
/* live waveforms (canvas, js/hero.js) replace the static SVG ones */
.wf-live .panel__viewer .waveform, .wf-live .clip--audio .waveform { display: none; }
.clip--audio .wf-canvas { position: absolute; left: 0; top: 2px; width: 100%; height: calc(100% - 4px); }
.stage__panel .marker--a { left: calc(var(--ph) + (100% - var(--ph)) * .45); bottom: 6px; position: absolute; }

/* the figure (layer 3) */
.stage__figure {
  position: absolute; z-index: 3; margin: 0;
  left: var(--fig-left);
  bottom: var(--fig-bottom);
  width: var(--fig-w); height: var(--fig-h);
  isolation: isolate;
}
.stage__figure img { width: 100%; height: 100%; object-fit: contain; }
/* contact shadow: grounds stool legs + sneaker, hides residual floor haze
   of the cut-out. Sits BEHIND the image, never over the figure. */
.stage__figure::before {
  content: ""; position: absolute; z-index: -1;
  left: 4%; right: -6%; bottom: -2.2%; height: 9%;
  background: radial-gradient(50% 50% at 50% 55%, rgba(8, 6, 4, .62), rgba(8, 6, 4, .25) 55%, transparent 100%);
}
/* local contact shadow under the CENTRE stool leg (foot at ~62.6% / 88.3% of the
   image). Behind the image: it absorbs the residual floor haze of the cut-out and
   the thin warm gap at the leg foot, without editing or fading the figure. */
.stage__figure::after {
  content: ""; position: absolute; z-index: -1;
  left: 52%; width: 22%; top: 84.5%; height: 7%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(8, 6, 4, .78), rgba(8, 6, 4, .38) 50%, transparent 100%);
}

/* front UI (layer 4) — never over the face (face sits in the top 16% of the figure) */
.stage__bbox {
  z-index: 4;
  left: calc(var(--fig-left) - var(--fig-w) * .07);
  width: calc(var(--fig-w) * 1.14);
  top: calc(var(--fig-top-y) - 4px);
  bottom: calc(var(--fig-bottom) - 10px);
}
.stage__chip {
  z-index: 4;
  left: max(0px, calc(var(--fig-cx) - var(--fig-w) * .86));
  top: calc(var(--fig-top-y) + var(--fig-h) * .6);
}

/* ---- Desktop title (>= 900 px): a gold playhead wave runs through the words ----
   js/hero.js adds html.sweep-on and drives --ph (playhead x, px) on the title and
   --ox (word offset) on every word, so all words share one horizontal frame.
   Without motion (reduced / ?static=1): cream text, ATTENTION in still gold.
   Phone and tablet (< 900 px): untouched. */
.title-ph { display: none; }
@media (min-width: 900px) {
  .hero__title { position: relative; width: fit-content; }
  .hero__title em { text-transform: uppercase; font-size: .8em; letter-spacing: .012em; }
  /* italic overhang: extend the painted box so no glyph edge gets clipped */
  .hero__title .w { padding: .06em .16em .16em; margin: 0 -.16em; }
  html:not(.sweep-on) .hero__title em.w {
    background: linear-gradient(90deg, #D9B26A, #F0C75E);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
  }
  .sweep-on .hero__title { --ph: -9999px; }
  .sweep-on .hero__title .w {
    --cream: #F1E8DA;
    background-image: linear-gradient(90deg,
      var(--cream) calc(var(--ph) - 5.2em),
      #D9B26A calc(var(--ph) - 2.6em),
      #F0C75E calc(var(--ph) - .55em),
      #FFF2CF var(--ph),
      #F0C75E calc(var(--ph) + .22em),
      var(--cream) calc(var(--ph) + 1.15em));
    background-size: var(--tw, 100%) 100%;
    background-position: calc(var(--ox, 0px) * -1) 0;
    background-repeat: no-repeat;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    transition: filter .5s var(--ease-out);
  }
  /* the word the playhead is crossing gets a short, brighter flash */
  .sweep-on .hero__title .w.is-hot { filter: drop-shadow(0 0 .12em rgba(240, 186, 84, .55)) drop-shadow(0 0 .02em rgba(255, 236, 190, .5)); }
  .sweep-on .title-ph {
    display: block; position: absolute; left: 0; top: -.04em; bottom: .02em; width: 1px;
    background: linear-gradient(180deg, rgba(240, 199, 94, 0), rgba(240, 199, 94, .8) 10%, rgba(217, 178, 106, .5) 90%, rgba(217, 178, 106, 0));
    box-shadow: 0 0 12px rgba(240, 180, 80, .45);
    opacity: 0; pointer-events: none; will-change: transform, opacity;
  }
  .sweep-on .title-ph::before { /* playhead head, like the timeline's */
    content: ""; position: absolute; top: -10px; left: -4px; width: 9px; height: 11px;
    background: #F0C75E; clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
  }

  /* "Scroll to play": the arrow drops, a short gold line runs down under it */
  .hero__scroll .arrow { position: relative; display: inline-block; height: 1.2em; }
  .hero__scroll .arrow__glyph { display: block; }
  .hero__scroll .arrow::after {
    content: ""; position: absolute; left: 50%; top: calc(100% + 2px);
    width: 1px; height: 22px; margin-left: -.5px;
    background: linear-gradient(180deg, #F0C75E, rgba(240, 199, 94, 0));
    transform-origin: top; opacity: .7;
  }
  .motion .hero__scroll .arrow__glyph { animation: cue-bob 2.2s var(--ease-in-out) infinite; }
  .motion .hero__scroll .arrow::after { animation: cue-line 2.2s var(--ease-out) infinite; }
}
@keyframes cue-bob { 0%, 100% { transform: translate3d(0, -2px, 0); } 45% { transform: translate3d(0, 5px, 0); } }
@keyframes cue-line {
  0%   { opacity: 0; transform: translate3d(0, -6px, 0) scaleY(.2); }
  35%  { opacity: .95; }
  70%  { opacity: .6; transform: translate3d(0, 6px, 0) scaleY(1); }
  100% { opacity: 0; transform: translate3d(0, 16px, 0) scaleY(.3); }
}

/* Phone + tablet (< 900 px): the last word of the title in capitals, italic, still gold (as on desktop, without the sweep) */
@media (max-width: 899.98px) {
  .hero__title em {
    text-transform: uppercase; font-size: .8em; letter-spacing: .012em;
    padding: .06em .16em .16em; margin: 0 -.16em;
    background: linear-gradient(90deg, #D9B26A, #F0C75E);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
  }
}

/* ---- Selected-work anchor placeholder ---- */
#selected-work { position: relative; z-index: 1; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1100px) and (min-width: 861px) {
  .stage { --fig-cx: 40cqw; }
  .panel__bar .label--secondary { display: none; }
}

/* stacked layout: tablet portrait + mobile */
@media (max-width: 860px) {
  .hero {
    height: auto;
    min-height: 100vh; min-height: 100svh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(440px, 1fr) auto;
    padding-top: calc(var(--nav-h) + 4px);
  }
  .hero__copy { align-self: start; padding: clamp(8px, 3svh, 40px) 0 0; }
  .stage {
    margin-inline: calc(-1 * var(--pad-x));
    margin-top: 8px;
    --fig-cx: 42cqw;
    --fig-bottom: 26px;
    --bleed: 2px;
    --fig-h: min(calc(100cqh - var(--fig-top) - var(--fig-bottom)), 116cqw, 760px);
  }
  .hero__scroll { position: static; padding: 6px 0 calc(24px + env(safe-area-inset-bottom, 0px)); }
  .stage__bbox { display: none; }
  .stage__chip { left: max(10px, calc(var(--fig-cx) - var(--fig-w) * 1.02)); }
}
@media (max-width: 480px) {
  .hero__title { font-size: clamp(2.7rem, 12.6vw, 3.6rem); letter-spacing: -.012em; }
  .hero__services { font-size: .84rem; }
  .panel__bar .label--secondary { display: none; }
  .tc-chip { padding: 8px 11px 9px; }
  .tc-chip__tc { font-size: .82rem; }
}
@media (max-width: 430px) {
  :root { --nav-h: 56px; }
  .hero { padding-top: var(--nav-h); }
  .hero__copy { padding-top: 4px; }
  .stage { margin-top: 0; --fig-bottom: 20px; }
  .hero__scroll { padding: 4px 0 calc(26px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 400px) {
  .hero { grid-template-rows: auto minmax(400px, 1fr) auto; }
  .hero__role { font-size: .6rem; letter-spacing: .2em; gap: 10px; margin-bottom: 14px; }
  .hero__role::before { width: 18px; }
  .hero__services { margin-top: 18px; }
}

/* =========================================================================
   ENTRANCE SEQUENCE — only when <html class="motion"> (set in <head>).
   No JS / reduced motion / ?static=1  →  everything visible and still.
   ========================================================================= */
@keyframes reveal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes reveal-rise {
  from { opacity: 0; transform: translate3d(0, var(--rise, var(--rise-hero)), 0); }
  to   { opacity: 1; transform: none; }
}
@keyframes reveal-draw {
  from { opacity: 0; transform: scaleY(0); }
  to   { opacity: 1; transform: scaleY(1); }
}
@keyframes glow-drift { from { opacity: .35; } to { opacity: 1; } }

.motion [data-reveal] { opacity: 0; }
.motion.is-playing [data-reveal] {
  animation: var(--anim, reveal-rise) var(--dur, var(--dur-md)) var(--ease-out) var(--delay, 0ms) both;
}
[data-reveal="bg"]     { --anim: reveal-fade; --dur: var(--dur-lg); --delay: var(--seq-bg); }
[data-reveal="glass"]  { --rise: var(--rise-hero); --dur: var(--dur-md); --delay: var(--seq-glass); }
[data-reveal="figure"] { --rise: var(--rise-hero); --dur: var(--dur-lg); --delay: var(--seq-figure); }
[data-reveal="text-1"] { --delay: calc(var(--seq-text) + var(--seq-stagger) * 0); }
[data-reveal="text-2"] { --delay: calc(var(--seq-text) + var(--seq-stagger) * 1); }
[data-reveal="text-3"] { --delay: calc(var(--seq-text) + var(--seq-stagger) * 2); }
[data-reveal="role"]   { --anim: reveal-fade; --dur: var(--dur-sm); --delay: max(0ms, calc(var(--seq-text) - 150ms)); }
[data-reveal="ui"]     { --anim: reveal-fade; --dur: var(--dur-sm); --delay: var(--seq-ui); }
[data-reveal="ui-2"]   { --anim: reveal-fade; --dur: var(--dur-sm); --delay: calc(var(--seq-ui) + 60ms); }
[data-reveal="draw"]   { --anim: reveal-draw; --dur: var(--dur-md); --delay: var(--seq-ui); }

/* after the entrance: one glow breathes very slowly (luminosity only) */
.motion.is-playing .stage__glow::after {
  animation: glow-drift var(--ambient-glow) var(--ease-in-out) var(--seq-ui) infinite alternate both;
}

@media (prefers-reduced-motion: reduce) {
  .motion [data-reveal], .motion.is-playing [data-reveal] { opacity: 1; animation: none; transform: none; }
  .motion.is-playing .stage__glow::after { animation: none; }
  .motion .hero__scroll .arrow__glyph, .motion .hero__scroll .arrow::after { animation: none; }
}
