/* ═══════════════════════════════════════════════════════════════════
   ZeroPhantom — PRO ANIMATION SYSTEM v1.0
   Drop this file in every page: <link rel="stylesheet" href="/assets/css/animations.css">
   ═══════════════════════════════════════════════════════════════════ */

/* ─── EASING VARIABLES ─────────────────────────────────────────────── */
:root {
  --ease-out-expo:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out:     cubic-bezier(0.83, 0, 0.17, 1);
  --ease-spring:     cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-smooth:     cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-bounce:     cubic-bezier(0.34, 1.56, 0.64, 1);

  --dur-instant:  80ms;
  --dur-fast:     150ms;
  --dur-base:     300ms;
  --dur-slow:     600ms;
  --dur-xslow:    1200ms;
  --dur-crawl:    2400ms;
}

/* ══════════════════════════════════════════════════════════════════
   KEYFRAMES LIBRARY — all animations in one place
   ══════════════════════════════════════════════════════════════════ */

/* ── Entrance ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-28px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-36px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(36px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes scaleInSpring {
  from { opacity: 0; transform: scale(0.5) rotate(-4deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}
@keyframes slideInUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes slideInDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
@keyframes blurIn {
  from { opacity: 0; filter: blur(16px); transform: scale(1.04); }
  to   { opacity: 1; filter: blur(0);    transform: scale(1); }
}
@keyframes revealRight {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0% 0 0); }
}
@keyframes revealLeft {
  from { clip-path: inset(0 0 0 100%); }
  to   { clip-path: inset(0 0 0 0%); }
}
@keyframes revealUp {
  from { clip-path: inset(100% 0 0 0); }
  to   { clip-path: inset(0% 0 0 0); }
}
@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.6); }
  70%  { transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── Exit ── */
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes fadeOutDown {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(20px); }
}
@keyframes scaleOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.9); }
}

