/* Scroll motion. site.js writes two numbers on every [data-m] layer of a scene, and everything here is a pure function
   of them, so scrolling back plays a scene backwards:
     --e  the entrance: 0 when the scene's top meets the bottom of the viewport, 1 when it reaches the top (or is pinned).
     --p  the story: in a pinned scene, 0 when its pin sticks and 1 when it lets go; elsewhere, while it crosses the view.
   Only transform and opacity change per frame. The properties are registered as non-inherited numbers, so a change
   restyles the layer itself, not the thousands of nodes in the window inside it. Without the .m class (reduced motion,
   ?still, no script) none of these rules apply: every scene shows its end state, flat, and nothing is pinned. */
@property --p { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --e { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --E { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --F { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --A { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --q { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --s { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --k { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --s1 { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --k1 { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --s2 { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --k2 { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --s3 { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --k3 { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --g { syntax: "<number>"; inherits: false; initial-value: 1; }
@property --c { syntax: "<number>"; inherits: false; initial-value: 1; }

/* phone: the same motion, half the turn */
:root { --tilt: 1; }
@media (max-width: 720px) { :root { --tilt: .5; } }

/* layout is measured with every layer at rest (site.js, on resize only) */
.measuring .m [data-m], .m.measuring [data-m] { transform: none !important; }

.tilt3d { position: relative; }
.m .live .tilt3d, .m .live .card { will-change: transform; }
.m .live [data-m]:not(.tilt3d, .card) { will-change: transform, opacity; }

/* ---------- pinned scenes: on wide, tall screens each scene is a scroll track; its pin holds the copy and the window
   in the viewport, under the header, while scroll plays the story. ---------- */
@media (min-width: 1101px) and (min-height: 700px) {
  .m .track { height: var(--track); }
  .m .pin { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; justify-content: center; padding-top: 72px; }
  .m .sec.scene { padding: 0; }
  .m .hero .pin { justify-content: flex-start; padding-top: 0; }
  /* the hero window runs past the pin; the page leaves room for it */
  .m .hero .track { margin-bottom: max(0px, 1240px - 100vh); }
}
.m .stage, .m .hero-stage, .m .fan { perspective: 2000px; }

/* ---------- the pose. Each window holds a three-quarter view while its story plays (--A = 1), arrives from a deeper
   one (--A up to 1 + --in), and at the payoff turns most of the way flat (--A = 0.3, never 0). ---------- */
.m .stage > .tilt3d {
  --E: calc(1 - (1 - var(--e)) * (1 - var(--e)) * (1 - var(--e)));
  --s: clamp(0, (var(--p) - var(--f0, .74)) / .2, 1);
  --F: calc(var(--s) * var(--s) * (3 - 2 * var(--s)));
  --A: calc((1 + (1 - var(--E)) * var(--in, 1) - var(--E) * var(--F) * .7) * var(--tilt));
  transform-style: preserve-3d; transform-origin: 50% 50%;
}

/* ---------- hero: the window rises and turns flat while the bird sends the first message into it ---------- */
.m .hero-stage .tilt3d {
  --s: clamp(0, var(--p) / .62, 1); --q: calc((1 - var(--s)) * (1 - var(--s)) * var(--tilt));
  transform-origin: 50% 0;
  transform: translateY(calc(var(--q) * 140px)) rotateX(calc(var(--q) * 32deg)) rotateZ(calc(var(--q) * -1.5deg)) scale(calc(1 - var(--q) * .1));
}
/* The letter: a copy of the top row, at the row's place, sent from the bird. It leaves the envelope small, flies up and
   out past the headline and down into the list on a cubic curve (site.js sets the points, relative to the row), grows
   to the row's size and lands on it as the window lies flat; the row itself shows when it lands. */
.m .letter {
  display: block; position: absolute; z-index: 8; left: 0; top: 0; border-radius: 8px; overflow: hidden; pointer-events: none;
  background: var(--surface-raised); box-shadow: 0 0 0 1px oklch(1 0 0 / 0.1), 0 18px 40px -10px oklch(0 0 0 / 0.75);
  --s: clamp(0, (var(--p) - .04) / .66, 1);
  --g: calc(.4 + .35 * clamp(0, var(--s) / .2, 1) + .25 * clamp(0, (var(--s) - .6) / .4, 1));
  opacity: calc(clamp(0, (var(--p) - .03) / .04, 1) - clamp(0, (var(--p) - .72) / .05, 1));
  transform: translate(
      calc((1 - var(--s)) * (1 - var(--s)) * (1 - var(--s)) * var(--dx) + 3 * (1 - var(--s)) * (1 - var(--s)) * var(--s) * var(--c1x) + 3 * (1 - var(--s)) * var(--s) * var(--s) * var(--c2x)),
      calc((1 - var(--s)) * (1 - var(--s)) * (1 - var(--s)) * var(--dy) + 3 * (1 - var(--s)) * (1 - var(--s)) * var(--s) * var(--c1y) + 3 * (1 - var(--s)) * var(--s) * var(--s) * var(--c2y)))
    scale(var(--g));
}
.m .letter .hb-thread { width: 100%; margin: 0; background: var(--surface-raised); }
.m .landing { opacity: clamp(0, (var(--p) - .7) / .05, 1); }

/* ---------- numbers: a cursor sweeps one frame; each bar fills with it until its measured time ---------- */
.m .ruler { overflow-x: clip; }
.m .ruler [data-m] { --c: calc(clamp(0, (var(--p) - .18) / .32, 1) * 4.17); }
.m .lane b { transform: scaleX(calc(min(var(--c), var(--v)) / var(--v))); }
.m .sweep { display: block; position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none;
  opacity: calc(clamp(0, (var(--p) - .17) / .02, 1) - clamp(0, (var(--p) - .52) / .04, 1));
  transform: translateX(calc(var(--c) / 4.17 * 100%)); }
.sweep::before { content: ""; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--indigo); }

/* ---------- triage: a slow dolly down the list at a fixed turn; J, J, E, and the toast ---------- */
.m .s-triage > .tilt3d {
  --in: 1.2;
  transform: translate3d(0, calc((1 - var(--E)) * 90px + (.5 - var(--p)) * 56px), calc((1 - var(--E)) * -200px + var(--p) * 40px))
    rotateX(calc(var(--A) * 8deg)) rotateY(calc(var(--A) * -14deg)) scale(calc(1 - (1 - var(--E)) * .08));
}
.m .s-triage .hb-listpane__rows { position: relative; }
.m .s-triage .hb-thread { position: relative; }
.tri-cur { position: absolute; z-index: 0; background: var(--surface-selected); }
.m .tri-cur {
  --s1: clamp(0, (var(--p) - .18) / .045, 1); --k1: calc(var(--s1) * var(--s1) * (3 - 2 * var(--s1)));
  --s2: clamp(0, (var(--p) - .32) / .045, 1); --k2: calc(var(--s2) * var(--s2) * (3 - 2 * var(--s2)));
  transform: translateY(calc((var(--k1) + var(--k2)) * var(--rstep)));
}
.m .s-triage .hb-thread.arch {
  --s: clamp(0, (var(--p) - .46) / .05, 1); --k: calc(var(--s) * var(--s) * (3 - 2 * var(--s)));
  opacity: calc(1 - var(--k)); transform: translateX(calc(var(--k) * -48px));
}
.m .s-triage .hb-thread.after {
  --s: clamp(0, (var(--p) - .49) / .06, 1); --k: calc(var(--s) * var(--s) * (3 - 2 * var(--s)));
  transform: translateY(calc(var(--k) * -1 * var(--rstep)));
}
/* the reader shows the selected thread: Flight change, then March invoice, then the review request; after E, the
   artboard's own reader (Q4 offsite). The app swaps it at once, so does the page. */
.m .s-triage .rv { opacity: calc(clamp(0, (var(--p) - var(--a)) / .006, 1) - clamp(0, (var(--p) - var(--b)) / .006, 1)); }
.m .s-triage .toastbox {
  --s: clamp(0, (var(--p) - .54) / .06, 1); --k: calc(var(--s) * var(--s) * (3 - 2 * var(--s)));
  opacity: var(--k); transform: translate3d(0, calc((1 - var(--k)) * 10px), calc(40px + (1 - var(--k)) * 100px));
}
/* the key being pressed rides beside the selection, on the list's edge, forward in depth */
.m .keycap {
  display: grid; place-items: center; position: absolute; z-index: 6; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 10px; background: var(--pg-2); box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.14), inset 0 -2px 0 oklch(1 0 0 / 0.06), 0 12px 32px -8px oklch(0 0 0 / 0.7);
  --s: clamp(0, (var(--p) - .1) / .04, 1); --k: clamp(0, (var(--p) - .56) / .04, 1);
  --s1: clamp(0, min(var(--p) - .168, .192 - var(--p)) / .012, 1);
  --s2: clamp(0, min(var(--p) - .308, .332 - var(--p)) / .012, 1);
  --s3: clamp(0, min(var(--p) - .448, .472 - var(--p)) / .012, 1);
  --k1: clamp(0, (var(--p) - .18) / .045, 1); --k2: clamp(0, (var(--p) - .32) / .045, 1);
  opacity: calc(var(--s) - var(--k));
  transform: translate3d(0, calc((var(--k1) * var(--k1) * (3 - 2 * var(--k1)) + var(--k2) * var(--k2) * (3 - 2 * var(--k2))) * var(--rstep, 0px) + (var(--s1) + var(--s2) + var(--s3)) * 3px), 70px);
}
.keycap kbd { font: 500 17px/1 var(--mono); color: var(--t1); }

/* ---------- palette: the camera pushes in on the palette and stops at it; the palette floats in front ---------- */
.m .s-pal > .tilt3d {
  --in: .8; --f0: .8;
  --s1: clamp(0, var(--p) / .55, 1); --k1: calc(1 - (1 - var(--s1)) * (1 - var(--s1)) * (1 - var(--s1)));
  transform-origin: 50% 40%;
  transform: translate3d(0, calc((1 - var(--E)) * 80px), calc((1 - var(--E)) * -200px - (1 - var(--k1)) * 340px))
    rotateX(calc(var(--A) * 7deg)) rotateY(calc(var(--A) * -10deg));
}
.m .pal-pop {
  --s1: clamp(0, var(--p) / .55, 1); --k1: calc(1 - (1 - var(--s1)) * (1 - var(--s1)) * (1 - var(--s1)));
  transform: translateZ(calc(30px + (1 - var(--k1)) * 140px));
}

/* ---------- search: a lateral pan from the query to the receipt at a fixed turn ---------- */
.m .s-search > .tilt3d {
  --in: 1.2; --f0: .8;
  transform: translate3d(0, calc((1 - var(--E)) * 90px), calc((1 - var(--E)) * -200px))
    rotateX(calc(var(--A) * 7deg)) rotateY(calc(var(--A) * 13deg)) scale(calc(1 - (1 - var(--E)) * .08));
}
.m .sr-panel > .win {
  --s: clamp(0, (var(--p) - .5) / .26, 1); --k: calc(var(--s) * var(--s) * (3 - 2 * var(--s)));
  transform: translateX(calc(var(--k) * -1 * var(--pan, 0px)));
}
.m .sr-panel .hb-chip.ap { --dy: 0px; }
.m .sr-panel .pre { opacity: calc(1 - clamp(0, (var(--p) - var(--a)) / .03, 1)); }

/* ---------- calendar: seen from above, it lies flat as the drag ends; the quick editor stands up beside it ---------- */
.m .s-cal > .tilt3d {
  --in: 0; --f0: .8;
  --s1: clamp(0, (var(--p) - .04) / .42, 1); --k1: calc(var(--s1) * var(--s1) * (3 - 2 * var(--s1)));
  transform-origin: 50% 30%;
  transform: translate3d(0, calc((1 - var(--E)) * 100px), calc((1 - var(--E)) * -160px))
    rotateX(calc(((1 - var(--E)) * 14deg + (1 - var(--k1)) * 38deg) * var(--tilt) + var(--A) * 7deg)) rotateY(calc(var(--A) * -8deg))
    rotateZ(calc((1 - var(--k1)) * -2deg * var(--tilt)));
}
.m .s-cal :is(.hb-ev.drag, .hb-ev.drag .hb-ev__text) {
  --s: clamp(0, (var(--p) - .12) / .32, 1); --k: calc(var(--s) * var(--s) * (3 - 2 * var(--s)));
  --g: calc(.3333 + var(--k) * .6667);
  transform-origin: 50% 0;
}
.m .s-cal .hb-ev.drag { opacity: clamp(0, (var(--p) - .1) / .015, 1); transform: scaleY(var(--g)); }
.m .s-cal .hb-ev.drag .hb-ev__text { transform: scaleY(calc(1 / var(--g))); }
.m .drag-ptr {
  display: block; position: absolute; z-index: 40; width: 18px; height: 18px; pointer-events: none;
  --s: clamp(0, (var(--p) - .12) / .32, 1); --k: calc(var(--s) * var(--s) * (3 - 2 * var(--s)));
  --g: calc(.3333 + var(--k) * .6667);
  opacity: calc(clamp(0, (var(--p) - .1) / .015, 1) - clamp(0, (var(--p) - .47) / .03, 1));
  transform: translateY(calc(var(--g) * var(--eh)));
}
.m .cal-pop {
  --s: clamp(0, (var(--p) - .47) / .07, 1); --k: calc(var(--s) * var(--s) * (3 - 2 * var(--s)));
  opacity: var(--k); transform: translate3d(calc((1 - var(--k)) * -16px), 0, calc(24px + (1 - var(--k)) * 100px));
}

/* ---------- offline: three cards in space, always fanned; the card whose step plays comes forward ---------- */
@media (min-width: 1101px) {
  .m .fan { display: block; position: relative; height: 440px; transform-style: preserve-3d; }
  .m .card {
    position: absolute; top: 20px; width: 300px;
    --E: calc(1 - (1 - var(--e)) * (1 - var(--e)) * (1 - var(--e)));
    /* --g: how far this card is forward, a plateau from --a to --b */
    --g: calc(clamp(0, (var(--p) - var(--a)) / .05, 1) - clamp(0, (var(--p) - var(--b)) / .05, 1));
    --k: calc(var(--g) * var(--g) * (3 - 2 * var(--g)));
    /* every card keeps the same turn, side by side in a staircase in depth; the one that plays comes forward along z
       and up a little. They never stand in front of each other's words. */
    transform: translate3d(calc((1 - var(--E)) * 60px), calc((1 - var(--E)) * 80px - var(--k) * 16px), calc(var(--z) + var(--k) * 90px + (1 - var(--E)) * -160px))
      rotateY(-20deg) rotateX(5deg);
  }
  .m .card:nth-child(1) { left: 0; --z: 0px; --a: -1; --b: .36; }
  .m .card:nth-child(2) { left: calc(50% - 150px); --z: -70px; --a: .36; --b: .66; }
  .m .card:nth-child(3) { left: calc(100% - 300px); --z: -140px; --a: .66; --b: 2; }
}
.m .off-pane .toastbox.ap { --dy: 12px; }

/* ---------- colors: each palette wipes across the last, left to right, behind a 1 px edge in its accent. The layer
   slides in and its window slides back by the same amount, so the window holds still and only the edge moves. ---------- */
.m .s-colors > .tilt3d {
  --in: 1; --f0: .86;
  transform: translate3d(0, calc((1 - var(--E)) * 90px), calc((1 - var(--E)) * -200px))
    rotateX(calc(var(--A) * 9deg)) rotateY(calc(var(--A) * -7deg)) scale(calc(1 - (1 - var(--E)) * .08));
}
.m .col-win { container-type: inline-size; }
.m .col-layer { overflow: visible; }
.m .col-layer, .m .col-layer > .win { --s: clamp(0, (var(--p) - var(--a)) / .2, 1); --k: calc(var(--s) * var(--s) * (3 - 2 * var(--s))); }
.m .col-layer { transform: translateX(calc((var(--k) - 1) * 100cqw)); overflow: hidden; }
.m .col-layer > .win { transform: translateX(calc((1 - var(--k)) * 100cqw)); }
.m .col-layer:nth-child(2), .m .col-layer:nth-child(2) > .win { --a: .2; }
.m .col-layer:nth-child(3), .m .col-layer:nth-child(3) > .win { --a: .56; }
/* the edge rides on the layer's right side, with the palette's name on it while it moves */
.m .col-layer > .edge {
  display: block; position: absolute; z-index: 2; top: 0; bottom: 0; right: 0; width: 1px; background: var(--edge); box-shadow: 0 0 18px 1px var(--edge);
  --s: clamp(0, (var(--p) - var(--a)) / .2, 1);
  opacity: clamp(0, min(var(--s), 1 - var(--s)) * 30, 1);
}
.edge b { position: absolute; top: 16px; right: 10px; padding: 4px 8px; border-radius: 6px; font: 500 12px/16px var(--mono); color: oklch(0.17 0.004 285); background: var(--edge); white-space: nowrap; }

/* ---------- privacy: it holds its turn while it is read, then turns most of the way flat ---------- */
.m .s-priv > .tilt3d {
  --in: 1.2; --f0: .5;
  transform: translate3d(0, calc((1 - var(--E)) * 90px), calc((1 - var(--E)) * -200px))
    rotateX(calc(var(--A) * 7deg)) rotateY(calc(var(--A) * 12deg)) scale(calc(1 - (1 - var(--E)) * .08));
}

/* One appear step: from --a over --l, eased in and out (smoothstep); site.js sets --a on layers in a sequence. */
.m .ap {
  --s: clamp(0, (var(--p) - var(--a)) / var(--l, .05), 1);
  --k: calc(var(--s) * var(--s) * (3 - 2 * var(--s)));
  opacity: var(--k); transform: translateY(calc((1 - var(--k)) * var(--dy, 6px)));
}

/* phone: a smaller key in the row gutter */
@media (max-width: 720px) { .m .keycap { width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 8px; } .m .keycap kbd { font-size: 14px; } }
