/*
  ClipReady landing page: ten heroes to choose from (h1.html to h10.html in this folder).
  Loaded after ../../../design/tokens.css, ../../styles.css and ../landing.css. Every colour, font,
  size, space, radius and shadow is a token from tokens.css; the button, phone frame, reels and
  placeholders are the ones the other pages use, unchanged.

  Each hero mixes three things from round 2, or tries a new idea in the same spirit:
      the black background   (v9)   class "dark" on the section
      the parallax effect    (v7)   the copy holds still while something rises over it
      the carousel           (v5)   a row of reels that drifts by itself

      h1   hx--rise     black + parallax
      h2   hx--drift    black + carousel
      h3   hx--tide     black + parallax + carousel
      h4   hx--slide    parallax + carousel, on white: rows that move as you scroll
      h5   hx--wall     new: a wall of reels behind the headline
      h6   hx--depth    new: reels at three depths
      h7   hx--zoom     new: one reel grows to fill the screen
      h8   hx--flow     new: a cover-flow carousel
      h9   hx--lights   new: white turns to black as the phone rises
      h10  hx--cols     new: columns of reels beside the headline

  TO USE ONE ON A PAGE
  Copy its whole <section class="hero h hx …"> in place of the page's hero, and add this file and
  heroes.js to the page's <head>, after landing.css and landing.js.
  (../combined.html uses h3 this way, with real pictures in its row: see "Reels with real pictures".)

  The plain numbers left in this file are sizes of drawn things (reel widths, how far a reel
  peeks), how fast a part moves against the scroll, and the breakpoints (760, 1000px).
  Motion runs only for visitors who have not asked their device to reduce it; without it, or
  without heroes.js, every hero is a still picture with nothing hidden.
*/

/* ---------- Shared ---------- */
.hx {
  --loop-gap: var(--cr-space-4);   /* between reels in a row that drifts */
  --loop-time: 90s;                /* one lap of a drifting row: the pace of v5's */
  --peek: clamp(56px, 13vh, 150px);/* how much of a rising phone or row shows on the first screen */
  padding: 0; overflow: visible;   /* visible, so a part inside can be held still on screen */
}
.hx.dark .lede { color: var(--cr-on-dark-muted); }
.hx .phone { animation: none; }
/* A headline one size down (the section-heading size), where the picture needs the room */
:is(.hx--wall, .hx--cols) h1 { max-width: 15em; margin-inline: auto; font-size: var(--cr-text-h2); line-height: var(--cr-leading-heading); letter-spacing: var(--cr-tracking-heading); }

