/* Electricity border — steady current + irregular surges, with fade in/out. */

.electric-border {
  --electric-radius: 1.25rem;
  --electric-green: #74c69d;
  --electric-bright: #f4fff9;
  --electric-cyan: #9ae7ff;
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.electric-border::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px rgba(116, 198, 157, 0.4),
    inset 0 0 18px rgba(116, 198, 157, 0.08);
}

.electric-border__spark,
.electric-border__dot {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  offset-path: rect(0 100% 100% 0 round var(--electric-radius));
  offset-distance: 0%;
  offset-anchor: center;
}

/* Steady main beam — linear lap + soft fade cycle */
.electric-border__spark {
  width: 78px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(46, 160, 90, 0.35) 12%,
    var(--electric-green) 32%,
    var(--electric-bright) 50%,
    var(--electric-cyan) 68%,
    rgba(125, 211, 252, 0.35) 84%,
    transparent 100%
  );
  filter:
    drop-shadow(0 0 2px #fff)
    drop-shadow(0 0 6px var(--electric-bright))
    drop-shadow(0 0 12px var(--electric-green))
    drop-shadow(0 0 22px rgba(125, 211, 252, 0.85))
    drop-shadow(0 0 36px rgba(46, 160, 90, 0.45));
  offset-rotate: auto;
  animation:
    electric-run 4.8s linear infinite,
    electric-fade-in 3.6s ease-in-out infinite,
    electric-flicker 1.35s steps(2, end) infinite;
}

/* Opposite beam — surge + fade out cycle (desynced) */
.electric-border__spark--tail {
  width: 42px;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(46, 160, 90, 0.25) 18%,
    var(--electric-green) 48%,
    var(--electric-cyan) 72%,
    transparent
  );
  filter:
    drop-shadow(0 0 4px var(--electric-green))
    drop-shadow(0 0 14px rgba(125, 211, 252, 0.7))
    drop-shadow(0 0 24px rgba(46, 160, 90, 0.4));
  animation:
    electric-surge-b 7.3s cubic-bezier(0.15, 0.7, 0.35, 1) infinite,
    electric-fade-out 4.2s ease-in-out infinite,
    electric-flicker 0.9s steps(3, jump-none) infinite reverse;
  animation-delay: -2.8s, -1.1s, -0.4s;
}

/* Steady glowing dot — fade in */
.electric-border__dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 35%, #fff 0%, var(--electric-bright) 35%, var(--electric-cyan) 70%, transparent 100%);
  box-shadow:
    0 0 4px 1px #fff,
    0 0 8px 2px var(--electric-bright),
    0 0 16px 5px var(--electric-green),
    0 0 28px 10px rgba(125, 211, 252, 0.55),
    0 0 42px 14px rgba(46, 160, 90, 0.3);
  offset-rotate: 0deg;
  animation:
    electric-run 6.4s linear infinite,
    electric-fade-in 5s ease-in-out infinite,
    electric-pulse 2.1s ease-in-out infinite;
  animation-delay: -1.1s, -0.3s, 0s;
}

/* Second dot — surge + fade out */
.electric-border__dot--two {
  width: 5px;
  height: 5px;
  background: radial-gradient(circle at 35% 35%, #fff 0%, var(--electric-cyan) 45%, var(--electric-green) 100%);
  box-shadow:
    0 0 3px 1px #fff,
    0 0 8px 2px var(--electric-cyan),
    0 0 18px 6px rgba(116, 198, 157, 0.65),
    0 0 30px 10px rgba(125, 211, 252, 0.35);
  animation:
    electric-surge-d 6.1s cubic-bezier(0.2, 0.85, 0.45, 0.15) infinite,
    electric-fade-out 3.4s ease-in-out infinite,
    electric-pulse 1.55s ease-in-out infinite reverse;
  animation-delay: -4.6s, -2.2s, -0.7s;
}

@keyframes electric-run {
  to {
    offset-distance: 100%;
  }
}

@keyframes electric-surge-b {
  0% { offset-distance: 0%; }
  8% { offset-distance: 6%; }
  22% { offset-distance: 31%; }
  27% { offset-distance: 33%; }
  49% { offset-distance: 61%; }
  63% { offset-distance: 68%; }
  81% { offset-distance: 92%; }
  100% { offset-distance: 100%; }
}

@keyframes electric-surge-d {
  0% { offset-distance: 0%; }
  10% { offset-distance: 21%; }
  19% { offset-distance: 24%; }
  40% { offset-distance: 44%; }
  52% { offset-distance: 66%; }
  61% { offset-distance: 70%; }
  85% { offset-distance: 93%; }
  100% { offset-distance: 100%; }
}

/* Brighten in, linger, ease away */
@keyframes electric-fade-in {
  0% { opacity: 0.15; }
  18% { opacity: 0.35; }
  40% { opacity: 1; }
  62% { opacity: 1; }
  82% { opacity: 0.45; }
  100% { opacity: 0.2; }
}

/* Start strong, drop out, return */
@keyframes electric-fade-out {
  0% { opacity: 1; }
  22% { opacity: 0.85; }
  45% { opacity: 0.12; }
  58% { opacity: 0.08; }
  78% { opacity: 0.7; }
  100% { opacity: 1; }
}

@keyframes electric-flicker {
  0%,
  100% { filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 6px var(--electric-bright)) drop-shadow(0 0 12px var(--electric-green)) drop-shadow(0 0 22px rgba(125, 211, 252, 0.85)) drop-shadow(0 0 36px rgba(46, 160, 90, 0.45)); }
  40% { filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 4px var(--electric-bright)) drop-shadow(0 0 8px var(--electric-green)) drop-shadow(0 0 14px rgba(125, 211, 252, 0.5)); }
  70% { filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 10px var(--electric-bright)) drop-shadow(0 0 18px var(--electric-green)) drop-shadow(0 0 28px rgba(125, 211, 252, 0.9)); }
}

@keyframes electric-pulse {
  0%,
  100% { transform: scale(1); }
  35% { transform: scale(1.15); }
  48% { transform: scale(0.92); }
  72% { transform: scale(1.08); }
}

@supports not (offset-path: rect(0 100% 100% 0 round 1.25rem)) {
  .electric-border__spark,
  .electric-border__dot {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .electric-border__spark,
  .electric-border__dot {
    animation: none;
    opacity: 0;
  }

  .electric-border::after {
    box-shadow:
      inset 0 0 0 1px rgba(116, 198, 157, 0.55),
      inset 0 0 24px rgba(116, 198, 157, 0.12),
      0 0 22px rgba(116, 198, 157, 0.22);
  }
}
