/**
 * Psyn.app - Animation System
 * Comprehensive animation library with micro-interactions
 * Developer: Aaliyah
 */

/* ============================================
   ENTRANCE ANIMATIONS
   ============================================ */

/* Fade Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale Animations */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleInCenter {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide Animations */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Bounce Animation */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

/* Rotate Animation */
@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-200deg);
  }
  to {
    opacity: 1;
    transform: rotate(0);
  }
}

/* Flip Animation */
@keyframes flipIn {
  from {
    opacity: 0;
    transform: perspective(400px) rotateX(90deg);
  }
  to {
    opacity: 1;
    transform: perspective(400px) rotateX(0);
  }
}

/* ============================================
   EXIT ANIMATIONS
   ============================================ */

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes fadeOutUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-30px);
  }
}

@keyframes fadeOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(30px);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes slideOutUp {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-100%);
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

/* Pulse */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

/* Heartbeat */
@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  10%, 30% {
    transform: scale(0.9);
  }
  20%, 40% {
    transform: scale(1.1);
  }
}

/* Shake */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* Wiggle */
@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
}

/* Float */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Bounce */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Swing */
@keyframes swing {
  0%, 100% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(15deg);
  }
  40% {
    transform: rotate(-10deg);
  }
  60% {
    transform: rotate(5deg);
  }
  80% {
    transform: rotate(-5deg);
  }
}

/* Glow */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(134, 192, 255, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(134, 192, 255, 0.8), 
                0 0 30px rgba(134, 192, 255, 0.6);
  }
}

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

/* Ripple */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

