: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;
}

.stack {
  position: relative;
  display: grid;
  justify-items: center;
  gap: clamp(0.65rem, 1.7vw, 1.2rem);
  transform: translateY(-3%);
}

.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.1rem, 4.4vw, 4.1rem);
  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;
}

.mail-copy {
  position: relative;
  display: grid;
  place-items: center;
  width: min(16ch, 72vw);
  margin-top: clamp(0.95rem, 2.4vw, 2.15rem);
  min-height: 1.8rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  cursor: copy;
  user-select: none;
  touch-action: manipulation;
  outline-offset: 0.25rem;
}

.mail-copy::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 0.15rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(66, 233, 255, 0.85), transparent);
  opacity: 0.14;
  transform: scaleX(0.4);
  transition: opacity 180ms ease, transform 180ms ease;
}

.mail-copy:is(:hover, :focus-visible)::after,
.mail-copy.is-visible::after,
.mail-copy.is-copying::after {
  opacity: 0.6;
  transform: scaleX(1);
}

.mail-copy__text {
  position: relative;
  font-size: clamp(0.56rem, 1.15vw, 0.9rem);
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: lowercase;
  white-space: nowrap;
  color: rgba(83, 255, 143, 0.88);
  text-shadow: 0 0 0.65em rgba(83, 255, 143, 0.5);
  opacity: 0;
  transition: opacity 190ms ease;
}

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

.mail-copy__text::before {
  color: var(--neon-cyan);
  transform: translate(-0.025em, -0.02em);
  text-shadow: -0.03em 0 0.3em rgba(66, 233, 255, 0.75);
  clip-path: polygon(0 4%, 100% 4%, 100% 43%, 0 43%);
}

.mail-copy__text::after {
  color: var(--neon-violet);
  transform: translate(0.03em, 0.02em);
  text-shadow: 0.03em 0 0.35em rgba(187, 120, 255, 0.8);
  clip-path: polygon(0 60%, 100% 60%, 100% 98%, 0 98%);
}

.mail-copy.is-visible .mail-copy__text {
  opacity: 0.92;
  animation: mail-flicker 880ms step-end infinite;
}

.mail-copy.is-visible .mail-copy__text::before,
.mail-copy.is-visible .mail-copy__text::after {
  opacity: 1;
}

.mail-copy.is-visible .mail-copy__text::before {
  animation: mail-slice-a 680ms steps(2, jump-none) infinite;
}

.mail-copy.is-visible .mail-copy__text::after {
  animation: mail-slice-b 760ms steps(2, jump-none) infinite;
}

.mail-copy.is-entering .mail-copy__text {
  animation:
    mail-enter-jolt 280ms steps(2, jump-none) 1,
    mail-flicker 880ms step-end infinite;
}

.mail-copy.is-entering .mail-copy__text::before {
  animation:
    mail-enter-chop-a 280ms steps(2, jump-none) 1,
    mail-slice-a 680ms steps(2, jump-none) infinite;
}

.mail-copy.is-entering .mail-copy__text::after {
  animation:
    mail-enter-chop-b 280ms steps(2, jump-none) 1,
    mail-slice-b 760ms steps(2, jump-none) infinite;
}

.mail-copy.is-exiting .mail-copy__text {
  animation: mail-exit-jolt 260ms steps(2, jump-none) 1 forwards;
}

.mail-copy.is-exiting .mail-copy__text::before {
  animation: mail-exit-chop-a 260ms steps(2, jump-none) 1 forwards;
}

.mail-copy.is-exiting .mail-copy__text::after {
  animation: mail-exit-chop-b 260ms steps(2, jump-none) 1 forwards;
}

.mail-copy.is-copying .mail-copy__text {
  opacity: 1;
  color: var(--neon-cyan);
  letter-spacing: 0.22em;
  text-shadow:
    0 0 0.12em rgba(66, 233, 255, 0.95),
    0 0 0.75em rgba(66, 233, 255, 0.75);
  animation: mail-copy-pop 190ms steps(2, jump-none) 6;
}

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 mail-flicker {
  0%,
  48%,
  100% {
    opacity: 0.86;
  }
  14%,
  16% {
    opacity: 0.3;
  }
  27% {
    opacity: 0.6;
  }
}

@keyframes mail-enter-jolt {
  0% {
    opacity: 0;
    transform: translate(-0.22em, 0.06em) skewX(12deg);
    filter: blur(0.85px);
  }
  38% {
    opacity: 1;
    transform: translate(0.12em, -0.03em) skewX(-8deg);
  }
  74% {
    transform: translate(-0.08em, 0.02em) skewX(4deg);
    filter: blur(0.25px);
  }
  100% {
    opacity: 0.92;
    transform: translate(0, 0) skewX(0deg);
    filter: blur(0);
  }
}

