/* Reset, page-level styles and global effects. Theme-neutral: every value
   comes from a semantic token set by the active theme. */

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Keeps a scrolled-to pane clear of the pinned prompt. */
  scroll-padding-bottom: calc(var(--line) * 4);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-body, var(--text-md));
  line-height: var(--leading);
  text-shadow: var(--glow-body);
  overflow-wrap: anywhere;
  /* Show `->` and `--` as typed, not as arrows and dashes. */
  font-variant-ligatures: none;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }

h1, h2, h3 {
  font-family: var(--font-heading);
  font-size: inherit;
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: var(--glow-title);
}

a { color: var(--link, inherit); text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--accent); color: var(--on-accent); text-shadow: none; }

/* Focus: inverted colors. Impossible to miss in either theme. */
:focus-visible {
  outline: none;
  background: var(--accent);
  color: var(--on-accent);
  text-shadow: none;
}

.sr-only {
  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: absolute; left: var(--pad-x); top: 0; z-index: 20;
  transform: translateY(-120%);
  padding: 0 1ch;
  background: var(--accent); color: var(--on-accent); text-shadow: none;
}
.skip-link:focus-visible { transform: none; }

.dim { color: var(--fg-dim); text-shadow: none; }
.accent-2 { color: var(--accent-2); text-shadow: var(--glow-accent-2); }
.err { color: var(--error); }

/* CRT overlay: above everything, never takes input. Each theme supplies its
   own scanline pattern. */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 30;
  pointer-events: none;
  background: var(--crt);
  background-size: var(--crt-size, auto);
}

@keyframes blink { 50% { opacity: 0; } }
.cursor {
  display: inline-block;
  animation: blink var(--blink) steps(1) infinite;
}

/* Queued typewriter lines stay hidden until typewriter.js reaches them. The
   `js` class is set by an inline script in <head>, so without JS nothing hides. */
@media (prefers-reduced-motion: no-preference) {
  .js [data-type] { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
