/* ============================================
   MICRO-WOW — Premium Micro-Interactions
   Stagger reveals, counter animations,
   streak celebrations, progress fills
   ============================================ */

/* --- Stagger Reveal (cards enter one by one) --- */
.stagger-reveal {
  opacity: 0;
  transform: translateY(24px) scale(0.97);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.stagger-reveal.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.stagger-reveal:nth-child(1) { transition-delay: 0ms; }
.stagger-reveal:nth-child(2) { transition-delay: 80ms; }
.stagger-reveal:nth-child(3) { transition-delay: 160ms; }
.stagger-reveal:nth-child(4) { transition-delay: 240ms; }
.stagger-reveal:nth-child(5) { transition-delay: 320ms; }
.stagger-reveal:nth-child(6) { transition-delay: 400ms; }
.stagger-reveal:nth-child(7) { transition-delay: 480ms; }
.stagger-reveal:nth-child(8) { transition-delay: 560ms; }

/* --- Counter Value Glow on Complete --- */
@keyframes countup-glow {
  0% { text-shadow: none; }
  50% { text-shadow: 0 0 20px rgba(212, 175, 55, 0.4); }
  100% { text-shadow: none; }
}
.countup-done {
  animation: countup-glow 0.8s ease-out;
}

/* --- Streak Badge Celebration --- */
@keyframes streak-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 165, 0, 0.4); }
  50% { transform: scale(1.08); box-shadow: 0 0 20px 4px rgba(255, 165, 0, 0.2); }
}
@keyframes streak-fire {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.2) rotate(-5deg); }
  75% { transform: scale(1.2) rotate(5deg); }
}
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.85rem;
  background: linear-gradient(135deg, rgba(255, 165, 0, 0.2), rgba(255, 69, 0, 0.15));
  border: 1px solid rgba(255, 165, 0, 0.3);
  color: #fbbf24;
}
.streak-badge--active {
  animation: streak-pulse 2s ease-in-out infinite;
}
.streak-badge__fire {
  font-size: 1.1em;
  animation: streak-fire 1.5s ease-in-out infinite;
  display: inline-block;
}

/* --- Progress Bar Animated Fill --- */
@keyframes progress-fill {
  from { width: 0%; }
}
.progress-bar-animated-fill {
  animation: progress-fill 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  background: linear-gradient(90deg, #d4af37, #fbbf24);
  border-radius: 99px;
  height: 100%;
  position: relative;
  overflow: hidden;
}
.progress-bar-animated-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer-bar 2s ease-in-out infinite 1.2s;
}
@keyframes shimmer-bar {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* --- Card Hover Icon Bounce --- */
@keyframes icon-bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
  60% { transform: translateY(-3px); }
}
.hover-icon-bounce:hover .card-icon,
.hover-icon-bounce:hover .kpi-card__icon i,
.hover-icon-bounce:hover .bi {
  animation: icon-bounce 0.5s ease;
}

/* --- Stat Number Slide-Up Entry --- */
@keyframes stat-slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.stat-enter {
  animation: stat-slide-up 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
}
.stat-enter:nth-child(1) { animation-delay: 0.1s; }
.stat-enter:nth-child(2) { animation-delay: 0.2s; }
.stat-enter:nth-child(3) { animation-delay: 0.3s; }

/* --- Avatar Shimmer Loading --- */
@keyframes avatar-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.avatar-loading {
  background: linear-gradient(90deg,
    var(--card-bg, #1a1a2e) 25%,
    rgba(212, 175, 55, 0.1) 50%,
    var(--card-bg, #1a1a2e) 75%
  );
  background-size: 200% 100%;
  animation: avatar-shimmer 1.5s ease-in-out infinite;
  border-radius: 50%;
}

/* --- Trend Arrow Micro-Animation --- */
@keyframes trend-bounce-up {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes trend-bounce-down {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}
.trend-up i.bi {
  animation: trend-bounce-up 2s ease-in-out infinite;
  display: inline-block;
}
.trend-down i.bi {
  animation: trend-bounce-down 2s ease-in-out infinite;
  display: inline-block;
}

/* --- Enhanced KPI Card Hover (gold theme) --- */
.kpi-card:hover {
  border-color: rgba(212, 175, 55, 0.3) !important;
  box-shadow: 0 8px 32px rgba(212, 175, 55, 0.12) !important;
}

/* --- Notification Badge Pop --- */
@keyframes badge-pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.badge-pop {
  animation: badge-pop 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Quick Action Card Pulse Border --- */
@keyframes pulse-border {
  0%, 100% { border-color: rgba(212, 175, 55, 0.1); }
  50% { border-color: rgba(212, 175, 55, 0.4); }
}
.action-card-pulse:hover {
  animation: pulse-border 1.5s ease-in-out infinite;
}

/* --- Light Mode Overrides --- */
[data-theme="light"] .streak-badge,
html.theme-light .streak-badge {
  background: linear-gradient(135deg, rgba(255, 165, 0, 0.12), rgba(255, 69, 0, 0.08));
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.3);
}

[data-theme="light"] .kpi-card:hover,
html.theme-light .kpi-card:hover {
  border-color: rgba(217, 119, 6, 0.3) !important;
  box-shadow: 0 8px 32px rgba(217, 119, 6, 0.1) !important;
}

[data-theme="light"] .progress-bar-animated-fill,
html.theme-light .progress-bar-animated-fill {
  background: linear-gradient(90deg, #b45309, #d97706);
}

[data-theme="light"] .avatar-loading,
html.theme-light .avatar-loading {
  background: linear-gradient(90deg,
    #f8fafc 25%,
    rgba(217, 119, 6, 0.08) 50%,
    #f8fafc 75%
  );
  background-size: 200% 100%;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .stagger-reveal { transition-duration: 0.01ms !important; transition-delay: 0ms !important; opacity: 1; transform: none; }
  .streak-badge--active { animation: none; }
  .streak-badge__fire { animation: none; }
  .progress-bar-animated-fill { animation: none; }
  .trend-up i.bi, .trend-down i.bi { animation: none; }
  .hover-icon-bounce:hover .bi { animation: none; }
  .countup-done { animation: none; }
}
