/* Complex Plane Technologies — motion layer.
   Everything animated lives here and is keyed on html.motion, which is only set when the
   visitor has not asked for reduced motion and the scripts run.

   Two kinds of motion:
   1. Load: the hero builds itself once (headline rises, the plane draws).
   2. Scroll: everything else is scrubbed. motion.js writes a 0..1 progress into --p on each
      element (and --hp on the hero); the rules below turn that number into position, so
      things move with the scrollbar and run backwards when you scroll up. */

/* ---------- small hover details ---------- */
.pill span[aria-hidden],
.link-line span[aria-hidden] { display: inline-block; transition: transform .25s ease; }
.pill:hover span[aria-hidden],
.link-line:hover span[aria-hidden] { transform: translateX(5px); }

/* ---------- load: headline lines rise out of a mask ---------- */
.line { display: block; overflow: hidden; padding-bottom: 0.14em; margin-bottom: -0.14em; }
.line > span { display: block; }
.motion [data-lines] .line > span {
  /* far enough that no ascender tips peek back into the mask before the line rises */
  transform: translateY(140%);
  transition: transform 1.15s cubic-bezier(.19, .9, .22, 1);
}
.motion [data-lines] .line:nth-child(2) > span { transition-delay: .13s; }
.motion [data-lines] .line:nth-child(3) > span { transition-delay: .26s; }
.motion [data-lines].is-in .line > span { transform: none; }

/* ---------- load: hero text and the plane ---------- */
.motion .hero__eyebrow,
.motion .hero__row {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .9s ease, transform .9s cubic-bezier(.2, .7, .2, 1);
}
.motion .hero__row { transition-delay: .5s; }
.motion .hero.is-ready .hero__eyebrow,
.motion .hero.is-ready .hero__row { opacity: 1; transform: none; }

.motion .strip [data-rings] circle {
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(.3);
  opacity: 0;
  transition: transform 1.5s cubic-bezier(.2, .8, .2, 1), opacity 1.1s ease;
  transition-delay: calc(.25s + var(--k, 0) * 45ms);
}
.motion .hero.is-ready .strip [data-rings] circle { transform: none; opacity: var(--o, .1); }

.motion .strip .ax {
  transform-origin: 1020px 290px;
  transition: transform 1.3s cubic-bezier(.3, .8, .2, 1) .1s;
}
.motion .strip .ax--x { transform: scaleX(0); }
.motion .strip .ax--y { transform: scaleY(0); transition-delay: .28s; }
.motion .hero.is-ready .strip .ax { transform: none; }

.motion .strip [data-fade] { opacity: 0; transition: opacity .8s ease 1.25s; }
.motion .hero.is-ready .strip [data-fade] { opacity: 1; }

.motion .strip [data-moving] { opacity: 0; transition: opacity .5s ease; }
.motion .strip [data-moving].is-live { opacity: 1; }

.strip [data-trail] { display: none; } /* superseded by the shader comet */

/* ---------- the comet: the point and its motion blur, drawn by a shader (see motion.js) ---------- */
.motion .hero { position: relative; }
.comet {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}
/* the shader draws the point, so the drawn one steps aside */
.hero.has-comet .strip [data-dot],
.hero.has-comet .strip [data-trail] { display: none; }

/* ---------- scroll: the hero is pinned while the camera moves into the plane ---------- */
.motion .hero__body {
  transform: translate3d(0, calc(var(--hp, 0) * -70px), 0);
  opacity: calc(1 - var(--hp, 0) * 1.1);
}