/* The grey box under each hero stands in for the rest of the page. It is not part of the hero. */
.hx-next { padding: var(--cr-space-22) 0; }
.hx-next__box { position: relative; height: 80vh; border-radius: var(--cr-radius-lg); background: var(--cr-tile); }
.hx-next .ph { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

/* ---------- The carousel: a row (or column) of reels that drifts without an end ----------
   heroes.js copies the reels so the row can loop, then adds is-moving. Until then it is a still row. */
.hx-loop { display: flex; justify-content: center; overflow: hidden; }
.hx-loop__track { display: flex; flex: none; gap: var(--loop-gap); }
.hx-loop .reel { flex: none; width: var(--loop-w, 150px); }
.hx-loop--up, .hx-loop--down { flex-direction: column; height: 100%; }
:is(.hx-loop--up, .hx-loop--down) .hx-loop__track { flex-direction: column; }
:is(.hx-loop--up, .hx-loop--down) .reel { width: 100%; }
@keyframes hx-left { to { transform: translateX(calc(-50% - var(--loop-gap) / 2)); } }
@keyframes hx-right { from { transform: translateX(calc(-50% - var(--loop-gap) / 2)); } }
@keyframes hx-up { to { transform: translateY(calc(-50% - var(--loop-gap) / 2)); } }
@keyframes hx-down { from { transform: translateY(calc(-50% - var(--loop-gap) / 2)); } }

/* ---------- Reels with real pictures ----------
   A reel marked data-reel="name" shows a still, name-poster.jpg, fetched only when the reel is
   about to be seen. While it is on screen it may play a short loop, name-loop.mp4, over the
   still: heroes.js lets at most three play at once, fetches a loop only when its reel is on
   screen, and plays none with "reduce motion" on. Until the files are in site/assets/reels/
   the frame keeps its gradient and says [REEL].
   The landing page's Styles section marks its four reels the same way. */
.reel[data-reel] .ph { display: none; }
.reel[data-reel].is-empty:not(.is-playing) .ph { display: block; }
.reel__poster { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.reel[data-reel] .reel__video { opacity: 0; }
.reel[data-reel].is-playing .reel__video { opacity: 1; }
/* A small label on a reel, for something the visitor should know about it ("AI presenter": the person
   in that reel is generated). The same dark pill as the [REEL] label, in the reel's bottom corner, over
   the still and the loop. It shows once the still is there, so an empty frame is not labelled. */
.reel__tag { position: absolute; left: var(--cr-space-2); bottom: var(--cr-space-2); z-index: 1; padding: var(--cr-space-1) var(--cr-space-2); border-radius: var(--cr-radius-pill); background: var(--cr-scrim); color: var(--cr-white); font-weight: var(--cr-weight-semibold); font-size: var(--cr-text-sm); line-height: var(--cr-leading-snug); letter-spacing: var(--cr-tracking-body); white-space: nowrap; pointer-events: none; }
.reel[data-reel]:not(.has-still) .reel__tag { display: none; }

/* ---------- The parallax: copy held still, something rising over it ----------
   .hx__pin holds the copy; .hx__over is what rises. heroes.js adds is-pinned when the copy fits on one screen, and sets --p from 0 to 1 as
   the page scrolls through. On a short screen it first tries with less room round the copy
   (is-tight); if the copy still does not fit on one screen, the hero is simply not held. */
.hx__pin {
  display: grid; align-items: center;
  min-height: calc(100vh - var(--cr-header-height)); min-height: calc(100svh - var(--cr-header-height));
  padding-block: clamp(var(--cr-space-4), 4vh, var(--cr-space-10)) calc(var(--peek) + clamp(var(--cr-space-3), 3vh, var(--cr-space-8)));
}
.hx__over { position: relative; z-index: 1; margin-top: calc(-1 * var(--peek)); padding-bottom: 18vh; pointer-events: none; }
.hx.is-tight { --peek: var(--cr-space-10); }
.hx.is-tight .hx__pin { padding-block: var(--cr-space-3) calc(var(--peek) + var(--cr-space-3)); }


/* ==========================================================================
   h1  hx--rise: black + parallax. A phone rises over the copy.
   ========================================================================== */
.hx--rise .hx__over, .hx--lights .hx__over { display: flex; justify-content: center; }


/* ==========================================================================
   h2  hx--drift: black + carousel. The copy over a drifting row of reels.
   ========================================================================== */
.hx--drift { padding: var(--cr-space-10) 0 var(--cr-space-14); }
.hx--drift .hx-loop { margin-top: var(--cr-space-14); }
/* The row fades into the black at both edges */
:is(.hx--drift, .hx--tide) .hx-loop { -webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent); mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent); }


/* ==========================================================================
   h3  hx--tide: black + parallax + carousel. A drifting row rises over the copy.
   ========================================================================== */
.hx--tide .hx-loop { --loop-w: 170px; }


/* ==========================================================================
   h4  hx--slide: parallax + carousel, on white. Two rows of reels that slide in opposite
   directions as the page scrolls. heroes.js sets --s, the distance scrolled, in pixels.
   ========================================================================== */
.hx--slide { --rw: 130px; --rate: .22; padding: var(--cr-space-10) 0 var(--cr-space-14); }
.hx__rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--cr-space-4); margin-top: var(--cr-space-14); overflow: hidden; }
.hx__row { display: flex; gap: var(--cr-space-4); width: max-content; margin-left: 50%; transform: translateX(calc(-50% + var(--x, 0px))); }
.hx__row .reel { flex: none; width: var(--rw); }
.hx__row:nth-child(even) { --x: calc(var(--rw) / 2); }   /* set half a reel across, so the rows do not line up */


