* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #020202;
  color: #f5f5f5;
  font-family: "Yu Gothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

/* blackdeath intro effect: remove blackdeath.html/css/js to delete this feature. */
.blackdeath-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 52%, rgba(88, 0, 0, 0.12), transparent 34%),
    #020202;
}

.background-image {
  position: absolute;
  inset: -2%;
  z-index: -4;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.26), rgba(0, 0, 0, 0.82)),
    url("./item/IMG_darksky.jpeg") center / cover no-repeat;
  filter: grayscale(0.28) contrast(1.16) brightness(0.58);
  transform: scale(1.04);
}

.noise-layer {
  position: absolute;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.035) 0,
      rgba(255, 255, 255, 0.035) 1px,
      transparent 1px,
      transparent 4px
    );
  mix-blend-mode: screen;
  opacity: 0.28;
  animation: scanline 900ms steps(2, end) infinite;
}

.glitch {
  position: relative;
  width: max-content;
  max-width: none;
  min-height: 1.4em;
  margin: 0;
  color: #e8e8e8;
  font-size: clamp(1rem, 4.55vw, 3.55rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-align: center;
  text-shadow:
    0 0 0.22rem rgba(255, 255, 255, 0.22),
    0 0 1.1rem rgba(116, 0, 0, 0.34),
    0 0 2.6rem rgba(0, 0, 0, 0.72);
  opacity: 0;
  transform: translateY(0.25rem);
}

.glitch.is-visible {
  animation: textAppear 780ms ease-out forwards, glitchJolt 1800ms steps(2, end) infinite;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: #e8e8e8;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}

.glitch.is-visible::before {
  left: -2px;
  text-shadow: 2px 0 #1d5dff;
  animation: glitchSliceBlue 1200ms infinite linear alternate-reverse;
  opacity: 0.72;
}

.glitch.is-visible::after {
  left: 2px;
  text-shadow: -2px 0 #ff1d1d;
  animation: glitchSliceRed 920ms infinite linear alternate-reverse;
  opacity: 0.68;
}

.glitch.is-clearing {
  animation: textVanish 240ms ease-in forwards;
}

@keyframes textAppear {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
    filter: blur(0.2rem);
  }

  to {
    opacity: 0.96;
    transform: translateY(0);
    filter: blur(0.01rem);
  }
}

@keyframes textVanish {
  from {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }

  to {
    opacity: 0;
    transform: translateY(-0.3rem);
    filter: blur(0.16rem);
  }
}

@keyframes glitchJolt {
  0%,
  88%,
  100% {
    transform: translate(0, 0);
  }

  90% {
    transform: translate(-2px, 1px);
  }

  92% {
    transform: translate(2px, -1px);
  }

  94% {
    transform: translate(-1px, -1px);
  }
}

@keyframes glitchSliceBlue {
  0% {
    clip-path: inset(8% 0 78% 0);
  }

  20% {
    clip-path: inset(42% 0 40% 0);
  }

  40% {
    clip-path: inset(72% 0 8% 0);
  }

  60% {
    clip-path: inset(20% 0 58% 0);
  }

  80% {
    clip-path: inset(54% 0 24% 0);
  }

  100% {
    clip-path: inset(12% 0 70% 0);
  }
}

@keyframes glitchSliceRed {
  0% {
    clip-path: inset(68% 0 12% 0);
  }

  18% {
    clip-path: inset(12% 0 72% 0);
  }

  36% {
    clip-path: inset(46% 0 34% 0);
  }

  54% {
    clip-path: inset(76% 0 6% 0);
  }

  72% {
    clip-path: inset(28% 0 48% 0);
  }

  100% {
    clip-path: inset(58% 0 24% 0);
  }
}

@keyframes scanline {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(4px);
  }
}

@media (max-width: 680px) {
  .glitch {
    font-size: clamp(0.92rem, 4.75vw, 1.72rem);
    line-height: 1.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .noise-layer,
  .glitch.is-visible,
  .glitch.is-visible::before,
  .glitch.is-visible::after,
  .glitch.is-clearing {
    animation-duration: 1ms;
    animation-iteration-count: 1;
  }
}
