/* ==========================================================================
   Brücken Bauen - Animations & Micro-Interactions
   Smooth transitions and engaging animations for better UX
   ========================================================================== */

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Screen Transition Animations */
.screen-enter {
  opacity: 0;
  transform: translateX(100px);
}

.screen-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.screen-exit {
  opacity: 1;
  transform: translateX(0);
}

.screen-exit-active {
  opacity: 0;
  transform: translateX(-100px);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

/* Fade In Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn var(--transition-normal) ease-out forwards;
}

.fade-in-delay-1 {
  animation: fadeIn var(--transition-normal) ease-out 0.1s forwards;
  opacity: 0;
}

.fade-in-delay-2 {
  animation: fadeIn var(--transition-normal) ease-out 0.2s forwards;
  opacity: 0;
}

.fade-in-delay-3 {
  animation: fadeIn var(--transition-normal) ease-out 0.3s forwards;
  opacity: 0;
}

/* Slide In Animations */
@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

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

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

.slide-in-bottom {
  animation: slideInFromBottom var(--transition-normal) ease-out forwards;
}

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

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

.scale-in {
  animation: scaleIn var(--transition-normal) ease-out forwards;
}

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

/* Bounce Animation for Success States */
@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

.bounce {
  animation: bounce 0.8s ease-out;
}

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

.shake {
  animation: shake 0.6s ease-in-out;
}

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

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

/* Glow Animation */
@keyframes glow {
  0% {
    box-shadow: 0 0 5px rgba(184, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(184, 0, 0, 0.6);
  }
  100% {
    box-shadow: 0 0 5px rgba(184, 0, 0, 0.3);
  }
}

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

/* Progress Bar Animations */
@keyframes progressFill {
  from {
    width: 0%;
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.progress-fill {
  animation: progressFill var(--transition-slow) ease-out;
}

/* Score Bar Animations */
@keyframes scoreIncrease {
  from {
    width: 0%;
    background: var(--gray-400);
  }
  to {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
  }
}

.score-fill {
  animation: scoreIncrease 1s ease-out forwards;
}

/* Button Hover Animations */
.cta-button {
  position: relative;
  overflow: hidden;
}

.cta-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left var(--transition-slow);
}

.cta-button:hover::before {
  left: 100%;
}

/* Card Hover Animations */
.glass-card {
  transition: all var(--transition-normal);
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 
    var(--shadow-xl),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Decision Option Animations */
.decision-option {
  transform: translateY(0);
  transition: all var(--transition-normal);
}

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

.decision-option.selected {
  animation: selectPulse 0.3s ease-out;
}

@keyframes selectPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

/* Loading Animations */
.loading-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Typing Animation for Text */
@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blinkCaret {
  from, to {
    border-color: transparent;
  }
  50% {
    border-color: var(--primary-color);
  }
}

.typing-effect {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--primary-color);
  animation: 
    typing 2s steps(40, end),
    blinkCaret 0.75s step-end infinite;
}

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

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

/* Ripple Effect for Interactions */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
  width: 300px;
  height: 300px;
}

/* Stagger Animation for Lists */
.stagger-item {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease-out forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }

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

/* Morphing Background Animation */
@keyframes morphBackground {
  0% {
    background: linear-gradient(135deg, var(--secondary-color) 0%, rgba(245, 245, 240, 0.8) 50%, rgba(184, 0, 0, 0.05) 100%);
  }
  50% {
    background: linear-gradient(225deg, rgba(245, 245, 240, 0.9) 0%, var(--secondary-color) 50%, rgba(184, 0, 0, 0.1) 100%);
  }
  100% {
    background: linear-gradient(135deg, var(--secondary-color) 0%, rgba(245, 245, 240, 0.8) 50%, rgba(184, 0, 0, 0.05) 100%);
  }
}

.morphing-background {
  animation: morphBackground 20s ease-in-out infinite;
}

/* Icon Animations */
.icon-spin {
  animation: spin 2s linear infinite;
}

.icon-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

.icon-bounce {
  animation: bounce 1s ease-out;
}

/* Text Highlight Animation */
@keyframes highlightText {
  0% {
    background-size: 0% 100%;
  }
  100% {
    background-size: 100% 100%;
  }
}

.highlight-text {
  background: linear-gradient(120deg, var(--accent-color) 0%, var(--accent-color) 100%);
  background-repeat: no-repeat;
  background-size: 0% 100%;
  background-position: 0 100%;
  animation: highlightText 0.8s ease-out forwards;
}

/* Focus Ring Animation */
@keyframes focusRing {
  0% {
    box-shadow: 0 0 0 0 rgba(184, 0, 0, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(184, 0, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(184, 0, 0, 0);
  }
}

.focus-ring:focus {
  animation: focusRing 0.6s ease-out;
}

/* Entrance Animations for Different Elements */
.entrance-slide-down {
  animation: slideInFromTop 0.6s ease-out;
}

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

/* Success Checkmark Animation */
@keyframes drawCheck {
  0% {
    stroke-dashoffset: 16;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

.success-check {
  stroke-dasharray: 16;
  animation: drawCheck 0.4s ease-out forwards;
}

/* Particle Effect (CSS Only) */
.particle-container {
  position: relative;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent-color);
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat 3s ease-out infinite;
}

@keyframes particleFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-100px) scale(0.5);
  }
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { left: 20%; animation-delay: 0.5s; }
.particle:nth-child(3) { left: 30%; animation-delay: 1s; }
.particle:nth-child(4) { left: 40%; animation-delay: 1.5s; }
.particle:nth-child(5) { left: 50%; animation-delay: 2s; }

/* Mobile Specific Animations */
@media (max-width: 768px) {
  .glass-card:hover {
    transform: none;
  }
  
  .decision-option:hover {
    transform: none;
  }
  
  /* Reduce animation intensity on mobile */
  .bounce {
    animation-duration: 0.4s;
  }
  
  .pulse {
    animation-duration: 1.5s;
  }
}

/* Performance Optimizations */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform, opacity;
}

/* Utility Classes for Manual Animation Control */
.no-animation {
  animation: none !important;
  transition: none !important;
}

.slow-animation {
  animation-duration: 2s !important;
  transition-duration: 2s !important;
}

.fast-animation {
  animation-duration: 0.2s !important;
  transition-duration: 0.2s !important;
}