:root {
  --base-bg: #020405;
  --overlay-1: rgba(0, 10, 14, 0.72);
  --overlay-2: rgba(6, 0, 14, 0.58);
  --neon-green: #53ff8f;
  --neon-cyan: #42e9ff;
  --neon-violet: #bb78ff;
  --glow: rgba(83, 255, 143, 0.45);
  --jitter-x: 0px;
  --jitter-y: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--base-bg);
}

body {
  position: relative;
  display: grid;
  place-items: center;
  font-family: "Chakra Petch", "Segoe UI", Tahoma, sans-serif;
  isolation: isolate;
}

body::before {
  content: "";
  position: absolute;
  inset: -3%;
  z-index: -3;
  background:
    radial-gradient(circle at 18% 20%, rgba(40, 255, 120, 0.2), transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(187, 120, 255, 0.2), transparent 48%),
    linear-gradient(125deg, var(--overlay-1), var(--overlay-2)),
    url("header.jpeg") center/cover no-repeat;
  filter: saturate(1.1) contrast(1.12) brightness(0.8);
  transform: translateZ(0) scale(1.03);
  animation: drift 11s ease-in-out infinite alternate;
}

body::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.065) 0px,
      rgba(255, 255, 255, 0.065) 1px,
      transparent 1px,
      transparent 3px
    ),
    linear-gradient(90deg, rgba(16, 255, 137, 0.04), rgba(66, 233, 255, 0.03), rgba(187, 120, 255, 0.03));
  mix-blend-mode: screen;
  opacity: 0.3;
  animation: scan 6s linear infinite;
}

.scene {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 2rem;
}

.glitch {
  position: relative;
  margin: 0;
  max-width: 16ch;
  text-align: center;
  text-transform: lowercase;
  letter-spacing: 0.14em;
  line-height: 1.05;
  font-size: clamp(1.6rem, 6.3vw, 5.8rem);
  font-weight: 700;
  color: var(--neon-green);
  text-shadow:
    0 0 0.15em rgba(83, 255, 143, 0.9),
    0 0 0.5em rgba(83, 255, 143, 0.65),
    0 0 1.3em var(--glow);
  animation: text-flicker 4.8s step-end infinite;
  transform: translate(var(--jitter-x), var(--jitter-y));
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.glitch::before {
  color: var(--neon-cyan);
  text-shadow: -0.02em 0 0.35em rgba(66, 233, 255, 0.85);
  transform: translate(-0.03em, -0.015em);
  clip-path: polygon(0 1%, 100% 1%, 100% 34%, 0 34%);
  animation: slice-a 2400ms steps(2, jump-none) infinite;
}

.glitch::after {
  color: var(--neon-violet);
  text-shadow: 0.02em 0 0.35em rgba(187, 120, 255, 0.95);
  transform: translate(0.03em, 0.02em);
  clip-path: polygon(0 65%, 100% 65%, 100% 99%, 0 99%);
  animation: slice-b 2800ms steps(2, jump-none) infinite;
}

body.glitch-burst::before {
  filter: saturate(1.32) contrast(1.3) brightness(0.72) hue-rotate(8deg);
}

body.glitch-burst::after {
  opacity: 0.65;
}

body.glitch-burst .glitch {
  text-shadow:
    0 0 0.1em rgba(83, 255, 143, 0.95),
    0 0 0.35em rgba(83, 255, 143, 0.75),
    0 0 1.7em rgba(83, 255, 143, 0.64),
    -0.07em 0 rgba(66, 233, 255, 0.75),
    0.07em 0 rgba(187, 120, 255, 0.75);
}

body.glitch-burst .glitch::before {
  transform: translate(-0.08em, -0.03em);
}

body.glitch-burst .glitch::after {
  transform: translate(0.08em, 0.04em);
}

@keyframes drift {
  0% {
    transform: scale(1.03) translate3d(-0.8%, -0.5%, 0);
  }
  100% {
    transform: scale(1.05) translate3d(0.9%, 0.6%, 0);
  }
}

@keyframes scan {
  0% {
    transform: translateY(-3px);
  }
  100% {
    transform: translateY(3px);
  }
}

@keyframes text-flicker {
  0%,
  15%,
  53%,
  100% {
    opacity: 1;
  }
  6%,
  8% {
    opacity: 0.85;
  }
  40%,
  41% {
    opacity: 0.94;
  }
}

@keyframes slice-a {
  0% {
    clip-path: polygon(0 2%, 100% 2%, 100% 34%, 0 34%);
  }
  16% {
    clip-path: polygon(0 26%, 100% 26%, 100% 59%, 0 59%);
  }
  33% {
    clip-path: polygon(0 12%, 100% 12%, 100% 47%, 0 47%);
  }
  50% {
    clip-path: polygon(0 39%, 100% 39%, 100% 71%, 0 71%);
  }
  66% {
    clip-path: polygon(0 18%, 100% 18%, 100% 42%, 0 42%);
  }
  83% {
    clip-path: polygon(0 44%, 100% 44%, 100% 78%, 0 78%);
  }
  100% {
    clip-path: polygon(0 2%, 100% 2%, 100% 34%, 0 34%);
  }
}

@keyframes slice-b {
  0% {
    clip-path: polygon(0 64%, 100% 64%, 100% 98%, 0 98%);
  }
  20% {
    clip-path: polygon(0 55%, 100% 55%, 100% 87%, 0 87%);
  }
  40% {
    clip-path: polygon(0 69%, 100% 69%, 100% 95%, 0 95%);
  }
  60% {
    clip-path: polygon(0 46%, 100% 46%, 100% 76%, 0 76%);
  }
  80% {
    clip-path: polygon(0 59%, 100% 59%, 100% 90%, 0 90%);
  }
  100% {
    clip-path: polygon(0 64%, 100% 64%, 100% 98%, 0 98%);
  }
}

@media (max-width: 760px) {
  .glitch {
    letter-spacing: 0.09em;
    font-size: clamp(1.5rem, 8.5vw, 3.3rem);
  }

  body::after {
    opacity: 0.22;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  .glitch,
  .glitch::before,
  .glitch::after {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }

  .glitch {
    transform: none;
  }
}
