/* =========================================================
   Motion layer
   Pairs with assets/motion.js. Every effect has a static
   fallback for reduced motion, touch devices and print.
   ========================================================= */

/* Hide hero until its intro timeline sets the start state (class removed by JS, 3 s safety timeout in <head>) */
.js-motion .hero-copy, .js-motion .hero-stage, .js-motion .hero-stats { visibility: hidden; }

/* ---------- Hero: aurora + grain + cursor spotlight (6.3, 6.5, 5) ---------- */
.hero::before { display: none; }
.hero-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.hero > .container, .hero .scroll-cue { position: relative; z-index: 1; }
.hero .scroll-cue { position: absolute; }
.aurora { position: absolute; display: block; border-radius: 50%; filter: blur(70px); opacity: .32; will-change: transform; }
.aurora.a1 { width: 46vw; height: 46vw; left: -10vw; top: -16vw; background: var(--chat); animation: drift1 22s ease-in-out infinite alternate; }
.aurora.a2 { width: 38vw; height: 38vw; right: -8vw; top: 4vw; background: var(--web); animation: drift2 26s ease-in-out infinite alternate; }
.aurora.a3 { width: 34vw; height: 34vw; left: 30vw; bottom: -20vw; background: var(--company); opacity: .22; animation: drift3 30s ease-in-out infinite alternate; }
:root[data-theme="light"] .aurora, :root:not([data-theme]) .aurora { opacity: .14; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .aurora { opacity: .17; } :root:not([data-theme="light"]) .aurora.a3 { opacity: .1; } }
:root[data-theme="dark"] .aurora { opacity: .17; }
:root[data-theme="dark"] .aurora.a3 { opacity: .1; }
@keyframes drift1 { to { transform: translate(8vw, 6vw) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-10vw, 8vw) scale(.92); } }
@keyframes drift3 { to { transform: translate(-6vw, -8vw) scale(1.15); } }
.grain {
  position: absolute; inset: -50%; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.hero-spot {
  position: absolute; inset: 0; opacity: 0; transition: opacity .5s;
  background: radial-gradient(420px circle at var(--hx, 50%) var(--hy, 40%), color-mix(in srgb, var(--primary) 16%, transparent), transparent 70%);
}
.hero.is-pointer .hero-spot { opacity: 1; }

/* Morphing blob behind Maya (4.4) */
.orbit-wrap { --mx: 0; --my: 0; }
.morph-blob {
  position: absolute; inset: 28%; z-index: 0; filter: blur(18px); opacity: .4;
  background: linear-gradient(135deg, var(--chat), var(--web) 60%, var(--company));
  border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%;
  animation: morph 12s ease-in-out infinite alternate;
}
@keyframes morph {
  33% { border-radius: 63% 37% 41% 59% / 55% 62% 38% 45%; }
  66% { border-radius: 38% 62% 56% 44% / 63% 35% 65% 37%; }
  100% { border-radius: 55% 45% 35% 65% / 45% 58% 42% 55%; }
}
.orbit-ring, .orbit-spin, .orbit-core { z-index: 1; }
.orbit-core { position: absolute; }

/* Mouse parallax (5) via the independent `translate` property, floating bubbles (7.4) via transform */
.orbit-ring { translate: calc(var(--mx) * 6px) calc(var(--my) * 6px); }
.orbit-core { translate: calc(var(--mx) * 10px) calc(var(--my) * 10px); }
.bubble-float.b1 { translate: calc(var(--mx) * -18px) calc(var(--my) * -14px); animation: float1 6s ease-in-out infinite; }
.bubble-float.b2 { translate: calc(var(--mx) * 16px) calc(var(--my) * 18px); animation: float2 7s ease-in-out infinite; }
.bubble-float { z-index: 2; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); background: color-mix(in srgb, var(--surface) 80%, transparent); }
@keyframes float1 { 50% { transform: translateY(-8px); } }
@keyframes float2 { 50% { transform: translateY(7px); } }
.bubble-float.swap { opacity: 0; filter: blur(4px); }

/* ---------- Split text (3.2 / 3.3) ---------- */
.split-w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .1em; margin-bottom: -.1em; }
.split-i { display: inline-block; will-change: transform; }
.grad.grad-split { background: none; color: inherit; -webkit-text-fill-color: initial; }
.grad-split .split-i { -webkit-background-clip: text; background-clip: text; color: transparent; }


/* ---------- 3D tilt + spotlight cards (2.4, 5) ---------- */
.tilt { transform-style: preserve-3d; will-change: transform; }
.tilt::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: radial-gradient(260px circle at var(--sx, 50%) var(--sy, 50%), color-mix(in srgb, var(--primary) 12%, transparent), transparent 70%);
}
.tilt:hover::after { opacity: 1; }
.tilt:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }

