.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.cursor-glow {
  position: fixed;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle, rgba(56, 182, 255, 0.06) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

body.has-cursor-glow .cursor-glow {
  opacity: 1;
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
  transition-delay: calc(var(--reveal-i, 0) * 70ms);
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

/* Scroll progress bar */
.scroll-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--violet));
  box-shadow: 0 0 12px var(--blue-glow);
  transition: width 0.12s linear;
  z-index: 1;
}

/* Magnetic buttons */
.magnetic {
  transition: transform 0.35s var(--ease-out), box-shadow 0.25s ease, background 0.2s ease, border-color 0.2s ease;
}

/* Tilt cards */
.tilt {
  transition: transform 0.5s var(--ease-out);
  will-change: transform;
}

/* Hero split-word entrance */
.hero-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  transition-delay: calc(var(--reveal-i, 0) * 60ms);
}

.hero-word.is-in {
  opacity: 1;
  transform: none;
}

/* Animated nav active indicator */
.nav-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--blue);
  box-shadow: 0 0 10px var(--blue-glow);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s var(--ease-out), width 0.35s var(--ease-out), opacity 0.25s ease;
}

.nav-indicator.is-visible {
  opacity: 1;
}

@media (max-width: 979px) {
  .nav-indicator {
    display: none;
  }
}

/* Tech stack marquee */
.marquee-section {
  overflow: hidden;
  padding: 28px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--black-elevated);
}

.marquee {
  overflow: hidden;
  width: 100%;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.marquee-track {
  display: flex;
  align-items: center;
  gap: 48px;
  width: max-content;
  animation: marquee-scroll 32s linear infinite;
}

.marquee:hover .marquee-track,
.marquee:focus-within .marquee-track {
  animation-play-state: paused;
}

@keyframes marquee-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

/* Parallax helper layers */
.hero-grid,
.particle-canvas {
  will-change: transform;
}

@keyframes scroll-pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scaleY(0.6);
    transform-origin: top;
  }

  50% {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: top;
  }
}

@keyframes hero-glow {
  0%,
  100% {
    text-shadow: 0 0 60px var(--blue-glow), 0 0 120px rgba(56, 182, 255, 0.2);
  }

  50% {
    text-shadow: 0 0 80px var(--blue-glow), 0 0 160px rgba(56, 182, 255, 0.35);
  }
}

.hero-line--accent {
  animation: hero-glow 4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .cursor-glow {
    display: none;
  }

  .hero-scroll-line {
    animation: none;
    opacity: 0.5;
  }

  .hero-word {
    opacity: 1;
    transform: none;
  }

  .marquee-track {
    animation: none;
  }

  .tilt,
  .magnetic {
    transition: none;
  }

  .nav-indicator {
    transition: none;
  }
}

@media (max-width: 979px) {
  .cursor-glow {
    display: none;
  }
}

@media (hover: none) {
  .cursor-glow {
    display: none;
  }
}
