/* ========================================
   HERO
   ======================================== */

.hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 136px 24px 64px;
  gap: var(--sp-6);
  overflow: hidden;
  min-height: 100vh;   /* fallback para navegadores sin soporte de dvh */
  min-height: 100dvh;
  justify-content: center;
}

.hero-background {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.circuit-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.18;
  pointer-events: none;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  animation: float 8s ease-in-out infinite;
  pointer-events: none;
}

.glow-orb-1 {
  top: -120px;
  left: 8%;
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, var(--glow-color), transparent 70%);
  animation-duration: 9s;
}

.glow-orb-2 {
  bottom: -140px;
  right: 6%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--teal-40), transparent 70%);
  animation-duration: 11s;
  animation-delay: 1.5s;
}

.rotating-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  animation: spin 40s linear infinite;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.ring-1 {
  width: 460px;
  height: 460px;
  border: 1px solid rgba(148, 52, 212, 0.25);
}

.hero-content {
  position: relative;
  z-index: 10;
  max-width: 700px;
}

.hero-logo-wrap {
  position: relative;
  display: inline-block;
  perspective: 900px;
}

/* Glow estático detrás del logo vía pseudo-elemento: reemplaza el
   drop-shadow animado (costoso, recalculaba por frame). */
.hero-logo-wrap::after {
  content: '';
  position: absolute;
  inset: -20%;
  z-index: -1;
  background: radial-gradient(circle, var(--accent-40) 0%, transparent 70%);
  opacity: 0.8;
  pointer-events: none;
}

.hero-logo {
  width: min(360px, 70vw);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 30px var(--glow-color));
  -webkit-mask-image: radial-gradient(circle, black 58%, transparent 82%);
  mask-image: radial-gradient(circle, black 58%, transparent 82%);
  transform: rotateX(var(--hero-tilt-x, 0deg)) rotateY(var(--hero-tilt-y, 0deg));
  transform-style: preserve-3d;
  transition: transform var(--dur-base) var(--ease-out);
}

/* Contenedor de la escena three.js: oculto hasta que js/sections/hero.js
   confirma soporte (WebGL + desktop + sin reduced-motion) y la activa. */
.hero-logo-3d {
  display: none;
  width: min(360px, 70vw);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

.hero-logo-3d.is-active {
  display: block;
}

.hero-logo-3d canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Cuando la escena 3D está activa, se oculta el <picture> de respaldo */
.hero-logo-wrap.has-3d .hero-logo {
  display: none;
}

.hero-tagline {
  font-family: var(--font-primary);
  font-size: var(--fs-lead);
  color: var(--cyan);
  letter-spacing: 0.5px;
  margin: 8px auto 0;
  max-width: 520px;
}

.hero-title {
  font-size: var(--fs-h1);
  letter-spacing: var(--ls-tighter);
  line-height: var(--lh-tight);
  text-wrap: balance;
  margin: 4px 0 0;
}

/* Palabra clave del titular en gradiente de marca */
.hero-title .text-gradient {
  background: var(--gradient-brand);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
}

.hero-cta-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4, 16px);
  /* Un renglón de aire entre el subtítulo y los CTA */
  margin-top: var(--sp-10);
}

@media (prefers-reduced-motion: reduce) {
  .hero-logo {
    transition: none;
  }
}

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

@keyframes spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* ========================================
   CIRCUITO DECORATIVO (SVG animado)
   ======================================== */

.circuit-trace {
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: drawTrace 2.4s ease-out forwards;
}

.circuit-nodes circle {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  /* fadeInNode: aparición única | nodePulse: latido ambiental en loop, arranca cuando termina el fade */
  animation: fadeInNode 0.6s ease-out forwards, nodePulse 2.8s ease-in-out infinite;
  animation-delay: 1.8s, 2.4s;
}

