/* ==========================================================================
   base.css — reset, element defaults, focus, scanline overlay
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--border-hi) var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
}

::selection {
  background: var(--selection);
  color: var(--fg);
}

/* headings and anything structural wear the mono face ---------------------- */
h1, h2, h3, h4,
th, dt,
.mono { font-family: var(--font-mono); }

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.01em;
}

p, ul, ol, dl, pre, figure, table { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}
a:hover,
a:focus-visible { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 1px;
}

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.925em; }

pre {
  background: var(--bg-sunk);
  border: var(--rule) solid var(--border);
  padding: var(--sp-4);
  overflow-x: auto;
  line-height: 1.5;
  color: var(--fg-dim);
}

kbd {
  display: inline-block;
  border: var(--rule) solid var(--border-hi);
  background: var(--bg-raise);
  color: var(--fg-dim);
  border-radius: 2px;
  padding: 0 0.35em;
  font-size: 0.85em;
  line-height: 1.5;
}

hr {
  border: 0;
  border-top: var(--rule) solid var(--border);
  margin: var(--sp-6) 0;
}

img, svg, video, canvas { max-width: 100%; height: auto; display: block; }

ul.plain, ol.plain { list-style: none; padding: 0; }

/* accessibility helpers ---------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -3rem;
  z-index: 100;
  background: var(--bg-raise);
  border: var(--rule) solid var(--border-hi);
  color: var(--fg);
  font-family: var(--font-mono);
  padding: var(--sp-2) var(--sp-3);
  transition: top 120ms ease;
}
.skip-link:focus { top: var(--sp-4); }

/* CRT scanlines — opt in with S or the command bar; never on by default ----- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.26) 0 1px,
      rgba(0, 0, 0, 0) 1px 3px
    );
  transition: opacity 200ms ease;
}
body[data-crt="on"]::after { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
