/* Motion layer. html.m is set in <head> when motion is allowed; html.m-on once js/motion.js runs.
   Keyframes use only a `from` state so each element settles on its own resting styles. */

@keyframes m-rise { from { opacity: 0; transform: translate3d(0, 1.75rem, 0); } }
@keyframes m-rise-sm { from { opacity: 0; transform: translate3d(0, 0.6rem, 0); } }
@keyframes m-fade { from { opacity: 0; } }
@keyframes m-line { from { transform: scaleX(0); } }
@keyframes m-word { from { transform: translate3d(0, 112%, 0) rotate(5deg); } }
@keyframes m-settle { from { scale: 1.16; } }
@keyframes m-arcs { from { opacity: 0; transform: translate3d(0, 38%, 0); } }
@keyframes m-drop { from { opacity: 0; transform: translate3d(0, -0.6rem, 0); } }
@keyframes m-pop { from { opacity: 0; transform: scale(0.4) rotate(-14deg); } }
@keyframes m-icon { from { opacity: 0; transform: translate3d(0, 0.5rem, 0) scale(0.7); } }

/* ---------- Page transitions (Chromium, same-origin navigations) ---------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
.site-header { view-transition-name: site-header; }
::view-transition-old(root) { animation: 0.3s var(--ease-smooth) both vt-out; }
::view-transition-new(root) { animation: 0.45s var(--ease-expo) both m-fade; }
::view-transition-group(site-header) { animation-duration: 0.45s; animation-timing-function: var(--ease-expo); }
@keyframes vt-out { to { opacity: 0; transform: translate3d(0, -0.75rem, 0); } }

/* ---------- Split headings ---------- */
.w {
  display: inline-block;
  overflow: clip;
  vertical-align: top;
  padding: 0 0.06em 0.16em;
  margin: 0 -0.06em -0.16em;
}
.w > span { display: inline-block; transform-origin: 0 100%; }

/* ---------- Hero entrance ---------- */
html.m main > :first-child h1:not(.is-split) { opacity: 0; }
html.m main > :first-child h1.is-split .w > span {
  animation: m-word 1.15s var(--ease-expo) both;
  animation-delay: calc(0.18s + var(--i, 0) * 55ms);
}

html.m :is(.home-hero-copy, main > header:first-child .max-w-3xl, main > section:first-child > .py-28, .post-page > div) > :not(h1, .post-grid) {
  animation: m-rise 1s var(--ease-expo) both;
}
html.m :is(.home-hero-copy, main > header:first-child .max-w-3xl, main > section:first-child > .py-28, .post-page > div) > :nth-child(1) { animation-delay: 0.05s; }
html.m :is(.home-hero-copy, main > header:first-child .max-w-3xl, main > section:first-child > .py-28, .post-page > div) > :nth-child(2) { animation-delay: 0.14s; }
html.m :is(.home-hero-copy, main > header:first-child .max-w-3xl, main > section:first-child > .py-28, .post-page > div) > :nth-child(3) { animation-delay: 0.5s; }
html.m :is(.home-hero-copy, main > header:first-child .max-w-3xl, main > section:first-child > .py-28, .post-page > div) > :nth-child(4) { animation-delay: 0.64s; }
html.m :is(.home-hero-copy, main > header:first-child .max-w-3xl, main > section:first-child > .py-28, .post-page > div) > :nth-child(5) { animation-delay: 0.76s; }
html.m .post-page > div > .post-grid { animation: m-rise 1.1s var(--ease-expo) 0.42s both; }
html.m main > :first-child p.uppercase::before { transform-origin: 0 50%; animation: m-line 1s var(--ease-expo) 0.2s both; }
html.m .home-hero-foot { animation: m-rise 1.1s var(--ease-expo) 0.9s both; }

html.m .home-hero-bg,
html.m main > .isolate.bg-ink:first-child > .absolute.inset-0.overflow-hidden > img {
  animation: m-settle 2.6s var(--ease-smooth) both;
}
html.m main > .isolate.bg-ink:first-child:not(.home-hero)::after {
  animation: m-arcs 1.7s var(--ease-expo) 0.3s both;
}
main > .isolate.bg-ink:first-child:not(.home-hero)::after { translate: var(--ax, 0px) var(--ay, 0px); }

/* ---------- Scroll reveals ---------- */
html.m-on .rv {
  opacity: 0;
  transform: translate3d(0, 2rem, 0);
  transition: opacity 0.9s var(--ease-smooth), transform 1.15s var(--ease-expo);
  transition-delay: var(--rd, 0ms);
}
html.m-on .rv.rv-scale { transform: translate3d(0, 2rem, 0) scale(0.96); }
html.m-on .rv.in { opacity: 1; transform: none; }