/* ==========================================================================
   h5  hx--wall: a wall of reels drifting behind the headline, one screen tall.
   Dark behind the words, brighter towards the edges.
   ========================================================================== */
.hx--wall { position: relative; isolation: isolate; display: grid; align-items: center; min-height: calc(100vh - var(--cr-header-height)); min-height: calc(100svh - var(--cr-header-height)); padding: var(--cr-space-14) 0; overflow: hidden; }
.hx__wall { --loop-w: 112px; --loop-gap: var(--cr-space-3); position: absolute; inset: 0; z-index: -1; display: grid; align-content: center; gap: var(--loop-gap); pointer-events: none; }
.hx__wall .hx-loop { opacity: .6; }
/* The veil: black where the words are, clearing towards the edges */
.hx__wall::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent, var(--cr-black) 30%, var(--cr-black) 70%, transparent); }


/* ==========================================================================
   h6  hx--depth: five reels at three depths. As the page scrolls the near one rises a little
   faster than the page and the far ones fall behind it, so they pull apart.
   (--k is each one's speed against the scroll: above 0 it rises, below 0 it falls behind.)
   ========================================================================== */
.hx--depth { padding: var(--cr-space-10) 0 0; overflow: hidden; }
.hx--depth .hx__copy { position: relative; z-index: 1; }
.hx__depth { display: flex; justify-content: center; align-items: flex-start; height: 250px; margin-top: var(--cr-space-14); }
.hx__depth .reel { flex: none; transform: translateY(calc(var(--s, 0) * var(--k) * -1px)); }
.hx__depth .reel::after { content: ""; position: absolute; inset: 0; background: var(--cr-black); opacity: 0; }
.d--near { --k: .1; z-index: 3; width: 180px; }
.d--mid { --k: 0; z-index: 2; width: 130px; margin-top: 44px; }
.d--far { --k: -.12; z-index: 1; width: 96px; margin-top: 72px; }
.hx__depth .d--mid::after { opacity: .4; }
.hx__depth .d--far::after { opacity: .68; }
/* Each one tucks behind the one in front of it */
.d--far:first-child { margin-right: -30px; }
.d--far:last-child { margin-left: -30px; }
.d--mid:nth-child(2) { margin-right: -40px; }
.d--mid:nth-child(4) { margin-left: -40px; }


/* ==========================================================================
   h7  hx--zoom: one small reel under the copy grows, as the page scrolls, until it fills
   the screen. Held still while it does. Not held: the reel simply sits under the copy.
   ========================================================================== */
.hx--zoom .hx__pin { display: block; padding-bottom: calc(var(--cr-space-8) + var(--cr-space-14)); }   /* the least room to leave under the copy: a gap, and a strip of the reel */
.hx__zoom { --gap: var(--cr-space-8); width: min(64vw, 300px); margin: var(--cr-space-12) auto 0; }
.hx--zoom.is-tight .hx__pin { padding-bottom: calc(var(--cr-space-5) + var(--cr-space-10)); }
.hx--zoom.is-tight .hx__zoom { --gap: var(--cr-space-5); }


/* ==========================================================================
   h8  hx--flow: a cover-flow carousel. One reel in front, its neighbours turned away and
   dimmed. It moves on by itself; it can also be swiped, or a reel clicked to bring it forward.
   Each reel sits in a plain holder (.hx__card), which is what the row snaps to; the reel inside is what
   turns. heroes.js sets, on each holder, --d (how many places from the middle, signed) and --a (the same, unsigned).
   ========================================================================== */