/* ── Continuous / Looping ── */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-14px); }
}
@keyframes floatRotate {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%       { transform: translateY(-10px) rotate(4deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
@keyframes pulseSlow {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes spinReverse {
  to { transform: rotate(-360deg); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0);    animation-timing-function: cubic-bezier(0.8,0,1,1); }
  50%       { transform: translateY(-22px); animation-timing-function: cubic-bezier(0,0,0.2,1); }
}
@keyframes shimmer {
  from { background-position: -200% center; }
  to   { background-position:  200% center; }
}
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes borderGlow {
  0%, 100% { border-color: var(--primary, #4f46e5); box-shadow: 0 0 0 0 rgba(79,70,229,0.4); }
  50%       { border-color: var(--accent, #6366f1);  box-shadow: 0 0 20px 4px rgba(79,70,229,0.2); }
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79,70,229,0.5); }
  50%       { box-shadow: 0 0 0 18px rgba(79,70,229,0); }
}
@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@keyframes glitch {
  0%, 100% { transform: none;                  clip-path: none; }
  20%       { transform: skewX(-2deg) translateX(3px);  clip-path: inset(10% 0 50% 0); }
  40%       { transform: skewX(1.5deg) translateX(-2px); clip-path: inset(55% 0 5% 0); }
  60%       { transform: none;                  clip-path: inset(20% 0 40% 0); }
  80%       { transform: skewX(-0.5deg);        clip-path: none; }
}
@keyframes textFlicker {
  0%,19%,21%,23%,25%,54%,56%,100% { opacity: 1; }
  20%,24%,55%                      { opacity: 0.45; }
}
@keyframes scanline {
  0%   { top: -5%; }
  100% { top: 105%; }
}
@keyframes waveBar {
  0%, 100% { transform: scaleY(0.25); }
  50%       { transform: scaleY(1); }
}
@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}
@keyframes orbit {
  from { transform: rotate(0deg) translateX(60px) rotate(0deg); }
  to   { transform: rotate(360deg) translateX(60px) rotate(-360deg); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  15%      { transform: translateX(-7px); }
  30%      { transform: translateX(7px); }
  45%      { transform: translateX(-5px); }
  60%      { transform: translateX(5px); }
  75%      { transform: translateX(-3px); }
  90%      { transform: translateX(3px); }
}
@keyframes typewriter {
  from { width: 0; }
  to   { width: 100%; }
}
@keyframes caretBlink {
  0%, 100% { border-right-color: var(--primary, #4f46e5); }
  50%       { border-right-color: transparent; }
}
@keyframes counterUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes morphBg {
  0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
  50%       { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
}
@keyframes staggerIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════════
   UTILITY CLASSES — add class="animate-X" to any element
   ══════════════════════════════════════════════════════════════════ */

/* ── Entrance (one-shot, add via JS or on render) ── */
.animate-fade-in        { animation: fadeIn        var(--dur-base) var(--ease-smooth) both; }
.animate-fade-in-up     { animation: fadeInUp      var(--dur-slow) var(--ease-out-expo) both; }
.animate-fade-in-down   { animation: fadeInDown    var(--dur-slow) var(--ease-out-expo) both; }
.animate-fade-in-left   { animation: fadeInLeft    var(--dur-slow) var(--ease-out-expo) both; }
.animate-fade-in-right  { animation: fadeInRight   var(--dur-slow) var(--ease-out-expo) both; }
.animate-scale-in       { animation: scaleIn       var(--dur-slow) var(--ease-out-back) both; }
.animate-scale-in-spring{ animation: scaleInSpring var(--dur-slow) var(--ease-spring)   both; }
.animate-blur-in        { animation: blurIn        var(--dur-slow) var(--ease-out-expo) both; }
.animate-pop-in         { animation: popIn         var(--dur-slow) var(--ease-spring)   both; }
.animate-slide-in-up    { animation: slideInUp     var(--dur-slow) var(--ease-out-expo) both; }
.animate-reveal-right   { animation: revealRight   var(--dur-slow) var(--ease-in-out)   both; }
.animate-reveal-up      { animation: revealUp      var(--dur-slow) var(--ease-in-out)   both; }

/* ── Exit ── */
.animate-fade-out       { animation: fadeOut       var(--dur-base) var(--ease-smooth)   both; }
.animate-fade-out-down  { animation: fadeOutDown   var(--dur-base) var(--ease-in-out)   both; }
.animate-scale-out      { animation: scaleOut      var(--dur-base) var(--ease-in-out)   both; }

/* ── Continuous ── */
.animate-float          { animation: float         3s ease-in-out infinite; }
.animate-float-rotate   { animation: floatRotate   4s ease-in-out infinite; }
.animate-pulse          { animation: pulse         2s ease-in-out infinite; }
.animate-pulse-scale    { animation: pulseSlow     2.5s ease-in-out infinite; }
.animate-spin           { animation: spin          1s linear infinite; }
.animate-spin-slow      { animation: spin          3s linear infinite; }
.animate-spin-reverse   { animation: spinReverse   2s linear infinite; }
.animate-bounce         { animation: bounce        1s ease infinite; }
.animate-breathe        { animation: breathe       2.5s ease-in-out infinite; }
.animate-border-glow    { animation: borderGlow    2s ease-in-out infinite; }
.animate-glitch         { animation: glitch        3s steps(1) infinite; }
.animate-flicker        { animation: textFlicker   4s linear infinite; }
.animate-shake          { animation: shake         0.6s var(--ease-out-back); }
.animate-morph          { animation: morphBg       6s ease-in-out infinite; }
.animate-orbit          { animation: orbit         6s linear infinite; }

/* ── Shimmer (skeleton/loading) ── */
.animate-shimmer {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.03) 25%,
    rgba(255,255,255,0.1) 50%,
    rgba(255,255,255,0.03) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}

/* ── Gradient text ── */
.animate-gradient-text {
  background: linear-gradient(135deg, var(--primary,#4f46e5), var(--accent,#6366f1), #6366f1, var(--primary,#4f46e5));
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease infinite;
}

/* ── Typewriter ── */
.animate-typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--primary, #4f46e5);
  width: 0;
  animation:
    typewriter 2.5s steps(40) var(--dur-slow) forwards,
    caretBlink 0.8s step-end infinite;
}

/* ── Waveform (audio visualizer bars) ── */
.wave-bar {
  display: inline-block;
  width: 3px;
  height: 24px;
  margin: 0 2px;
  border-radius: 2px;
  background: var(--primary, #4f46e5);
  transform-origin: bottom;
  animation: waveBar 0.8s ease-in-out infinite;
}
.wave-bar:nth-child(1) { animation-delay: 0.0s; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }
.wave-bar:nth-child(6) { animation-delay: 0.3s; }
.wave-bar:nth-child(7) { animation-delay: 0.2s; }

/* ── Ticker (scrolling text) ── */
.ticker-wrap {
  overflow: hidden;
  white-space: nowrap;
}
.ticker-content {
  display: inline-block;
  animation: ticker 20s linear infinite;
}

/* ── Scanline overlay (cyberpunk effect) ── */
.scanline-overlay {
  position: relative;
  overflow: hidden;
}
.scanline-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 50%, rgba(0,0,0,0.04) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 1;
}

/* ══════════════════════════════════════════════════════════════════
   DELAY MODIFIERS — chain staggered lists with .delay-N
   ══════════════════════════════════════════════════════════════════ */
.delay-0   { animation-delay: 0ms; }
.delay-50  { animation-delay: 50ms; }
.delay-100 { animation-delay: 100ms; }
.delay-150 { animation-delay: 150ms; }
.delay-200 { animation-delay: 200ms; }
.delay-250 { animation-delay: 250ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }
.delay-700 { animation-delay: 700ms; }
.delay-800 { animation-delay: 800ms; }
.delay-900 { animation-delay: 900ms; }
.delay-1000{ animation-delay: 1000ms; }
.delay-1200{ animation-delay: 1200ms; }
.delay-1500{ animation-delay: 1500ms; }
.delay-2000{ animation-delay: 2000ms; }

/* ══════════════════════════════════════════════════════════════════
   DURATION MODIFIERS
   ══════════════════════════════════════════════════════════════════ */
.duration-150  { animation-duration: 150ms !important; }
.duration-300  { animation-duration: 300ms !important; }
.duration-500  { animation-duration: 500ms !important; }
.duration-700  { animation-duration: 700ms !important; }
.duration-1000 { animation-duration: 1000ms !important; }
.duration-1500 { animation-duration: 1500ms !important; }
.duration-2000 { animation-duration: 2000ms !important; }
.duration-3000 { animation-duration: 3000ms !important; }

/* ══════════════════════════════════════════════════════════════════
   SCROLL-TRIGGERED — initial hidden state before JS adds .visible
   Usage: <div class="scroll-reveal animate-fade-in-up">
   JS: observer adds class "visible" → animation fires
   ══════════════════════════════════════════════════════════════════ */
.scroll-reveal {
  opacity: 0;
  transition: none;
}
.scroll-reveal.visible {
  opacity: 1; /* animation classes handle the rest */
}

/* ══════════════════════════════════════════════════════════════════
   INTERACTION — hover / active micro-interactions
   ══════════════════════════════════════════════════════════════════ */
.hover-lift {
  transition: transform var(--dur-base) var(--ease-out-back),
              box-shadow var(--dur-base) var(--ease-smooth);
}
.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}

.hover-scale {
  transition: transform var(--dur-base) var(--ease-out-back);
}
.hover-scale:hover  { transform: scale(1.04); }
.hover-scale:active { transform: scale(0.97); }

.hover-glow {
  transition: box-shadow var(--dur-base) var(--ease-smooth);
}
.hover-glow:hover {
  box-shadow: 0 0 28px rgba(79,70,229,0.45);
}

.hover-bright {
  transition: filter var(--dur-fast) var(--ease-smooth);
}
.hover-bright:hover { filter: brightness(1.12); }

.hover-rotate {
  transition: transform var(--dur-base) var(--ease-out-back);
}
.hover-rotate:hover { transform: rotate(8deg) scale(1.1); }

/* ── Click ripple effect — add class + JS call ── */
.ripple-container {
  position: relative;
  overflow: hidden;
}
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════════
   LOADING STATES
   ══════════════════════════════════════════════════════════════════ */

/* Skeleton bone */
.skeleton {
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.08) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}

/* Spinner ring */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(255,255,255,0.12);
  border-top-color: var(--primary, #4f46e5);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.spinner-lg {
  width: 42px;
  height: 42px;
  border-width: 3.5px;
}

/* Dots loader */
.dots-loader {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}
.dots-loader span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary, #4f46e5);
  animation: pulseSlow 1s ease-in-out infinite;
}
.dots-loader span:nth-child(1) { animation-delay: 0s; }
.dots-loader span:nth-child(2) { animation-delay: 0.16s; }
.dots-loader span:nth-child(3) { animation-delay: 0.32s; }

/* ══════════════════════════════════════════════════════════════════
   PAGE TRANSITIONS
   ══════════════════════════════════════════════════════════════════ */
.page-enter {
  animation: fadeInUp var(--dur-slow) var(--ease-out-expo) both;
}
.page-exit {
  animation: fadeOutDown var(--dur-base) var(--ease-in-out) both;
}

/* ══════════════════════════════════════════════════════════════════
   NOTIFICATION / TOAST ANIMATIONS
   ══════════════════════════════════════════════════════════════════ */
.toast-enter {
  animation: slideInDown var(--dur-slow) var(--ease-out-back) both;
}
.toast-exit {
  animation: fadeOutDown var(--dur-base) var(--ease-in-out) both;
}

/* ══════════════════════════════════════════════════════════════════
   STAGGER HELPERS — use on parent with children having .stagger-child
   JS sets --i variable: el.style.setProperty('--i', index)
   ══════════════════════════════════════════════════════════════════ */
.stagger-child {
  animation: staggerIn var(--dur-slow) var(--ease-out-expo) both;
  animation-delay: calc(var(--i, 0) * 80ms);
}

/* ══════════════════════════════════════════════════════════════════
   REDUCED MOTION — respects user OS preference
   ══════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
