/* ============================================
   VTU PLATFORM — ANIMATIONS
   All transitions, skeletons, micro-interactions
   ============================================ */


/* ─── KEYFRAMES ─────────────────────────────
   ─────────────────────────────────────────── */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounceIn {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes walletPulse {
  0%   { box-shadow: 0 0 80px rgba(22, 163, 74, 0.06), 0 0 160px rgba(22, 163, 74, 0.03); }
  50%  { box-shadow: 0 0 100px rgba(22, 163, 74, 0.12), 0 0 200px rgba(22, 163, 74, 0.06); }
  100% { box-shadow: 0 0 80px rgba(22, 163, 74, 0.06), 0 0 160px rgba(22, 163, 74, 0.03); }
}

@keyframes successRing {
  0%   { transform: scale(0.8); opacity: 0; }
  50%  { transform: scale(1.2); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px) scale(0.95);
  }
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}

@keyframes confettiFall {
  0%   { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes streakFlame {
  0%, 100% { transform: scaleY(1) rotate(-2deg); }
  50%       { transform: scaleY(1.1) rotate(2deg); }
}


/* ─── PAGE TRANSITIONS ──────────────────────
   ─────────────────────────────────────────── */

.page-enter {
  animation: fadeInUp 300ms ease forwards;
}

.page-exit {
  animation: fadeIn 200ms ease reverse forwards;
}

/* Staggered children animation */
.stagger-children > * {
  opacity: 0;
  animation: fadeInUp 300ms ease forwards;
}
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }


/* ─── SKELETON LOADERS ──────────────────────
   ─────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-hover)    50%,
    var(--bg-elevated) 75%
  );
  background-size: 400px 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
  pointer-events: none;
  user-select: none;
}

/* Skeleton shapes */
.skeleton--text {
  height: 14px;
  width: 100%;
}
.skeleton--text-sm {
  height: 12px;
  width: 70%;
}
.skeleton--title {
  height: 20px;
  width: 60%;
}
.skeleton--amount {
  height: 40px;
  width: 55%;
}
.skeleton--circle {
  border-radius: var(--radius-full);
}
.skeleton--avatar-sm  { width: 32px; height: 32px; }
.skeleton--avatar-md  { width: 44px; height: 44px; }
.skeleton--avatar-lg  { width: 64px; height: 64px; }
.skeleton--btn        { height: 44px; width: 100%; }
.skeleton--card       { height: 120px; width: 100%; border-radius: var(--radius-md); }
.skeleton--icon       { width: 40px; height: 40px; border-radius: var(--radius-md); }
.skeleton--line       { height: 14px; flex: 1; }
.skeleton--line-sm    { height: 14px; width: 60px; flex: none; }

/* Wallet card skeleton */
.skeleton-wallet {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 28px var(--card-padding);
}

/* Transaction item skeleton */
.skeleton-tx {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.skeleton-tx:last-child { border-bottom: none; }


/* ─── LOADING SPINNER ───────────────────────
   ─────────────────────────────────────────── */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-soft);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner--sm { width: 14px; height: 14px; border-width: 1.5px; }
.spinner--lg { width: 32px; height: 32px; border-width: 3px; }
.spinner--success { border-color: var(--success-soft); border-top-color: var(--success); }


/* ─── FULL PAGE LOADER ──────────────────────
   ─────────────────────────────────────────── */

.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-lg);
  z-index: var(--z-top);
  transition: opacity var(--transition-normal);
}
.page-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}
.page-loader__logo {
  width: 48px;
  height: 48px;
  animation: pulse 1.5s ease infinite;
}
.page-loader__text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  animation: pulse 1.5s ease infinite;
}


/* ─── SUCCESS ANIMATION ─────────────────────
   ─────────────────────────────────────────── */

.success-anim {
  position: relative;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.success-anim__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--success);
  animation: successRing 0.8s ease forwards;
}
.success-anim__icon {
  font-size: 32px;
  animation: bounceIn 0.5s ease 0.2s both;
}


/* ─── TOAST NOTIFICATIONS ───────────────────
   ─────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: calc(var(--top-bar-height) + var(--space-md));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  pointer-events: all;
  animation: toastSlideIn 300ms var(--transition-spring) forwards;
  backdrop-filter: blur(8px);
}
.toast.is-leaving {
  animation: toastSlideOut 250ms ease forwards;
}

.toast__icon { font-size: 18px; flex-shrink: 0; }
.toast__content { flex: 1; min-width: 0; }
.toast__title {
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--text-primary);
}
.toast__message {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}
.toast__close {
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px;
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger);  }
.toast--pending { border-left: 3px solid var(--pending); }
.toast--info    { border-left: 3px solid var(--info);    }


/* ─── WALLET CREDIT PULSE ───────────────────
   Plays when money lands in wallet
   ─────────────────────────────────────────── */

.wallet-credited {
  animation: walletPulse 1.5s ease 1;
}

.balance-update {
  animation: countUp 400ms ease forwards;
}


/* ─── CONFETTI ──────────────────────────────
   Success celebration (JS-driven)
   Each .confetti-piece is created by JS
   ─────────────────────────────────────────── */

.confetti-piece {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: var(--z-top);
  animation: confettiFall linear forwards;
}


/* ─── PIN PAD SHAKE ─────────────────────────
   ─────────────────────────────────────────── */

.pin-shake {
  animation: pinShake 400ms ease;
}


/* ─── STREAK FLAME ──────────────────────────
   ─────────────────────────────────────────── */

.streak-flame {
  display: inline-block;
  animation: streakFlame 0.8s ease infinite;
  transform-origin: center bottom;
}


/* ─── UTILITY ANIMATION CLASSES ─────────────
   ─────────────────────────────────────────── */

.animate-fade-in     { animation: fadeIn     300ms ease forwards; }
.animate-fade-in-up  { animation: fadeInUp   300ms ease forwards; }
.animate-fade-in-down{ animation: fadeInDown 300ms ease forwards; }
.animate-scale-in    { animation: scaleIn    300ms ease forwards; }
.animate-bounce-in   { animation: bounceIn   400ms ease forwards; }
.animate-slide-right { animation: slideInRight 300ms ease forwards; }
.animate-slide-left  { animation: slideInLeft  300ms ease forwards; }
.animate-pulse       { animation: pulse 1.5s ease infinite; }
.animate-spin        { animation: spin 0.7s linear infinite; }

/* Delay utilities */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