@keyframes mail-exit-jolt {
  0% {
    opacity: 0.92;
    transform: translate(0, 0) skewX(0deg);
  }
  32% {
    opacity: 1;
    transform: translate(0.11em, -0.02em) skewX(-9deg);
  }
  72% {
    opacity: 0.5;
    transform: translate(-0.16em, 0.04em) skewX(11deg);
  }
  100% {
    opacity: 0;
    transform: translate(0.2em, -0.04em) skewX(0deg);
  }
}

@keyframes mail-enter-chop-a {
  0% {
    clip-path: polygon(0 1%, 100% 1%, 100% 17%, 0 17%);
    transform: translate(-0.18em, 0.03em);
    opacity: 1;
  }
  55% {
    clip-path: polygon(0 36%, 100% 36%, 100% 64%, 0 64%);
    transform: translate(0.11em, -0.03em);
  }
  100% {
    clip-path: polygon(0 6%, 100% 6%, 100% 39%, 0 39%);
    transform: translate(-0.025em, -0.02em);
    opacity: 1;
  }
}

@keyframes mail-enter-chop-b {
  0% {
    clip-path: polygon(0 72%, 100% 72%, 100% 100%, 0 100%);
    transform: translate(0.19em, -0.03em);
    opacity: 1;
  }
  55% {
    clip-path: polygon(0 44%, 100% 44%, 100% 83%, 0 83%);
    transform: translate(-0.11em, 0.03em);
  }
  100% {
    clip-path: polygon(0 60%, 100% 60%, 100% 98%, 0 98%);
    transform: translate(0.03em, 0.02em);
    opacity: 1;
  }
}

@keyframes mail-exit-chop-a {
  0% {
    clip-path: polygon(0 6%, 100% 6%, 100% 39%, 0 39%);
    transform: translate(-0.025em, -0.02em);
    opacity: 1;
  }
  55% {
    clip-path: polygon(0 28%, 100% 28%, 100% 58%, 0 58%);
    transform: translate(0.1em, -0.02em);
    opacity: 0.9;
  }
  100% {
    clip-path: polygon(0 0%, 100% 0%, 100% 13%, 0 13%);
    transform: translate(-0.2em, 0.03em);
    opacity: 0;
  }
}

@keyframes mail-exit-chop-b {
  0% {
    clip-path: polygon(0 60%, 100% 60%, 100% 98%, 0 98%);
    transform: translate(0.03em, 0.02em);
    opacity: 1;
  }
  55% {
    clip-path: polygon(0 53%, 100% 53%, 100% 89%, 0 89%);
    transform: translate(-0.09em, 0.03em);
    opacity: 0.88;
  }
  100% {
    clip-path: polygon(0 84%, 100% 84%, 100% 100%, 0 100%);
    transform: translate(0.22em, -0.02em);
    opacity: 0;
  }
}

@keyframes mail-slice-a {
  0% {
    clip-path: polygon(0 6%, 100% 6%, 100% 39%, 0 39%);
  }
  35% {
    clip-path: polygon(0 22%, 100% 22%, 100% 56%, 0 56%);
  }
  70% {
    clip-path: polygon(0 10%, 100% 10%, 100% 33%, 0 33%);
  }
  100% {
    clip-path: polygon(0 6%, 100% 6%, 100% 39%, 0 39%);
  }
}

@keyframes mail-slice-b {
  0% {
    clip-path: polygon(0 58%, 100% 58%, 100% 98%, 0 98%);
  }
  40% {
    clip-path: polygon(0 50%, 100% 50%, 100% 84%, 0 84%);
  }
  80% {
    clip-path: polygon(0 66%, 100% 66%, 100% 92%, 0 92%);
  }
  100% {
    clip-path: polygon(0 58%, 100% 58%, 100% 98%, 0 98%);
  }
}

@keyframes mail-copy-pop {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-0.04em);
  }
  75% {
    transform: translateX(0.04em);
  }
}

@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.05rem, 6vw, 2.3rem);
  }

  .mail-copy {
    margin-top: clamp(0.8rem, 4.1vw, 1.45rem);
    min-height: 1.65rem;
  }

  .mail-copy__text {
    font-size: clamp(0.5rem, 2.7vw, 0.74rem);
    letter-spacing: 0.11em;
  }

  body::after {
    opacity: 0.22;
  }
}

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

  .glitch {
    transform: none;
  }

  .mail-copy__text,
  .mail-copy__text::before,
  .mail-copy__text::after {
    opacity: 0.86;
  }
}
