/**
 * komainu-vigil — Shrine Animations
 *
 * Reusable animation keyframes and utility classes.
 * Requires: design-tokens.css (loaded first).
 *
 * All animations respect prefers-reduced-motion via components.css.
 *
 * Animations:
 *   - float          — gentle vertical float
 *   - glow           — pulsing glow
 *   - pulse-glow     — expanding glow circle
 *   - shimmer        — loading skeleton
 *   - fade-in        — entrance fade
 *   - slide-up       — entrance slide
 *   - card-enter     — staggered card entrance
 *   - vault-glow     — backup vault pulsing
 *   - error-pulse    — error state pulse
 *   - notification   — slide in / fade out
 *   - ring-fill      — status ring scale in
 *   - lantern-flame  — flickering flame
 *   - haiku-fade     — stone carving reveal
 *   - drift          — slow horizontal drift
 */

/* ═══════════════════════════════════════════
   Float — gentle vertical bobbing
   ═══════════════════════════════════════════ */

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.animate-float {
  animation: float 4s ease-in-out infinite;
}

/* ═══════════════════════════════════════════
   Glow — pulsing opacity glow
   ═══════════════════════════════════════════ */

@keyframes glow {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

.animate-glow {
  animation: glow 3s ease-in-out infinite;
}

/* ═══════════════════════════════════════════
   Pulse glow — expanding radial glow circle
   ═══════════════════════════════════════════ */

@keyframes pulse-glow {
  0%, 100% {
    opacity: 0.3;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1.2);
  }
}

.animate-pulse-glow {
  animation: pulse-glow 3s ease-in-out infinite;
}

/* ═══════════════════════════════════════════
   Shimmer — loading skeleton gradient sweep
   ═══════════════════════════════════════════ */

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

.animate-shimmer {
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-surface-hover) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* ═══════════════════════════════════════════
   Fade in — entrance
   ═══════════════════════════════════════════ */

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

.animate-fade-in {
  animation: fade-in 0.8s ease-out forwards;
}

/* ═══════════════════════════════════════════
   Slide up — entrance from below
   ═══════════════════════════════════════════ */

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

.animate-slide-up {
  animation: slide-up 0.6s ease-out forwards;
}

/* ═══════════════════════════════════════════
   Card enter — staggered grid entrance
   ═══════════════════════════════════════════ */

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

.animate-card-enter {
  animation: card-enter 0.4s ease-out both;
}

/* Stagger delays for grid children */
.animate-stagger > :nth-child(1)  { animation-delay: 0.05s; }
.animate-stagger > :nth-child(2)  { animation-delay: 0.1s; }
.animate-stagger > :nth-child(3)  { animation-delay: 0.15s; }
.animate-stagger > :nth-child(4)  { animation-delay: 0.2s; }
.animate-stagger > :nth-child(5)  { animation-delay: 0.25s; }
.animate-stagger > :nth-child(6)  { animation-delay: 0.3s; }
.animate-stagger > :nth-child(7)  { animation-delay: 0.35s; }
.animate-stagger > :nth-child(8)  { animation-delay: 0.4s; }
.animate-stagger > :nth-child(9)  { animation-delay: 0.45s; }

/* ═══════════════════════════════════════════
   Vault glow — backup vault pulsing glow
   ═══════════════════════════════════════════ */

@keyframes vault-glow {
  0%, 100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.05);
  }
}

.animate-vault-glow {
  animation: vault-glow 4s ease-in-out infinite;
}

/* ═══════════════════════════════════════════
   Error pulse — attention-grabbing pulse
   ═══════════════════════════════════════════ */

@keyframes error-pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

.animate-error-pulse {
  animation: error-pulse 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════
   Notification — slide in from top
   ═══════════════════════════════════════════ */

@keyframes notification-slide {
  0%   { opacity: 0; transform: translateY(-16px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes notification-fade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

.animate-notification-in {
  animation: notification-slide 0.4s ease-out;
}

.animate-notification-out {
  animation: notification-fade 0.5s ease-out forwards;
}

/* ═══════════════════════════════════════════
   Ring fill — scale-in for status rings
   ═══════════════════════════════════════════ */

@keyframes ring-fill {
  0%   { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.animate-ring-fill {
  animation: ring-fill 0.4s ease-out forwards;
}

/* ═══════════════════════════════════════════
   Lantern flame — flickering candle effect
   ═══════════════════════════════════════════ */

@keyframes lantern-flame {
  0%, 100% { opacity: 0.8; transform: scale(1) rotate(-1deg); }
  25%      { opacity: 1;   transform: scale(1.05) rotate(1deg); }
  50%      { opacity: 0.85; transform: scale(0.98) rotate(-0.5deg); }
  75%      { opacity: 0.95; transform: scale(1.02) rotate(0.5deg); }
}

.animate-flame {
  animation: lantern-flame 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════
   Haiku fade — stone carving reveal
   ═══════════════════════════════════════════ */

@keyframes haiku-fade-in {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-haiku-line-1 {
  animation: haiku-fade-in 2s ease-out 0.3s forwards;
  opacity: 0;
}

.animate-haiku-line-2 {
  animation: haiku-fade-in 2s ease-out 0.9s forwards;
  opacity: 0;
}

.animate-haiku-line-3 {
  animation: haiku-fade-in 2s ease-out 1.5s forwards;
  opacity: 0;
}

.animate-haiku-divider {
  animation: haiku-fade-in 1.5s ease-out 0.8s forwards;
  opacity: 0;
}

.animate-haiku-season {
  animation: haiku-fade-in 2s ease-out 1.2s forwards;
  opacity: 0;
}

/* ═══════════════════════════════════════════
   Drift — slow horizontal movement
   ═══════════════════════════════════════════ */

@keyframes drift {
  0%   { transform: translateX(-10px); }
  50%  { transform: translateX(10px); }
  100% { transform: translateX(-10px); }
}

.animate-drift {
  animation: drift 8s ease-in-out infinite;
}

/* ═══════════════════════════════════════════
   Utility classes
   ═══════════════════════════════════════════ */

/* Prevent animation on element */
.no-animate {
  animation: none !important;
}

/* Delay utilities */
.delay-100  { animation-delay: 0.1s; }
.delay-200  { animation-delay: 0.2s; }
.delay-300  { animation-delay: 0.3s; }
.delay-500  { animation-delay: 0.5s; }
.delay-1000 { animation-delay: 1s; }
