/* ============================================================
   STMLab - animations.css
   Keyframes, entrance animations, transitions
   ============================================================ */

/* ── Keyframe Definitions ─────────────────────────────────── */

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%       { transform: translateY(-30px) scale(1.05); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
  50%       { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(139,92,246,0.15); }
}

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

@keyframes slide-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes gradient-shift {
  0%   { background-position: 0%   50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0%   50%; }
}

@keyframes count-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

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

@keyframes border-glow {
  0%, 100% { border-color: rgba(225,29,72,0.2); }
  50%       { border-color: rgba(225,29,72,0.6); }
}

/* ── Entrance Animations ──────────────────────────────────── */

/* Applied via JS IntersectionObserver */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}

.reveal-stagger.visible > *:nth-child(1)  { transition-delay: 0ms;   opacity: 1; transform: none; }
.reveal-stagger.visible > *:nth-child(2)  { transition-delay: 80ms;  opacity: 1; transform: none; }
.reveal-stagger.visible > *:nth-child(3)  { transition-delay: 160ms; opacity: 1; transform: none; }
.reveal-stagger.visible > *:nth-child(4)  { transition-delay: 240ms; opacity: 1; transform: none; }
.reveal-stagger.visible > *:nth-child(5)  { transition-delay: 320ms; opacity: 1; transform: none; }
.reveal-stagger.visible > *:nth-child(6)  { transition-delay: 400ms; opacity: 1; transform: none; }
.reveal-stagger.visible > *:nth-child(n+7){ transition-delay: 480ms; opacity: 1; transform: none; }

/* ── Hero entrance ────────────────────────────────────────── */
.hero-content > * {
  animation: slide-up 0.8s var(--ease-out) both;
}

.hero-content > *:nth-child(1) { animation-delay: 0.1s; }
.hero-content > *:nth-child(2) { animation-delay: 0.2s; }
.hero-content > *:nth-child(3) { animation-delay: 0.3s; }
.hero-content > *:nth-child(4) { animation-delay: 0.45s; }
.hero-content > *:nth-child(5) { animation-delay: 0.55s; }

/* ── Page transitions ─────────────────────────────────────── */
.page-enter {
  animation: fade-in 0.4s var(--ease-out) both;
}

/* ── Card hover micro-interactions ───────────────────────────*/
.card { transition: background var(--t-normal), border-color var(--t-normal),
                    transform var(--t-normal), box-shadow var(--t-normal); }

/* ── Skeleton loading ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    rgba(255,255,255,0.05) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 22px; margin-bottom: 12px; width: 60%; }
.skeleton-avatar{ width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px; }

/* ── Loading spinner ──────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--space-8) auto;
}

/* ── Stats counter animation ──────────────────────────────── */
.stat-number {
  animation: count-up 0.6s var(--ease-out) both;
}

.stat-item:nth-child(1) .stat-number { animation-delay: 0.1s; }
.stat-item:nth-child(2) .stat-number { animation-delay: 0.2s; }
.stat-item:nth-child(3) .stat-number { animation-delay: 0.3s; }
.stat-item:nth-child(4) .stat-number { animation-delay: 0.4s; }

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .hero::before,
  .hero::after { animation: none; }
}
