/* ==========================================================================
   Motion Utilities (opt-in)
   - Keep this file safe: no global element overrides, only classes.
   ========================================================================== */

:root {
  --motion-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
  --motion-fast: 100ms;
  --motion-med: 180ms;
  --motion-slow: 360ms;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes motion-fade-up {
  from { opacity: 0; translate: 0 12px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes motion-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Page/container entrance */
.motion-page {
  animation: motion-fade-up var(--motion-slow) var(--motion-ease) both;
}

/* Re-triggerable small entrance (used when switching tabs) */
.motion-enter {
  animation: motion-fade-up 280ms var(--motion-ease) both;
}

/* Staggered reveal for lists/grids (up to 12 children) */
.motion-stagger > * {
  opacity: 0;
  translate: 0 10px;
  animation: motion-fade-up 360ms var(--motion-ease) both;
}
.motion-stagger > *:nth-child(1) { animation-delay: 20ms; }
.motion-stagger > *:nth-child(2) { animation-delay: 45ms; }
.motion-stagger > *:nth-child(3) { animation-delay: 70ms; }
.motion-stagger > *:nth-child(4) { animation-delay: 95ms; }
.motion-stagger > *:nth-child(5) { animation-delay: 120ms; }
.motion-stagger > *:nth-child(6) { animation-delay: 145ms; }
.motion-stagger > *:nth-child(7) { animation-delay: 170ms; }
.motion-stagger > *:nth-child(8) { animation-delay: 195ms; }
.motion-stagger > *:nth-child(9) { animation-delay: 220ms; }
.motion-stagger > *:nth-child(10) { animation-delay: 245ms; }
.motion-stagger > *:nth-child(11) { animation-delay: 270ms; }
.motion-stagger > *:nth-child(12) { animation-delay: 295ms; }

/* Staggered reveal starting later (e.g. for bottom sections) */
.motion-stagger-delayed > * {
  opacity: 0;
  translate: 0 10px;
  animation: motion-fade-up 360ms var(--motion-ease) both;
}
.motion-stagger-delayed > *:nth-child(1) { animation-delay: 300ms; }
.motion-stagger-delayed > *:nth-child(2) { animation-delay: 340ms; }
.motion-stagger-delayed > *:nth-child(3) { animation-delay: 380ms; }

/* Micro-interactions (use translate/scale properties to avoid clobbering existing transform) */
.motion-lift {
  transition:
    translate var(--motion-med) var(--motion-ease),
    filter var(--motion-med) var(--motion-ease),
    box-shadow var(--motion-med) var(--motion-ease);
  will-change: translate, filter;
}
.motion-lift:hover {
  translate: 0 -4px;
  filter: brightness(1.08);
}
.motion-lift:active {
  translate: 0 -2px;
}

.motion-press {
  transition: scale var(--motion-fast) var(--motion-ease), filter var(--motion-fast) var(--motion-ease);
  will-change: scale, filter;
}
.motion-press:hover { filter: brightness(1.08); }
.motion-press:active { scale: 0.96; }

/* Subtle attention pulse for tiny UI elements (badges, dots, etc.) */
@keyframes motion-soft-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.motion-soft-pulse { animation: motion-soft-pulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* Optional ambient float */
@keyframes motion-float-slow {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -4px; }
}
.motion-float-slow {
  animation: motion-float-slow 2.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Breathing glow for badges/cards */
@keyframes motion-glow-breathe {
  0%, 100% { box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
  50% { box-shadow: 0 0 18px rgba(57, 255, 20, 0.25); }
}
.motion-glow-breathe {
  animation: motion-glow-breathe 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Glass sweep highlight, best on translucent cards */
.motion-glass-shine {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.motion-glass-shine::after {
  content: "";
  position: absolute;
  top: 0;
  left: -130%;
  width: 48%;
  height: 100%;
  transform: skewX(-18deg);
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.14), transparent);
  pointer-events: none;
  transition: left 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.motion-glass-shine:hover::after {
  left: 160%;
}

/* Reusable delayed stagger for cards/grids */
.motion-card-stack > * {
  opacity: 0;
  translate: 0 12px;
  animation: motion-fade-up 360ms var(--motion-ease) both;
}
.motion-card-stack > *:nth-child(1) { animation-delay: 40ms; }
.motion-card-stack > *:nth-child(2) { animation-delay: 80ms; }
.motion-card-stack > *:nth-child(3) { animation-delay: 120ms; }
.motion-card-stack > *:nth-child(4) { animation-delay: 160ms; }
.motion-card-stack > *:nth-child(5) { animation-delay: 200ms; }
.motion-card-stack > *:nth-child(6) { animation-delay: 240ms; }
