/* ==========================================================================
   SyncLoad — Motion System
   Scroll choreography, depth, and micro-interactions.
   Loads after index.css — load this second.
   ========================================================================== */

:root {
  --ease-expo:  cubic-bezier(0.16, 1, 0.30, 1);
  --ease-power: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --------------------------------------------------------------------------
   1. Scroll progress rail
   -------------------------------------------------------------------------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 2000;
  background: linear-gradient(90deg, var(--blue), #00d4ff);
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   2. Film grain — subtle tactile depth
   -------------------------------------------------------------------------- */
.grain {
  position: fixed;
  inset: -60%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 8s steps(6) infinite;
}
@keyframes grainShift {
  0%, 100% { transform: translate(0, 0); }
  16%      { transform: translate(-2%, -3%); }
  33%      { transform: translate(3%, -1%); }
  50%      { transform: translate(-1%, 2%); }
  66%      { transform: translate(2%, 3%); }
  83%      { transform: translate(-3%, 1%); }
}

/* --------------------------------------------------------------------------
   3. Header — auto-hide on scroll down, link underline sweep
   -------------------------------------------------------------------------- */
.site-header {
  transition: box-shadow .2s, transform .5s var(--ease-expo);
}
.site-header.is-hidden { transform: translateY(-100%); }

.nav-link { position: relative; }
.nav-link::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 2px; border-radius: 2px;
  background: #4d8fff;
  transform: scaleX(0);
  transform-origin: 100% 50%;
  transition: transform .4s var(--ease-expo);
}
.nav-link:hover::after {
  transform: scaleX(1);
  transform-origin: 0 50%;
}

/* --------------------------------------------------------------------------
   4. Reveal engine upgrade — blur-to-sharp focus pull + directional variants
   -------------------------------------------------------------------------- */
.reveal {
  transition:
    opacity .9s var(--ease-expo),
    transform .9s var(--ease-expo),
    filter .7s var(--ease-expo);
  filter: blur(6px);
  will-change: transform, opacity;
}
.reveal.is-visible {
  filter: blur(0);
  will-change: auto;
}

.reveal-left  { transform: translate3d(-46px, 0, 0); }
.reveal-right { transform: translate3d(46px, 0, 0); }
.reveal-left.is-visible,
.reveal-right.is-visible { transform: translate3d(0, 0, 0); }

.reveal-delay-1 { transition-delay: .1s; }
.reveal-delay-2 { transition-delay: .2s; }
.reveal-delay-3 { transition-delay: .3s; }
.reveal-delay-4 { transition-delay: .4s; }

/* Auto-stagger sibling cards inside these grids by source order */
.features-grid > .reveal:nth-child(1) { transition-delay: 0s; }
.features-grid > .reveal:nth-child(2) { transition-delay: .06s; }
.features-grid > .reveal:nth-child(3) { transition-delay: .12s; }
.features-grid > .reveal:nth-child(4) { transition-delay: .18s; }
.features-grid > .reveal:nth-child(5) { transition-delay: .24s; }
.features-grid > .reveal:nth-child(6) { transition-delay: .30s; }
.features-grid > .reveal:nth-child(7) { transition-delay: .36s; }
.features-grid > .reveal:nth-child(8) { transition-delay: .42s; }
.features-grid > .reveal:nth-child(9) { transition-delay: .48s; }

.price-cards > .reveal:nth-child(1) { transition-delay: 0s; }
.price-cards > .reveal:nth-child(2) { transition-delay: .1s; }
.price-cards > .reveal:nth-child(3) { transition-delay: .2s; }

/* --------------------------------------------------------------------------
   5. Masked word reveal — heading entrance
   Words only start hidden once JS has actually split them (.is-split is
   added by the same script that wraps the text), so content never
   disappears if JS fails to run. The reveal itself piggybacks on the
   site's existing .reveal/.is-visible scroll observer on the ancestor —
   no second observer needed.
   -------------------------------------------------------------------------- */
.w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: .14em;
  margin-bottom: -.14em;
}
.is-split .w__i {
  display: inline-block;
  transform: translate3d(0, 112%, 0) rotate(3deg);
  opacity: 0;
  transition: transform 1s var(--ease-expo), opacity .7s var(--ease-expo);
  transition-delay: var(--wd, 0s);
  will-change: transform;
}
.reveal.is-visible .is-split .w__i {
  transform: translate3d(0, 0, 0) rotate(0);
  opacity: 1;
}
/* Gradient-clipped text (if any is added later) can't use the overflow
   mask — it may wrap to multiple lines, so it fades/slides instead. */
