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

html {
  scroll-behavior: smooth;
  /* hidden だと overflow-y が auto 扱いになり html/body で縦バーが二重になる。clip は他軸を汚さない */
  overflow-x: clip;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: clip;
  padding-bottom: 2.75rem;
  font-family: var(--font-sans);
  font-size: clamp(0.95rem, 2.2vw, 1.05rem);
  font-weight: 400;
  line-height: 1.72;
  letter-spacing: 0.01em;
  color: var(--fg);
  background-color: var(--bg);
  transition:
    background-color 0.2s linear,
    color 0.2s linear;
}

@supports not (overflow-x: clip) {
  html {
    overflow-x: hidden;
    overflow-y: auto;
  }

  body {
    overflow-x: visible;
    overflow-y: visible;
  }
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: solid;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--fg);
  background: var(--accent);
}

:focus-visible {
  outline: 1px dashed var(--glow);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 8px;
  top: 8px;
  z-index: 10000;
  padding: 6px 10px;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
  transform: translateY(-200%);
  transition: transform 0.15s linear;
  border: 1px solid var(--bg);
}

.skip-link:focus {
  transform: translateY(0);
}

.halftone {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.12;
  background-image: radial-gradient(circle, var(--fg) 1px, transparent 1px);
  background-size: 5px 5px;
  mix-blend-mode: overlay;
  filter: hue-rotate(calc(var(--scroll-hue) * 1deg));
}

@media (prefers-reduced-motion: reduce) {
  .halftone {
    filter: none;
  }
}

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

.chromatic-edge {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 2;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--fg) 18%, transparent),
    inset 0 0 60px color-mix(in srgb, var(--void) 40%, transparent);
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 3;
  opacity: 0.04;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    color-mix(in srgb, var(--fg) 40%, transparent) 2px,
    color-mix(in srgb, var(--fg) 40%, transparent) 3px
  );
}

.glitch-blocks {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.glitch-blocks__bar {
  position: absolute;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  animation: bar-drift 18s linear infinite;
}

.glitch-blocks__bar--1 {
  width: 140%;
  height: 3px;
  top: 22%;
  left: -20%;
  transform: rotate(-8deg);
  animation-delay: 0s;
}

.glitch-blocks__bar--2 {
  width: 4px;
  height: 120%;
  top: -10%;
  right: 18%;
  animation-delay: -6s;
  animation-duration: 24s;
}

.glitch-blocks__bar--3 {
  width: 80%;
  height: 2px;
  bottom: 30%;
  right: -10%;
  transform: rotate(4deg);
  animation-delay: -12s;
}

@keyframes bar-drift {
  0%,
  100% {
    opacity: 0.25;
    transform: translateX(0) rotate(-8deg);
  }
  50% {
    opacity: 0.55;
    transform: translateX(4%) rotate(-6deg);
  }
}

.glitch-blocks__bar--2 {
  animation-name: bar-drift-v;
}

@keyframes bar-drift-v {
  0%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  50% {
    opacity: 0.5;
    transform: translateY(3%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .glitch-blocks__bar {
    animation: none;
    opacity: 0.2;
  }
}
