/* ==========================================================================
   base — reset, typography, and the CRT envelope the whole page sits inside
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  font-variant-ligatures: none;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }

a {
  color: var(--cyan);
  text-decoration-color: color-mix(in srgb, var(--cyan) 40%, transparent);
  text-underline-offset: 0.25em;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover { color: var(--cyan-bright); text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--phos);
  outline-offset: 3px;
}

::selection {
  background: var(--phos);
  color: var(--bg);
}

/* ---- headings ---------------------------------------------------------- */

.h-display {
  font-family: var(--font-display);
  font-size: var(--t-2xl);
  line-height: 0.92;
  letter-spacing: -0.01em;
  color: var(--txt);
  text-wrap: balance;
  text-shadow: 0 0 18px rgba(41, 255, 155, 0.16);
}

.h-section {
  font-family: var(--font-display);
  font-size: var(--t-xl);
  line-height: var(--lh-tight);
  letter-spacing: -0.005em;
  color: var(--txt);
  text-wrap: balance;
  text-shadow: 0 0 16px rgba(41, 255, 155, 0.14);
}

.h-sub {
  font-family: var(--font-display);
  font-size: var(--t-lg);
  line-height: var(--lh-snug);
  color: var(--txt);
}

.lead {
  font-size: var(--t-md);
  line-height: 1.62;
  color: var(--txt-2);
  max-width: min(var(--measure), 100%);
}

.prose { max-width: min(var(--measure), 100%); color: var(--txt-2); }
.prose p + p { margin-top: var(--s-4); }
.prose strong { color: var(--txt); font-weight: 700; }

.mono-note {
  font-size: var(--t-sm);
  color: var(--txt-3);
  line-height: var(--lh-snug);
}

code, kbd, samp { font-family: var(--font-body); font-size: 0.95em; }

.tok-key { color: var(--cyan); }
.tok-str { color: var(--phos); }
.tok-num { color: var(--amber); }
.tok-cmt { color: var(--txt-3); }
.tok-op  { color: var(--txt-2); }

/* ---- CRT envelope ------------------------------------------------------
   Fixed, non-interactive. Three stacked layers: horizontal scanlines, a slow
   vertical roll band, and a corner vignette. This is the page's material.
   ------------------------------------------------------------------------ */

.crt {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.crt__scan {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.28) 3px,
    rgba(0, 0, 0, 0.28) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.7;
}

.crt__roll {
  position: absolute;
  left: 0;
  right: 0;
  height: 38vh;
  background: linear-gradient(
    to bottom,
    rgba(41, 255, 155, 0) 0%,
    rgba(41, 255, 155, 0.028) 45%,
    rgba(41, 255, 155, 0.045) 52%,
    rgba(41, 255, 155, 0) 100%
  );
  animation: crt-roll 11s linear infinite;
}

.crt__vig {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    122% 96% at 50% 42%,
    rgba(0, 0, 0, 0) 42%,
    rgba(0, 0, 0, 0.42) 82%,
    rgba(0, 0, 0, 0.78) 100%
  );
}

@keyframes crt-roll {
  0%   { transform: translateY(-40vh); }
  100% { transform: translateY(140vh); }
}

@media (prefers-reduced-motion: reduce) {
  .crt__roll { animation: none; opacity: 0.35; }
}

/* The weave field lives behind everything. */
#weave {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.66;
}

/* Veil: keeps the field readable as texture and unreadable as noise. */
.veil {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(96% 74% at 26% 46%,
      rgba(4, 6, 10, 0.97) 0%,
      rgba(4, 6, 10, 0.9) 34%,
      rgba(4, 6, 10, 0.42) 74%,
      rgba(4, 6, 10, 0.05) 100%),
    linear-gradient(to bottom, rgba(4, 6, 10, 0.52) 0%, rgba(4, 6, 10, 0.7) 46%, rgba(4, 6, 10, 0.88) 100%);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: var(--s-3) var(--s-4);
  background: var(--phos);
  color: var(--bg);
  font-weight: 700;
}

.skip:focus { left: var(--s-4); top: var(--s-4); }

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