/* =========================================================
   Digi Gosticx: motion system
   Source: design/boards/Motion-System.dc.html (12 types)
   - Scroll-linked effects use CSS scroll-driven animations
     (animation-timeline: view() / scroll()). No JavaScript.
   - Every view() range ends with the element fully visible
     (entry 100%), so nothing is left half-faded.
   - Browsers without scroll timelines simply show the final
     state (all scroll effects live inside @supports).
   - prefers-reduced-motion: reduce turns everything off.

   How to use on a page (class hooks):
   01 Text reveal ........ .hero h1 (on load) · .sec .h2 / .th-dark .h2 (wipe on scroll)
   02 Fade and move ...... .m-card (stagger 3 at a time)
   03 Mountain parallax .. .hero (ridgeline ::before/::after)
   04 Ticker ............. .ticker > .ticker-t > span (content twice)
   05 Zoom scroll ........ .signature > .wrap
   06 Spiral 3D .......... .signature (rings ::before/::after)
   07 Scroll rotation .... .final-cta (badge ::after)
   08 Horizontal scroll .. .m-hz
   09 Sticky ............. .m-sticky
   10 3D tilt ............ .m-card:hover / .m-tilt:hover
   11 Parallax ........... .hero .orb · footer .ft-wm
   12 Fade ............... .hero .intro (on load) · .m-fade · footer
   ========================================================= */

/* ---------- 01 Text reveal (hero H1, on load) ---------- */
.hero h1 { animation: mx-h1 1.1s var(--ease) both; }
@keyframes mx-h1 {
  from { clip-path: inset(0 0 100% 0); translate: 0 40px; opacity: 0; }
  to { clip-path: inset(-10% -10% -10% -10%); translate: 0 0; opacity: 1; }
}

/* ---------- 12 Fade (hero intro, on load) ---------- */
.hero .intro, .hero .m-in { animation: mx-fade .9s .35s var(--ease) both; }
.hero .m-in-2 { animation: mx-fade .9s .5s var(--ease) both; }
@keyframes mx-fade { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }

/* ---------- Hero shell + 03 Mountain parallax ---------- */
.hero { position: relative; overflow: hidden; padding: 90px 0 130px; }
.hero > .wrap { position: relative; z-index: 1; }
.hero::before, .hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; z-index: 0; pointer-events: none;
  background-repeat: no-repeat; background-size: 100% 100%;
}
.hero::before {
  height: 120px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 220' preserveAspectRatio='none'><defs><linearGradient id='g' x1='0' x2='1'><stop offset='0' stop-color='%232457C9'/><stop offset='.5' stop-color='%237A2FD0'/><stop offset='1' stop-color='%23C42A6B'/></linearGradient></defs><path d='M0 220 L0 150 L120 96 L230 140 L360 60 L470 128 L600 70 L720 136 L860 40 L990 120 L1110 74 L1240 132 L1340 90 L1440 120 L1440 220 Z' fill='url(%23g)' opacity='.20'/><path d='M0 150 L120 96 L230 140 L360 60 L470 128 L600 70 L720 136 L860 40 L990 120 L1110 74 L1240 132 L1340 90 L1440 120' fill='none' stroke='url(%23g)' stroke-width='2' stroke-dasharray='2 9' stroke-linecap='round' opacity='.9'/></svg>");
}
.hero::after {
  height: 44px; opacity: .9;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 160' preserveAspectRatio='none'><path d='M0 160 L0 120 L160 70 L300 112 L460 50 L620 104 L780 64 L940 118 L1100 58 L1260 100 L1440 72 L1440 160 Z' fill='%23000'/></svg>");
}

/* Hero glow orbs (11 Parallax) */
.orb { position: absolute; z-index: 0; border-radius: 50%; pointer-events: none; }
.orb-1 { width: 620px; height: 620px; right: -160px; top: -220px; background: radial-gradient(circle, rgba(122, 47, 208, .30), rgba(122, 47, 208, 0) 65%); }
.orb-2 { width: 420px; height: 420px; left: -140px; top: 160px; background: radial-gradient(circle, rgba(36, 87, 201, .22), rgba(36, 87, 201, 0) 65%); }
.orb-3 { width: 320px; height: 320px; right: 30%; bottom: -160px; background: radial-gradient(circle, rgba(196, 42, 107, .20), rgba(196, 42, 107, 0) 65%); }

