/*
Hypercube Network Background
how to use it: include this css and hypercube-bg.js, finally, set <hypercube-bg></hypercube-bg>
optional: overwrite --hc-color to change the red color*/

hypercube-bg {
  display: contents;
}

.hypercube-bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  background: transparent;
}

.hypercube-bg svg {
  width: 100%;
  height: 100%;
  display: block;
  color: var(--hc-color, #000000);
  opacity: var(--hc-scroll-opacity, 1);
  transition: opacity 200ms ease-out;
}

.hc-edge {
  fill: none;
  stroke: currentColor;
  stroke-width: 0.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.12;
}

.hc-echo {
  fill: none;
  stroke: currentColor;
  stroke-width: 0.35;
  opacity: 0.08;
  transform-origin: 0px 0px;
}

.hc-bridge {
  fill: none;
  stroke: currentColor;
  stroke-width: 0.65;
  stroke-dasharray: 4 6;
  opacity: 0.14;
}

.hc-face {
  fill: currentColor;
  stroke: none;
  opacity: 0;
}

.hc-node {
  fill: currentColor;
  opacity: 0.2;
}

.net-link {
  fill: none;
  stroke: currentColor;
  stroke-width: 0.6;
  opacity: 0.1;
}

.net-pulse {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-dasharray: 45 480;
  opacity: 0;
}

.cube-alpha {
  transform-origin: 0px 0px;
  animation: driftAlpha calc(var(--dur, 23s) + 0s) ease-in-out infinite alternate;
  animation-delay: var(--del, 0s);
}

.cube-beta {
  transform-origin: 0px 0px;
  animation: driftBeta calc(var(--dur, 23s) + 4s) ease-in-out infinite alternate;
  animation-delay: calc(var(--del, 0s) - 7s);
}

.echo-layer-1 {
  animation: twistEcho1 calc(var(--dur, 29s) + 2s) ease-in-out infinite alternate;
  animation-delay: calc(var(--del, 0s) - 3s);
}

.echo-layer-2 {
  animation: twistEcho2 calc(var(--dur, 31s) + 6s) ease-in-out infinite alternate;
  animation-delay: calc(var(--del, 0s) - 11s);
}

.hl-1 {
  animation: highlightEdge1 calc(var(--dur, 17s) + 0s) ease-in-out infinite;
  animation-delay: calc(var(--del, 0s) - 2s);
}

.hl-2 {
  animation: highlightEdge2 calc(var(--dur, 19s) + 4s) ease-in-out infinite;
  animation-delay: calc(var(--del, 0s) - 9s);
}

.hl-3 {
  animation: highlightEdge1 calc(var(--dur, 23s) + 6s) ease-in-out infinite;
  animation-delay: calc(var(--del, 0s) - 15s);
}

.hl-4 {
  animation: highlightEdge2 calc(var(--dur, 29s) + 2s) ease-in-out infinite;
  animation-delay: calc(var(--del, 0s) - 5s);
}

.face-pulse-a {
  animation: highlightFace calc(var(--dur, 23s) + 8s) ease-in-out infinite;
  animation-delay: calc(var(--del, 0s) - 6s);
}

.face-pulse-b {
  animation: highlightFace calc(var(--dur, 31s) + 6s) ease-in-out infinite;
  animation-delay: calc(var(--del, 0s) - 17s);
}

.node-pulse {
  animation: pulseNode calc(var(--dur, 13s) + 4s) ease-in-out infinite;
  animation-delay: calc(var(--del, 0s) - 4s);
}

.pulse-stream-1 {
  animation: flowPacket 19s linear infinite;
  animation-delay: -3s;
}

.pulse-stream-2 {
  animation: flowPacket 23s linear infinite reverse;
  animation-delay: -11s;
}

.pulse-stream-3 {
  animation: flowPacket 29s linear infinite;
  animation-delay: -17s;
}

/* Keyframes */
@keyframes driftAlpha {
  0%   { transform: translate(-4px, -3px) scale(0.98) rotate(-1.5deg); }
  50%  { transform: translate(3px, 4px) scale(1.02) rotate(1deg); }
  100% { transform: translate(5px, -2px) scale(0.99) rotate(2deg); }
}

@keyframes driftBeta {
  0%   { transform: translate(4px, 3px) scale(1.02) rotate(1.5deg); }
  50%  { transform: translate(-3px, -4px) scale(0.97) rotate(-1.2deg); }
  100% { transform: translate(-5px, 2px) scale(1.01) rotate(-2deg); }
}

@keyframes twistEcho1 {
  0%   { transform: scale(0.84) rotate(-6deg); opacity: 0.05; }
  50%  { transform: scale(0.90) rotate(4deg);  opacity: 0.14; }
  100% { transform: scale(0.82) rotate(9deg);  opacity: 0.06; }
}

@keyframes twistEcho2 {
  0%   { transform: scale(0.68) rotate(8deg);  opacity: 0.04; }
  50%  { transform: scale(0.75) rotate(-5deg); opacity: 0.12; }
  100% { transform: scale(0.66) rotate(-10deg); opacity: 0.05; }
}

@keyframes highlightEdge1 {
  0%, 68%, 100% {
    opacity: 0.11;
    stroke-width: 0.7;
  }
  78% {
    opacity: 0.78;
    stroke-width: 1.45;
  }
  88% {
    opacity: 0.25;
    stroke-width: 0.9;
  }
}

@keyframes highlightEdge2 {
  0%, 42%, 100% {
    opacity: 0.10;
    stroke-width: 0.7;
  }
  52% {
    opacity: 0.72;
    stroke-width: 1.4;
  }
  62% {
    opacity: 0.18;
    stroke-width: 0.8;
  }
}

@keyframes highlightFace {
  0%, 70%, 100% { opacity: 0; }
  82%           { opacity: 0.045; }
  92%           { opacity: 0.01; }
}

@keyframes pulseNode {
  0%, 60%, 100% { opacity: 0.18; }
  74%           { opacity: 0.85; }
}

@keyframes flowPacket {
  0%   { stroke-dashoffset: 525; opacity: 0; }
  10%  { opacity: 0.65; }
  85%  { opacity: 0.65; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}

/* Accesibilidad: respeta preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .cube-alpha, .cube-beta, .echo-layer-1, .echo-layer-2,
  .hl-1, .hl-2, .hl-3, .hl-4, .face-pulse-a, .face-pulse-b,
  .node-pulse, .net-pulse {
    animation: none !important;
  }
}
