/* #hero - load intro, bone/ink circle layers, the data band end state (CONTRACT 6.1).
   Specs: 01-layout section 3, 03-motion sections 2, 3, N2, N3, 02-tokens section 3.
   Modes:
   - circle (desktop >= 768 px, JS on, motion allowed): pinned stage, ink layer clipped to a
     circle that follows the pointer and floods into the band copy on scroll (hero.js).
   - stacked (JS off, reduced motion, or < 768 px): no track; wordmark then the band, static.
   z: stage layers 10-12 (contract 10-19); the loader is the one named exception, z 55. */

#hero{
  --hero-pad-x:clamp(24px,4vw,64px);
  --hero-pad-b:clamp(20px,4vh,44px);
  --hero-word-size:16.8vw;            /* measured: word = 5.12 x font-size, so "RABBIT." spans ~86 % (ref-00 ~80 %) */
  --hero-ease-p2out:cubic-bezier(.215,.61,.355,1);  /* GSAP power2.out (03-motion s1) */
  --hero-ease-p2in:cubic-bezier(.55,.055,.675,.19);
  --hero-ease-p3io:cubic-bezier(.77,0,.175,1);
  --hero-ease-back:cubic-bezier(.34,1.56,.64,1);
  --hero-ease-sine:cubic-bezier(.445,.05,.55,.95);
  --local-glow:var(--accent-tint);
  position:relative;
}

/* ---------- 1. Loader (N2) ---------- */
#hero .hero-loader{ display:none; }
html[data-js] #hero .hero-loader{
  display:block; position:fixed; inset:0; z-index:55;
  background-color:var(--bone); color:var(--ink); overflow:hidden;
  animation:hero-loader-failsafe 400ms var(--ease-out) 6500ms forwards;
}
/* A-H1: never over the open age gate (hero.js also removes it at once while gated) */
html[data-js]:not([data-age="ok"]) #hero .hero-loader{ display:none; }
#hero .hero-loader[data-leaving]{ opacity:0; transition:opacity 350ms var(--ease-out-quad); }
#hero .hero-loader-mark{ position:absolute; inset:0; display:grid; place-items:center; }
#hero .hero-loader-word,
#hero .hero-word{
  font-family:var(--font-wordmark); font-stretch:125%; font-weight:900;
  line-height:.78; letter-spacing:-.03em; text-transform:uppercase; white-space:nowrap;
}
#hero .hero-loader-word{ font-size:clamp(40px,5.5vw,76px); transform-origin:0 0; }
#hero .hero-loader-fill{
  --fill:0%;
  background-image:linear-gradient(90deg, var(--ink) var(--fill), color-mix(in srgb, var(--ink) 12%, transparent) var(--fill));
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
#hero .hero-loader-dot,
#hero .hero-dot{
  display:inline-block; width:.24em; height:.24em; margin-left:.035em; background-color:var(--accent);
}
#hero .hero-loader-dot{
  opacity:0; transform:translateY(-.6em);
  transition:opacity 450ms var(--hero-ease-p2out), transform 450ms var(--hero-ease-p2out);
}
#hero .hero-loader[data-phase~="dot"] .hero-loader-dot{ opacity:1; transform:none; }
#hero .hero-loader-count{
  position:absolute; left:var(--hero-pad-x); bottom:var(--hero-pad-b);
  font-family:var(--font-display); font-weight:400; font-size:15px; line-height:1;
  font-variant-numeric:tabular-nums; letter-spacing:.08em; color:var(--fg-2);
}
#hero .hero-loader-pills{ position:absolute; inset:0; pointer-events:none; }
#hero .hero-loader-pill{
  position:absolute; left:var(--px); top:var(--py); translate:-50% -50%;
  display:inline-flex; align-items:center; height:38px; padding-inline:18px calc(18px - var(--tr-pill));
  border:1px solid var(--line-strong); border-radius:var(--r-pill); background-color:var(--bone);
  font-size:11px; font-weight:500; letter-spacing:var(--tr-pill); text-transform:uppercase; white-space:nowrap;
  color:var(--ink); opacity:0;
  animation:hero-pill 4.96s linear calc(500ms + var(--i) * 420ms) infinite both;
}
@keyframes hero-loader-failsafe{ to{ opacity:0; visibility:hidden; } }
/* one 4.96 s cycle per pill (03-motion section 2): pop .45 s back.out, float .95 s sine, exit .32 s power2.in */
@keyframes hero-pill{
  0%{ opacity:0; transform:translateY(10px) scale(.55) rotate(var(--rot)); animation-timing-function:var(--hero-ease-back); }
  9.07%{ opacity:1; transform:none; animation-timing-function:var(--hero-ease-sine); }
  28.2%{ opacity:1; transform:translateY(-6px); animation-timing-function:var(--hero-ease-p2in); }
  34.7%{ opacity:0; transform:translateY(-18px) scale(.94); }
  100%{ opacity:0; transform:translateY(-18px) scale(.94); }
}
@media (max-width:767px){
  #hero .hero-loader-pill:nth-child(n+5){ display:none; }
}
@media (prefers-reduced-motion:reduce){
  /* A-M1 belt: gone by 400 ms even if hero.js is late (hero.js removes it at 400 ms) */
  html[data-js] #hero .hero-loader{ animation-duration:150ms; animation-delay:150ms; }
  #hero .hero-loader-pills{ display:none; }
  #hero .hero-loader-dot{ transform:none; transition:opacity 200ms var(--ease-out); }
}

