/* ============================================
   TOS Network - Animations
   Keyframes, transitions, and effects
   ============================================ */

/* ============ 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);
  }
}

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

/* Slide In Up */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Slide In Down */
@keyframes slideInDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Pulse Glow Effect */
@keyframes pulseGlow {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* Breathe Effect (for logo) */
@keyframes breathe {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

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

/* Bounce */
@keyframes bounce {
  0%, 100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

/* Ping */
@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

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

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

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

/* Glow Pulse */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px var(--primary-blue-glow);
  }
  50% {
    box-shadow: 0 0 40px var(--glow-strong);
  }
}

/* ============ Page Loader Animations ============ */

.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--gradient-start);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-top);
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.page-loader.page-loader--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(74, 144, 226, 0.2);
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.animate-ready {
  opacity: 0;
}

.animate-in {
  animation: fadeInUp 0.6s var(--ease-out) forwards;
}

/* Staggered Animation Delays */
.animate-in:nth-child(1) { animation-delay: 0ms; }
.animate-in:nth-child(2) { animation-delay: 100ms; }
.animate-in:nth-child(3) { animation-delay: 200ms; }
.animate-in:nth-child(4) { animation-delay: 300ms; }
.animate-in:nth-child(5) { animation-delay: 400ms; }
.animate-in:nth-child(6) { animation-delay: 500ms; }
.animate-in:nth-child(7) { animation-delay: 600ms; }
.animate-in:nth-child(8) { animation-delay: 700ms; }
.animate-in:nth-child(9) { animation-delay: 800ms; }
.animate-in:nth-child(10) { animation-delay: 900ms; }
.animate-in:nth-child(11) { animation-delay: 1000ms; }
.animate-in:nth-child(12) { animation-delay: 1100ms; }
.animate-in:nth-child(13) { animation-delay: 1200ms; }
.animate-in:nth-child(14) { animation-delay: 1300ms; }
.animate-in:nth-child(15) { animation-delay: 1400ms; }

/* ============ Hero Section Animations ============ */

.hero-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.hero-gradient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient-hero);
}

.hero-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient-hero);
  animation: pulseGlow 8s ease-in-out infinite;
}

/* ============ Logo Animation ============ */

.logo-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  animation: breathe 3s ease-in-out infinite;
  transition: all var(--transition-base);
}

.logo-wrapper:hover {
  animation: none;
  transform: scale(1.05);
}

/* ============ Button Shine Effect ============ */

.btn-primary::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);
}

.btn-primary:hover::before {
  left: 100%;
}

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

.feature-card {
  position: relative;
  transition: all var(--transition-base);
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    transparent 0%,
    var(--primary-blue-light) 50%,
    transparent 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.feature-card:hover::before {
  opacity: 1;
}

.feature-card:hover {
  transform: translateY(-8px);
}

.card-icon {
  transition: transform var(--transition-base);
}

.feature-card:hover .card-icon {
  transform: scale(1.1) rotate(5deg);
}

/* ============ Link Underline Animation ============ */

.nav-link,
.dropdown-link,
.footer-links a,
.docs-link,
.whitepaper-link {
  position: relative;
}

.nav-link::after,
.footer-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary-blue);
  transition: width var(--transition-fast);
}

.nav-link:hover::after,
.footer-links a:hover::after {
  width: 100%;
}

/* ============ FAQ Icon Rotation ============ */

.faq-icon {
  transition: transform var(--transition-base);
}

.faq-question[aria-expanded="true"] .faq-icon {
  transform: rotate(180deg);
}

/* ============ Social Icon Hover ============ */

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.05);
  transition: all var(--transition-base);
}

.social-link:hover {
  background: rgba(74, 144, 226, 0.2);
  transform: translateY(-3px);
  box-shadow: 0 4px 12px var(--primary-blue-glow);
}

.social-link svg {
  transition: transform var(--transition-base);
}

.social-link:hover svg {
  transform: scale(1.1);
}

/* ============ Navbar Scroll Effects ============ */

.navbar {
  transition: all var(--transition-base);
}

.navbar--scrolled {
  background: rgba(15, 20, 25, 0.8);
  backdrop-filter: blur(var(--blur-xl));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.navbar--hidden {
  transform: translateY(-100%);
}

/* ============ Floating Animation ============ */

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

/* ============ Shimmer Effect ============ */

.shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

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

[data-parallax] {
  will-change: transform;
}

/* ============ Reduced Motion ============ */

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

  .animate-ready {
    opacity: 1;
  }

  .hero-glow {
    animation: none;
  }

  .logo-wrapper {
    animation: none;
  }
}

/* ============ Performance Optimizations ============ */

.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}
