:root {
  color-scheme: dark;
  --x: 50%;
  --y: 50%;
  --cyan: #6ef7ff;
  --cyan-hot: #d8fdff;
  --violet: #8b5cff;
  --pulse: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #030405;
}

body {
  min-height: 100svh;
}

main {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at var(--x) var(--y), rgba(255, 255, 255, .045), transparent 25rem),
    radial-gradient(ellipse at 50% 50%, #10141a 0, #07090c 38%, #020304 78%);
}

main::before {
  content: "";
  position: absolute;
  inset: -50%;
  z-index: -2;
  background-image:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
  background-size: 64px 64px;
  transform: perspective(600px) rotateX(62deg) translateY(16%);
  mask-image: radial-gradient(ellipse, black, transparent 55%);
}

main::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background: radial-gradient(ellipse, transparent 35%, rgba(0, 0, 0, .42) 72%, rgba(0, 0, 0, .88));
}

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

.halo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(62vw, 820px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(calc(1 + var(--pulse) * .025));
  background: radial-gradient(circle, rgba(255, 255, 255, .07), rgba(255, 255, 255, .018) 35%, transparent 67%);
  filter: blur(8px);
  animation: halo 4s ease-in-out infinite;
}

.core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(82vw, 920px);
  height: min(55vw, 430px);
  transform: translate(-50%, -50%);
}

.resistor {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 122px;
  display: flex;
  align-items: center;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, .65));
  animation: float 5s ease-in-out infinite;
}

.wire {
  position: relative;
  flex: 1;
  height: 8px;
  overflow: hidden;
  background: linear-gradient(#58636a, #12171b 45%, #020405 55%, #334047);
  box-shadow: 0 0 1px #a9c2c8 inset, 0 4px 8px #000;
}

.current {
  position: absolute;
  left: -18%;
  top: calc(50% - 4px);
  z-index: 10;
  width: 18%;
  height: 8px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--cyan-hot) 55%, transparent);
  filter: blur(.4px);
  box-shadow: 0 0 12px var(--cyan), 0 0 26px rgba(110, 247, 255, .7);
  animation: full-current 2.2s linear infinite;
}

.wire::after {
  content: "";
  position: absolute;
  top: 0;
  width: 24%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--cyan-hot), transparent);
  filter: blur(1px);
  box-shadow: 0 0 14px var(--cyan), 0 0 32px var(--cyan);
  display: none;
}

.wire-left::after {
  left: -26%;
}

.wire-right::after {
  left: -26%;
  animation-delay: 1.1s;
}

.wire b {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan-hot);
  transform: translateY(-50%);
  opacity: 0;
  box-shadow: 0 0 8px 2px var(--cyan), 0 0 26px 7px var(--cyan);
  display: none;
}

.wire-right b {
  animation-delay: 1.1s;
}

.body {
  position: relative;
  width: clamp(210px, 36vw, 390px);
  height: 72px;
  flex: none;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, transparent calc(50% - 4px), #58636a calc(50% - 4px), #12171b 48%, #020405 52%, #334047 calc(50% + 4px), transparent calc(50% + 4px));
  box-shadow: none;
}

.body::before {
  display: none;
  content: "";
  position: absolute;
  inset: 8px 3%;
  z-index: 3;
  border-radius: inherit;
  background:
    linear-gradient(110deg, transparent 15%, rgba(255, 255, 255, .34) 30%, transparent 46%),
    linear-gradient(180deg, rgba(255, 255, 255, .13), transparent 28%);
  mix-blend-mode: screen;
}

.body::after {
  display: none;
  content: "";
  position: absolute;
  left: -35%;
  top: 0;
  z-index: 4;
  width: 24%;
  height: 100%;
  opacity: .8;
  background: linear-gradient(90deg, transparent, rgba(216, 253, 255, .9), transparent);
  filter: blur(8px);
  animation: body-current 2.2s linear infinite;
}

.body em {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: calc(.06 + var(--pulse) * .18);
  background: radial-gradient(ellipse, var(--cyan-hot), transparent 62%);
  mix-blend-mode: screen;
  animation: breathe 2.2s ease-in-out infinite;
}

.band {
  position: absolute;
  top: 0;
  z-index: 2;
  width: 8.5%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 4px;
  box-shadow: 2px 0 5px rgba(0, 0, 0, .3), -1px 0 2px rgba(255, 255, 255, .12);
}