/* ---------- 2. Shared pieces (both modes) ---------- */
#hero .hero-stage{ background-color:var(--bone); }
#hero .hero-bone{
  position:relative; min-height:100vh; min-height:100svh;
  display:flex; flex-direction:column; background-color:var(--bone); color:var(--ink);
}
#hero .hero-word{
  flex:1; display:flex; align-items:center; justify-content:center;
  font-size:var(--hero-word-size); color:var(--fg);
}
#hero .hero-word-inner{ display:inline-block; }
#hero .hero-l{ display:inline-block; }
#hero .hero-foot{
  display:flex; align-items:flex-end; justify-content:space-between; gap:var(--space-6);
  padding:0 var(--hero-pad-x) var(--hero-pad-b);
}
#hero .hero-tagline{
  flex:1 1 0; font-family:var(--font-display); font-weight:400; font-size:var(--fs-tagline);
  line-height:1.15; letter-spacing:-.01em; color:var(--fg);
}
#hero .hero-tagline span{ display:block; }
#hero .hero-cue{ flex:none; display:flex; flex-direction:column; align-items:center; gap:var(--space-3); }
#hero .hero-cue-label{
  font-size:11px; line-height:1; letter-spacing:var(--tr-label); text-transform:uppercase;
  padding-left:var(--tr-label); color:var(--fg-2);
}
#hero .hero-cue-pill{
  position:relative; display:block; width:22px; height:38px; border-radius:11px;
  border:1px solid color-mix(in oklab, var(--fg) 35%, transparent);
}
#hero .hero-cue-dot{
  position:absolute; left:50%; top:7px; width:5px; height:5px; margin-left:-2.5px; border-radius:50%;
  background-color:var(--fg-2); opacity:0;
  animation:hero-cue 1.65s linear infinite both;
}
/* 03-motion section 3: fade in .25 s, travel 19 px from .1 s for 1 s, fade .3 s at .85 s; cycle 1.65 s */
@keyframes hero-cue{
  0%{ opacity:0; transform:translateY(0); animation-timing-function:var(--ease-out-quad); }
  6.06%{ transform:translateY(0); animation-timing-function:var(--hero-ease-p3io); }
  15.15%{ opacity:1; }
  51.5%{ opacity:1; animation-timing-function:var(--hero-ease-p2in); }
  66.7%{ transform:translateY(19px); }
  69.7%{ opacity:0; }
  100%{ opacity:0; transform:translateY(19px); }
}
#hero .hero-corner{
  flex:1 1 0; display:flex; flex-direction:column; align-items:flex-end; text-align:right;
  font-size:12px; line-height:1.65; letter-spacing:var(--tr-eyebrow); text-transform:uppercase; color:var(--fg-2);
}

