/* SmartStack page mockup: hero (brief 7.1), the stack turns as you scroll.
   Two layouts:
   - default (reduced motion, no GSAP, no script): the poster as a still in a rounded frame beside the three lines;
   - html.has-motion: a pinned full-screen card with the film on a canvas, the studio carried out to the card edges,
     the grids, the tracking overlay and the three beats taking turns in the left column (landscape cards) or at the
     top (portrait cards). js/sections/hero.js drives it.
   Every selector is scoped under #hero. */

/* ------------------------------------------------------------------ shared */
#hero {
  --hero-wall: #c7bfb6;                 /* the studio wall in the frames (centre, upper half) */
  --hero-ink-line: rgba(11, 11, 13, .62);
  background: var(--studio-floor);
}
#hero .hero__beat { position: relative; }
#hero .hero__beat--1 { display: grid; gap: 22px; }
#hero .hero__beat--3 { display: grid; gap: 30px; }
#hero .hero__beat--1 .eyebrow { white-space: nowrap; }   /* a mono label on one line (hero.js lets it wrap when it would touch the stack) */
#hero .hero__h1 { max-width: 11ch; }
#hero .hero__beat--2 .t-m, #hero .hero__beat--3 .t-m { max-width: 20ch; }
#hero .hero__btns { gap: 10px; }
#hero .hero__icon-down { transition: transform var(--dur-hover) var(--ease-out); }
#hero .btn:hover .hero__icon-down { transform: translateY(2px); }
/* hero.js splits the lines as spans (valid inside the beats' paragraphs), so they are made blocks here: each
   mask clips one line and each line moves with a transform, as the div lines SplitText makes by default did */
#hero .hero__line-mask, #hero .hero__line { display: block; position: relative; }
#hero .hero__line-mask { padding-block: .1em .18em; margin-block: -.1em -.18em; }
#hero .hero__caption { margin: 0; }

/* ------------------------------------------------------------------ default: the still layout (reduced motion, no GSAP) */
#hero {
  padding: calc(var(--nav-clear) + clamp(28px, 7vh, 88px)) 0 clamp(64px, 10vh, 120px);
}
#hero .hero__card {
  width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter);
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--col-gap); row-gap: 14px;
  align-items: center;
}
#hero .hero__copy { grid-column: 1 / span 5; grid-row: 1 / span 2; display: grid; gap: 30px; align-content: center; padding-right: 8px; }
#hero .hero__media {
  grid-column: 6 / span 7; grid-row: 1; position: relative; overflow: hidden; isolation: isolate;
  aspect-ratio: 4 / 3; border-radius: var(--r-media); background: var(--hero-wall); box-shadow: var(--shadow-float);
}
#hero .hero__still { display: block; width: 100%; height: 100%; object-fit: cover; }
#hero .hero__caption { grid-column: 6 / span 7; grid-row: 2; }
#hero .hero__canvas, #hero .hero__back, #hero .hero__floor,
#hero .hero__grid, #hero .hero__overlay, #hero .hero__cue { display: none; }
@media (max-width: 767.98px) {
  #hero .hero__card { row-gap: 0; }
  #hero .hero__copy { grid-column: 1 / -1; grid-row: 1; gap: 24px; padding: 0 0 36px; }
  #hero .hero__media { grid-column: 1 / -1; grid-row: 2; aspect-ratio: 4 / 5; }
  #hero .hero__caption { grid-column: 1 / -1; grid-row: 3; padding-top: 12px; }
  #hero .hero__btns .btn { flex: 1 1 auto; }
}

/* ------------------------------------------------------------------ motion: the pinned film */
html.has-motion #hero {
  /* above the next section, so the lifted card's shadow is not cut off where this section ends */
  height: 100vh; height: 100svh; padding: 0; overflow: visible; z-index: 1;
}
html.has-motion #hero .hero__card {
  /* a size container, so the canvases, the copy column and the overlay can size from the card (cqw, cqh) */
  container-type: size;
  position: absolute; inset: 0; display: block; max-width: none; margin: 0; padding: 0;
  overflow: hidden; isolation: isolate; background: var(--hero-wall);
  transform-origin: 50% 50%; border-radius: 0;
  /* The frame's height on landscape cards: 92% of the card, less on short cards so the box label clears the nav
     (the same sum as target() in hero.js, which also sets the exact value here). */
  --hero-fh: min(92cqh, calc((100cqh - 146px) * 1.1153));
  /* The left column, tied to the card (brief 7.1: about 6% to 36% of the width), never wider than 640px, and clear
     of the stack: the box's widest left edge, padding included, is 0.237 frame heights left of the centre. */
  --hero-left: max(var(--gutter), 6cqw);
  --hero-copy-w: min(calc(36cqw - var(--hero-left)), calc(50cqw - var(--hero-fh) * 0.237 - var(--hero-left) - 28px), 640px);
  --hero-fade: 20px;                    /* the floor fade over the frame's bottom rows (hero.js sets it) */
}
html.has-motion #hero .hero__media {
  position: absolute; inset: 0; aspect-ratio: auto; border-radius: 0; box-shadow: none; background: none; overflow: visible;
}
html.has-motion #hero .hero__still { display: none; }

