/* =========================================================
   KryvexCore — motion layer
   Loaded AFTER style.css. Everything here is a progressive
   enhancement: with JS off, or reduced-motion, or if the
   animation CDNs fail, the page stays fully visible and usable
   (nothing is hidden unless html.has-motion is present, and
   motion.js removes that class the moment it can't animate).
   ========================================================= */

/* ---------- Lenis smooth scroll (official recommended CSS) ---------- */
html.lenis,
html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }
.lenis.lenis-smooth iframe { pointer-events: none; }

/* ---------- Reveal primitives (JS-gated, never blank without JS) ---------- */
.has-motion [data-animate] { opacity: 0; will-change: opacity, transform; }
.has-motion [data-hero]   { opacity: 0; }
/* failsafe: if motion.js never confirms it started, reveal everything */
.has-motion:not(.motion-run) [data-animate],
.has-motion:not(.motion-run) [data-hero] { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .has-motion [data-animate],
  .has-motion [data-hero] { opacity: 1 !important; transform: none !important; }
}

/* ---------- Hero canvas (particle field) ---------- */
.hero { isolation: isolate; }
.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: .55;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, #000 45%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 45%, transparent 100%);
}
.hero__inner { position: relative; z-index: 2; }
.hero__grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: clamp(24px, 5vw, 56px);
  align-items: center;
}
.hero__visual { display: flex; justify-content: center; }
@media (max-width: 960px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__visual { order: -1; transform: scale(.86); margin-bottom: -20px; }
}

/* kinetic headline: each word wrapped in a clip mask */
.hero h1 .word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: .14em;
  margin-bottom: -.14em;
}
.hero h1 .word > span { display: inline-block; will-change: transform; }
/* gradient on the final two words once the headline has been split */
.has-motion [data-hero-title] .word:nth-last-child(-n+2) > span {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Marquee ---------- */
.marquee {
  --gap: clamp(28px, 5vw, 64px);
  overflow: hidden;
  border-block: 1px solid var(--border-soft);
  padding-block: 18px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee__track {
  display: flex;
  align-items: center;
  gap: var(--gap);
  width: max-content;
  padding-left: var(--gap);
  will-change: transform;
}
.marquee__track span {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: clamp(1.1rem, 2.4vw, 1.55rem);
  letter-spacing: .01em;
  color: var(--text-muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--gap);
}
.marquee__track span::after {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand-2);
}

/* ---------- Scroll-scrubbed "build" sequence ---------- */
.build {
  position: relative;
  background: var(--bg-2);
  min-height: 100vh;
  overflow: clip;
}
.build__inner {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(48px, 9vw, 96px) var(--gutter);
  overflow: hidden;
}
.build__stage {
  position: relative;
  width: min(960px, 100%);
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(124,108,255,.10), transparent 55%),
    radial-gradient(120% 120% at 100% 100%, rgba(34,211,238,.08), transparent 55%),
    var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.build__canvas,
.build__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.build__video { object-fit: cover; }
.build__hud {
  position: absolute;
  left: 18px; right: 18px; bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: "Space Grotesk", sans-serif;
  font-size: .82rem;
  letter-spacing: .04em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.build__hud .step { min-width: 9ch; }
.build__bar { flex: 1; height: 3px; border-radius: 3px; background: var(--border); overflow: hidden; }
.build__bar i { display: block; height: 100%; width: 0%; background: var(--gradient); }
.build__caption {
  text-align: center;
  max-width: 620px;
  margin: 0 auto clamp(24px, 4vw, 40px);
}

/* ---------- Horizontal pinned track ---------- */
.hscroll-wrap { position: relative; background: var(--bg); overflow: clip; }
.hscroll-viewport { overflow: hidden; }
.hscroll {
  display: flex;
  gap: clamp(16px, 3vw, 32px);
  padding: 4px clamp(20px, 5vw, 40px);
  width: max-content;
  will-change: transform;
}
.hpanel {
  flex: 0 0 min(78vw, 440px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hpanel .num {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: .9rem;
  color: var(--brand-ink);
  background: var(--gradient);
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  margin-bottom: 8px;
}
@media (max-width: 760px) {
  /* no pinning on small screens — plain vertical stack */
  .hscroll {
    flex-direction: column;
    width: auto;
    padding-inline: 0;
  }
  .hpanel { flex: none; }
}

/* ---------- Tilt / spotlight cards ---------- */
.spotlight { position: relative; }
.spotlight::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(240px 240px at var(--mx, 50%) var(--my, 0%),
              color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%);
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .spotlight:hover::before { opacity: 1; }
}

/* ---------- Magnetic button ---------- */
.magnetic { will-change: transform; }

/* ---------- Scroll progress bar ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: var(--gradient);
  z-index: 200;
  pointer-events: none;
}

/* ---------- Section fade dividers ---------- */
.section-glow { position: relative; }
.section-glow::before {
  content: "";
  position: absolute;
  left: 50%; top: -1px;
  width: min(560px, 80%);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: .5;
}