.hx--flow { padding: var(--cr-space-10) 0 var(--cr-space-12); }
.hx__flow { --fw: 200px; position: relative; display: flex; gap: var(--cr-space-2); margin-top: var(--cr-space-10); padding-block: var(--cr-space-4); overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.hx__flow::-webkit-scrollbar { display: none; }
/* Room at each end, so the first and last reel can reach the middle */
.hx__flow::before, .hx__flow::after { content: ""; flex: none; width: calc(50% - var(--fw) / 2 - var(--cr-space-2)); }
.hx__card { flex: none; width: var(--fw); scroll-snap-align: center; cursor: pointer; }
.hx__flow .reel { transform: perspective(1000px) rotateY(calc(var(--d, 0) * -24deg)) scale(calc(1 - var(--a, 0) * .14)); }
.hx__flow .reel::after { content: ""; position: absolute; inset: 0; background: var(--cr-black); opacity: calc(var(--a, 0) * .34); pointer-events: none; }
.js .hx__card { --a: 1; }   /* until heroes.js has placed them */


/* ==========================================================================
   h9  hx--lights: starts white, like the current page. As the phone rises over the copy,
   the page turns black around it.
   ========================================================================== */
.hx--lights .hx__pin { position: relative; isolation: isolate; }
.hx--lights .hx__pin::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--cr-black); opacity: 0; }


/* ==========================================================================
   h10  hx--cols: three columns of reels, running up and down. Beside the copy on a wide
   screen, under it on a phone.
   ========================================================================== */
.hx--cols { padding: var(--cr-space-10) 0 0; }
.hx__cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--cr-space-3); height: 380px; margin-top: var(--cr-space-12); overflow: hidden; -webkit-mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent); }
.hx__cols { --loop-gap: var(--cr-space-3); }


/* ---------- Wider screens ---------- */
@media (min-width: 760px) {
  .hx { --loop-gap: var(--cr-space-5); }
  .hx-loop { --loop-w: 200px; }
  .hx--tide .hx-loop { --loop-w: 250px; }
  .hx--slide { --rw: 200px; }
  .hx__rows, .hx__row { gap: var(--cr-space-5); }
  .hx__wall { --loop-w: 170px; --loop-gap: var(--cr-space-4); }
  .hx__wall::after { background: radial-gradient(ellipse 62% 64% at 50% 50%, var(--cr-black) 30%, transparent 100%); }
  .hx__depth { height: 400px; }
  .d--near { width: 290px; }
  .d--mid { width: 210px; margin-top: 70px; }
  .d--far { width: 150px; margin-top: 120px; }
  .d--far:first-child { margin-right: -40px; }
  .d--far:last-child { margin-left: -40px; }
  .d--mid:nth-child(2) { margin-right: -56px; }
  .d--mid:nth-child(4) { margin-left: -56px; }
  .hx__flow { --fw: 270px; gap: var(--cr-space-3); }
  .hx__flow::before, .hx__flow::after { width: calc(50% - var(--fw) / 2 - var(--cr-space-3)); }
  .hx__cols { height: 460px; }
}
@media (min-width: 1000px) {
  .hx--drift, .hx--slide, .hx--flow { padding-top: var(--cr-space-16); }
  .hx--drift, .hx--slide { padding-bottom: var(--cr-space-22); }
  .hx--drift .hx-loop, .hx__rows { margin-top: var(--cr-space-22); }
  .hx--depth { padding-top: var(--cr-space-16); }
  .hx__depth { margin-top: var(--cr-space-22); }
  .hx__flow { margin-top: var(--cr-space-14); }
  .hx--flow { padding-bottom: var(--cr-space-16); }
  /* h10: side by side, one screen tall, the columns running the full height */
  .hx--cols { padding: 0; text-align: left; }
  .hx__split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: var(--cr-space-16); align-items: center; }
  .hx--cols h1, .hx--cols .lede { margin-inline: 0; }
  .hx__cols { height: calc(100vh - var(--cr-header-height)); height: calc(100svh - var(--cr-header-height)); min-height: 560px; margin-top: 0; }
}