/* ink layer + band copy */
#hero .hero-ink{ position:relative; background-color:var(--surface); color:var(--fg); }
#hero .hero-visual{ position:relative; }
#hero .hero-bloom{ position:absolute; left:50%; top:50%; width:0; height:0; pointer-events:none; z-index:0; }
/* HERO-3: wide disc, bright band pushed out past the puck edge so the circle reads lit */
#hero .hero-bloom-core{
  position:absolute; left:-45vh; top:-45vh; width:90vh; height:90vh; border-radius:50%;
  background-image:radial-gradient(closest-side,
    var(--local-glow) 0%,
    var(--local-glow) 38%,
    color-mix(in srgb, var(--local-glow) 80%, transparent) 52%,
    color-mix(in srgb, var(--local-glow) 30%, transparent) 72%,
    transparent 90%);
  opacity:.85; filter:blur(6px);
  animation:hero-bloom 2s var(--hero-ease-sine) infinite alternate both;
}
@keyframes hero-bloom{ from{ transform:scale(.95); opacity:.72; } to{ transform:scale(1.05); opacity:.9; } }
#hero .hero-port{ display:contents; } /* layout-transparent outside circle mode (section 3) */
#hero .hero-can{ position:relative; z-index:1; }
#hero .hero-can img{ width:100%; height:100%; object-fit:contain; }
#hero .hero-copy{ position:relative; z-index:2; }
#hero .hero-copy-title{ margin-top:var(--space-5); font-size:clamp(32px,3.15vw,52px); line-height:1.02; }
#hero .hero-copy-rule{
  display:block; width:72px; height:1px; margin-top:var(--space-7);
  background-color:var(--accent); transform-origin:left;
}
#hero .hero-copy-body{ margin-top:var(--space-7); max-width:42ch; color:var(--fg-2); }
#hero .hero-stats{ margin-top:var(--space-8); display:flex; flex-wrap:wrap; align-items:baseline; gap:var(--space-2) var(--space-6); }
#hero .hero-stat{ display:inline-flex; align-items:baseline; gap:6px; }
#hero .hero-stat-v{ font-size:17px; color:var(--fg); }
#hero .hero-stat-l{ font-size:13px; color:var(--fg-2); }
#hero .hero-stat-sep{ color:var(--sep); }
#hero .hero-ring{ display:none; }

/* stacked desktop band (JS off / reduced motion): copy left, poster right */
@media (min-width:768px){
  #hero .hero-ink{
    min-height:100vh; display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    align-items:center; column-gap:var(--space-12); padding:var(--space-24) var(--gutter);
  }
  #hero .hero-copy{ grid-column:1; grid-row:1; }
  #hero .hero-visual{ grid-column:2; grid-row:1; display:grid; place-items:center; }
  #hero .hero-can{ width:min(100%,440px); aspect-ratio:1; }
}

/* shop CTA (owner 2026-10-02): stage level so the pointer circle never covers it or takes its clicks.
   Desktop: bottom-left, UNDER the tagline (owner review: "the button should be under the body text");
   the tagline column reserves the button height + gap below itself, the button takes that slot.
   The containing block is the sticky stage in circle mode and the pin track otherwise; both start at
   the hero top. The bone hairline is invisible on bone and outlines the button over the ink circle. */
@media (min-width:768px){
  #hero .hero-tagline{ margin-bottom:calc(48px + var(--space-5)); } /* margin, not padding: the box ends where the text ends */
  #hero .hero-shop{
    position:absolute; z-index:12; left:var(--hero-pad-x);
    top:calc(100vh - var(--hero-pad-b) - 48px);
  }
  #hero .hero-shop-btn{ box-shadow:0 0 0 1px var(--bone); }
}

/* JS off: the pin track must not stay 220vh tall (base.css only collapses it on mobile / reduced) */
html:not([data-js]) #hero .pin-track{ height:auto; }
html:not([data-js]) #hero .pin-stage{ position:static; height:auto; overflow:visible; }