/* ---------- 04 Ticker ---------- */
.ticker {
  position: relative; overflow: hidden; width: 100%; contain: inline-size;
  background: #000; border-top: 1px solid #1A1A1D; border-bottom: 1px solid #1A1A1D; padding: 18px 0;
}
.ticker-t { display: flex; width: max-content; animation: mx-tick 38s linear infinite; }
.ticker-t span {
  display: inline-flex; align-items: center; gap: 22px; padding: 0 22px;
  font: 600 15px var(--f-head); letter-spacing: -.01em; color: #B3B3B3; white-space: nowrap;
}
.ticker-t span::after { content: "✦"; color: #C4B5FD; }
.ticker:hover .ticker-t, .ticker:focus-within .ticker-t { animation-play-state: paused; }
@keyframes mx-tick { to { transform: translateX(-50%); } }

/* ---------- 06 Spiral 3D (signature section) ---------- */
.signature { position: relative; overflow: hidden; }
.signature > .wrap { position: relative; z-index: 1; }
.signature::before, .signature::after {
  content: ""; position: absolute; left: 50%; top: 50%; z-index: 0; border-radius: 50%; pointer-events: none;
}
.signature::before {
  width: 1100px; height: 1100px; margin: -550px 0 0 -550px;
  border: 1.5px dashed rgba(196, 181, 253, .22); animation: mx-spiral 40s linear infinite;
}
.signature::after {
  width: 720px; height: 720px; margin: -360px 0 0 -360px;
  border: 1px solid rgba(244, 114, 182, .18); border-top-color: rgba(138, 176, 255, .55);
  animation: mx-spiral2 26s linear infinite;
}
@keyframes mx-spiral { from { transform: perspective(1400px) rotateX(68deg) rotateZ(0); } to { transform: perspective(1400px) rotateX(68deg) rotateZ(360deg); } }
@keyframes mx-spiral2 { from { transform: perspective(1400px) rotateX(72deg) rotateY(14deg) rotateZ(360deg); } to { transform: perspective(1400px) rotateX(72deg) rotateY(14deg) rotateZ(0); } }

/* ---------- 07 Scroll rotation badge (final CTA) ---------- */
.final-cta { position: relative; overflow: hidden; padding: 110px 0; }
.final-cta::after {
  content: ""; position: absolute; right: max(24px, calc(50% - 700px)); top: 30px; z-index: 2;
  width: 150px; height: 150px; pointer-events: none;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><defs><path id='c' d='M100 100 m-78 0 a78 78 0 1 1 156 0 a78 78 0 1 1 -156 0'/></defs><circle cx='100' cy='100' r='98' fill='none' stroke='%23ffffff' stroke-opacity='.25'/><text font-family='Sora,Arial' font-size='15.5' font-weight='700' letter-spacing='4.2' fill='%23ffffff'><textPath href='%23c'>TRACE · DIAGNOSE · PLAN · RISE · DIGI GOSTICX · </textPath></text><circle cx='100' cy='100' r='9' fill='%23C4B5FD'/></svg>") center/contain no-repeat;
  animation: mx-spin 30s linear infinite;
}
@keyframes mx-spin { to { rotate: 360deg; } }
@media (max-width: 760px) { .final-cta::after { width: 96px; height: 96px; top: 14px; right: 12px; } }

/* ---------- 09 Sticky ---------- */
.m-sticky { position: sticky; top: calc(var(--hdr-h) + 16px); align-self: flex-start; }

/* ---------- 10 3D tilt on hover ---------- */
.m-card, .m-tilt { transition: transform .45s var(--ease), box-shadow .45s, border-color .3s; transform-style: preserve-3d; }
@media (hover: hover) {
  .m-card:hover, .m-tilt:hover {
    transform: perspective(900px) rotateX(5deg) rotateY(-4deg) translateY(-6px);
    box-shadow: 0 30px 60px -30px rgba(122, 47, 208, .45);
  }
}

/* ---------- Primary button shine ---------- */
.btn-p::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
  transform: skewX(-20deg); animation: mx-shine 3.8s ease-in-out infinite; pointer-events: none;
}
@keyframes mx-shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }

/* ---------- Scroll-driven effects ---------- */
@supports (animation-timeline: view()) {
  /* 01 Section titles wipe in left to right */
  .sec .h2, .th-dark .h2, .m-wipe { animation: mx-wipe linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  @keyframes mx-wipe { from { clip-path: inset(0 100% 0 0); opacity: .2; } to { clip-path: inset(-10% -10% -10% -10%); opacity: 1; } }
  .sec .tag, .th-dark .tag, .m-fade { animation: mx-fade linear both; animation-timeline: view(); animation-range: entry 0% entry 80%; }
  /* Hero items run on load, not on scroll */
  .hero .h2, .hero .tag { animation: mx-fade .9s .2s var(--ease) both; animation-timeline: auto; }

  /* 02 Cards rise 48px and fade in, three at a time */
  .m-card { animation: mx-move linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  .m-card:nth-child(3n+2) { animation-range: entry 10% entry 100%; }
  .m-card:nth-child(3n+3) { animation-range: entry 20% entry 100%; }
  @keyframes mx-move { from { opacity: 0; translate: 0 48px; scale: .96; } to { opacity: 1; translate: 0 0; scale: 1; } }

  /* 05 Zoom scroll: signature section scales from 86% */
  .signature > .wrap { animation: mx-zoom linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  @keyframes mx-zoom { from { scale: .86; opacity: .35; } to { scale: 1; opacity: 1; } }

  /* 07 Badge turns as you scroll past the final CTA */
  .final-cta::after { animation: mx-spin linear both; animation-timeline: view(); animation-range: cover 0% cover 100%; }

  /* 08 Horizontal: slides in sideways */
  .m-hz { animation: mx-hz linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  @keyframes mx-hz { from { translate: 18% 0; } to { translate: 0 0; } }

  /* 03 + 11 Hero ridgeline and orbs move slower than the page */
  .hero::before { animation: mx-par linear both; animation-timeline: scroll(root); animation-range: 0px 900px; }
  .hero .orb { animation: mx-par2 linear both; animation-timeline: scroll(root); animation-range: 0px 900px; }
  @keyframes mx-par { to { translate: 0 -70px; } }
  @keyframes mx-par2 { to { translate: 0 160px; } }

  /* 11 + 12 Footer wordmark rises, footer fades in */
  .ft-wm { animation: mx-wm linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  @keyframes mx-wm { from { translate: 0 60%; opacity: 0; } to { translate: 0 0; opacity: .3; } }
  .ft-g { animation: mx-fade linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
}

/* Header scroll progress bar */
@supports (animation-timeline: scroll()) {
  .hdr-prog { animation: mx-prog linear both; animation-timeline: scroll(root); }
  @keyframes mx-prog { to { transform: scaleX(1); } }
}

/* ---------- Reduced motion: final state, no movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .m-card:hover, .m-tilt:hover { transform: none; }
  .btn-p::after { display: none; }
  .hdr-prog { display: none; }
}
