/* ==========================================================================
   XHYPHER TECH — ANIMATIONS
   ========================================================================== */

/* --- Background grid + moving light (hero) --- */
.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 60% at 60% 40%, black 40%, transparent 90%);
  pointer-events: none;
  z-index: 0;
}

.bg-light {
  position: absolute;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.16;
  pointer-events: none;
  z-index: 0;
}

.bg-light-blue { background: var(--blue); top: -10%; right: 5%; animation: drift-a 18s ease-in-out infinite; }
.bg-light-red { background: var(--red); bottom: -15%; left: 0%; opacity: 0.10; animation: drift-b 22s ease-in-out infinite; }

@keyframes drift-a {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-40px, 30px); }
}
@keyframes drift-b {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, -20px); }
}

/* --- Hero entrance sequence --- */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-eyebrow, .hero-line span, .hero p.lead, .hero-actions, .hero-meta, .hero-visual {
  animation: rise-in 0.8s var(--ease) both;
}

.hero-eyebrow { animation-delay: 0.05s; }
.hero-line:nth-of-type(1) span { animation-delay: 0.15s; }
.hero-line:nth-of-type(2) span { animation-delay: 0.25s; }
.hero p.lead { animation-delay: 0.4s; }
.hero-actions { animation-delay: 0.52s; }
.hero-meta { animation-delay: 0.64s; }
.hero-visual { animation-delay: 0.3s; }

/* --- Circuit visual draw-on --- */
.circuit-path {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: draw 2.2s var(--ease) 0.4s forwards;
}
@keyframes draw {
  to { stroke-dashoffset: 0; }
}

.circuit-node {
  opacity: 0;
  animation: node-in 0.5s var(--ease) forwards;
}
@keyframes node-in {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}

/* --- Staggered reveal for grids (children get incremental delay via inline style or nth-child) --- */
.grid.reveal-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.grid.reveal-stagger.in-view > *:nth-child(1) { transition-delay: 0s; }
.grid.reveal-stagger.in-view > *:nth-child(2) { transition-delay: 0.08s; }
.grid.reveal-stagger.in-view > *:nth-child(3) { transition-delay: 0.16s; }
.grid.reveal-stagger.in-view > *:nth-child(4) { transition-delay: 0.24s; }
.grid.reveal-stagger.in-view > *:nth-child(5) { transition-delay: 0.32s; }
.grid.reveal-stagger.in-view > *:nth-child(6) { transition-delay: 0.4s; }
.grid.reveal-stagger.in-view > *:nth-child(7) { transition-delay: 0.48s; }
.grid.reveal-stagger.in-view > *:nth-child(8) { transition-delay: 0.56s; }
.grid.reveal-stagger.in-view > * { opacity: 1; transform: translateY(0); }

/* --- Theme transition ripple --- */
.theme-toggle-btn svg { transition: transform 0.4s var(--ease); }
.theme-toggle-btn:active svg { transform: rotate(25deg) scale(0.9); }

@media (prefers-reduced-motion: reduce) {
  .hero-eyebrow, .hero-line span, .hero p.lead, .hero-actions, .hero-meta, .hero-visual,
  .circuit-path, .circuit-node, .grid.reveal-stagger > * {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
    stroke-dashoffset: 0 !important;
  }
  .bg-light-blue, .bg-light-red { animation: none; }
}