/* ---------- Sliding indicators (state-based / FLIP-style, 4.2) ---------- */
.nav { position: relative; }
.nav a { position: relative; z-index: 1; }
.nav a.active { background: transparent; }
.nav-ind { position: absolute; left: 0; top: 50%; height: 26px; margin-top: -13px; border-radius: 6px; background: var(--primary-soft); opacity: 0; z-index: 0; pointer-events: none;
  transition: transform .5s cubic-bezier(.3, .9, .3, 1), width .5s cubic-bezier(.3, .9, .3, 1), opacity .3s; }
/* Animated underline on hover (2.7) */
.nav a::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 2px; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .35s cubic-bezier(.3, .9, .3, 1); opacity: .5; }
.nav a:hover::after { transform: scaleX(1); }
.nav a.active::after { display: none; }
.nav a:hover { background: transparent; }

.tabs { position: relative; }
.tabs .tab { position: relative; z-index: 1; transition: color .3s, border-color .3s; }
.tabs.has-ind .tab[aria-selected="true"] { background: transparent !important; border-color: transparent; }
.tab-ind { position: absolute; left: 0; top: 0; border-radius: 9px; z-index: 0; pointer-events: none; background: var(--ind, var(--primary));
  transition: transform .5s cubic-bezier(.3, .9, .3, 1), width .5s cubic-bezier(.3, .9, .3, 1), height .5s, background-color .4s; }

/* ---------- Glow (6.6) ---------- */
.btn-primary { transition: transform .15s, box-shadow .3s, background .15s; }
.btn-primary:hover { box-shadow: 0 8px 26px color-mix(in srgb, var(--primary) 45%, transparent); }

/* ---------- Story runner dot (8.3 motion path) ---------- */
.story-svg .runner { fill: var(--primary); filter: drop-shadow(0 0 6px var(--primary)); opacity: 0; }

/* ---------- 3D flip cards: decisions (7.3) ---------- */
.flip { all: unset; display: block; box-sizing: border-box; perspective: 1100px; cursor: pointer; border-radius: 12px; }
.flip:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.flip-inner { display: grid; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.2, .8, .2, 1); height: 100%; }
.flip-face {
  grid-area: 1 / 1; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); backface-visibility: hidden; -webkit-backface-visibility: hidden; min-height: 150px; box-sizing: border-box;
}
.flip-face .q { font-weight: 800; color: var(--ink); font-family: var(--font-display); font-size: .88rem; }
.flip-face .why { font-size: .8rem; color: var(--muted); }
.flip-face .q-sm { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.flip-face .sugg { font-size: .84rem; color: var(--ink-2); }
.flip-face .sugg b { color: var(--company); }
.flip-hint { margin-top: auto; font-size: .7rem; font-weight: 700; color: var(--primary); }
.flip-face.back { transform: rotateY(180deg); background: color-mix(in srgb, var(--company) 9%, var(--surface)); border-color: color-mix(in srgb, var(--company) 35%, var(--line)); }
.flip.on .flip-inner { transform: rotateY(180deg); }
@media (hover: hover) and (pointer: fine) { .flip:hover .flip-inner { transform: rotateY(180deg); } }

/* ---------- Animated gradient border (6.7) ---------- */
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.cta { position: relative; border-color: transparent; }
.cta::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--ang), var(--chat), var(--web), var(--company), var(--outb), var(--chat));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: spinBorder 6s linear infinite;
}
@keyframes spinBorder { to { --ang: 360deg; } }

/* ---------- Page wipe transition (4.1) ---------- */
.page-wipe { position: fixed; inset: 0; z-index: 10000; pointer-events: none; transform: scaleY(0);
  background: linear-gradient(135deg, #312e81, var(--primary) 55%, #0ea5e9); }
.wipe-in::after { content: ""; position: fixed; inset: 0; z-index: 10000; background: linear-gradient(135deg, #312e81, #4f46e5 55%, #0ea5e9); }

/* ---------- Theme switch: circular reveal (4.3) ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* ---------- Fallbacks ---------- */
@media (prefers-reduced-motion: reduce) {
  .aurora, .morph-blob, .bubble-float, .cta::before { animation: none !important; }
  .flip-inner { transform: none !important; gap: 0; }
  .flip-face { position: static; transform: none !important; backface-visibility: visible; grid-area: auto; min-height: 0; }
  .flip-face.front { border-radius: 12px 12px 0 0; border-bottom: 0; padding-bottom: 8px; }
  .flip-face.back { border-radius: 0 0 12px 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
  .flip-face .q-sm, .flip-hint { display: none; }
}
/* Flip card faces: plain suggestion text (no nested box from the older .decide .sugg style) */
.flip-face .sugg { background: none; padding: 0; border-radius: 0; }
@media print {
  .hero-bg, .page-wipe { display: none !important; }
  .flip-inner { transform: none !important; } .flip-face { transform: none !important; grid-area: auto; backface-visibility: visible; }
  .flip-face .q-sm, .flip-hint { display: none; }
}

/* Banner off-screen: pause and skip painting its animated background layers */
.hero-off .hero-bg { visibility: hidden; }
.hero-off .aurora, .hero-off .morph-blob, .hero-off .bubble-float, .hero-off .orbit-spin, .hero-off .orbit-node > div, .hero-off .orbit-core::after { animation-play-state: paused; }
