/* ═══════════════════════════════════════════════════════
   Thư viện Sơn Nhai — Parallax Animations CSS v2.0
   ═══════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────
   1. CANVAS BASE
   ─────────────────────────────────────────────────────── */

#parallax-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  pointer-events: none;
}

/* ───────────────────────────────────────────────────────
   2. GRID BACKGROUND PATTERN
   ─────────────────────────────────────────────────────── */

body {
  background-image:
    linear-gradient(rgba(28, 34, 50, 0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 34, 50, 0.3) 1px, transparent 1px);
  background-size: 40px 40px;
  background-attachment: fixed;
}

/* ───────────────────────────────────────────────────────
   2. PARALLAX LAYERS
   ─────────────────────────────────────────────────────── */

.parallax-scene {
  position: relative;
  overflow: hidden;
}

.parallax-layer {
  position: absolute;
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ───────────────────────────────────────────────────────
   3. GRADIENT WAVE ANIMATION
   ─────────────────────────────────────────────────────── */

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

.gradient-wave {
  background: linear-gradient(120deg, #00D4D4 0%, #00FFFF 25%, #00B4D8 50%, #00D4D4 75%, #00FFFF 100%);
  background-size: 200% 200%;
  animation: gradientWave 8s ease-in-out infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px rgba(0, 212, 212, 0.4));
}

/* ───────────────────────────────────────────────────────
   4. SCROLL REVEAL
   ─────────────────────────────────────────────────────── */

.parallax-reveal {
  opacity: 0;
  transform: translateY(40px) scale(0.96);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ───────────────────────────────────────────────────────
   5. GLOW PULSE ANIMATION
   ─────────────────────────────────────────────────────── */

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(0, 212, 212, 0.2),
                0 0 40px rgba(0, 212, 212, 0.1);
  }
  50% {
    box-shadow: 0 0 30px rgba(0, 212, 212, 0.4),
                0 0 60px rgba(0, 212, 212, 0.2);
  }
}

.glow-pulse {
  animation: glowPulse 3s ease-in-out infinite;
}

/* ───────────────────────────────────────────────────────
   6. SCROLL PROGRESS BAR
   ─────────────────────────────────────────────────────── */

#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, #00D4D4 0%, #00FFFF 50%, #00D4D4 100%);
  z-index: 9999;
  transition: width 0.1s linear;
  box-shadow: 0 0 10px rgba(0, 212, 212, 0.8);
}

/* ───────────────────────────────────────────────────────
   7. BACK TO TOP BUTTON
   ─────────────────────────────────────────────────────── */

#back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  background: rgba(0, 212, 212, 0.15);
  border: 1px solid rgba(0, 212, 212, 0.4);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.2s ease,
              box-shadow 0.2s ease;
  z-index: 998;
  backdrop-filter: blur(12px);
  pointer-events: none;
}

#back-to-top.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#back-to-top:hover {
  background: rgba(0, 212, 212, 0.25);
  box-shadow: 0 0 20px rgba(0, 212, 212, 0.4);
  transform: translateY(-2px) scale(1.05);
}

#back-to-top svg {
  width: 20px;
  height: 20px;
  color: #00D4D4;
}

/* ───────────────────────────────────────────────────────
   8. NAVBAR SCROLL EFFECTS
   ─────────────────────────────────────────────────────── */

.nav {
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.3s ease,
              box-shadow 0.3s ease,
              border-color 0.3s ease;
}

.nav.scrolled {
  background: rgba(8, 9, 14, 0.98) !important;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  border-bottom-color: rgba(0, 212, 212, 0.2) !important;
}

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

/* ───────────────────────────────────────────────────────
   9. FLOATING ANIMATION (for cards/elements)
   ─────────────────────────────────────────────────────── */

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

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

/* ───────────────────────────────────────────────────────
   10. SHIMMER EFFECT
   ─────────────────────────────────────────────────────── */

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

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

/* ───────────────────────────────────────────────────────
   11. BORDER GLOW ANIMATION
   ─────────────────────────────────────────────────────── */

@keyframes borderGlow {
  0%, 100% {
    border-color: rgba(0, 212, 212, 0.3);
  }
  50% {
    border-color: rgba(0, 212, 212, 0.6);
  }
}

.border-glow {
  animation: borderGlow 2.5s ease-in-out infinite;
}

/* ───────────────────────────────────────────────────────
   12. FADE IN PAGE LOAD
   ─────────────────────────────────────────────────────── */

body {
  opacity: 0;
  animation: fadeInPage 0.6s ease-out forwards;
}

@keyframes fadeInPage {
  to {
    opacity: 1;
  }
}

/* ───────────────────────────────────────────────────────
   13. RESPONSIVE & REDUCED MOTION
   ─────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .parallax-layer[data-depth],
  .parallax-layer[data-mouse-depth] {
    transform: none !important;
  }

  #parallax-canvas {
    opacity: 0.6;
  }

  .gradient-wave {
    animation-duration: 12s;
  }
}

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

  .parallax-layer[data-depth],
  .parallax-layer[data-mouse-depth] {
    transform: none !important;
  }

  #parallax-canvas {
    display: none;
  }

  .gradient-wave {
    animation: none;
    background: linear-gradient(120deg, #00D4D4 0%, #00FFFF 100%);
    background-size: 100% 100%;
  }
}

body.reduced-motion * {
  animation: none !important;
  transition: none !important;
}

body.reduced-motion .parallax-layer {
  transform: none !important;
}

body.reduced-motion #parallax-canvas {
  display: none;
}

/* ───────────────────────────────────────────────────────
   14. UTILITY CLASSES
   ─────────────────────────────────────────────────────── */

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

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

/* Stagger delays for multiple elements */
.parallax-reveal:nth-child(1) { transition-delay: 0s; }
.parallax-reveal:nth-child(2) { transition-delay: 0.08s; }
.parallax-reveal:nth-child(3) { transition-delay: 0.16s; }
.parallax-reveal:nth-child(4) { transition-delay: 0.24s; }
.parallax-reveal:nth-child(5) { transition-delay: 0.32s; }
.parallax-reveal:nth-child(6) { transition-delay: 0.40s; }
