/* ==========================================================================
   Base - reset, dark document, modern typography (Refraction theme)
   ========================================================================== */

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

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

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

body {
  font-family: var(--font-text);
  font-size: var(--fs-200);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  min-height: 100vh;
  overflow-x: hidden;
}

/* PRISM-style fixed glow field behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 10% -5%, rgba(139, 63, 196, 0.22), transparent 60%),
    radial-gradient(820px 520px at 95% 6%, rgba(255, 198, 41, 0.09), transparent 55%),
    radial-gradient(1000px 700px at 50% 112%, rgba(0, 77, 255, 0.14), transparent 60%);
}

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  color: var(--ink-900);
  text-wrap: balance;
}

h1 { font-size: var(--fs-700); }
h2 { font-size: var(--fs-600); }
h3 { font-size: var(--fs-500); }
h4 { font-size: var(--fs-400); }

p { max-width: var(--measure); }
p + p { margin-top: var(--space-4); }

a { color: var(--brass-500); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brass-400); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brass-500); color: #1a1330; }

/* utility */
.eyebrow {
  font-family: var(--font-text);
  font-size: var(--fs-50);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass-500);
}
.lead { font-size: var(--fs-300); color: var(--ink-700); }
.center { text-align: center; }
.spectrum-text { background: var(--spectrum-soft); -webkit-background-clip: text; background-clip: text; color: transparent; }
.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: absolute; left: var(--space-4); top: -100%;
  background: var(--brass-500); color: #1a1330;
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-sm);
  z-index: 100; font-weight: 700; transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--space-4); color: #1a1330; }

.container { width: min(100% - 2.5rem, var(--container)); margin-inline: auto; }
.container-narrow { width: min(100% - 2.5rem, var(--container-narrow)); margin-inline: auto; }

main { position: relative; z-index: 1; }

/* --- Reading-mode toggle (study-mode.js): Sources (default) vs Plain --- */
.reading-mode { position: fixed; right: 1rem; bottom: 1rem; z-index: 1500; display: flex; align-items: center; gap: 0.3rem; background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: 999px; padding: 0.3rem 0.45rem; box-shadow: var(--shadow); font-size: var(--fs-50); }
.reading-mode__label { color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 0.25rem; }
.reading-mode button { border: 1px solid transparent; background: transparent; color: var(--ink-700); border-radius: 999px; padding: 0.25rem 0.65rem; cursor: pointer; font: inherit; line-height: 1; }
.reading-mode button[aria-pressed="true"] { background: var(--brass-500); color: #1a1430; font-weight: 600; }
.reading-mode button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
@media print { .reading-mode { display: none; } }
/* Plain mode tucks away the scholarly apparatus (sources, confidence chips, caveats). */
html.mode-plain .source-note,
html.mode-plain .chip,
html.mode-plain .tl-item__src { display: none !important; }
