/* Advanced Stepped Form - Animations */

/* Step transition animations */
.asf-form[data-animation="slide"] .asf-step {
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

.asf-form[data-animation="slide"] .asf-step-active {
  transform: translateX(0);
}

.asf-form[data-animation="slide"] .asf-step.asf-prev {
  transform: translateX(-100%);
}

.asf-form[data-animation="fade"] .asf-step {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.asf-form[data-animation="fade"] .asf-step-active {
  opacity: 1;
  transform: scale(1);
}

.asf-form[data-animation="scale"] .asf-step {
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.asf-form[data-animation="scale"] .asf-step-active {
  opacity: 1;
  transform: scale(1);
}

.asf-form[data-animation="flip"] .asf-step {
  opacity: 0;
  transform: rotateY(90deg);
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform-origin: center;
}

.asf-form[data-animation="flip"] .asf-step-active {
  opacity: 1;
  transform: rotateY(0deg);
}

/* Option animations */
.asf-options {
  animation-delay: 0.2s;
  animation-fill-mode: both;
}

.asf-step-active .asf-option {
  animation: asfSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.asf-step-active .asf-option:nth-child(1) { animation-delay: 0.1s; }
.asf-step-active .asf-option:nth-child(2) { animation-delay: 0.15s; }
.asf-step-active .asf-option:nth-child(3) { animation-delay: 0.2s; }
.asf-step-active .asf-option:nth-child(4) { animation-delay: 0.25s; }
.asf-step-active .asf-option:nth-child(5) { animation-delay: 0.3s; }
.asf-step-active .asf-option:nth-child(6) { animation-delay: 0.35s; }

@keyframes asfSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Form field animations */
.asf-step-active .asf-field {
  animation: asfFadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
  transform: translateY(15px);
}

.asf-step-active .asf-field:nth-child(1) { animation-delay: 0.1s; }
.asf-step-active .asf-field:nth-child(2) { animation-delay: 0.2s; }
.asf-step-active .asf-field:nth-child(3) { animation-delay: 0.3s; }
.asf-step-active .asf-field:nth-child(4) { animation-delay: 0.4s; }

@keyframes asfFadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Button animations */
.asf-step-active .asf-step-actions {
  animation: asfSlideUpActions 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: 0.3s;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes asfSlideUpActions {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Progress dot animations */
.asf-dot {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.asf-dot-active {
  animation: asfPulse 0.6s ease-in-out;
}

@keyframes asfPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1.2);
  }
}

/* Hover effects */
.asf-option {
  position: relative;
  overflow: hidden;
}

.asf-option::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  transition: left 0.6s;
}

.asf-option:hover::before {
  left: 100%;
}

/* Selection animations */
.asf-option.asf-selecting {
  animation: asfWiggle 0.4s ease-in-out;
}

.asf-next:active,
.asf-submit:active,
.asf-prev:active {
  animation: asfWiggle 0.3s ease-in-out;
}

@keyframes asfWiggle {
  0% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(-2deg);
  }
  40% {
    transform: rotate(2.5deg);
  }
  60% {
    transform: rotate(-1.5deg);
  }
  80% {
    transform: rotate(1deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

/* Success animation */
.asf-result.asf-success {
  animation: asfSuccessSlide 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes asfSuccessSlide {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Loading animation */
.asf-submit.asf-loading {
  animation: asfLoadingPulse 2s infinite;
}

@keyframes asfLoadingPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Form wrapper entrance */
.asf-form-wrapper {
  animation: asfFormEntrance 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes asfFormEntrance {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Micro-interactions */
.asf-next:active,
.asf-submit:active {
  animation: asfButtonPress 0.1s ease;
}

@keyframes asfButtonPress {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
  }
}

/* Focus animations */
.asf-field input:focus,
.asf-field textarea:focus,
.asf-field select:focus {
  animation: asfFocusGlow 0.3s ease;
}

@keyframes asfFocusGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(24,144,255,0.1);
  }
  100% {
    box-shadow: 0 0 0 3px rgba(24,144,255,0.1);
  }
}

/* Error shake animation */
.asf-field.asf-error {
  animation: asfErrorShake 0.5s ease-in-out;
}

@keyframes asfErrorShake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Click animations for buttons */
@keyframes asf-fade {
  0% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
  }
}

@keyframes asf-scale {
  0% {
    transform: scale(0.95);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes asf-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.4);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 10px rgba(24, 144, 255, 0);
    opacity: 1;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0);
    opacity: 1;
  }
}

/* Ensure buttons stay visible during animation */
.asf-option.asf-selecting {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .asf-step,
  .asf-option,
  .asf-field,
  .asf-step-actions,
  .asf-dot,
  .asf-result,
  .asf-form-wrapper {
    animation: none !important;
    transition: none !important;
  }
  
  .asf-option::before {
    display: none;
  }
}

/* High performance mode for older devices */
@media (max-width: 480px) and (max-resolution: 150dpi) {
  .asf-step,
  .asf-option,
  .asf-field {
    animation-duration: 0.2s;
    transition-duration: 0.2s;
  }
  
  .asf-option::before {
    display: none;
  }
}