/* Button Press */
@keyframes buttonPress {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

/* Tilt */
@keyframes tilt {
  0%, 100% {
    transform: perspective(1000px) rotateY(0deg);
  }
  50% {
    transform: perspective(1000px) rotateY(10deg);
  }
}

/* ============================================
   LOADING ANIMATIONS
   ============================================ */

/* Spinner */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Dots */
@keyframes dotPulse {
  0%, 80%, 100% {
    opacity: 0;
    transform: scale(0);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Progress Bar */
@keyframes progressIndeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

/* Skeleton */
@keyframes skeletonLoading {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

/* Wave */
@keyframes wave {
  0%, 60%, 100% {
    transform: initial;
  }
  30% {
    transform: translateY(-15px);
  }
}

/* Blink (Terminal Cursor) */
@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* ============================================
   ATTENTION SEEKERS
   ============================================ */

/* Flash */
@keyframes flash {
  0%, 50%, 100% {
    opacity: 1;
  }
  25%, 75% {
    opacity: 0;
  }
}

/* Rubber Band */
@keyframes rubberBand {
  0%, 100% {
    transform: scale(1);
  }
  30% {
    transform: scaleX(1.25) scaleY(0.75);
  }
  40% {
    transform: scaleX(0.75) scaleY(1.25);
  }
  50% {
    transform: scaleX(1.15) scaleY(0.85);
  }
  65% {
    transform: scaleX(0.95) scaleY(1.05);
  }
  75% {
    transform: scaleX(1.05) scaleY(0.95);
  }
}

/* Jello */
@keyframes jello {
  0%, 100% {
    transform: skewX(0deg) skewY(0deg);
  }
  30% {
    transform: skewX(25deg) skewY(25deg);
  }
  40% {
    transform: skewX(-20deg) skewY(-20deg);
  }
  50% {
    transform: skewX(15deg) skewY(15deg);
  }
  65% {
    transform: skewX(-10deg) skewY(-10deg);
  }
  75% {
    transform: skewX(5deg) skewY(5deg);
  }
}

/* Tada */
@keyframes tada {
  0%, 100% {
    transform: scale(1) rotate(0deg);
  }
  10%, 20% {
    transform: scale(0.9) rotate(-3deg);
  }
  30%, 50%, 70%, 90% {
    transform: scale(1.1) rotate(3deg);
  }
  40%, 60%, 80% {
    transform: scale(1.1) rotate(-3deg);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Entrance Utilities */
.animate-fade-in {
  animation: fadeIn var(--duration-base) var(--ease-out);
}

.animate-fade-in-up {
  animation: fadeInUp var(--duration-base) var(--ease-out);
}

.animate-fade-in-down {
  animation: fadeInDown var(--duration-base) var(--ease-out);
}

.animate-fade-in-left {
  animation: fadeInLeft var(--duration-base) var(--ease-out);
}

.animate-fade-in-right {
  animation: fadeInRight var(--duration-base) var(--ease-out);
}

.animate-scale-in {
  animation: scaleIn var(--duration-base) var(--ease-out);
}

.animate-bounce-in {
  animation: bounceIn var(--duration-slow) var(--ease-bounce);
}

.animate-slide-in-up {
  animation: slideInUp var(--duration-base) var(--ease-out);
}

.animate-slide-in-down {
  animation: slideInDown var(--duration-base) var(--ease-out);
}

.animate-zoom-in {
  animation: zoomIn var(--duration-base) var(--ease-out);
}

/* Exit Utilities */
.animate-fade-out {
  animation: fadeOut var(--duration-base) var(--ease-out);
}

.animate-fade-out-up {
  animation: fadeOutUp var(--duration-base) var(--ease-out);
}

.animate-scale-out {
  animation: scaleOut var(--duration-base) var(--ease-out);
}

/* Micro-interaction Utilities */
.animate-pulse {
  animation: pulse 2s var(--ease-in-out) infinite;
}

.animate-heartbeat {
  animation: heartbeat 1.5s var(--ease-in-out) infinite;
}

.animate-shake {
  animation: shake 0.5s var(--ease-out);
}

.animate-wiggle {
  animation: wiggle 0.5s var(--ease-in-out);
}

.animate-float {
  animation: float 3s var(--ease-in-out) infinite;
}

.animate-bounce {
  animation: bounce 1s var(--ease-in-out) infinite;
}

.animate-glow {
  animation: glow 2s var(--ease-in-out) infinite;
}

.animate-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s linear infinite;
}

/* Loading Utilities */
.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-blink {
  animation: blink 1s step-end infinite;
}

/* Attention Utilities */
.animate-flash {
  animation: flash 1s var(--ease-in-out);
}

.animate-rubber-band {
  animation: rubberBand 1s var(--ease-out);
}

.animate-jello {
  animation: jello 1s var(--ease-out);
}

.animate-tada {
  animation: tada 1s var(--ease-out);
}

/* ============================================
   ANIMATION DELAYS
   ============================================ */

.animate-delay-100 {
  animation-delay: 100ms;
}

.animate-delay-200 {
  animation-delay: 200ms;
}

.animate-delay-300 {
  animation-delay: 300ms;
}

.animate-delay-400 {
  animation-delay: 400ms;
}

.animate-delay-500 {
  animation-delay: 500ms;
}

.animate-delay-600 {
  animation-delay: 600ms;
}

.animate-delay-700 {
  animation-delay: 700ms;
}

.animate-delay-800 {
  animation-delay: 800ms;
}

/* ============================================
   ANIMATION DURATIONS
   ============================================ */

.animate-duration-fast {
  animation-duration: var(--duration-fast);
}

.animate-duration-base {
  animation-duration: var(--duration-base);
}

.animate-duration-slow {
  animation-duration: var(--duration-slow);
}

.animate-duration-glacial {
  animation-duration: var(--duration-glacial);
}

/* ============================================
   HOVER ANIMATIONS
   ============================================ */

.hover-lift {
  transition: transform var(--duration-fast) var(--ease-out);
}

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

.hover-grow {
  transition: transform var(--duration-fast) var(--ease-out);
}

.hover-grow:hover {
  transform: scale(1.05);
}

.hover-shrink {
  transition: transform var(--duration-fast) var(--ease-out);
}

.hover-shrink:hover {
  transform: scale(0.95);
}

.hover-tilt {
  transition: transform var(--duration-fast) var(--ease-out);
}

.hover-tilt:hover {
  transform: rotate(5deg);
}

.hover-glow {
  transition: box-shadow var(--duration-fast) var(--ease-out);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(134, 192, 255, 0.5),
              0 0 40px rgba(134, 192, 255, 0.3);
}

.hover-underline {
  position: relative;
}

.hover-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--syntax-gold);
  transition: width var(--duration-fast) var(--ease-out);
}

.hover-underline:hover::after {
  width: 100%;
}

/* ============================================
   SCROLL ANIMATIONS
   ============================================ */

.scroll-fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.scroll-fade-in.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.scroll-slide-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.scroll-slide-left.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.scroll-slide-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.scroll-slide-right.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.scroll-scale {
  opacity: 0;
  transform: scale(0.8);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.scroll-scale.is-visible {
  opacity: 1;
  transform: scale(1);
}

/* ============================================
   STAGGER ANIMATIONS
   ============================================ */

.stagger-fade > * {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp var(--duration-base) var(--ease-out) both;
}

.stagger-fade > *:nth-child(1) { animation-delay: 0ms; }
.stagger-fade > *:nth-child(2) { animation-delay: 100ms; }
.stagger-fade > *:nth-child(3) { animation-delay: 200ms; }
.stagger-fade > *:nth-child(4) { animation-delay: 300ms; }
.stagger-fade > *:nth-child(5) { animation-delay: 400ms; }
.stagger-fade > *:nth-child(6) { animation-delay: 500ms; }
.stagger-fade > *:nth-child(7) { animation-delay: 600ms; }
.stagger-fade > *:nth-child(8) { animation-delay: 700ms; }
.stagger-fade > *:nth-child(9) { animation-delay: 800ms; }
.stagger-fade > *:nth-child(10) { animation-delay: 900ms; }

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

@keyframes pageSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pageSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-20px);
  }
}

.page-enter {
  animation: pageSlideIn var(--duration-base) var(--ease-out);
}

.page-exit {
  animation: pageSlideOut var(--duration-base) var(--ease-out);
}

/* ============================================
   BACKGROUND ANIMATIONS
   ============================================ */

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

.animate-gradient {
  background-size: 200% 200%;
  animation: gradientShift 15s ease infinite;
}

/* Particle Float */
@keyframes particleFloat {
  0%, 100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(10px, -10px);
  }
  50% {
    transform: translate(-5px, -20px);
  }
  75% {
    transform: translate(-10px, -10px);
  }
}

.animate-particles {
  animation: particleFloat 20s ease-in-out infinite;
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  /* Disable infinite animations */
  .animate-pulse,
  .animate-heartbeat,
  .animate-float,
  .animate-bounce,
  .animate-glow,
  .animate-spin,
  .animate-blink,
  .animate-shimmer,
  .animate-gradient,
  .animate-particles {
    animation: none !important;
  }
  
  /* Keep essential feedback */
  .hover-lift:hover,
  .hover-grow:hover,
  .hover-shrink:hover {
    transform: none;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  * {
    animation: none !important;
    transition: none !important;
  }
}
