/* ═══════════════════════════════════════════════════════════════════
   Motion layer — creative animations for the public site.
   Patterns adapted from Magic UI (scroll-progress, word-rotate,
   hyper-text, number-ticker, blur-fade, animated-beam, magic-card,
   animated-grid-pattern, confetti); icons from Iconify (Lucide).
   Everything is disabled under prefers-reduced-motion.
   ═══════════════════════════════════════════════════════════════════ */

/* 1 ── scroll progress */
#mo-progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 1000;
  background: linear-gradient(90deg, var(--green-500), var(--amber-400));
  transform-origin: 0 50%; transform: scaleX(0);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
  pointer-events: none;
}

/* 2 ── hero word rotate */
.mo-rot {
  display: inline-block;
  background: linear-gradient(135deg, var(--green-500), var(--amber-400));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: opacity .45s ease, transform .55s cubic-bezier(.22,1,.36,1), filter .45s ease;
  will-change: transform, opacity, filter;
}
.mo-rot.out { opacity: 0; transform: translateY(-0.45em) rotateX(50deg); filter: blur(8px); }
.mo-rot.pre { opacity: 0; transform: translateY(0.45em) rotateX(-50deg); filter: blur(8px); transition: none; }
.sr-only-mo { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 3 ── haul truck driving along the stats bar */
.stats-bar.mo-road-on { position: relative; overflow: hidden; padding-top: 70px; }
.mo-road { position: absolute; left: 0; right: 0; top: 0; height: 64px; pointer-events: none; }
.mo-road::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 6px; height: 2px;
  background: repeating-linear-gradient(90deg, rgba(251,191,36,.45) 0 18px, transparent 18px 34px);
  animation: mo-lane 1.1s linear infinite;
}
@keyframes mo-lane { to { background-position: -34px 0; } }
.mo-truck {
  position: absolute; left: 0; bottom: 0; width: 120px; height: 60px; color: var(--green-500);
  transform: translateX(-160px);
  filter: drop-shadow(0 0 8px rgba(34,197,94,.35));
}
.mo-truck.go { animation: mo-drive 9s cubic-bezier(.45,.05,.55,.95) forwards; }
@keyframes mo-drive { to { transform: translateX(calc(100vw + 40px)); } }
.mo-truck svg { width: 100%; height: 100%; overflow: visible; }
.mo-truck .body { animation: mo-bob .32s ease-in-out infinite alternate; transform-origin: 50% 100%; }
@keyframes mo-bob { to { transform: translateY(-1.2px); } }
.mo-truck .wheel { transform-box: fill-box; transform-origin: center; animation: mo-spin .5s linear infinite; }
@keyframes mo-spin { to { transform: rotate(360deg); } }
.mo-truck .cargo { color: var(--amber-400); }
.mo-truck .cargo .jig { transform-box: fill-box; transform-origin: 50% 100%; animation: mo-jiggle .64s ease-in-out infinite alternate; }
.mo-truck .cargo > g:nth-child(2) .jig { animation-delay: .2s; }
@keyframes mo-jiggle { from { transform: rotate(-3deg); } to { transform: rotate(3deg) translateY(-1px); } }
.mo-dust {
  position: absolute; bottom: 8px; width: 8px; height: 8px; border-radius: 50%;
  background: rgba(214, 211, 199, .35); pointer-events: none;
  animation: mo-puff .9s ease-out forwards;
}
@keyframes mo-puff { to { transform: translate(-22px, -10px) scale(2.6); opacity: 0; } }
.stat-item.mo-hit .stat-num { animation: mo-pop .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes mo-pop { 40% { transform: scale(1.14); color: var(--amber-400); } }
.stat-num { display: inline-block; }

/* 4 ── blur-fade (extends the existing .reveal) */
.reveal, .mo-fade { filter: blur(6px); transition: opacity .7s ease, transform .7s cubic-bezier(.22,1,.36,1), filter .7s ease !important; }
.reveal.in, .mo-fade.in { filter: none; }
.mo-fade { opacity: 0; transform: translateY(18px); }
.mo-fade.in { opacity: 1; transform: none; }

/* 5 ── animated beam through the 3 steps */
.hiw-connector.mo-beam { opacity: 1; background: rgba(255,255,255,.08); overflow: hidden; }
.hiw-connector.mo-beam::after {
  content: ""; position: absolute; top: -1px; bottom: -1px; width: 28%;
  background: linear-gradient(90deg, transparent, var(--green-500), var(--amber-400), transparent);
  box-shadow: 0 0 14px rgba(251,191,36,.7);
  animation: mo-beam 4.5s cubic-bezier(.65,0,.35,1) infinite;
}
@keyframes mo-beam { from { left: -30%; } to { left: 102%; } }
.mo-beam-on .hiw-emoji { animation: mo-node 4.5s cubic-bezier(.65,0,.35,1) infinite; }
.mo-beam-on .hiw-step:nth-of-type(2) .hiw-emoji { animation-delay: 0s; }
.mo-beam-on .hiw-step:nth-of-type(3) .hiw-emoji { animation-delay: 1.6s; }
.mo-beam-on .hiw-step:nth-of-type(4) .hiw-emoji { animation-delay: 3.1s; }
@keyframes mo-node {
  0%, 30%, 100% { box-shadow: 0 0 0 0 rgba(251,191,36,0); }
  12% { box-shadow: 0 0 0 6px rgba(251,191,36,.18), 0 0 28px rgba(34,197,94,.55); transform: scale(1.08); }
}

/* 6 ── self-drawing icons */
.mo-draw path, .mo-draw circle, .mo-draw rect, .mo-draw line, .mo-draw polyline, .mo-draw ellipse {
  stroke-dasharray: 1; stroke-dashoffset: 1;
}
.mo-draw.drawn path, .mo-draw.drawn circle, .mo-draw.drawn rect, .mo-draw.drawn line, .mo-draw.drawn polyline, .mo-draw.drawn ellipse {
  stroke-dashoffset: 0; transition: stroke-dashoffset 1.3s cubic-bezier(.65,0,.35,1);
}

/* 7 ── magic card: cursor spotlight + 3D tilt (uses `rotate`, so existing hover transforms still apply) */
.svc-grid, .services-grid, .pricing-grid, .price-grid { perspective: 1100px; }
.mo-card { rotate: var(--mo-ax, 0) var(--mo-ay, 0) 0 var(--mo-deg, 0deg); transition: rotate .5s cubic-bezier(.22,1,.36,1), transform var(--transition), box-shadow var(--transition), border-color var(--transition); }
.mo-card.tilting { transition: rotate .08s linear, transform var(--transition), box-shadow var(--transition), border-color var(--transition); }
.mo-spot {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 0;
  opacity: 0; transition: opacity .35s ease;
  background: radial-gradient(420px circle at var(--mo-x, 50%) var(--mo-y, 50%), rgba(34,197,94,.13), transparent 45%);
}
.price-card .mo-spot { background: radial-gradient(380px circle at var(--mo-x, 50%) var(--mo-y, 50%), rgba(251,191,36,.14), transparent 45%); }
.mo-card:hover .mo-spot { opacity: 1; }
.mo-card > :not(.mo-spot) { position: relative; z-index: 1; }

/* 8 ── before/after "clean sweep" wipe */
.showcase-img-wrap.mo-sweep { position: relative; }
.showcase-img-wrap.mo-sweep img { clip-path: inset(0 100% 0 0); }
.showcase-img-wrap.mo-sweep.swept img { clip-path: inset(0 0 0 0); transition: clip-path 1.6s cubic-bezier(.65,0,.35,1); }
.mo-broom {
  position: absolute; top: 0; bottom: 0; left: 0; width: 3px; z-index: 2; pointer-events: none;
  background: linear-gradient(var(--green-500), var(--amber-400));
  box-shadow: 0 0 18px 4px rgba(251,191,36,.55); opacity: 0;
}
.swept .mo-broom { animation: mo-broom 1.6s cubic-bezier(.65,0,.35,1) forwards; }
@keyframes mo-broom { 0% { left: 0; opacity: 1; } 92% { opacity: 1; } 100% { left: 100%; opacity: 0; } }

/* 9 ── living hive behind the final CTA */
.mo-hive { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.mo-hive polygon { fill: transparent; stroke: rgba(255,255,255,.05); stroke-width: 1; transition: fill 1.4s ease, stroke 1.4s ease; }
.mo-hive polygon.lit { fill: rgba(251,191,36,.12); stroke: rgba(251,191,36,.35); }
.mo-hive polygon.lit.g { fill: rgba(34,197,94,.12); stroke: rgba(34,197,94,.35); }
.final-cta .fcta-inner { position: relative; z-index: 1; }

/* 10 ── magnetic buttons */
.mo-mag { transition: translate .35s cubic-bezier(.22,1,.36,1); }
.mo-mag.pulling { transition: translate .1s linear; }

/* 11 ── hexagon confetti canvas */
#mo-confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 10050; }

@media (max-width: 768px) {
  .stats-bar.mo-road-on { padding-top: 56px; }
  .mo-truck { width: 100px; height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  #mo-progress, .mo-road, .mo-hive, #mo-confetti, .mo-spot, .mo-broom { display: none !important; }
  .stats-bar.mo-road-on { padding-top: 28px; }
  .reveal, .mo-fade { filter: none !important; }
  .mo-draw path, .mo-draw circle, .mo-draw rect, .mo-draw line, .mo-draw polyline, .mo-draw ellipse { stroke-dashoffset: 0 !important; }
  .showcase-img-wrap.mo-sweep img { clip-path: none !important; }
  .hiw-connector.mo-beam::after, .mo-beam-on .hiw-emoji { animation: none !important; }
  .mo-card { rotate: none !important; }
}
