/**
 * Risk Lens Review — Animations
 * Loading states, transitions, and micro-interactions
 */

/* ============================================
   LOADING STATES
   ============================================ */

/* Button loading spinner (inline) */
.loading-spinner-sm {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Full-page loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

/* Pulse animation for loading steps */
.loading-step.active i {
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* Progress bar animation */
.progress-bar {
  height: 4px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-hover));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-indeterminate .progress-fill {
  width: 30%;
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-secondary) 25%,
    var(--color-bg-tertiary) 50%,
    var(--color-bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-card {
  height: 200px;
}

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

/* Smooth view transitions */
.view-enter {
  animation: viewEnter 0.3s ease-out;
}

.view-exit {
  animation: viewExit 0.2s ease-in;
}

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

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

/* Staggered card animations */
.card-stagger {
  animation: cardStagger 0.4s ease-out both;
}

.card-stagger:nth-child(1) { animation-delay: 0ms; }
.card-stagger:nth-child(2) { animation-delay: 50ms; }
.card-stagger:nth-child(3) { animation-delay: 100ms; }
.card-stagger:nth-child(4) { animation-delay: 150ms; }
.card-stagger:nth-child(5) { animation-delay: 200ms; }
.card-stagger:nth-child(6) { animation-delay: 250ms; }

@keyframes cardStagger {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Modal animations */
.modal-enter {
  animation: modalEnter 0.3s ease-out;
}

.modal-exit {
  animation: modalExit 0.2s ease-in;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalExit {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
}

/* Dropdown animations */
.dropdown-enter {
  animation: dropdownEnter 0.15s ease-out;
}

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

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

/* Button hover lift */
.btn-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-lift:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-lift:active:not(:disabled) {
  transform: translateY(0);
}

/* Icon bounce on hover */
.icon-bounce:hover svg {
  animation: iconBounce 0.4s ease;
}

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

/* Ripple effect */
.ripple {
  position: relative;
  overflow: hidden;
}

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

.ripple:active::after {
  width: 200%;
  height: 200%;
}

/* Focus ring animation */
.focus-ring:focus {
  outline: none;
  animation: focusRing 0.2s ease-out;
}

@keyframes focusRing {
  from {
    box-shadow: 0 0 0 0 var(--color-accent);
  }
  to {
    box-shadow: 0 0 0 3px var(--color-accent-muted);
  }
}

/* ============================================
   VERDICT ANIMATIONS
   ============================================ */

/* Verdict banner entrance */
.verdict-banner {
  animation: verdictEnter 0.5s ease-out;
}

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

/* Critical pulse for critical verdict */
.verdict-critical {
  animation: verdictEnter 0.5s ease-out, criticalPulse 2s ease-in-out infinite 0.5s;
}

@keyframes criticalPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
  50% {
    box-shadow: 0 0 20px 0 rgba(239, 68, 68, 0.15);
  }
}

/* ============================================
   SUCCESS STATES
   ============================================ */

/* Checkmark animation */
.checkmark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: block;
  stroke-width: 2;
  stroke: var(--color-success);
  stroke-miterlimit: 10;
  margin: 10% auto;
  box-shadow: inset 0 0 0 var(--color-success);
  animation: checkFill 0.4s ease-in-out 0.4s forwards, checkScale 0.3s ease-in-out 0.9s both;
}

.checkmark__circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: var(--color-success);
  fill: none;
  animation: checkStroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark__check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: checkStroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes checkStroke {
  100% { stroke-dashoffset: 0; }
}

@keyframes checkScale {
  0%, 100% { transform: none; }
  50% { transform: scale3d(1.1, 1.1, 1); }
}

@keyframes checkFill {
  100% { box-shadow: inset 0 0 0 30px rgba(34, 197, 94, 0.1); }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .loading-spinner,
  .loading-spinner-sm {
    animation: none;
  }
}