/* The backdrop: hero.js paints it once per layout from the first frame (the wall rows and columns carried out to the
   card edges, the floor flat). Until then this gradient stands in for the studio. */
html.has-motion #hero .hero__back {
  display: block; position: absolute; inset: 0; width: 100%; height: 100%;
  background: linear-gradient(to bottom, #b4aea8 0, #b2aba5 52%, #d6cfc5 74%, #f3ebe0 100%);
}

/* The film canvas covers exactly the frame's own place (hero.js sets its box), so frameSequence's 'contain' draw is
   the final picture: one drawImage per frame, straight from the image. The poster is the same picture as frame 1.
   Landscape default below (the same numbers as target() in hero.js): the frame centred, its top so the box label
   clears the nav. */
html.has-motion #hero .hero__canvas {
  display: block; position: absolute; max-width: none; margin: 0;
  height: var(--hero-fh); width: calc(var(--hero-fh) * 16 / 9);
  left: calc(50% - var(--hero-fh) * 8 / 9);
  top: max(calc(106px - var(--hero-fh) * 0.1067), calc((100cqh - var(--hero-fh)) * 0.3));
  background: url("../../assets/hero-colour-b/poster.jpg") 50% 0 / auto 100% no-repeat;
}

/* a frame narrower than the card: its side edges fade into the backdrop (see hero.js paintBack) */
html.has-motion #hero .hero__card[data-carry="sides"] .hero__canvas {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
}

/* The studio floor under the frame: flat --studio-floor below it, faded in over the frame's bottom rows so the
   contact shadow runs out into the floor (no stretched rows). hero.js sets its top to the frame's bottom less the fade. */
html.has-motion #hero .hero__floor {
  display: block; position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none;
  top: calc(max(calc(106px - var(--hero-fh) * 0.1067), calc((100cqh - var(--hero-fh)) * 0.3)) + var(--hero-fh) - var(--hero-fade));
  background: linear-gradient(to bottom,
    rgba(243, 235, 224, 0) 0,
    rgba(243, 235, 224, .06) calc(var(--hero-fade) * .35),
    rgba(243, 235, 224, .3) calc(var(--hero-fade) * .6),
    rgba(243, 235, 224, .72) calc(var(--hero-fade) * .82),
    var(--studio-floor) var(--hero-fade));
}

/* Grid plane on the floor: the wrapper carries the multiply blend and the opacity (0 to about .18, from hero.js).
   Geometry in card units: near edge just below the card, far edge about 40% of the card height up (over the dolly and
   the lower stack), horizon about a third down, vanishing point on the stack's centre line (a line runs through it). */
html.has-motion #hero .hero__grid {
  display: block; position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  mix-blend-mode: multiply; opacity: 0; visibility: hidden;
}
html.has-motion #hero .hero__grid .grid-plane {
  --grid-line: rgba(11, 11, 13, .92);
  --grid-mark-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='144' height='144' viewBox='0 0 144 144'%3E%3Cpath d='M64.5 72.5h16M72.5 64.5v16' fill='none' stroke='%230b0b0d' stroke-width='1.25'/%3E%3C/svg%3E");
  --grid-size: 9.8cqh; --grid-tilt: 62deg; --grid-persp: 137.9cqh;
  --grid-x: -3.7cqh;                    /* 133.5cqh (the centre) is a line: 133.5 - 14 x 9.8 */
  mix-blend-mode: normal;
  width: 267cqh; height: 274cqh; bottom: -6.7cqh;
  -webkit-mask-image: radial-gradient(ellipse 36% 100% at 50% 100%, #000 0%, rgba(0, 0, 0, .75) 55%, transparent 100%);
          mask-image: radial-gradient(ellipse 36% 100% at 50% 100%, #000 0%, rgba(0, 0, 0, .75) 55%, transparent 100%);
}

/* Overlay: SVG for the upright grid, the brackets and the leaders, HTML for the mono labels (placed by hero.js every
   frame). The upright grid is a pattern fixed to the frame, seen through the tracking box, so its lines cross the stack
   while the box is drawn (about .12, ink, which reads the same as multiply on this light studio). */
html.has-motion #hero .hero__overlay { display: block; position: absolute; inset: 0; pointer-events: none; }
html.has-motion #hero .hero__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
html.has-motion #hero .hero__vgrid { opacity: 0; }
html.has-motion #hero .hero__vgrid-line { fill: none; stroke: var(--ink); stroke-width: 1; }
html.has-motion #hero .hero__box { opacity: 0; }
html.has-motion #hero .hero__brackets { fill: none; stroke: var(--ink); stroke-width: 1; stroke-linecap: square; }
html.has-motion #hero .hero__squares rect { fill: var(--yellow); stroke: var(--ink); stroke-width: 1; }
html.has-motion #hero .hero__leader { fill: none; stroke: var(--hero-ink-line); stroke-width: 1; }
html.has-motion #hero .hero__dot { fill: var(--ink); }
html.has-motion #hero .hero__tag, html.has-motion #hero .hero__deg, html.has-motion #hero .hero__part {
  position: absolute; left: 0; top: 0; margin: 0; white-space: nowrap; color: var(--ink);
  opacity: 0; visibility: hidden; will-change: transform;
}
html.has-motion #hero .hero__deg { font-variant-numeric: tabular-nums; }

