/* ============================================================
   AeroX AI — Shared Motion Layer
   Adds professional motion on top of the existing design system.
   Uses ONLY existing tokens: no new colors, themes or fonts.
   Loaded on: landing, user dashboard, admin, developer portal, checkout.
   ============================================================ */

/* --- 1. Route progress bar (top of viewport) --- */
.ax-route-bar {
  position: fixed; top: 0; left: 0; height: 2px; width: 100%;
  z-index: 100000; pointer-events: none;
  transform-origin: 0 50%; transform: scaleX(0);
  background: var(--text-primary);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.45);
  opacity: 0;
}
.ax-route-bar.is-loading {
  opacity: 1;
  transition: transform 8s cubic-bezier(0.08, 0.82, 0.17, 1), opacity 0.2s ease;
  transform: scaleX(0.85);
}
.ax-route-bar.is-done {
  opacity: 0;
  transform: scaleX(1);
  transition: transform 0.25s var(--ease-out), opacity 0.4s ease 0.2s;
}

/* --- 2. Staggered rise for cards when a section / tab is shown --- */
@keyframes axRise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
/* `backwards` (not `both`) so hover transforms work once the entrance ends */
.ax-rise {
  animation: axRise 0.55s var(--ease-out) backwards;
  animation-delay: calc(var(--ax-i, 0) * 45ms);
}

/* --- 3. Scroll reveal --- */
.ax-reveal { opacity: 0; transform: translateY(18px); }
.ax-reveal.ax-in {
  opacity: 1; transform: none;
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  transition-delay: calc(var(--ax-i, 0) * 60ms);
}

/* --- 4. Spotlight glow + lift on cards (pointer-tracked) --- */
.ax-spot { position: relative; isolation: isolate; }
.ax-spot::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; z-index: -1; opacity: 0;
  background: radial-gradient(380px circle at var(--ax-mx, 50%) var(--ax-my, 50%),
              rgba(255, 255, 255, 0.055), transparent 45%);
  transition: opacity 0.35s ease;
}
.ax-spot:hover::after { opacity: 1; }
.ax-lift {
  transition: transform 0.3s var(--ease-out), border-color 0.3s ease, box-shadow 0.3s ease;
}
.ax-lift:hover {
  transform: translateY(-3px);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.02);
}

/* --- 5. Button ripple + primary shine --- */
.ax-ripple-host { position: relative; overflow: hidden; }
.ax-ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  background: currentColor; opacity: 0.18;
  animation: axRipple 0.6s var(--ease-out) forwards;
}
@keyframes axRipple { to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

.nav-btn-primary { position: relative; overflow: hidden; }
.btn-primary::before, .nav-btn-primary::before {
  content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  pointer-events: none;
  background: linear-gradient(105deg, transparent, rgba(0, 0, 0, 0.12), transparent);
  transform: skewX(-18deg);
  transition: left 0.7s var(--ease-out);
}
.btn-primary:hover::before, .nav-btn-primary:hover::before { left: 130%; }

/* --- 6. Sliding nav indicator (dashboard sidebar + admin nav) --- */
:where(.ax-glider-host) { position: relative; }
.ax-glider {
  position: absolute; left: 0; top: 0; width: 3px; height: 0;
  border-radius: 0 3px 3px 0; pointer-events: none; z-index: 2;
  background: var(--text-primary);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
  transition: transform 0.45s var(--ease-spring), height 0.45s var(--ease-out), opacity 0.3s ease;
  opacity: 0;
}
.ax-glider.is-on { opacity: 1; }
/* The glider replaces the static per-item bars */
.ax-glider-host .sidebar-link.active::before,
.ax-glider-host .admin-nav-item::before { display: none; }

/* --- 7. Value change tick (numbers that update live) --- */
@keyframes axTick {
  0%   { opacity: 0.35; transform: translateY(4px); }
  100% { opacity: 1; transform: none; }
}
.ax-tick { display: inline-block; animation: axTick 0.45s var(--ease-out); }

/* --- 8. Inputs: soft focus halo (monochrome) --- */
.form-input, .form-select, .form-textarea {
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

/* --- 9. Tables: row hover glide --- */
.admin-table tbody tr, .data-table tbody tr { transition: background-color 0.2s ease; }
.admin-table tbody tr:hover, .data-table tbody tr:hover { background: var(--bg-hover); }

/* --- 10. Icons nudge inside buttons/links --- */
.btn svg, .topbar-btn svg, .dev-nav-item svg { transition: transform 0.3s var(--ease-spring); }
.btn:hover svg, .topbar-btn:hover svg, .dev-nav-item:hover svg { transform: translateY(-1px) scale(1.08); }

/* --- 11. Progress bars grow in when first shown --- */
@keyframes axGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.ax-grow { transform-origin: 0 50%; animation: axGrow 0.9s var(--ease-out) backwards; }

/* --- 12. Badges pop --- */
@keyframes axPop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.ax-pop { animation: axPop 0.45s var(--ease-spring) backwards; animation-delay: calc(var(--ax-i, 0) * 40ms + 120ms); }

/* --- Reduced motion: everything static --- */
@media (prefers-reduced-motion: reduce) {
  .ax-rise, .ax-tick, .ax-grow, .ax-pop, .ax-ripple { animation: none !important; }
  .ax-reveal { opacity: 1 !important; transform: none !important; }
  .ax-lift:hover { transform: none; }
  .ax-glider { transition: none; }
  .btn-primary::before, .nav-btn-primary::before { display: none; }
  .ax-route-bar { display: none; }
}

/* ============================================================
   Developer Portal + API Docs (body.dev-body)
   ============================================================ */

/* Navbar drops in; reading progress line sits on its bottom edge */
@keyframes axDropIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
.dev-body .dev-navbar { animation: axDropIn 0.6s var(--ease-out) backwards; }
.ax-read-progress {
  position: absolute; left: 0; bottom: -1px; height: 1px; width: 100%;
  transform-origin: 0 50%; transform: scaleX(0); pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,0.15), var(--text-primary));
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}
.dev-body .dev-nav-item { position: relative; }
.dev-body .dev-nav-item::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 1px;
  background: var(--text-primary); transform: scaleX(0); transform-origin: 50% 50%;
  transition: transform 0.35s var(--ease-out); pointer-events: none;
}
.dev-body .dev-nav-item:hover::after { transform: scaleX(1); }

