/**
 * Apple-Grade Animations
 * Smooth, natural animations following Apple's design principles
 */

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

@keyframes slide-in-from-bottom {
  from {
    transform: translateY(1rem);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slide-in-from-top {
  from {
    transform: translateY(-1rem);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slide-in-from-left {
  from {
    transform: translateX(-1rem);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slide-in-from-right {
  from {
    transform: translateX(1rem);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

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

/* Animation utilities */
.animate-in {
  animation-duration: 500ms;
  animation-fill-mode: both;
}

.fade-in {
  animation-name: fade-in;
}

.slide-in-from-bottom-4 {
  animation-name: slide-in-from-bottom;
}

.slide-in-from-top-4 {
  animation-name: slide-in-from-top;
}

.slide-in-from-left-4 {
  animation-name: slide-in-from-left;
}

.slide-in-from-right-4 {
  animation-name: slide-in-from-right;
}

.scale-in {
  animation-name: scale-in;
}

.duration-300 {
  animation-duration: 300ms;
}

.duration-500 {
  animation-duration: 500ms;
}

.duration-700 {
  animation-duration: 700ms;
}

/* Smooth transitions */
.transition-smooth {
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover lift effect */
.hover-lift {
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
  transform: translateY(-2px);
}

/* Skeleton shimmer */
.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    hsl(var(--muted)) 0%,
    hsl(var(--muted) / 0.8) 50%,
    hsl(var(--muted)) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

/* ── Onboarding celebration confetti (2026-10-07) ──────────────────────── */
@keyframes onb-confetti-fall {
  0% {
    transform: translateY(-18px) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translateY(320px) rotate(560deg);
    opacity: 0;
  }
}

.onb-confetti-piece {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation-name: onb-confetti-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

@media (prefers-reduced-motion: reduce) {
  .onb-confetti-piece {
    animation: none;
    opacity: 0.3;
    transform: translateY(90px);
  }
}

/**
 * Apple-Grade Notification Animations
 * Subtle, elegant animations following Apple's design principles
 */

@keyframes subtle-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.05);
  }
}

/* Apply to notification badge */
.notification-badge-pulse {
  animation: subtle-pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/**
 * Reduced-motion safety net for the auth surfaces.
 *
 * Scoped to `[data-auth-surface]` on purpose. A repo-wide reset is not this
 * lane's to make, and a blanket `animation: none` would also delete the
 * feedback a busy state depends on — Visual System §13 requires reduced motion
 * to remove spatial and celebratory effects *without removing feedback*.
 *
 * This block covers the animation framer-motion cannot: Tailwind utility
 * keyframes and CSS transitions. framer-motion ignores the CSS media query
 * entirely, so `<MotionConfig reducedMotion="user">` in AuthShell and
 * /forgot-password is the half that stops `motion.*` components. Both halves
 * are needed; neither is sufficient. (AUTH_UX_PLAN U-6, BUG_REGISTER TCA-042.)
 */

/* Keep hover, focus and selection feedback within the premium interaction
 * budget while Story-owned auth routes converge on shared motion tokens. */
[data-auth-surface] .transition-colors,
[data-auth-surface] .transition-all {
  transition-duration: 120ms !important;
}

@media (prefers-reduced-motion: reduce) {
  [data-auth-surface] *,
  [data-auth-surface] *::before,
  [data-auth-surface] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /*
    Busy indicators are the exception: they are the only signal that a request
    is in flight, and freezing them would leave a pending sign-in looking
    identical to an idle one. Kept, but slowed to a non-vestibular rate.
  */
  [data-auth-surface] .animate-spin {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }

  /* Purely decorative attention pulses have no such justification. */
  [data-auth-surface] .animate-pulse,
  [data-auth-surface] .animate-bounce,
  [data-auth-surface] .animate-ping {
    animation: none !important;
  }
}