.band-one {
  left: 22%;
  background: linear-gradient(90deg, #1d0d07, #6d2f19 38%, #b15b34 52%, #35150b);
}

.band-two {
  left: 38%;
  background: linear-gradient(90deg, #000, #202326 46%, #050606 75%, #000);
}

.band-three {
  left: 54%;
  background: linear-gradient(90deg, #260708, #86181c 42%, #d83c40 54%, #480b0d);
}

.band-four {
  right: 18%;
  width: 6%;
  background: linear-gradient(90deg, #47350d, #b89331 34%, #f0d67a 52%, #6b5115);
}

.orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-8deg);
}

.orbit::after {
  content: "";
  position: absolute;
  left: 13%;
  top: 8%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px 2px rgba(255, 255, 255, .55), 0 0 28px rgba(255, 255, 255, .25);
}

.orbit-one {
  width: 76%;
  height: 112%;
  animation: orbit-one 11s linear infinite;
}

.orbit-two {
  width: 92%;
  height: 150%;
  opacity: .42;
  animation: orbit-two 17s linear infinite reverse;
}

.spark {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, .5), 0 0 22px 4px rgba(255, 255, 255, .2);
  opacity: 0;
  animation: spark 3.8s ease-out infinite;
}

.spark-one {
  left: 29%;
  top: 28%;
}

.spark-two {
  right: 31%;
  bottom: 25%;
  animation-delay: 1.4s;
}

.spark-three {
  right: 19%;
  top: 38%;
  animation-delay: 2.6s;
}

.circuit {
  position: absolute;
  top: 50%;
  width: 23vw;
  min-width: 190px;
  height: 38vh;
  opacity: .22;
  transform: translateY(-50%);
}

.circuit-a {
  left: 0;
}

.circuit-b {
  right: 0;
  transform: translateY(-50%) scaleX(-1);
}

.circuit i {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35) 42%, transparent);
  transform-origin: left;
}

.circuit i::after {
  content: "";
  position: absolute;
  right: 18%;
  top: -3px;
  width: 7px;
  height: 7px;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 50%;
  background: #080b0e;
  box-shadow: 0 0 8px rgba(255, 255, 255, .4);
}

.circuit i:nth-child(1) { top: 12%; transform: rotate(8deg); }
.circuit i:nth-child(2) { top: 31%; transform: rotate(-5deg) scaleX(.72); }
.circuit i:nth-child(3) { top: 50%; transform: scaleX(.9); }
.circuit i:nth-child(4) { top: 69%; transform: rotate(5deg) scaleX(.68); }
.circuit i:nth-child(5) { top: 88%; transform: rotate(-8deg); }

.edge {
  position: absolute;
  left: 50%;
  width: 1px;
  height: 13vh;
  opacity: .45;
  background: linear-gradient(transparent, rgba(255, 255, 255, .7));
}

.edge::after {
  content: "";
  position: absolute;
  left: -3px;
  bottom: -4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 14px 2px rgba(255, 255, 255, .45);
}

.edge-top {
  top: 0;
}

.edge-bottom {
  bottom: 0;
  transform: rotate(180deg);
}

.surge .body,
.surge .wire {
  filter: brightness(1.45);
}

@keyframes current {
  0% { left: -26%; opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { left: 102%; opacity: 0; }
}

@keyframes full-current {
  0% { left: -18%; opacity: 0; }
  8% { opacity: 1; }
  92% { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}

@keyframes electron {
  0% { left: -2%; opacity: 0; }
  10%, 88% { opacity: 1; }
  100% { left: 101%; opacity: 0; }
}

@keyframes body-current {
  0% { left: -35%; opacity: 0; }
  18%, 82% { opacity: .85; }
  100% { left: 115%; opacity: 0; }
}

@keyframes float {
  0%, 100% { transform: translate(-50%, -50%) translateY(-5px) rotate(-.35deg); }
  50% { transform: translate(-50%, -50%) translateY(6px) rotate(.35deg); }
}

@keyframes halo {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

@keyframes breathe {
  0%, 100% { opacity: .04; }
  50% { opacity: .18; }
}

@keyframes orbit-one {
  to { transform: translate(-50%, -50%) rotate(352deg); }
}

@keyframes orbit-two {
  to { transform: translate(-50%, -50%) rotate(352deg); }
}

@keyframes spark {
  0%, 72% { opacity: 0; transform: translate(0, 0) scale(.2); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(34px, -26px) scale(1.2); }
}

@media (max-width: 700px) {
  .core {
    width: 92vw;
    height: 58vw;
  }

  .resistor {
    height: 86px;
  }

  .body {
    width: 58vw;
    height: 58px;
  }

  .wire {
    height: 5px;
  }

  .circuit {
    opacity: .12;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
}