/* Cursor aura over the grid background */
.ax-aura {
  position: fixed; left: 0; top: 0; width: 560px; height: 560px; margin: -280px 0 0 -280px;
  border-radius: 50%; pointer-events: none; z-index: 0; opacity: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.045), transparent 62%);
  transition: opacity 0.6s ease; will-change: transform;
}
.ax-aura.is-on { opacity: 1; }
/* Slow breathing drift on the grid */
@keyframes axGridDrift { from { background-position: 0 0, 0 0; } to { background-position: 52px 52px, 52px 52px; } }
/* (grid drift removed: animating background-position repainted the whole screen every frame) */

/* Headline word reveal */
.ax-words .ax-word { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: 0.08em; }
.ax-words .ax-word > span {
  display: inline-block; transform: translateY(105%);
  animation: axWordUp 0.8s var(--ease-out) forwards;
  animation-delay: calc(var(--ax-w, 0) * 70ms + 120ms);
}
@keyframes axWordUp { to { transform: none; } }

/* Section headings: underline draws in */
.dev-body .docs-h2 { position: relative; }
.dev-body .docs-h2::after {
  content: ''; position: absolute; left: 0; bottom: -1px; height: 1px; width: 100%;
  background: linear-gradient(90deg, var(--text-primary), rgba(255,255,255,0.08) 60%, transparent);
  transform: scaleX(0); transform-origin: 0 50%;
  transition: transform 1.1s var(--ease-out) 0.15s;
}
.dev-body .docs-h2.ax-in::after { transform: scaleX(1); }

/* Code blocks print in top-to-bottom when revealed */
@keyframes axCodeWipe { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
.ax-code-in .code-box-pre { animation: axCodeWipe 0.9s var(--ease-out) 0.15s backwards; }

/* Step numbers pop when their step enters */
.ax-in .dev-step-num { animation: axPop 0.5s var(--ease-spring) 0.2s backwards; }

/* Content swapped by tabs (OS / language switch) */
@keyframes axSwap { from { opacity: 0.2; transform: translateY(4px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
.ax-swap { animation: axSwap 0.4s var(--ease-out); }

/* Active tab pills: smooth state change */
.code-lang-tab, .os-tab-btn, .quick-link-pill { transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease-spring); }
.code-lang-tab:active, .os-tab-btn:active, .quick-link-pill:active { transform: scale(0.95); }
.quick-link-pill:hover { transform: translateY(-2px); }

/* Docs sidebar glider: replace the static active background with a sliding one */
.docs-sidebar.ax-glider-host .ax-glider { left: 0; }

/* Portal buttons ripple host */
.dev-btn { position: relative; overflow: hidden; }
.dev-btn-primary::before {
  content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; pointer-events: none;
  background: linear-gradient(105deg, transparent, rgba(0, 0, 0, 0.12), transparent);
  transform: skewX(-18deg); transition: left 0.7s var(--ease-out);
}
.dev-btn-primary:hover::before { left: 130%; }

/* Portal key table rows stagger in when rendered */
.ax-row-in { animation: axRise 0.45s var(--ease-out) backwards; animation-delay: calc(var(--ax-i, 0) * 40ms); }

@media (prefers-reduced-motion: reduce) {
  .dev-body .dev-navbar, .dev-body .dev-grid-bg, .ax-code-in .code-box-pre, .ax-in .dev-step-num,
  .ax-swap, .ax-row-in { animation: none !important; }
  .ax-words .ax-word > span { animation: none !important; transform: none !important; }
  .dev-body .docs-h2::after { transform: scaleX(1); transition: none; }
  .ax-aura { display: none; }
}
