/* ===================================================================
   BanterBox Policy Animation Library
   Version: 1.0
   Description: Comprehensive animation system for the BanterBox Policy Platform
   
   This file contains:
   - Micro-interactions for UI elements
   - Page transitions and entrance animations
   - Advanced animation effects
   - Performance optimizations
   =================================================================== */

/* Import design system */
@import url('policy-design-system.css');

/* ===================================================================
   1. MICRO-INTERACTIONS
   =================================================================== */

/* Hover effects */
.hover-lift {
  transition: transform var(--transition-fast) var(--ease-out);
}

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

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

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

.hover-glow {
  transition: all var(--transition-fast) var(--ease-out);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.hover-underline {
  position: relative;
  overflow: hidden;
}

.hover-underline::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-accent-500);
  transform: translateX(-100%);
  transition: transform var(--transition-base) var(--ease-out);
}

.hover-underline:hover::after {
  transform: translateX(0);
}

/* Focus states */
.focus-ring {
  transition: all var(--transition-fast) var(--ease-out);
}

.focus-ring:focus-visible {
  outline: 2px solid var(--color-accent-500);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.1);
}

/* Loading animations */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-gray-200);
  border-top-color: var(--color-accent-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner--small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner--large {
  width: 60px;
  height: 60px;
  border-width: 4px;
}

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

/* Pulse animation */
.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Bounce animation */
.bounce {
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

/* Success/Error animations */
.success-check {
  width: 60px;
  height: 60px;
  position: relative;
}

.success-check-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 2;
  stroke: var(--color-success);
  fill: none;
  animation: success-circle 0.6s ease-in-out forwards;
}

.success-check-mark {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke: var(--color-success);
  animation: success-check-mark 0.3s ease-in-out 0.6s forwards;
}

@keyframes success-circle {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes success-check-mark {
  to {
    stroke-dashoffset: 0;
  }
}

.error-cross {
  width: 60px;
  height: 60px;
  position: relative;
}

.error-cross-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 2;
  stroke: var(--color-error);
  fill: none;
  animation: error-circle 0.6s ease-in-out forwards;
}

.error-cross-x {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke: var(--color-error);
  animation: error-x 0.3s ease-in-out 0.6s forwards;
}

@keyframes error-circle {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes error-x {
  to {
    stroke-dashoffset: 0;
  }
}

/* ===================================================================
   2. PAGE TRANSITIONS
   =================================================================== */

/* Fade animations */
.fade-in {
  animation: fadeIn var(--transition-base) var(--ease-out) forwards;
}

.fade-out {
  animation: fadeOut var(--transition-base) var(--ease-out) forwards;
}

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

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

/* Slide animations */
.slide-in-up {
  animation: slideInUp var(--transition-base) var(--ease-out) forwards;
}

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

.slide-in-left {
  animation: slideInLeft var(--transition-base) var(--ease-out) forwards;
}

.slide-in-right {
  animation: slideInRight var(--transition-base) var(--ease-out) forwards;
}

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

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

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

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

/* Scale animations */
.scale-in {
  animation: scaleIn var(--transition-base) var(--ease-out) forwards;
}

.scale-out {
  animation: scaleOut var(--transition-base) var(--ease-out) forwards;
}

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

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

/* Stagger animations */
.stagger-children > * {
  opacity: 0;
  animation: fadeInUp var(--transition-base) var(--ease-out) forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }
.stagger-children > *:nth-child(9) { animation-delay: 400ms; }
.stagger-children > *:nth-child(10) { animation-delay: 450ms; }

/* Parallax setup */
.parallax-container {
  position: relative;
  overflow: hidden;
}

.parallax-layer {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.parallax-layer--slow {
  transform: translateY(calc(var(--scroll-y, 0) * 0.5));
}

.parallax-layer--medium {
  transform: translateY(calc(var(--scroll-y, 0) * 0.3));
}

.parallax-layer--fast {
  transform: translateY(calc(var(--scroll-y, 0) * 0.1));
}

/* ===================================================================
   3. ADVANCED ANIMATIONS
   =================================================================== */

/* Gradient animations */
.gradient-shift {
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
}

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

/* Text reveal animations */
.text-reveal {
  overflow: hidden;
}

.text-reveal-line {
  display: block;
  overflow: hidden;
}

.text-reveal-line span {
  display: inline-block;
  transform: translateY(100%);
  animation: textReveal var(--transition-slow) var(--ease-out) forwards;
}

@keyframes textReveal {
  to {
    transform: translateY(0);
  }
}

/* Typewriter effect */
.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--color-accent-500);
  animation: 
    typewriter 3s steps(40, end),
    blink 0.75s step-end infinite;
}

@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink {
  from, to { border-color: transparent; }
  50% { border-color: var(--color-accent-500); }
}

/* Morphing shapes */
.morph {
  animation: morph 8s ease-in-out infinite;
}

@keyframes morph {
  0%, 100% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
  25% {
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
  }
  50% {
    border-radius: 50% 60% 30% 60% / 30% 70% 40% 60%;
  }
  75% {
    border-radius: 60% 30% 70% 40% / 70% 40% 60% 30%;
  }
}

/* Particle system base */
.particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--color-accent-400);
  border-radius: 50%;
  opacity: 0;
  animation: particle-float 10s linear infinite;
}

@keyframes particle-float {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) scale(1);
    opacity: 0;
  }
}

/* ===================================================================
   4. PERFORMANCE OPTIMIZATIONS
   =================================================================== */

/* GPU acceleration hints */
.will-animate {
  will-change: transform;
}

.will-animate-opacity {
  will-change: opacity;
}

.will-animate-all {
  will-change: transform, opacity;
}

/* Remove will-change after animation */
.animation-done {
  will-change: auto;
}

/* Prefers reduced motion */
@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;
  }
  
  .parallax-layer {
    transform: none !important;
  }
  
  .hover-lift:hover,
  .hover-scale:hover {
    transform: none;
  }
  
  .spinner {
    animation: none;
    border-color: var(--color-accent-500);
  }
}

/* ===================================================================
   5. UTILITY ANIMATIONS
   =================================================================== */

/* Shake animation */
.shake {
  animation: shake 0.5s ease-in-out;
}

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

/* Wiggle animation */
.wiggle {
  animation: wiggle 1s ease-in-out infinite;
}

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

/* Float animation */
.float {
  animation: float 3s ease-in-out infinite;
}

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

/* Heartbeat animation */
.heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
  0% { transform: scale(1); }
  14% { transform: scale(1.3); }
  28% { transform: scale(1); }
  42% { transform: scale(1.3); }
  70% { transform: scale(1); }
}

/* Flash animation */
.flash {
  animation: flash 1s ease-in-out;
}

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

/* Rubber band animation */
.rubber-band {
  animation: rubberBand 1s ease-in-out;
}

@keyframes rubberBand {
  0% { 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); }
  100% { transform: scale(1); }
}

/* Jello animation */
.jello {
  animation: jello 1s ease-in-out;
}

@keyframes jello {
  0%, 100% { transform: skewX(0deg) skewY(0deg); }
  30% { transform: skewX(-12.5deg) skewY(-12.5deg); }
  40% { transform: skewX(6.25deg) skewY(6.25deg); }
  50% { transform: skewX(-3.125deg) skewY(-3.125deg); }
  65% { transform: skewX(1.5625deg) skewY(1.5625deg); }
  75% { transform: skewX(-0.78125deg) skewY(-0.78125deg); }
  85% { transform: skewX(0.390625deg) skewY(0.390625deg); }
  95% { transform: skewX(-0.1953125deg) skewY(-0.1953125deg); }
}