.not-found {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--colour-panel);
  color: var(--colour-fg);
  font-family: var(--font-body);
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.not-found--open {
  opacity: 1;
  transform: scale(1);
}

.not-found__error {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 24px var(--gutter);
}

.not-found__code {
  margin: 0;
  font-family: "Archivo Black", "Arial Black", sans-serif;
  font-size: clamp(72px, 22vw, 140px);
  line-height: 0.9;
  letter-spacing: -0.03em;
}

.not-found__title {
  margin: 0;
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 600;
  line-height: 1.2;
}

.not-found__detail {
  margin: 0;
  font-size: 16px;
  color: var(--colour-muted);
}

.not-found__host {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  color: var(--colour-fg);
}

.not-found__retry {
  margin-top: 18px;
  padding: 12px 22px;
  border: 2px solid var(--colour-fg);
  border-radius: 999px;
  background: var(--colour-fg);
  color: var(--colour-panel);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}

.not-found__retry:hover {
  background: transparent;
  color: var(--colour-fg);
}

.not-found__retry:focus-visible {
  outline: 2px solid var(--colour-fg);
  outline-offset: 3px;
}

.not-found__retry[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.6;
}

.not-found__hint {
  margin: 6px 0 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  color: var(--colour-muted);
  opacity: 0;
  transition: opacity 300ms ease;
}

.not-found__hint--visible {
  opacity: 1;
}

.not-found__dots::after {
  content: "";
  animation: not-found-dots 900ms steps(4, end) infinite;
}

@keyframes not-found-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.not-found__error--glitch {
  animation: not-found-glitch 360ms steps(2, end) 2;
}

@keyframes not-found-glitch {
  0% { transform: translate(0, 0); filter: none; }
  25% { transform: translate(-6px, 2px) skewX(-6deg); filter: hue-rotate(90deg); }
  50% { transform: translate(5px, -3px); filter: invert(1); }
  75% { transform: translate(-3px, 1px) skewX(4deg); filter: none; }
  100% { transform: translate(0, 0); }
}

.not-found__legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  padding: 16px;
  font-size: 13px;
}

.not-found__link {
  color: var(--colour-muted);
  text-underline-offset: 3px;
}

.not-found__link:hover,
.not-found__link:focus-visible {
  color: var(--colour-fg);
}

.not-found__arrival {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background: var(--colour-bg);
  color: var(--colour-fg);
  transform: translateX(100%);
}

.not-found__arrival--in {
  box-shadow: -24px 0 48px rgb(0 0 0 / 0.25);
  animation: not-found-arrive 650ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes not-found-arrive {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.not-found__name {
  margin: 0;
  font-family: "Archivo Black", "Arial Black", sans-serif;
  font-size: clamp(96px, min(34vw, 56vh), 560px);
  letter-spacing: -0.03em;
  line-height: 0.9;
}

.not-found__url {
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
  .not-found,
  .not-found__error--glitch,
  .not-found__dots::after {
    transition: none;
    animation: none;
  }

  .not-found__arrival--in {
    animation-duration: 1ms;
  }
}