/* ---------- 3. Circle mode (desktop, JS on, motion allowed) ---------- */
@media (min-width:768px) and (prefers-reduced-motion:no-preference){
  html[data-js] #hero .hero-stage{ background-color:var(--ink); }
  html[data-js] #hero .hero-bone{ position:absolute; inset:0; z-index:10; min-height:0; }
  /* HERO-1: the I stays a real letter on the bone layer; the opaque ink circle (centred on it,
     hero.js) covers it at rest and it shows again wherever the circle moves off it */
  html[data-js] #hero .hero-ink{
    position:absolute; inset:0; z-index:11; display:block; min-height:0; padding:0;
    clip-path:circle(170px at 50% 48%); /* hero.js writes the live value every frame */
  }
  html[data-js] #hero .hero-visual{ position:absolute; inset:0; display:block; }
  html[data-js] #hero .hero-bloom{ left:0; top:0; transform:translate3d(50vw,48vh,0); }
  /* the port: the ink clip-path cuts a composited WebGL canvas only to the circle's bounding box,
     so the tin sits in a real round overflow frame that hero.js moves with the same r / cx / cy;
     .hero-can stays stage-sized and counter-translated so the canvas never moves with it */
  html[data-js] #hero .hero-port{
    display:block; position:absolute; left:0; top:0;
    width:calc(var(--port-r,170px) * 2); height:calc(var(--port-r,170px) * 2);
    transform:translate3d(calc(var(--port-x,50vw) - var(--port-r,170px)), calc(var(--port-y,48vh) - var(--port-r,170px)), 0);
    border-radius:50%; overflow:hidden; isolation:isolate; will-change:transform;
  }
  html[data-js] #hero .hero-can{
    position:absolute; inset:auto; left:0; top:0; width:var(--stage-w,100vw); height:var(--stage-h,100vh); aspect-ratio:auto;
    transform:translate3d(calc(var(--port-r,170px) - var(--port-x,50vw)), calc(var(--port-r,170px) - var(--port-y,48vh)), 0);
  }
  html[data-js] #hero .hero-can img{
    position:absolute; left:var(--home-x,50%); top:var(--home-y,48%); width:calc(var(--hero-r0,170px) * 1.72); height:auto;
    translate:-50% -50%;
  }
  html[data-js] #hero .hero-copy{
    position:absolute; top:0; bottom:0; left:0; z-index:12; width:min(100%,max(34vw,460px));
    display:flex; flex-direction:column; justify-content:center; padding-left:clamp(24px,7vw,120px);
    pointer-events:none;
  }
  html[data-js] #hero .hero-copy > *{ pointer-events:auto; }
  /* copy stack (N3): hidden until p > .58, items y 26 -> 0, 550 ms power2.out, stagger 80 ms;
     rule scaleX 500 ms at +200 ms; below p .35 it fades out 250 ms and re-arms */
  html[data-js] #hero .hero-copy-item{
    opacity:0; transform:translate3d(0,26px,0);
    transition:opacity 250ms var(--ease-out), transform 250ms var(--ease-out);
  }
  html[data-js] #hero .hero-copy-rule{ transform:scaleX(0); transition:transform 250ms var(--ease-out); }
  html[data-js] #hero .hero-copy[data-shown] .hero-copy-item{
    opacity:1; transform:none;
    transition:opacity 550ms var(--hero-ease-p2out), transform 550ms var(--hero-ease-p2out);
    transition-delay:calc(var(--k,0) * 80ms);
  }
  html[data-js] #hero .hero-copy[data-shown] .hero-copy-rule{
    transform:none; transition:transform 500ms var(--hero-ease-p2out) 200ms;
  }
  html[data-js] #hero .hero-ring{
    display:block; position:absolute; left:0; top:0; z-index:12; width:459px; height:459px;
    margin:-229.5px 0 0 -229.5px; border-radius:50%; pointer-events:none; opacity:0;
    background-image:radial-gradient(closest-side, transparent 72%,
      color-mix(in srgb, var(--ink) 9%, transparent) 75%,
      color-mix(in srgb, var(--ink) 4%, transparent) 86%, transparent 100%);
  }
  /* the hero.js rAF writes transform / opacity on these three layers only */
  html[data-js] #hero .hero-ring{ will-change:transform, opacity; }
}