/* ==========================================================================
   MOTION
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  /* On arrival: the copy settles in, one piece after another (the delays are in landing.css), then the picture */
  .hx :is(h1, .lede, .h__cta) { animation: rise var(--lv-rise) var(--lv-ease) both; }
  :is(.hx--drift, .hx--flow) :is(.hx-loop, .hx__flow), .hx__rows, .hx__depth, .hx__cols, .hx__over > *, .hx__zoom > * { animation: rise 1s var(--lv-ease) .25s both; }
  .hx__wall { animation: pop 1.4s var(--lv-ease) both; }

  .reel[data-reel] .reel__video { transition: opacity var(--cr-duration) var(--cr-ease); }

  /* The carousel */
  .hx-loop.is-moving { justify-content: flex-start; }
  .hx-loop.is-moving .hx-loop__track { animation: hx-left calc(var(--loop-time) * var(--loop-sets, 1)) linear infinite; will-change: transform; }
  .hx-loop--right.is-moving .hx-loop__track { animation-name: hx-right; }
  .hx-loop--up.is-moving .hx-loop__track { animation-name: hx-up; }
  .hx-loop--down.is-moving .hx-loop__track { animation-name: hx-down; }
  .hx__wall .hx-loop:nth-child(2) { --loop-time: 120s; }
  .hx__wall .hx-loop:nth-child(3) { --loop-time: 75s; }
  .hx__cols .hx-loop { --loop-time: 60s; }
  .hx__cols .hx-loop:nth-child(2) { --loop-time: 80s; }

  /* The parallax: the copy is held, fades and shrinks a little as the page scrolls through (--p: 0 to 1) */
  .js .hx.is-pinned .hx__pin { position: -webkit-sticky; position: sticky; top: var(--cr-header-height); }
  .js .hx.is-pinned .hx__copy { opacity: calc(1 - var(--p, 0) * 1.8); transform: scale(calc(1 - var(--p, 0) * .08)); }
  .js .hx.is-pinned.is-faded .hx__copy { visibility: hidden; }

  /* h4: the rows slide with the scroll, one each way */
  .js .hx__row { will-change: transform; }
  .js .hx__row:nth-child(odd) { --x: calc(var(--s, 0) * var(--rate) * -1px); }
  .js .hx__row:nth-child(even) { --x: calc(var(--rw) / 2 + var(--s, 0) * var(--rate) * 1px); }

  /* h6 */
  .js .hx__depth .reel { will-change: transform; }

  /* h7: held for a screen and a bit of scrolling. The reel starts small, just under the copy
     (heroes.js measures where, as --from), and ends large in the middle of the screen. */
  .js .hx--zoom.is-pinned { height: calc(210vh - var(--cr-header-height)); height: calc(100svh - var(--cr-header-height) + 110vh); }
  .js .hx--zoom.is-pinned .hx__pin { --zh: min((100vh - var(--cr-header-height)) * .84, (100vw - 2 * var(--cr-gutter)) * 16 / 9); height: calc(100vh - var(--cr-header-height)); height: calc(100svh - var(--cr-header-height)); overflow: hidden; }
  .js .hx--zoom.is-pinned .hx__copy { opacity: calc(1 - var(--p, 0) * 3.2); transform: translateY(calc(var(--p, 0) * -90px)); }
  .js .hx--zoom.is-pinned .hx__zoom {
    --g: min(1, var(--p, 0) * 1.3);   /* fully grown a little before the hero lets go */
    position: absolute; left: 50%; top: calc(50% - var(--zh) / 2); width: calc(var(--zh) * 9 / 16); margin: 0 0 0 calc(var(--zh) * 9 / -32);
    transform-origin: 50% 0; transform: translateY(calc((1 - var(--g)) * var(--from, 0px))) scale(calc(.4 + .6 * var(--g))); will-change: transform;
  }

  /* h9: the black comes up behind the copy as it fades */
  .js .hx--lights.is-pinned .hx__copy { opacity: calc(1 - var(--p, 0) * 2.4); }
  .js .hx--lights.is-pinned .hx__pin::before { opacity: clamp(0, (var(--p, 0) - .12) * 2.2, 1); }
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  :is(.hx--drift, .hx--tide) .hx-loop.is-moving:hover .hx-loop__track { animation-play-state: paused; }
}
