/* ============================================================
   MechatronicSurge - motion layer (added 2026-11-23)
   Loaded after styles.css. Almost everything here is scoped to
   html.fx - a class the small script in each page's <head> adds
   only when the visitor has NOT asked their device to reduce motion.
   To switch all of it off: remove the motion.css line, the inline
   script, and the motion.js line from the <head> of each page.
   ============================================================ */

/* ---- Page-to-page transitions (clicking between the 3 pages) ---- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .nav { view-transition-name: site-nav; }
  ::view-transition-old(root) { animation: fx-vt-out 0.26s cubic-bezier(0.4, 0, 1, 1) both; }
  ::view-transition-new(root) { animation: fx-vt-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both; }
}
@keyframes fx-vt-out { to { opacity: 0; transform: translateY(-14px) scale(0.985); filter: blur(6px); } }
@keyframes fx-vt-in { from { opacity: 0; transform: translateY(24px) scale(0.985); filter: blur(6px); } }

/* ---- Background layers: signal pulses + cursor flashlight on the grid ---- */
.fx-canvas, .fx-spot { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.fx-canvas { width: 100%; height: 100%; opacity: 0.9; }
.fx-spot {
  opacity: 0;
  transition: opacity 0.6s ease;
  background-image:
    radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%), rgba(245, 158, 11, 0.10), transparent 70%),
    linear-gradient(rgba(245, 158, 11, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245, 158, 11, 0.22) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
  -webkit-mask-image: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), #000 0%, transparent 72%);
  mask-image: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), #000 0%, transparent 72%);
}
.fx-spot.on { opacity: 1; }

/* Slow "breathing" of the amber glow behind the hero */
html.fx body::after { animation: fx-breathe 10s ease-in-out infinite alternate; }
@keyframes fx-breathe {
  from { opacity: 0.32; transform: translateX(-50%) scale(1); }
  to   { opacity: 0.55; transform: translateX(-50%) scale(1.12); }
}

/* ---- Nav: scroll progress bar + logo mark that turns as you scroll ---- */
.fx-progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--amber), var(--amber-soft), var(--steel));
  box-shadow: 0 0 12px var(--amber-glow);
  transform-origin: 0 50%;
  scale: 0 1;
  pointer-events: none;
}
@supports (animation-timeline: scroll()) {
  .fx-progress { animation: fx-grow linear both; animation-timeline: scroll(root block); }
  html.fx .brand-mark { animation: fx-spin linear both; animation-timeline: scroll(root block); }
}
@keyframes fx-grow { from { scale: 0 1; } to { scale: 1 1; } }
@keyframes fx-spin { to { rotate: 360deg; } }