/* intro states (hero.js sets data-intro="pending" on init, "done" after the loader) */
#hero .hero-rise{ animation:hero-rise 900ms var(--hero-ease-p2out) backwards; animation-delay:calc(150ms + var(--d,0) * 80ms); }
#hero[data-intro="pending"] .hero-rise{ animation-play-state:paused; }
html:not([data-js]) #hero .hero-rise{ animation:none; }
@keyframes hero-rise{ from{ opacity:0; transform:translate3d(0,16px,0); } to{ opacity:1; transform:none; } }

/* ---------- 4. Mobile (< 768 px): ink hero, stacked (refm-00, refm-01) ---------- */
@media (max-width:767px){
  #hero .hero-stage{ display:flex; flex-direction:column; background-color:var(--ink); color:var(--bone); }
  #hero .hero-bone, #hero .hero-ink{ display:contents; }
  #hero .hero-word{
    order:1; justify-content:flex-start; flex:none; padding:calc(var(--nav-h) + 24px) 20px 0;
    font-size:17.4vw; line-height:.82; color:var(--bone); /* 5.12 x 17.4vw = 89vw: fits the 20 px gutters */
  }
  #hero .hero-foot{ display:contents; }
  #hero .hero-tagline{
    order:2; flex:none; margin-top:var(--space-4); padding-inline:20px;
    font-size:26px; color:var(--bone);
  }
  #hero .hero-tagline span{ display:inline; }
  /* shop CTA right under the tagline (same order, later in the DOM), above the tin: first screen */
  #hero .hero-shop{ order:2; flex:none; position:relative; z-index:2; margin-top:var(--space-5); padding-inline:20px; } /* above the tin bloom */
  #hero .hero-shop-btn{ background-color:var(--bone); color:var(--ink); }
  #hero .hero-cue{ display:none; }
  #hero .hero-visual{ order:3; position:relative; height:52vh; margin-top:var(--space-2); }
  #hero .hero-can{ position:absolute; inset:0; touch-action:pan-y; }
  #hero .hero-can img{ position:absolute; left:50%; top:50%; width:min(64vw,300px); height:auto; translate:-50% -50%; }
  #hero .hero-corner{
    order:4; flex:none; align-items:flex-start; text-align:left; padding:0 20px var(--space-10);
    color:color-mix(in oklab, var(--bone) 60%, transparent);
  }
  #hero .hero-copy{ order:5; padding:var(--space-6) 20px var(--space-20); }
  #hero .hero-copy-title{ font-size:clamp(32px,9vw,40px); }
  #hero .hero-copy-body{ max-width:44ch; font-size:16px; color:color-mix(in oklab, var(--bone) 80%, transparent); }
  #hero .hero-stats{ margin-top:var(--space-7); flex-direction:column; align-items:flex-start; gap:var(--space-2); }
  #hero .hero-stat-sep{ display:none; }
  /* letters rise after the intro (N3 last lines): y 40 -> 0, 900 ms power2.out, stagger 50 ms */
  html[data-js] #hero .hero-l{ animation:hero-letter 900ms var(--hero-ease-p2out) backwards; animation-delay:calc(var(--l) * 50ms); }
  #hero[data-intro="pending"] .hero-l{ animation-play-state:paused; }
}
@keyframes hero-letter{ from{ opacity:0; transform:translate3d(0,40px,0); } to{ opacity:1; transform:none; } }

/* ---------- 5. Reduced motion: no track, ink layer open, poster only ---------- */
@media (prefers-reduced-motion:reduce){
  #hero .hero-rise, html[data-js] #hero .hero-l{ animation:hero-fade 200ms var(--ease-out) both; animation-delay:0ms; }
  #hero .hero-cue-dot{ animation:none; opacity:1; }
  #hero .hero-bloom-core{ animation:none; }
}
@keyframes hero-fade{ from{ opacity:0; } to{ opacity:1; } }