html.m-on .rv-clip {
  clip-path: inset(100% 0 0 0 round var(--r, 1rem));
  transition: clip-path 1.3s var(--ease-expo);
  transition-delay: var(--rd, 0ms);
}
html.m-on .rv-clip img { scale: 1.22; transition: scale 1.8s var(--ease-expo); transition-delay: var(--rd, 0ms); }
html.m-on .rv-clip.in { clip-path: inset(0 0 0 0 round var(--r, 1rem)); }
html.m-on .rv-clip.in img { scale: 1; }

html.m-on .rv-eyebrow { opacity: 0; transition: opacity 0.8s var(--ease-smooth) var(--rd, 0ms); }
html.m-on .rv-eyebrow::before {
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 1s var(--ease-expo) calc(var(--rd, 0ms) + 0.1s);
}
html.m-on .rv-eyebrow.in { opacity: 1; }
html.m-on .rv-eyebrow.in::before { transform: none; }

html.m-on .split .w > span {
  transform: translate3d(0, 112%, 0) rotate(5deg);
  transition: transform 1.1s var(--ease-expo);
  transition-delay: calc(var(--rd, 0ms) + var(--i, 0) * 45ms);
}
html.m-on .split.in .w > span { transform: none; }

/* Details that play once a card arrives. */
html.m-on .voice.rv.in .voice-mark { animation: m-pop 1s var(--ease-spring) calc(var(--rd, 0ms) + 0.25s) both; }
html.m-on .platform-grid > li.rv.in img { animation: m-icon 0.9s var(--ease-spring) calc(var(--rd, 0ms) + 0.1s) both; }

html.m-on .cta-band > div::after,
html.m-on footer.site-footer::after {
  transition: transform 1.6s var(--ease-expo) 0.2s, opacity 1.2s var(--ease-smooth) 0.2s;
}
html.m-on .cta-band > div:not(.seen)::after,
html.m-on footer.site-footer:not(.seen)::after { opacity: 0; transform: translate3d(0, 40%, 0); }

/* ---------- Header: compacts on scroll, tucks away going down, returns going up ---------- */
.site-header {
  transition: background-color 0.5s var(--ease-expo), border-color 0.5s, box-shadow 0.5s, translate 0.6s var(--ease-expo);
}
.site-header .header-bar { transition: padding 0.5s var(--ease-expo); }
.site-header.is-hidden { translate: 0 -100%; }

/* ---------- Menus ---------- */
nav[aria-label="Primary"] > .group > div { background: var(--surface); }
@media (min-width: 1024px) {
  html.m-on nav[aria-label="Primary"] > .group:hover > div { animation: m-drop 0.45s var(--ease-expo) both; }
  html.m-on nav[aria-label="Primary"] > .group:hover > div a {
    animation: m-rise-sm 0.55s var(--ease-expo) both;
    animation-delay: calc(0.05s + var(--i, 0) * 28ms);
  }
}
html.m-on body.is-nav-open .mobile-nav { animation: m-fade 0.3s var(--ease-smooth) both; }
html.m-on body.is-nav-open .mobile-nav a {
  animation: m-rise-sm 0.6s var(--ease-expo) both;
  animation-delay: calc(0.05s + var(--i, 0) * 30ms);
}

/* ---------- Pointer effects ---------- */
.spot { --px: 50%; --py: 50%; }
.spot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(26rem circle at var(--px) var(--py), rgb(254 91 42 / 0.1), transparent 55%);
  opacity: 0;
  transition: opacity 0.45s var(--ease-smooth);
}
.spot:hover::after { opacity: 1; }

.logo-marquee:hover .logo-marquee-track { animation-play-state: paused; }
.logo-marquee img { transition: transform 0.5s var(--ease-expo); }
.logo-marquee li:hover img,
.logo-marquee a:hover img { transform: scale(1.08); }

/* ---------- Case study filters ---------- */
[data-work].is-filtering .work-item:not([hidden]) {
  animation: m-rise 0.8s var(--ease-expo) both;
  animation-delay: calc(var(--wi, 0) * 70ms);
}

/* ---------- Reading progress on articles ---------- */
.read-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 60;
  height: 3px;
  background: var(--orange);
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .site-header.is-hidden { translate: none; }
  .read-progress { display: none; }
}