/* The colourway label (beat 3): the colour section's chip dots and name, one at a time. The names share one grid cell,
   so the mask is as wide as the longest; each rises in and out through it (hero.js). */
html.has-motion #hero .hero__way {
  position: absolute; left: 0; top: 0; margin: 0; white-space: nowrap; color: var(--ink);
  opacity: 0; visibility: hidden; will-change: transform;
}
#hero .hero__way-mask { display: grid; overflow: clip; padding-block: 3px; margin-block: -3px; }
#hero .hero__way-item { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 10px; }
#hero .hero__way .chip__dot { width: 10px; height: 10px; }
#hero .hero__way .chip__dot + .chip__dot { margin-left: -3px; }

/* Copy: the beats sit on top of each other, vertically centred below the nav, in the left column.
   --hero-portrait tells hero.js which layout the container query below has chosen, so the two never disagree. */
html.has-motion #hero .hero__copy {
  --hero-portrait: 0;
  display: block; position: absolute; left: var(--hero-left); top: calc(50% + var(--nav-clear) / 2);
  width: var(--hero-copy-w); height: 0; padding: 0; z-index: 2;
}
html.has-motion #hero .hero__beat { position: absolute; left: 0; right: 0; top: 0; transform: translateY(-50%); }
html.has-motion #hero .hero__h1, html.has-motion #hero .hero__beat .t-m { max-width: none; }
html.has-motion #hero .hero__card[data-eyebrow="wrap"] .hero__beat--1 .eyebrow { white-space: normal; }
/* before hero.js has split the lines: beat 1 waits (a 3 s fallback shows it if the script never runs), 2 and 3 hidden */
html.has-motion #hero .hero__h1:not([data-split]) { visibility: hidden; animation: hero-show 0s linear 3s forwards; }
html.has-motion #hero .hero__beat--1 .eyebrow:not([data-in]) { opacity: 0; animation: hero-show 0s linear 3s forwards; }
html.has-motion #hero .hero__beat--2:not([data-split]), html.has-motion #hero .hero__beat--3:not([data-split]) { visibility: hidden; }
/* landscape: the two buttons stack at one width (the column is too narrow for a row) */
html.has-motion #hero .hero__btns {
  display: inline-grid; grid-template-columns: max-content; justify-self: start; gap: 10px;
  opacity: 0; pointer-events: none;
}
html.has-motion #hero .hero__btns.is-live { pointer-events: auto; }
html.has-motion #hero .hero__btns .btn--ghost {
  background: rgba(245, 242, 237, .38);
  -webkit-backdrop-filter: blur(10px) saturate(130%); backdrop-filter: blur(10px) saturate(130%);
}
html.has-motion #hero .hero__btns .btn--ghost:hover { background: rgba(245, 242, 237, .62); }
@keyframes hero-show { to { visibility: visible; opacity: 1; } }

