/*
 * IWonnaP — Animations
 * Reusable base keyframes + utility classes for micro-interactions.
 *
 * NOTE (ADR-026): feedback-bound keyframes (rs-pulse, ef-flash, modal-spin,
 * timeline-blink) moved to motion.css so they live next to their
 * prefers-reduced-motion overrides and can win the cascade.
 *
 * What stays here: base motion primitives (fade / scale / pop / slide /
 * shimmer / spin / dot / sheen / pulse-glow), utility classes (.anim-*,
 * .hover-*, .pulse-dot, .skeleton), and the global motion kill switch.
 */

/* ─── Keyframes ──────────────────────────────────── */

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

@keyframes iwp-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes iwp-fade-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes iwp-pop-up {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes iwp-slide-up {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes iwp-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(40, 200, 210, .35); }
  50%      { box-shadow: 0 0 0 6px rgba(40, 200, 210, 0); }
}

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

@keyframes iwp-running-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

@keyframes iwp-sheen {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(120%); }
}

/* ─── Utility classes ────────────────────────────── */

.anim-fade-in   { animation: iwp-fade-in   var(--t-base) both; }
.anim-fade-up   { animation: iwp-fade-up   var(--t-base) both; }
.anim-fade-down { animation: iwp-fade-down var(--t-base) both; }
.anim-scale-in  { animation: iwp-scale-in  var(--t-base) both; }
.anim-pop-up    { animation: iwp-pop-up    var(--t-spring) both; }
.anim-slide-up  { animation: iwp-slide-up  var(--t-base) both; }

/* Stagger helpers for lists */
.anim-stagger > *               { animation: iwp-fade-up var(--t-base) both; }
.anim-stagger > *:nth-child(1)  { animation-delay:   0ms; }
.anim-stagger > *:nth-child(2)  { animation-delay:  40ms; }
.anim-stagger > *:nth-child(3)  { animation-delay:  80ms; }
.anim-stagger > *:nth-child(4)  { animation-delay: 120ms; }
.anim-stagger > *:nth-child(5)  { animation-delay: 160ms; }
.anim-stagger > *:nth-child(6)  { animation-delay: 200ms; }
.anim-stagger > *:nth-child(7)  { animation-delay: 240ms; }
.anim-stagger > *:nth-child(8)  { animation-delay: 280ms; }
.anim-stagger > *:nth-child(n+9) { animation-delay: 320ms; }

/* Hover lift — for cards */
.hover-lift {
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
}

/* Sheen on hover (subtle highlight pass) */
.hover-sheen { position: relative; overflow: hidden; }
.hover-sheen::after {
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.08) 50%, transparent 70%);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  transform: translateX(-100%);
  transition: transform var(--t-slow);
}
.hover-sheen:hover::after { transform: translateX(120%); }

/* Pulsing dot for "running" indicator */
.pulse-dot {
  animation: iwp-pulse-glow 1.6s ease-in-out infinite;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  height: 8px;
  width: 8px;
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-soft) 0%,
    var(--surface-elev) 50%,
    var(--surface-soft) 100%
  );
  background-size: 200% 100%;
  animation: iwp-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
  min-height: 16px;
}

/* ─── Global reduced-motion kill switch ───────────────
 * Feedback-keyframe overrides (modal-spin / timeline-blink) live in motion.css.
 * This block neuters every other animation/transition globally.
 * ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
