/* ═══════════════════════════════════════════════════════════════════════════
   TOS LABS — ADVANCED ANIMATIONS & EFFECTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   SCROLL-TRIGGERED REVEAL ANIMATIONS
   ───────────────────────────────────────────────────────────────────────────── */

/* Base state for animated elements */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Reveal from left */
.reveal-left {
  opacity: 0;
  transform: translateX(-60px);
  transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
}

.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Reveal from right */
.reveal-right {
  opacity: 0;
  transform: translateX(60px);
  transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
}

.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Reveal scale */
.reveal-scale {
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.6s var(--ease-spring), transform 0.6s var(--ease-spring);
}

.reveal-scale.visible {
  opacity: 1;
  transform: scale(1);
}

/* Reveal rotate */
.reveal-rotate {
  opacity: 0;
  transform: rotateX(-15deg) translateY(40px);
  transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
  transform-origin: center bottom;
}

.reveal-rotate.visible {
  opacity: 1;
  transform: rotateX(0) translateY(0);
}

/* Stagger children animation */
.stagger-children > * {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s var(--ease-out-expo), transform 0.6s var(--ease-out-expo);
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0.05s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.1s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.15s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.2s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.25s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(6) { transition-delay: 0.3s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(7) { transition-delay: 0.35s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(8) { transition-delay: 0.4s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(n+9) { transition-delay: 0.45s; opacity: 1; transform: translateY(0); }

/* ─────────────────────────────────────────────────────────────────────────────
   CARD GLOW EFFECT (Simplified - no 3D tilt)
   ───────────────────────────────────────────────────────────────────────────── */
.card-glow {
  position: relative;
}

.card-glow::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(
    135deg,
    var(--accent-primary) 0%,
    var(--accent-secondary) 50%,
    var(--accent-primary) 100%
  );
  background-size: 200% 200%;
  border-radius: calc(var(--radius-xl) + 2px);
  opacity: 0;
  transition: opacity 0.3s var(--ease-out-expo);
  z-index: -1;
  animation: glowRotate 3s linear infinite;
}

.card-glow:hover::before {
  opacity: 0.5;
}

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

/* ─────────────────────────────────────────────────────────────────────────────
   MAGNETIC BUTTON EFFECT
   ───────────────────────────────────────────────────────────────────────────── */
.magnetic-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s var(--ease-spring);
}

.magnetic-btn-inner {
  transition: transform 0.3s var(--ease-spring);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   ANIMATED GRADIENT BACKGROUND
   ───────────────────────────────────────────────────────────────────────────── */
.animated-gradient {
  background: linear-gradient(
    -45deg,
    #0a0a0f,
    #12121a,
    #1a1a2e,
    #0d1f1a,
    #0a0a0f
  );
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
}

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

/* Aurora effect */
.aurora-bg {
  position: relative;
  overflow: hidden;
}

.aurora-bg::before,
.aurora-bg::after {
  content: '';
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  background: radial-gradient(
    ellipse at center,
    var(--accent-primary-glow) 0%,
    transparent 50%
  );
  animation: aurora 20s ease-in-out infinite;
  pointer-events: none;
  opacity: 0.3;
}

.aurora-bg::after {
  background: radial-gradient(
    ellipse at center,
    rgba(124, 58, 237, 0.2) 0%,
    transparent 50%
  );
  animation: aurora 25s ease-in-out infinite reverse;
  animation-delay: -5s;
}

@keyframes aurora {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(5%, 5%) rotate(5deg);
  }
  50% {
    transform: translate(-5%, 10%) rotate(-5deg);
  }
  75% {
    transform: translate(-10%, -5%) rotate(3deg);
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   FLOATING PARTICLES
   ───────────────────────────────────────────────────────────────────────────── */
.particles-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent-primary);
  border-radius: 50%;
  opacity: 0.3;
  animation: float 20s infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.3;
  }
  90% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(-100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   TEXT REVEAL ANIMATION
   ───────────────────────────────────────────────────────────────────────────── */
.text-reveal {
  overflow: hidden;
}

.text-reveal-inner {
  display: inline-block;
  transform: translateY(100%);
  animation: textReveal 0.8s var(--ease-out-expo) forwards;
}

@keyframes textReveal {
  to {
    transform: translateY(0);
  }
}

/* Split text character animation */
.char {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px) rotateX(-90deg);
  animation: charReveal 0.5s var(--ease-out-expo) forwards;
}

@keyframes charReveal {
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   GLITCH EFFECT
   ───────────────────────────────────────────────────────────────────────────── */
.glitch {
  position: relative;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch::before {
  animation: glitch1 2s infinite linear alternate-reverse;
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
  color: #ff00ff;
  opacity: 0.8;
}

.glitch::after {
  animation: glitch2 3s infinite linear alternate-reverse;
  clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
  color: #00ffff;
  opacity: 0.8;
}

@keyframes glitch1 {
  0%, 90%, 100% { transform: translate(0); }
  92% { transform: translate(-2px, 1px); }
  94% { transform: translate(2px, -1px); }
  96% { transform: translate(-1px, 2px); }
  98% { transform: translate(1px, -2px); }
}

@keyframes glitch2 {
  0%, 90%, 100% { transform: translate(0); }
  91% { transform: translate(2px, -1px); }
  93% { transform: translate(-2px, 1px); }
  95% { transform: translate(1px, 2px); }
  97% { transform: translate(-1px, -2px); }
}

/* ─────────────────────────────────────────────────────────────────────────────
   PULSE RING ANIMATION
   ───────────────────────────────────────────────────────────────────────────── */
.pulse-ring {
  position: relative;
}

.pulse-ring::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid var(--accent-primary);
  animation: pulseRing 2s ease-out infinite;
  opacity: 0;
}

@keyframes pulseRing {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   SHIMMER LOADING EFFECT
   ───────────────────────────────────────────────────────────────────────────── */
.shimmer {
  background: linear-gradient(
    90deg,
    var(--glass-bg) 0%,
    var(--glass-bg-hover) 50%,
    var(--glass-bg) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* ─────────────────────────────────────────────────────────────────────────────
   UNDERLINE DRAW ANIMATION
   ───────────────────────────────────────────────────────────────────────────── */
.underline-draw {
  position: relative;
  display: inline-block;
}

.underline-draw::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent-primary);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s var(--ease-out-expo);
}

.underline-draw:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ─────────────────────────────────────────────────────────────────────────────
   MORPHING BORDER
   ───────────────────────────────────────────────────────────────────────────── */
.morph-border {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.morph-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(
    60deg,
    var(--accent-primary),
    var(--accent-secondary),
    var(--accent-tertiary),
    var(--accent-primary)
  );
  background-size: 300% 300%;
  animation: morphGradient 4s ease infinite;
  border-radius: inherit;
  z-index: -1;
}

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

/* ─────────────────────────────────────────────────────────────────────────────
   BOUNCE IN ANIMATION
   ───────────────────────────────────────────────────────────────────────────── */
.bounce-in {
  animation: bounceIn 0.8s var(--ease-spring) forwards;
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   FLIP CARD EFFECT
   ───────────────────────────────────────────────────────────────────────────── */
.flip-card {
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s var(--ease-out-expo);
  transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-card-back {
  transform: rotateY(180deg);
}

/* ─────────────────────────────────────────────────────────────────────────────
   WAVE ANIMATION
   ───────────────────────────────────────────────────────────────────────────── */
.wave {
  display: inline-flex;
  gap: 3px;
}

.wave span {
  display: inline-block;
  animation: wave 1.2s ease-in-out infinite;
}

.wave span:nth-child(1) { animation-delay: 0s; }
.wave span:nth-child(2) { animation-delay: 0.1s; }
.wave span:nth-child(3) { animation-delay: 0.2s; }
.wave span:nth-child(4) { animation-delay: 0.3s; }
.wave span:nth-child(5) { animation-delay: 0.4s; }

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

/* ─────────────────────────────────────────────────────────────────────────────
   HOVER LIFT EFFECT
   ───────────────────────────────────────────────────────────────────────────── */
.hover-lift {
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s var(--ease-out-expo);
}

.hover-lift:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), var(--shadow-glow);
}

/* ─────────────────────────────────────────────────────────────────────────────
   TYPEWRITER EFFECT
   ───────────────────────────────────────────────────────────────────────────── */
.typewriter {
  overflow: hidden;
  border-right: 2px solid var(--accent-primary);
  white-space: nowrap;
  animation: typing 3s steps(40) forwards, blink 0.75s step-end infinite;
}

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

@keyframes blink {
  50% { border-color: transparent; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   SPOTLIGHT EFFECT
   ───────────────────────────────────────────────────────────────────────────── */
.spotlight {
  position: relative;
}

.spotlight::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(255, 255, 255, 0.06),
    transparent 40%
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.spotlight:hover::before {
  opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   ROTATING GLOW
   ───────────────────────────────────────────────────────────────────────────── */
.rotating-glow {
  position: relative;
}

.rotating-glow::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: conic-gradient(
    from 0deg,
    transparent,
    var(--accent-primary),
    transparent 30%
  );
  animation: rotateGlow 3s linear infinite;
  z-index: -1;
}

.rotating-glow::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: var(--color-bg);
  border-radius: inherit;
  z-index: -1;
}

@keyframes rotateGlow {
  100% { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────────────────────────────────────
   PARALLAX LAYERS
   ───────────────────────────────────────────────────────────────────────────── */
.parallax-slow {
  will-change: transform;
}

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

/* ─────────────────────────────────────────────────────────────────────────────
   LOADING ANIMATIONS
   ───────────────────────────────────────────────────────────────────────────── */
@keyframes loadingDots {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

.loading-dots {
  display: inline-flex;
  gap: 4px;
}

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

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

/* ─────────────────────────────────────────────────────────────────────────────
   SKELETON LOADING
   ───────────────────────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--glass-bg) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    var(--glass-bg) 100%
  );
  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; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   RIPPLE EFFECT
   ───────────────────────────────────────────────────────────────────────────── */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 1s;
}

.ripple:active::after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}

/* ─────────────────────────────────────────────────────────────────────────────
   NAV LINK UNDERLINE ANIMATION
   ───────────────────────────────────────────────────────────────────────────── */
.nav-link {
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--accent-primary);
  transition: all 0.3s var(--ease-out-expo);
  transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 80%;
}

/* ─────────────────────────────────────────────────────────────────────────────
   APP CARD ENHANCED EFFECTS
   ───────────────────────────────────────────────────────────────────────────── */
.app-card {
  transform-style: preserve-3d;
  will-change: transform;
}

.app-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
  opacity: 0;
  transition: opacity 0.5s var(--ease-out-expo);
  pointer-events: none;
  border-radius: inherit;
}

.app-card:hover::after {
  opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   GLOW BORDER ANIMATION
   ───────────────────────────────────────────────────────────────────────────── */
.glow-border {
  position: relative;
}

.glow-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
  background-size: 200% 200%;
  border-radius: inherit;
  z-index: -1;
  animation: glowBorder 3s linear infinite;
  opacity: 0;
  transition: opacity 0.3s;
}

.glow-border:hover::before {
  opacity: 1;
}

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

/* ─────────────────────────────────────────────────────────────────────────────
   FADE IN UP (for sections without JS)
   ───────────────────────────────────────────────────────────────────────────── */
.fade-in-up {
  animation: fadeInUp 0.6s var(--ease-out-expo) forwards;
}

/* ─────────────────────────────────────────────────────────────────────────────
   SCROLL PROGRESS BAR
   ───────────────────────────────────────────────────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  z-index: 10000;
  transition: width 0.1s linear;
}

/* ─────────────────────────────────────────────────────────────────────────────
   COOKIE BANNER SLIDE UP
   ───────────────────────────────────────────────────────────────────────────── */
.cookie-banner {
  transform: translateY(100%);
  transition: transform 0.5s var(--ease-out-expo);
}

.cookie-banner.visible {
  transform: translateY(0);
}

/* ─────────────────────────────────────────────────────────────────────────────
   GRADIENT TEXT ANIMATION
   ───────────────────────────────────────────────────────────────────────────── */
.gradient-text-animated {
  background: linear-gradient(
    90deg,
    var(--accent-primary),
    var(--accent-secondary),
    var(--accent-tertiary),
    var(--accent-primary)
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientText 5s linear infinite;
}

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

/* ─────────────────────────────────────────────────────────────────────────────
   SECTION DIVIDER ANIMATION
   ───────────────────────────────────────────────────────────────────────────── */
.section-divider {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--glass-border),
    transparent
  );
  margin: 4rem 0;
  position: relative;
}

.section-divider::after {
  content: '';
  position: absolute;
  left: -100%;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent-primary),
    transparent
  );
  animation: dividerSweep 3s ease-in-out infinite;
}

@keyframes dividerSweep {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   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;
  }
  
  .reveal,
  .reveal-left,
  .reveal-right,
  .reveal-scale,
  .reveal-rotate {
    opacity: 1;
    transform: none;
  }
  
  .particle {
    display: none;
  }
}