@media (min-width: 900px) and (min-height: 620px) {
  .motion .hero-pin { height: calc(100svh + 90vh); }
  .motion .hero {
    position: sticky;
    top: 0;
    height: 100svh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .motion .hero__body {
    padding: clamp(20px, 5vh, 80px) 0 clamp(20px, 3.5vh, 56px);
    opacity: calc(1 - var(--hp, 0) * 2.8); /* the text clears early so the plane has the stage */
  }
  .motion .hero .display { font-size: clamp(42px, min(7.6vw, 12.5vh), 120px); }
  .motion .hero .strip {
    flex: 1 1 0;
    height: 0;
    min-height: 200px;
    transform-origin: 70.83% 72.5%; /* the origin of the plane */
    transform: translate3d(0, calc(var(--hp, 0) * -22vh), 0) scale(calc(1 + var(--hp, 0) * 0.9));
    will-change: transform;
  }
}

/* ---------- scroll: scrubbed blocks ---------- */
.motion [data-scrub] {
  opacity: var(--p, 1);
  transform: translate3d(0, calc((1 - var(--p, 1)) * var(--dy, 44px)), 0);
}

.motion .label[data-scrub] { --dy: 0px; }

/* the big statements fill in word by word */
.motion .statement[data-scrub] { opacity: 1; transform: none; }

/* principles: three columns arrive at different speeds, the z tips upright */
.motion .tri__item[data-scrub] {
  --dy: calc(36px + var(--i, 0) * 64px);
  opacity: calc(.08 + var(--p, 1) * .92);
}
.motion .tri__sym--z {
  transform-origin: 0.25em 85%;
  transform: rotate(calc((1 - var(--p, 1)) * -55deg));
}

/* product: the ink band opens out to full width, the name and status slide to meet */
.motion .section--expand[data-scrub] {
  opacity: 1;
  transform: none;
  clip-path: inset(0 calc((1 - var(--p, 1)) * 7vw) round calc((1 - var(--p, 1)) * 44px));
}
.motion .product-band[data-scrub] { opacity: 1; transform: none; }
.motion .product-band__name { transform: translate3d(calc((1 - var(--p, 1)) * -16vw), 0, 0); }
.motion .product-band__status {
  transform: translate3d(calc((1 - var(--p, 1)) * 16vw), 0, 0);
  opacity: var(--p, 1);
}
.motion .product-band__icon {
  transform: rotate(calc((1 - var(--p, 1)) * -140deg)) scale(calc(.5 + var(--p, 1) * .5));
}
.motion .product-band__status::before { animation: ping 2.6s ease-out infinite; }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(255, 75, 43, .5); }
  80%, 100% { box-shadow: 0 0 0 16px rgba(255, 75, 43, 0); }
}

/* what we do: each rule draws itself, title and text come in from opposite sides */
.motion .rows__row[data-scrub] {
  position: relative;
  opacity: calc(.12 + var(--p, 1) * .88);
  transform: none;
  border-bottom-color: transparent;
}
.motion .rows__row[data-scrub]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--rule-strong);
  transform: scaleX(var(--p, 1));
  transform-origin: left;
}
.motion .rows__row[data-scrub] .h3 { transform: translate3d(calc((1 - var(--p, 1)) * -64px), 0, 0); }
.motion .rows__row[data-scrub] p { transform: translate3d(calc((1 - var(--p, 1)) * 64px), 0, 0); }

/* beliefs and other grids: neighbours travel different distances */
.motion .beliefs li[data-scrub] { --dy: calc(30px + var(--i, 0) * 26px); }
.motion .team__person[data-scrub] { --dy: calc(40px + var(--i, 0) * 50px); }
.motion .team__mono { transform: rotate(calc((1 - var(--p, 1)) * -100deg)); }
.motion .facts > div[data-scrub],
.motion .milestones li[data-scrub] { --dy: 24px; }

/* contact: the invitation grows as it arrives */
.motion .footer .display[data-scrub] {
  opacity: calc(.12 + var(--p, 1) * .88);
  transform-origin: left bottom;
  transform: scale(calc(.6 + var(--p, 1) * .4));
}
.motion .contact__row[data-scrub] { --dy: 0px; }
.motion .contact__email { display: inline-block; transform: translate3d(calc((1 - var(--p, 1)) * 90px), 0, 0); }

/* ---------- scroll: a small axis on the right edge shows where you are ---------- */
.rail, .rail-dot { display: none; }
@media (min-width: 1100px) {
  .motion .rail {
    display: block;
    position: fixed;
    right: 22px;
    top: 50%;
    width: 9px;
    height: 38vh;
    transform: translateY(-50%);
    z-index: 40;
    pointer-events: none;
    mix-blend-mode: difference;
    opacity: .55;
    background:
      linear-gradient(#fff, #fff) center / 1px 100% no-repeat,
      repeating-linear-gradient(to bottom, #fff 0 1px, transparent 1px 8.3333%);
  }
  .motion .rail-dot {
    display: block;
    position: fixed;
    right: 22px;
    top: calc(50% - 19vh + var(--page, 0) * 38vh);
    width: 9px;
    height: 9px;
    margin-top: -4.5px;
    border-radius: 50%;
    background: var(--accent);
    z-index: 41;
    pointer-events: none;
  }
}