/* ---- Hero intro: letters flip up one by one, then the rest rises in ---- */
html.fx .hero > *, html.fx .page-hero > * { opacity: 0; }
html.fx.fx-ready .hero > h1, html.fx.fx-ready .page-hero > h1 { opacity: 1; }
html.fx.fx-ready .hero > :not(h1), html.fx.fx-ready .page-hero > :not(h1) {
  animation: fx-rise 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: var(--d, 0.5s);
}
html.fx.fx-ready .hero > .accent-line { animation-name: fx-line; }
@keyframes fx-rise { from { opacity: 0; transform: translateY(26px); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes fx-line { from { opacity: 0; scale: 0 1; } to { opacity: 1; scale: 1 1; } }

html.fx .fx-word { display: inline-block; white-space: nowrap; perspective: 700px; }
html.fx .fx-ch { display: inline-block; opacity: 0; }
html.fx.fx-ready .fx-ch {
  animation: fx-ch-in 0.95s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(0.12s + var(--i, 0) * 0.036s);
}
@keyframes fx-ch-in {
  from { opacity: 0; transform: translateY(0.55em) rotateX(-75deg) scale(0.92); filter: blur(10px); }
  to   { opacity: 1; transform: none; filter: none; }
}
/* Home-page title keeps its white-to-amber gradient across the split letters */
html.fx .hero h1.fx-split { background: none; }
html.fx .hero h1.fx-split .fx-ch {
  background-image: linear-gradient(135deg, #fff 0%, var(--amber-soft) 100%);
  background-repeat: no-repeat;
  background-size: var(--w, 100%) 100%;
  background-position: calc(var(--x, 0px) * -1) 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Hero sinks back and fades as you scroll away from it */
@supports (animation-timeline: scroll()) {
  html.fx .hero, html.fx .page-hero {
    animation: fx-hero-out linear both;
    animation-timeline: scroll(root block);
    animation-range: 140px 680px;
  }
}
@keyframes fx-hero-out { to { opacity: 0.1; transform: translateY(-50px) scale(0.95); filter: blur(6px); } }

/* ---- Reveal on scroll (motion.js tags elements with data-rv) ---- */
html.fx [data-rv] {
  transition:
    opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1),
    translate 0.9s cubic-bezier(0.16, 1, 0.3, 1),
    scale 0.9s cubic-bezier(0.16, 1, 0.3, 1),
    filter 0.9s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: calc(var(--i, 0) * 70ms);
}
html.fx [data-rv]:not(.in) { opacity: 0; translate: 0 34px; filter: blur(8px); }
html.fx [data-rv="left"]:not(.in) { translate: -40px 0; }
html.fx [data-rv="right"]:not(.in) { translate: 40px 0; }
html.fx [data-rv="pop"]:not(.in) { translate: 0 22px; scale: 0.94; }
@media (max-width: 860px) {
  html.fx [data-rv="left"]:not(.in), html.fx [data-rv="right"]:not(.in) { translate: 0 28px; }
}

/* Section headings: each word slides up from behind a mask */
html.fx .fx-w { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: 0.14em; margin-bottom: -0.14em; }
html.fx .fx-wi { display: inline-block; translate: 0 115%; transition: translate 0.95s cubic-bezier(0.16, 1, 0.3, 1); transition-delay: calc(var(--i, 0) * 55ms); }
html.fx .in > .fx-w > .fx-wi { translate: 0 0; }

/* ---- Screenshot frames: tilt up out of the page as they scroll in ---- */
@supports (animation-timeline: view()) {
  html.fx .shot {
    transform-origin: 50% 100%;
    animation: fx-shot-in linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 42%;
  }
}
@keyframes fx-shot-in {
  from { opacity: 0.15; transform: perspective(1400px) rotateX(24deg) scale(0.86) translateY(70px); }
  to   { opacity: 1; transform: none; }
}

/* ---- Cards: glow that follows the cursor (tilt is applied by motion.js) ---- */
html.fx .card::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: radial-gradient(380px circle at var(--px, 50%) var(--py, 0%), rgba(245, 158, 11, 0.16), transparent 55%);
}
html.fx .card:hover::after { opacity: 1; }

/* ---- Buttons: pull toward the cursor + light sweep on hover ---- */
html.fx .btn {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease,
              translate 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
html.fx .btn-primary { position: relative; overflow: hidden; }
html.fx .btn-primary::after {
  content: "";
  position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-18deg);
  transition: left 0.6s ease;
  pointer-events: none;
}
html.fx .btn-primary:hover::after { left: 120%; }

/* ---- Stack chips become an endless conveyor (home page) ---- */
html.fx .fx-marquee {
  flex-wrap: nowrap;
  justify-content: flex-start !important;
  gap: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
html.fx .fx-track { display: flex; flex: none; gap: 0.6rem; padding-right: 0.6rem; animation: fx-marquee 34s linear infinite; }
html.fx .fx-marquee:hover .fx-track { animation-play-state: paused; }
html.fx .fx-marquee .chip { white-space: nowrap; font-size: 0.85rem; padding: 0.45rem 0.95rem; }
@keyframes fx-marquee { to { transform: translateX(-100%); } }

/* ---- Status pill: live pulse ---- */
html.fx .status::before { animation: fx-pulse 2.2s ease-out infinite; }
@keyframes fx-pulse {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---- Architecture diagram: boxes fade in by column, lines draw, data dots travel ---- */
html.fx .diagram.fx-d > rect, html.fx .diagram.fx-d > text { opacity: 0; transition: opacity 0.7s ease; transition-delay: var(--d, 0ms); }
html.fx .diagram.fx-d.in > rect, html.fx .diagram.fx-d.in > text { opacity: 1; }
html.fx .diagram .fx-dot { fill: #fbbf24; filter: drop-shadow(0 0 4px #f59e0b); }

/* ---- Printing: never hide anything ---- */
@media print {
  html.fx [data-rv], html.fx .hero > *, html.fx .page-hero > *, html.fx .fx-ch, html.fx .shot {
    opacity: 1 !important; translate: none !important; scale: none !important; filter: none !important;
    transform: none !important; animation: none !important;
  }
  html.fx .fx-wi { translate: none !important; }
  .fx-canvas, .fx-spot, .fx-progress { display: none !important; }
}
