/* ========================================
   DYDX Solutions - Animations
   Smooth Animations & Micro-interactions
   ======================================== */

/* ========================================
   Keyframe Animations
   ======================================== */

/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade In Up */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Down */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Left */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In Right */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide Up */
@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Slide Down */
@keyframes slideDown {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

/* Bounce */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0) translateX(-50%);
  }
  40% {
    transform: translateY(-15px) translateX(-50%);
  }
  60% {
    transform: translateY(-10px) translateX(-50%);
  }
}

/* Pulse */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
  }
  50% {
    box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
  }
}

/* Rotate */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Shimmer */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Float */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

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

/* Glow */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(249, 115, 22, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.8);
  }
}

/* ========================================
   Scroll Animation Classes
   ======================================== */

/* Elements hidden before animation */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
  opacity: 1;
  transform: translateY(0);
}

/* Fade Animations */
.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

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

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

.fade-in-left {
  animation: fadeInLeft 0.8s ease forwards;
}

.fade-in-right {
  animation: fadeInRight 0.8s ease forwards;
}

/* Delay Classes */
.delay-100 {
  animation-delay: 0.1s;
}

.delay-200 {
  animation-delay: 0.2s;
}

.delay-300 {
  animation-delay: 0.3s;
}

.delay-400 {
  animation-delay: 0.4s;
}

.delay-500 {
  animation-delay: 0.5s;
}

/* ========================================
   Hover Animations
   ======================================== */

/* Lift on Hover */
.hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
}

/* Scale on Hover */
.hover-scale {
  transition: transform 0.3s ease;
}

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

/* Rotate on Hover */
.hover-rotate {
  transition: transform 0.3s ease;
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

/* Glow on Hover */
.hover-glow {
  transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.5);
}

/* ========================================
   Loading Animations
   ======================================== */

/* Spinner */
.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(30, 58, 138, 0.2);
  border-top-color: #1e3a8a;
  border-radius: 50%;
  animation: rotate 1s linear infinite;
}

/* Dots Loading */
.dots-loading {
  display: inline-flex;
  gap: 8px;
}

.dots-loading span {
  width: 10px;
  height: 10px;
  background: var(--primary-blue);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.dots-loading span:nth-child(1) {
  animation-delay: -0.32s;
}

.dots-loading span:nth-child(2) {
  animation-delay: -0.16s;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

/* ========================================
   Counter Animation
   ======================================== */

.counter {
  transition: transform 0.3s ease;
}

.counter.counting {
  animation: pulse 0.5s ease;
}

/* ========================================
   Parallax Effect
   ======================================== */

.parallax {
  transition: transform 0.5s cubic-bezier(0, 0, 0.2, 1);
}

/* ========================================
   Stagger Animation
   ======================================== */

.stagger-item {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease 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; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }

/* ========================================
   Progress Bar Animation
   ======================================== */

.progress-bar {
  height: 4px;
  background: var(--bg-light);
  overflow: hidden;
  border-radius: 2px;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  transform: translateX(-100%);
  transition: transform 1s ease;
}

.progress-fill.active {
  transform: translateX(0);
}

/* ========================================
   Ripple Effect
   ======================================== */

.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.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

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

/* ========================================
   Gradient Animation
   ======================================== */

.gradient-animate {
  background: linear-gradient(
    -45deg,
    var(--primary-blue),
    var(--primary-dark),
    var(--secondary-orange),
    var(--accent-yellow)
  );
  background-size: 400% 400%;
  animation: gradient 15s ease infinite;
}

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

/* ========================================
   Text Animations
   ======================================== */

/* Typing Effect */
.typing {
  overflow: hidden;
  border-right: 3px solid var(--primary-blue);
  white-space: nowrap;
  animation: typing 3.5s steps(40, end), blink 0.75s step-end infinite;
}

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

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

/* Text Reveal */
.text-reveal {
  position: relative;
  overflow: hidden;
}

.text-reveal::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--secondary-orange);
  animation: reveal 1s ease forwards;
}

@keyframes reveal {
  0% {
    left: 0;
  }
  50% {
    left: 0;
  }
  100% {
    left: 100%;
  }
}

/* ========================================
   Page Transitions
   ======================================== */

.page-transition {
  animation: fadeIn 0.5s ease;
}

/* ========================================
   Scroll Reveal Animation Classes
   ======================================== */

.reveal {
  position: relative;
  opacity: 0;
}

.reveal.active {
  opacity: 1;
}

.reveal.fade-bottom {
  transform: translateY(50px);
}

.reveal.fade-bottom.active {
  animation: fadeInUp 1s ease;
  opacity: 1;
  transform: translateY(0);
}

.reveal.fade-left {
  transform: translateX(-50px);
}

.reveal.fade-left.active {
  animation: fadeInLeft 1s ease;
  opacity: 1;
  transform: translateX(0);
}

.reveal.fade-right {
  transform: translateX(50px);
}

.reveal.fade-right.active {
  animation: fadeInRight 1s ease;
  opacity: 1;
  transform: translateX(0);
}

.reveal.zoom-in {
  transform: scale(0.9);
}

.reveal.zoom-in.active {
  animation: scaleIn 1s ease;
  opacity: 1;
  transform: scale(1);
}

/* ========================================
   Button Animations
   ======================================== */

.btn-animate {
  position: relative;
  overflow: hidden;
}

.btn-animate::before {
  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.6s, height 0.6s;
}

.btn-animate:hover::before {
  width: 300px;
  height: 300px;
}

/* ========================================
   Icon Animations
   ======================================== */

.icon-spin {
  animation: rotate 2s linear infinite;
}

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

.icon-bounce {
  animation: bounce 2s infinite;
}

/* ========================================
   Image Hover Effects
   ======================================== */

.img-zoom {
  overflow: hidden;
}

.img-zoom img {
  transition: transform 0.5s ease;
}

.img-zoom:hover img {
  transform: scale(1.1);
}

.img-tilt {
  transition: transform 0.3s ease;
}

.img-tilt:hover {
  transform: perspective(1000px) rotateY(10deg);
}

/* ========================================
   Notification Animation
   ======================================== */

.notification {
  animation: slideDown 0.5s ease, fadeIn 0.5s ease;
}

.notification.hide {
  animation: slideUp 0.5s ease, fadeIn 0.5s ease reverse;
}

/* ========================================
   Modal Animations
   ======================================== */

.modal.show {
  animation: fadeIn 0.3s ease;
}

.modal.show .modal-content {
  animation: slideUp 0.3s ease;
}

.modal.hide {
  animation: fadeIn 0.3s ease reverse;
}

.modal.hide .modal-content {
  animation: slideUp 0.3s ease reverse;
}
