/* Motion layer for the landing page.
   Everything here is opt-in: rules only apply once JS adds .motion-ready to <html>, so a failed
   script leaves the page exactly as it renders without this file. Positions and opacity only, no
   layout properties, so nothing here can shift the page after paint. */

/* --- line masks ------------------------------------------------------------ */
.m-line { display: block; overflow: hidden; }
.m-line-in {
  display: inline-block;
  transform: translate3d(0, 110%, 0);
  transition: transform .95s cubic-bezier(.19, 1, .22, 1);
  will-change: transform;
}
.motion-ready .is-in .m-line-in { transform: translate3d(0, 0, 0); }

/* --- section reveals ------------------------------------------------------ */
.motion-ready .m-reveal {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition: opacity .7s ease, transform .8s cubic-bezier(.19, 1, .22, 1);
}
.motion-ready .m-reveal.is-in { opacity: 1; transform: none; }

/* --- magnetic primary actions -------------------------------------------- */
.m-magnet { transition: transform .35s cubic-bezier(.22, 1, .36, 1); }

/* --- cursor aura (pointer devices only) ---------------------------------- */
#m-aura {
  position: fixed; left: 0; top: 0; width: 260px; height: 260px; margin: -130px 0 0 -130px;
  border-radius: 50%; pointer-events: none; z-index: 3; opacity: 0;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 16%, transparent), transparent 72%);
  transition: opacity .5s ease;
}
.motion-ready #m-aura { opacity: .45; }
#m-aura.is-hot { opacity: .9; }
@media (hover: none), (pointer: coarse) { #m-aura { display: none; } }

/* --- grain ---------------------------------------------------------------
   Static plate, painted once. A moving grain layer repainted the whole viewport
   twelve times a second and cost a third of the frame budget on a GPU-less host. */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 2; pointer-events: none; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

/* --- contour fields ------------------------------------------------------ */
/* Both canvases are taken out of flow. A canvas left in flow is a transparent block of its own
   size, which reads as a long empty gap under the content that follows it. */
.m-field, #m-field {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
  opacity: .5; z-index: 0;
}
.m-host { position: relative; }
.hero { position: relative; }
.hero > * { position: relative; z-index: 1; }
.m-host > *:not(.m-field) { position: relative; z-index: 1; }

/* --- device tilt --------------------------------------------------------- */
.showcase-device { perspective: 1200px; }
.showcase-device .slider {
  transform: rotateX(var(--tx, 0deg)) rotateY(var(--ty, 0deg));
  transition: transform .45s cubic-bezier(.22, 1, .36, 1);
}
.showcase-device .slide img { transform: translate3d(var(--ix, 0px), var(--iy, 0px), 0) scale(1.02); transition: transform .45s ease; }

/* --- spec tape ----------------------------------------------------------- */
.m-tape {
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  overflow: hidden; padding: .7rem 0; background: color-mix(in srgb, var(--panel) 60%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}
.m-tape-track { display: flex; width: max-content; gap: 2.2rem; animation: m-scroll 38s linear infinite; }
.m-tape:hover .m-tape-track, .m-tape:focus-within .m-tape-track { animation-play-state: paused; }
.m-tape span { font: .78rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.m-tape b { color: var(--accent); font-weight: 600; }
@keyframes m-scroll { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-50%, 0, 0); } }

/* --- sticky header retreat ---------------------------------------------- */
.site-head { transition: transform .4s cubic-bezier(.22, 1, .36, 1), box-shadow .3s ease; }
.site-head.m-nav-hidden { transform: translateY(-105%); }

/* --- intro curtain ------------------------------------------------------- */
#m-intro {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; gap: 1rem;
  background: var(--bg); transition: opacity .5s ease, visibility .5s;
}
#m-intro.is-done { opacity: 0; visibility: hidden; }
#m-intro i {
  display: block; height: 1px; width: min(38vw, 320px); background: var(--line); position: relative; overflow: hidden;
}
#m-intro i::after {
  content: ""; position: absolute; inset: 0; background: var(--accent);
  transform: scaleX(0); transform-origin: left; animation: m-load .9s cubic-bezier(.22, 1, .36, 1) forwards;
}
#m-intro b { font: 600 .72rem/1 ui-monospace, monospace; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); }
@keyframes m-load { to { transform: scaleX(1); } }

/* --- reduced motion: keep the page honest, just still ------------------- */
@media (prefers-reduced-motion: reduce) {
  .m-line-in, .motion-ready .m-reveal, .showcase-device .slider, .showcase-device .slide img {
    transform: none !important; opacity: 1 !important; transition: none !important;
  }
  .m-tape-track { animation: none; }
  #m-intro { display: none; }
  #m-grain, #m-aura, #m-field { display: none; }
}

/* --- lite mode ----------------------------------------------------------- */
/* Set by the frame-cost governor when the device cannot hold the ambient layers. The page keeps
   its typography, masks, reveals and tape; only the two full-viewport paints go. */
.m-lite #m-aura, .m-lite #m-field { display: none !important; }

/* --- signal rail ---------------------------------------------------------
   A 22px instrument strip riding the bottom edge of the sticky header. The wave shape comes from a
   fixed seed, so it is the same shape every load; only its amplitude follows how fast you scroll.
   Its second job is scroll position: the accent segment fills left to right as the page advances. */
.signal-rail {
  position: absolute; left: 0; right: 0; bottom: -22px; height: 22px; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  overflow: hidden;
}
.signal-rail canvas { display: block; width: 100%; height: 22px; }
@media (prefers-reduced-motion: reduce) { .signal-rail { display: none; } }
