/* Animations - Ignition Design System */

/* Entrance Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@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);
  }
}

/* Loading Animations */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes pulseSubtle {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Chart Animations */
@keyframes drawLine {
  from {
    stroke-dashoffset: 1000;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes growBar {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

/* Price Update Animations */
@keyframes priceFlashUp {
  0% {
    background-color: transparent;
    color: var(--color-text-primary);
  }
  50% {
    background-color: rgba(217, 95, 14, 0.2);
    color: var(--color-status-positive);
  }
  100% {
    background-color: transparent;
    color: var(--color-text-primary);
  }
}

@keyframes priceFlashDown {
  0% {
    background-color: transparent;
    color: var(--color-text-primary);
  }
  50% {
    background-color: rgba(165, 42, 42, 0.2);
    color: var(--color-status-negative);
  }
  100% {
    background-color: transparent;
    color: var(--color-text-primary);
  }
}

/* Notification Animations */
@keyframes notificationSlide {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* Hover Animations */
@keyframes glow {
  0% {
    box-shadow: 0 0 5px rgba(217, 95, 14, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(217, 95, 14, 0.8);
  }
  100% {
    box-shadow: 0 0 5px rgba(217, 95, 14, 0.5);
  }
}

/* Value Change Glow Animations */
@keyframes glowGreen {
  0% {
    text-shadow: 0 0 0 transparent;
  }
  40% {
    text-shadow: 0 0 15px rgba(34, 197, 94, 0.9), 0 0 25px rgba(34, 197, 94, 0.7), 0 0 35px rgba(34, 197, 94, 0.5);
    color: rgb(34, 197, 94);
  }
  100% {
    text-shadow: 0 0 0 transparent;
  }
}

@keyframes glowRed {
  0% {
    text-shadow: 0 0 0 transparent;
  }
  40% {
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.9), 0 0 25px rgba(239, 68, 68, 0.7), 0 0 35px rgba(239, 68, 68, 0.5);
    color: rgb(239, 68, 68);
  }
  100% {
    text-shadow: 0 0 0 transparent;
  }
}

/* Data Update Animations */
@keyframes dataUpdate {
  0% {
    background-color: rgba(217, 95, 14, 0.1);
  }
  100% {
    background-color: transparent;
  }
}

/* Skeleton Loading */
@keyframes skeletonWave {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Ticker Animation */
@keyframes ticker {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Connection Status */
@keyframes connectionPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

/* Animation Classes */
.animate-fade-in {
  animation: fadeIn 0.8s ease-out forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.8s ease-out forwards;
}

.animate-fade-in-down {
  animation: fadeInDown 0.8s ease-out forwards;
}

.animate-slide-in-left {
  animation: slideInLeft 0.8s ease-out forwards;
}

.animate-slide-in-right {
  animation: slideInRight 0.8s ease-out forwards;
}

.animate-scale-in {
  animation: scaleIn 0.8s ease-out forwards;
}

.animate-bounce-in {
  animation: bounceIn 0.9s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-pulse-subtle {
  animation: pulseSubtle 3s ease-in-out infinite;
}

.home-reveal-scope .reveal-pending {
  animation-play-state: paused;
}

.home-reveal-scope .reveal-visible {
  animation-play-state: running;
}

.animate-bounce {
  animation: bounce 1s ease-in-out infinite;
}

.animate-shimmer {
  animation: shimmer 2s linear infinite;
  background: linear-gradient(
    to right,
    var(--color-secondary-bg) 0%,
    var(--color-tertiary-bg) 50%,
    var(--color-secondary-bg) 100%
  );
  background-size: 1000px 100%;
}

.animate-draw-line {
  stroke-dasharray: 1000;
  animation: drawLine 2s ease-out forwards;
}

.animate-grow-bar {
  transform-origin: bottom;
  animation: growBar 0.5s ease-out forwards;
}

.animate-price-up {
  animation: priceFlashUp 0.5s ease-out;
}

.animate-price-down {
  animation: priceFlashDown 0.5s ease-out;
}

.animate-notification {
  animation: notificationSlide 0.3s ease-out;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

.animate-data-update {
  animation: dataUpdate 0.5s ease-out;
}

.animate-ticker {
  animation: ticker 30s linear infinite;
}

.animate-connection {
  animation: connectionPulse 2s ease-in-out infinite;
}

/* Value Glow Animations */
.animate-glow-green {
  animation: glowGreen 0.4s ease-out;
}

.animate-glow-red {
  animation: glowRed 0.4s ease-out;
}

/* Animation Delays */
.animation-delay-100 {
  animation-delay: 100ms;
}

.animation-delay-200 {
  animation-delay: 200ms;
}

.animation-delay-300 {
  animation-delay: 300ms;
}

.animation-delay-400 {
  animation-delay: 400ms;
}

.animation-delay-500 {
  animation-delay: 500ms;
}

/* Stagger Children Animation */
.stagger-children > * {
  opacity: 0;
  animation: fadeInUp 0.3s 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; }

/* Squircle Shapes - True iOS-style rounded corners */
/* Enhanced squircle system with complete size range and browser compatibility */

/* CSS Custom Properties for Dynamic Squircles */
:root {
  --squircle-xs: 12px;      /* Similar to rounded-md */
  --squircle-sm: 16px;      /* Similar to rounded-lg */
  --squircle-md: 20px;      /* Similar to rounded-xl */
  --squircle-lg: 24px;      /* Similar to rounded-2xl */
  --squircle-xl: 32px;      /* Similar to rounded-3xl */
  --squircle-full: 50%;     /* Circle */
}

/* Enhanced Squircle Classes with Progressive Enhancement */
.squircle-xs {
  border-radius: 12px; /* Fallback for older browsers */
  border-radius: var(--squircle-xs);
}

.squircle-sm {
  border-radius: 16px; /* Fallback for older browsers */
  border-radius: var(--squircle-sm);
}

.squircle-md {
  border-radius: 20px; /* Fallback for older browsers */
  border-radius: var(--squircle-md);
}

.squircle-lg {
  border-radius: 24px; /* Fallback for older browsers */
  border-radius: var(--squircle-lg);
}

.squircle-xl {
  border-radius: 32px; /* Fallback for older browsers */
  border-radius: var(--squircle-xl);
}

.squircle-full {
  border-radius: 50%; /* Fallback for older browsers */
  border-radius: var(--squircle-full);
}

/* Browser Compatibility with Feature Detection */
@supports (border-radius: var(--squircle-xs)) {
  .squircle-xs { border-radius: var(--squircle-xs); }
  .squircle-sm { border-radius: var(--squircle-sm); }
  .squircle-md { border-radius: var(--squircle-md); }
  .squircle-lg { border-radius: var(--squircle-lg); }
  .squircle-xl { border-radius: var(--squircle-xl); }
  .squircle-full { border-radius: var(--squircle-full); }
}

/* Webkit-specific optimizations */
@supports (-webkit-appearance: none) {
  .squircle-xs { -webkit-border-radius: var(--squircle-xs); }
  .squircle-sm { -webkit-border-radius: var(--squircle-sm); }
  .squircle-md { -webkit-border-radius: var(--squircle-md); }
  .squircle-lg { -webkit-border-radius: var(--squircle-lg); }
  .squircle-xl { -webkit-border-radius: var(--squircle-xl); }
  .squircle-full { -webkit-border-radius: var(--squircle-full); }
}

/* Legacy squircle-smooth classes maintained for backward compatibility */
.squircle-smooth-sm {
  border-radius: 16px; /* Fallback */
  border-radius: var(--squircle-sm);
}

.squircle-smooth-md {
  border-radius: 20px; /* Fallback */
  border-radius: var(--squircle-md);
}

.squircle-smooth-lg {
  border-radius: 24px; /* Fallback */
  border-radius: var(--squircle-lg);
}

.squircle-smooth-xl {
  border-radius: 32px; /* Fallback */
  border-radius: var(--squircle-xl);
}

/* CSS Houdini Paint API for true squircles (when supported) */
@supports (background: paint(squircle)) {
  .squircle-paint-sm {
    --squircle-radius: 16;
    --squircle-smooth: 0.8;
    background: paint(squircle);
    border-radius: 0;
  }
  
  .squircle-paint-md {
    --squircle-radius: 20;
    --squircle-smooth: 0.8;
    background: paint(squircle);
    border-radius: 0;
  }
  
  .squircle-paint-lg {
    --squircle-radius: 24;
    --squircle-smooth: 0.8;
    background: paint(squircle);
    border-radius: 0;
  }
  
  .squircle-paint-xl {
    --squircle-radius: 32;
    --squircle-smooth: 0.8;
    background: paint(squircle);
    border-radius: 0;
  }
}

/* Enhanced squircle using pseudo-elements for smoother corners */
.squircle-enhanced {
  position: relative;
  --squircle-ratio: 0.88;
}

.squircle-enhanced::before,
.squircle-enhanced::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.squircle-enhanced-sm {
  border-radius: calc(16px * var(--squircle-ratio));
}

.squircle-enhanced-md {
  border-radius: calc(20px * var(--squircle-ratio));
}

.squircle-enhanced-lg {
  border-radius: calc(24px * var(--squircle-ratio));
}

.squircle-enhanced-xl {
  border-radius: calc(32px * var(--squircle-ratio));
}

/* 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;
  }
}