.circuit-nodes circle:nth-child(2) { animation-delay: 1.8s, 2.9s; }
.circuit-nodes circle:nth-child(3) { animation-delay: 1.8s, 3.4s; }
.circuit-nodes circle:nth-child(4) { animation-delay: 1.8s, 3.9s; }
.circuit-nodes circle:nth-child(n+5) { animation-delay: 2.6s, 3.1s; }
.circuit-nodes circle:nth-child(3n+5) { animation-delay: 2.6s, 3.7s; }
.circuit-nodes circle:nth-child(3n+6) { animation-delay: 2.6s, 4.3s; }

/* Los trazos agregados se dibujan escalonados, después de los 4 principales */
.circuit-bg g:first-child .circuit-trace:nth-child(n+5) { animation-delay: 0.6s; }
.circuit-bg g:first-child .circuit-trace:nth-child(2n+6) { animation-delay: 1s; }
.circuit-traces-thin { opacity: 0.7; }
.circuit-traces-thin .circuit-trace { animation-delay: 1.2s; }

@keyframes drawTrace {
  to { stroke-dashoffset: 0; }
}

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

/* Latido sutil de los nodos: transform en vez de radio/filtro para quedar en GPU */
@keyframes nodePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

/* Circuito "vivo": punto de luz recorriendo cada trazo en loop, vía CSS motion path.
   offset-path repite el mismo "d" del trazo correspondiente. */
.circuit-pulses circle {
  fill: var(--cyan);
  opacity: 0;
  animation: circuitFlow 5.5s linear infinite;
  animation-delay: 2.4s;
}

.circuit-pulses circle:nth-child(1) {
  offset-path: path('M0 200 H300 V500 H700 V180');
  animation-delay: 2.4s;
}

.circuit-pulses circle:nth-child(2) {
  offset-path: path('M1920 300 H1600 V700 H1200 V400');
  animation-delay: 3.6s;
}

.circuit-pulses circle:nth-child(3) {
  offset-path: path('M0 950 H250 V650 H650');
  animation-delay: 4.8s;
}

.circuit-pulses circle:nth-child(4) {
  offset-path: path('M1920 850 H1650 V550 H1300 V750');
  animation-delay: 6s;
}

.circuit-pulses circle:nth-child(5) {
  offset-path: path('M0 80 H180 V320 H420');
  animation-delay: 3s;
}

.circuit-pulses circle:nth-child(6) {
  offset-path: path('M1920 60 H1720 V240 H1480 V120');
  animation-delay: 4.2s;
}

.circuit-pulses circle:nth-child(7) {
  offset-path: path('M0 560 H140 V800 H420 V900');
  animation-delay: 5.4s;
}

.circuit-pulses circle:nth-child(8) {
  offset-path: path('M800 1000 V880 H1100 V940 H1250');
  animation-delay: 6.6s;
}

@keyframes circuitFlow {
  0% { offset-distance: 0%; opacity: 0; }
  8% { opacity: 0.9; }
  92% { opacity: 0.9; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* Degradación prolija en navegadores sin soporte de motion path: ocultar los pulsos */
@supports not (offset-path: path('M0 0')) {
  .circuit-pulses {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .circuit-trace {
    stroke-dashoffset: 0;
  }

  .circuit-nodes circle {
    opacity: 1;
    transform: none;
  }

  .circuit-pulses {
    display: none;
  }
}

@media (max-width: 768px) {
  .hero {
    padding: 100px 24px 48px;
  }

  /* .circuit-bg es decoración del hero (vive dentro de .hero-background,
     que ya es position:absolute) pero su propio position:fixed hace que
     se vea "pegado" detrás de TODAS las secciones al hacer scroll, cortando
     tarjetas con líneas gruesas fuera de contexto en pantallas angostas.
     Al confinarlo a su contenedor queda solo detrás del hero, como se
     ve en desktop. */
  .circuit-bg {
    position: absolute;
  }

  .hero-cta-group {
    flex-direction: column;
    width: 100%;
  }

  .hero-cta-group .btn {
    width: 100%;
    justify-content: center;
  }
}
