/* The website's motion, shared by the homepage (React) and every static page.
   Cards that lean toward the pointer, and everything that moves with the
   scroll: driven by --p / --pc / --e, written by src/site3d/depth.ts.
   The page itself is plain white; nothing is drawn behind it.

   vercel.json caches /assets/* as immutable for a year and this file's name
   has no hash: after changing it, bump the ?v= on every link to it
   (index.html and all of public/*.html), or returning visitors keep the old one. */

/* ---------- Cards that lean toward the pointer ---------- */
.t3 {
  --tx: 0deg;
  --ty: 0deg;
  --mx: 50%;
  --my: 50%;
  transform: perspective(1200px) rotateX(var(--tx)) rotateY(var(--ty));
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.t3.t3-live { transition-duration: 0.16s, 0.7s; }
.t3--lift.t3-live { transform: perspective(1200px) rotateX(var(--tx)) rotateY(var(--ty)) translateZ(14px); }

.t3-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1;
}
.t3-sheen--white {
  background: radial-gradient(520px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 62%);
}
.t3-sheen--blue {
  background: radial-gradient(520px circle at var(--mx) var(--my), rgba(0, 74, 173, 0.085), rgba(0, 74, 173, 0) 62%);
}
.t3-live > .t3-sheen { opacity: 1; }

/* ---------- Moving with the scroll ----------
   --e  0..1  arrival: 0 below the screen, 1 once the top edge is 62% of the
              way down it. Arrival happens in the bottom third of the screen,
              so whatever is being read is always fully there.
   --p  0..1  the whole trip, bottom edge of the screen to off the top.
   --pc -1..1 the same, 0 at the middle of the screen.
   The individual translate / scale / rotate properties are used here, never
   `transform`, so they stack with the pointer lean (.t3) and the one-shot
   reveal instead of replacing them. */

/* Headings: each word lights up and rises in its turn. */
.m-words .w {
  display: inline-block;
  --wq: clamp(0, calc((var(--e, 1) * (var(--wn, 1) + 3) - var(--wi, 0)) / 3), 1);
  opacity: calc(0.12 + 0.88 * var(--wq));
  translate: 0 calc((1 - var(--wq)) * 0.42em);
}

/* Cards rise, grow to full size and settle. */
.m-card {
  opacity: clamp(0, calc(var(--e, 1) * 2.5), 1);
  translate: 0 calc((1 - var(--e, 1)) * 64px);
  scale: calc(0.92 + 0.08 * var(--e, 1));
}

/* Screenshots and pictures grow into place, then drift a little against the text. */
.m-shot {
  opacity: clamp(0, calc(var(--e, 1) * 2.5), 1);
  scale: calc(0.86 + 0.14 * var(--e, 1));
  translate: 0 calc(var(--pc, 0) * -28px);
}

/* Chat bubbles slide in from their own side. */
.m-start, .m-end { opacity: clamp(0, calc(var(--e, 1) * 2), 1); }
.m-start { translate: calc((1 - var(--e, 1)) * -64px) 0; }
.m-end   { translate: calc((1 - var(--e, 1)) * 64px) 0; }

/* The hero film sinks back a little as the page moves on past it. */
.m-recede { scale: calc(1 - max(0, var(--pc, 0) - 0.15) * 0.12); }

/* A phone turning as it passes: faces the reader at the middle of the screen. */
.d3-turn {
  transform: perspective(1400px) rotateY(calc(var(--pc, 0) * -16deg)) rotateX(calc(var(--pc, 0) * 5deg));
  transform-style: preserve-3d;
  will-change: transform;
}
.d3-turn--rev {
  transform: perspective(1400px) rotateY(calc(var(--pc, 0) * 16deg)) rotateX(calc(var(--pc, 0) * 5deg));
}
/* A screen opening toward the reader as it arrives, then flat. */
.d3-lift {
  --d3-k: max(0, calc(0.5 - var(--p, 0.5)));
  transform: perspective(1400px) rotateX(calc(var(--d3-k) * 36deg)) translateY(calc(var(--d3-k) * 70px));
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
  will-change: transform;
}
/* Decorations drifting at their own depth inside a band. */
.d3-orb { transform: translate3d(0, calc(var(--pc, 0) * var(--dz, 1) * -70px), 0); will-change: transform; }
.d3-float { transform: translate3d(0, calc(var(--pc, 0) * var(--dz, 1) * -36px), 0); will-change: transform; }

/* ---------- Rising into place, once ---------- */
@keyframes d3Rise {
  from { opacity: 0; transform: perspective(1200px) translateY(30px) rotateX(10deg); }
  to   { opacity: 1; transform: perspective(1200px) translateY(0) rotateX(0); }
}
.d3-rise { animation: d3Rise 1s cubic-bezier(0.22, 1, 0.36, 1) both; transform-origin: 50% 100%; }
.d3-rise-2 { animation-delay: 0.12s; }
.d3-rise-3 { animation-delay: 0.26s; }

html.site3d .rv {
  opacity: 0;
  transform: perspective(1000px) translateY(24px) rotateX(8deg);
  transform-origin: 50% 100%;
  transition:
    opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1) var(--rv-d, 0ms),
    transform 0.9s cubic-bezier(0.22, 1, 0.36, 1) var(--rv-d, 0ms);
}
html.site3d .rv.rv-in { opacity: 1; transform: none; }

/* Static-page cards gain a little depth of their own. */
html.site3d :is(.card, .k-card, .note, .post) {
  position: relative;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 14px 40px -18px rgba(0, 40, 100, 0.22);
}
html.site3d .t3--lift.t3-live:is(.card, .k-card, .note, .post) {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 30px 60px -22px rgba(0, 40, 100, 0.32);
}

/* ---------- Phones: every static page ----------
   The 70 pages with a `header.top` (blog, city pages, comparisons, for-schools)
   carry their own styles; these are the fixes they all need. */
@media (max-width: 640px) {
  /* The wordmark and the header link were 19-26px tall: a 44px target each,
     without changing how the bar looks. */
  header.top > a { display: inline-flex; align-items: center; min-height: 44px; }
  /* Privacy and terms. */
  body > .wrap > a.back { display: inline-flex; align-items: center; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .t3, .t3--lift.t3-live, .d3-turn, .d3-turn--rev, .d3-lift, .d3-orb, .d3-float { transform: none !important; }
  .m-card, .m-shot, .m-start, .m-end, .m-recede, .m-words .w { opacity: 1 !important; translate: none !important; scale: none !important; }
  .d3-rise { animation: none; }
  html.site3d .rv { opacity: 1; transform: none; transition: none; }
}