.is-split .w--plain { overflow: visible; padding-bottom: 0; margin-bottom: 0; }
.is-split .w--plain .w__i { transform: translate3d(0, 0.3em, 0) rotate(0); }
.reveal.is-visible .is-split .w--plain .w__i { transform: translate3d(0, 0, 0); }

/* --------------------------------------------------------------------------
   6. Card depth — 3D tilt + cursor spotlight
   -------------------------------------------------------------------------- */
.tilt {
  transform:
    perspective(1000px)
    rotateX(var(--rx, 0deg))
    rotateY(var(--ry, 0deg))
    translate3d(0, var(--lift, 0px), 0);
  transition: transform .5s var(--ease-expo), box-shadow .5s var(--ease-expo);
}
.tilt.is-tilting { transition: transform .12s linear, box-shadow .5s var(--ease-expo); }

.spotlight { position: relative; isolation: isolate; }
.spotlight::before {
  content: "";
  position: absolute; inset: 0;
  z-index: 0;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease;
  background: radial-gradient(
    340px circle at var(--mx, 50%) var(--my, 50%),
    rgba(29, 107, 255, .10),
    transparent 62%
  );
}
.spotlight:hover::before { opacity: 1; }
.spotlight > * { position: relative; z-index: 1; }

/* Dark-surface cards (phone mocks, how-col visual float) get a brighter spot */
.app-phones .spotlight::before,
.phone-mock.spotlight::before {
  background: radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%), rgba(0, 194, 255, .18), transparent 62%);
}

/* --------------------------------------------------------------------------
   7. Magnetic buttons + shine sweep
   -------------------------------------------------------------------------- */
.btn {
  transform: translate3d(var(--btn-x, 0px), var(--btn-y, 0px), 0);
}
.btn.is-magnetic { transition: transform .15s var(--ease-power); }

.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: -60%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent);
  transform: skewX(-18deg);
  transition: left .75s var(--ease-expo);
  pointer-events: none;
}
.btn-primary:hover::after { left: 125%; }

.store-badge { transform: translate3d(var(--btn-x, 0px), var(--btn-y, 0px), 0); }
.store-badge.is-magnetic { transition: transform .15s var(--ease-power), box-shadow .35s ease, background .2s; }

/* --------------------------------------------------------------------------
   8. Parallax — hero background drifts slower than scroll
   -------------------------------------------------------------------------- */
.hero-bg {
  transform: translate3d(0, var(--py, 0px), 0) scale(1.08);
  will-change: transform;
}

/* --------------------------------------------------------------------------
   9. Numerals stay aligned
   -------------------------------------------------------------------------- */
.proof-item strong, .phone-stat-value { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   10. Focus states
   -------------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 6px;
}

/* --------------------------------------------------------------------------
   11. Reduced motion — everything resolves instantly and visibly
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal, .w__i {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
  .grain { display: none; }
  .hero-bg { transform: none !important; }
  .site-header.is-hidden { transform: none !important; }
}

/* --------------------------------------------------------------------------
   12. Touch devices — skip tilt/magnetic/parallax, keep reveal + grain
   -------------------------------------------------------------------------- */
@media (pointer: coarse) {
  .tilt { transform: none !important; }
  .spotlight::before { display: none; }
}
