@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@800&display=swap');

:root {
  --clr-neon: hsl(317 100% 54%);
  --clr-bg: hsl(323 21% 16%);
  --clr-neon-off: hsl(0, 0%, 17%);
  --clr-bg-off: hsl(0, 0%, 11%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

button {
  /** Reset button styles */
  background: none;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
}

body {
  display: grid;
  place-items: center;
  height: 100vh;
  border: 0;
  margin: 0;
  background: var(--clr-bg-off);
  color: var(--clr-neon);
  font-family: 'Nunito', sans-serif;
}

a {
  position: fixed;
  left: 1em;
  top: 1em;
  color: white;
}

.neon-button {
  display: inline-block;
  position: relative;
  padding: 0.25em 1em;
  border: var(--clr-neon-off) 0.125em solid;
  border-radius: 0.25em;
  color: var(--clr-neon-off);
  font-size: 4rem;

  box-shadow: inset 0 0 0.5em 0 rgba(255, 255, 255, 0.082);
  transition: all 10ms linear;
}

.neon-button::before {
  pointer-events: none;
  content: '';
  position: absolute;
  background: #00000047;
  top: 150%;
  left: 50%;
  width: 110%;
  aspect-ratio: 9/1;
  border-radius: 50%;
  transform: translateX(-50%);
  filter: blur(0.15em);
}

.neon-button::after {
  content: '';
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--clr-bg);
  z-index: -1;
  opacity: 0;
  transition: opacity 100ms linear;
}

.neon-button:hover,
.neon-button:focus {
  border-color: var(--clr-neon);
  background-color: var(--clr-neon);
  color: white;
  text-shadow: 0 0 0.1em currentColor, 0 0 0.5em currentColor;
  box-shadow: 0 0 2em 0.4em var(--clr-neon), 0 0 0.5em var(--clr-neon);
  animation: flickering-button 3s infinite alternate;
}

.neon-button:hover::before,
.neon-button:focus::before {
  pointer-events: none;
  content: '';
  position: absolute;
  background: var(--clr-neon);
  top: 120%;
  left: 0;
  width: 100%;
  height: 100%;
  transform: perspective(1em) rotateX(40deg) scale(1, 0.35);
  filter: blur(1em);
  opacity: 0.7;
  animation: flickering-shadow 3s infinite alternate;
}

.neon-button:hover::after,
.neon-button:focus::after {
  opacity: 1;
  animation: flickering-background 3s infinite alternate;
}

@keyframes flickering-button {
  0%,
  19%,
  21%,
  23%,
  25%,
  54%,
  56%,
  100% {
    border-color: var(--clr-neon);
    background-color: var(--clr-neon);
    color: white;
    text-shadow: 0 0 0.1em currentColor, 0 0 0.5em currentColor;
    box-shadow: 0 0 2em 0.4em var(--clr-neon), 0 0 0.5em var(--clr-neon);
  }
  20%,
  24%,
  55% {
    border: var(--clr-neon-off) 0.125em solid;
    border-radius: 0.25em;
    color: var(--clr-neon-off);
    text-shadow: none;
    box-shadow: none;
  }
}

@keyframes flickering-shadow {
  0%,
  19%,
  21%,
  23%,
  25%,
  54%,
  56%,
  100% {
    background: var(--clr-neon);
  }
  20%,
  24%,
  55% {
    background: #00000050;
  }
}

@keyframes flickering-background {
  0%,
  19%,
  21%,
  23%,
  25%,
  54%,
  56%,
  100% {
    opacity: 1;
  }
  20%,
  24%,
  55% {
    opacity: 0;
  }
}

@media screen and (max-width: 600px) {
  .neon-button {
    font-size: 2.5rem;
  }
}