/* Scroll cue and caption, bottom corners of the card */
html.has-motion #hero .hero__cue {
  display: block; position: absolute; left: var(--hero-left); bottom: 34px; z-index: 2; color: var(--ink);
}
html.has-motion #hero .hero__card[data-cue="off"] .hero__cue { display: none; }
html.has-motion #hero .hero__cue-in { display: inline-flex; align-items: center; gap: 12px; opacity: 0; animation: hero-show 0s linear 3s forwards; }
html.has-motion #hero .hero__cue-in[data-in] { animation: none; }
html.has-motion #hero .hero__cue-line { position: relative; display: block; width: 1px; height: 30px; background: rgba(11, 11, 13, .22); overflow: hidden; }
html.has-motion #hero .hero__cue-line i {
  position: absolute; left: -1px; top: 0; width: 3px; height: 9px; border-radius: 2px; background: var(--ink);
  animation: hero-cue 2.2s cubic-bezier(.65, 0, .35, 1) infinite;
}
@keyframes hero-cue { 0% { transform: translateY(-10px); } 70%, 100% { transform: translateY(31px); } }
html.has-motion #hero .hero__caption {
  position: absolute; right: var(--hero-left); bottom: 34px; z-index: 2; color: rgba(11, 11, 13, .66);
}

/* ------------------------------------------------------------------ motion on portrait cards: text on top, stack below
   Phones and portrait tablets alike (the card is a size container; hero.js reads --hero-portrait to match). Part labels
   and leaders are left out; the box and readout stay. The canvas numbers are the default until hero.js places the
   frame under the tallest beat (--hero-copy-h estimates that beat). */
@container (max-aspect-ratio: 11/10) {
  html.has-motion #hero .hero__copy {
    --hero-portrait: 1;
    top: calc(var(--nav-clear) + 14px); left: var(--hero-left); right: var(--hero-left); width: auto; max-width: 640px;
  }
  html.has-motion #hero .hero__beat { transform: none; }
  html.has-motion #hero .hero__beat--1 { gap: 16px; }
  html.has-motion #hero .hero__beat--3 { gap: 22px; }
  html.has-motion #hero .hero__btns { display: flex; flex-wrap: wrap; gap: 10px; justify-self: start; }
  html.has-motion #hero .hero__part, html.has-motion #hero .hero__leaders { display: none; }
  /* the colourway label sits in the card's bottom left corner, on the caption's line */
  html.has-motion #hero .hero__way { top: auto; left: var(--hero-left); bottom: 34px; }
  html.has-motion #hero .hero__canvas, html.has-motion #hero .hero__floor {
    --hero-copy-h: 100px;
    --hero-ptop: calc(var(--nav-clear) + 14px + var(--hero-copy-h) + 36px);       /* the box's top edge */
    --hero-pfh: max(40cqh, min(calc((100cqh - 46px - var(--hero-ptop)) * 1.1153), 92cqh));
  }
  html.has-motion #hero .hero__canvas {
    height: var(--hero-pfh); width: calc(var(--hero-pfh) * 16 / 9);
    left: calc(50% - var(--hero-pfh) * 8 / 9); top: calc(var(--hero-ptop) - var(--hero-pfh) * 0.1067);
  }
  html.has-motion #hero .hero__floor { top: calc(var(--hero-ptop) - var(--hero-pfh) * 0.1067 + var(--hero-pfh) - var(--hero-fade)); }
}

/* ------------------------------------------------------------------ motion on phones */
@media (max-width: 767.98px) {
  /* portrait phones use the 600x900 phone frames (2:3), placed under the text */
  @container (max-aspect-ratio: 11/10) {
    html.has-motion #hero .hero__canvas, html.has-motion #hero .hero__floor {
      --hero-copy-h: 171px;
      --hero-pfh: max(40cqh, min(calc((100cqh - 46px - var(--hero-ptop)) * 1.1153), 187.5cqw));
    }
    html.has-motion #hero .hero__canvas { width: calc(var(--hero-pfh) * 2 / 3); left: calc(50% - var(--hero-pfh) / 3); }
  }
  html.has-motion #hero .hero__beat--3 { gap: 20px; }
  /* one row when both fit, otherwise two full-width pills */
  html.has-motion #hero .hero__btns { gap: 8px; justify-self: stretch; }
  html.has-motion #hero .hero__btns .btn { flex: 1 1 auto; --btn-h: 44px; padding: 0 12px; font-size: 13.5px; gap: 8px; }
  html.has-motion #hero .hero__btns .btn__icon { display: none; }
  html.has-motion #hero .hero__cue { bottom: 14px; }
  html.has-motion #hero .hero__cue-line { height: 22px; }
  html.has-motion #hero .hero__caption { bottom: 12px; font-size: 12px; }
  /* a size down on narrow phones, so the longest name keeps clear of the caption (22px at 360 wide) */
  html.has-motion #hero .hero__way { bottom: 13px; font-size: min(10.5px, 2.75vw); letter-spacing: .04em; }
  #hero .hero__way-item { gap: 8px; }
}
