/*
  Research-terminal theme, shared with dsmorgan.com: Everforest Light and Dark,
  monospace headings and navigation, sans-serif body. Loaded last; it maps
  Everforest onto the tokens in tokens.css and overrides the book styling.
  Palette: https://github.com/sainnhe/everforest (contrast-adjusted light accents).
*/
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --paper: #fdf6e3;
  --surface: #f4f0d9;
  --paper-light: #f4f0d9;
  --paper-shade: #efebd4;
  --ink: #5c6a72;
  --ink-soft: #59675e;
  --rule: #939f91;
  --accent: #486337;
  --accent-bright: #286b70;
  --accent-ink: #fdf6e3;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --font-book: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-code: var(--font-mono);
  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: clamp(1.3rem, 3vw, 1.6rem);
  --step-3: clamp(1.5rem, 4vw, 2rem);
  --step-4: clamp(1.8rem, 5vw, 3rem);
  --leading: 1.75;
  --tracking-caps: normal;
  --measure: 44rem;
  --page-width: 68rem;
  --page-margin: clamp(1rem, 5vw, 4rem);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #2d353b;
  --surface: #343f44;
  --paper-light: #343f44;
  --paper-shade: #3d484d;
  --ink: #d3c6aa;
  --ink-soft: #b3bbab;
  --rule: #859289;
  --accent: #a7c080;
  --accent-bright: #83c092;
  --accent-ink: #2d353b;
}

body {
  background: var(--paper);
  font-variant-numeric: lining-nums tabular-nums;
}

h1, h2, h3 { font-family: var(--font-mono); font-weight: 600; line-height: 1.3; }

.running-head, .terminal-nav, .footer-links, .entry-row-head, .filters,
.breadcrumb, .entry-meta, .tags, .theorem-link {
  font-family: var(--font-mono);
  font-variant-caps: normal;
  letter-spacing: normal;
}

.workspace-label {
  margin-bottom: var(--space-s);
  color: var(--ink-soft);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-head, .empty-state, .missing { text-align: left; }
.page-head > p, .abstract, .empty-state { font-style: normal; }
.tags li { background: var(--surface); color: var(--accent); }
.entry-meta, .breadcrumb { font-size: var(--step--1); }

.theorem, .definition, .lemma { background: var(--surface); }
.prose pre { background: var(--surface); }
.document .sc { font-variant-caps: normal; letter-spacing: normal; font-weight: 600; }

/* Explorers and LaTeX figures draw with fixed light-background colours, so in
   the dark theme they sit on an Everforest Light panel. */
:root[data-theme="dark"] .explore {
  color-scheme: light;
  --paper: #fdf6e3;
  --surface: #f4f0d9;
  --paper-light: #f4f0d9;
  --paper-shade: #efebd4;
  --ink: #5c6a72;
  --ink-soft: #59675e;
  --rule: #939f91;
  --accent: #486337;
  --accent-bright: #286b70;
  --accent-ink: #fdf6e3;
  padding: var(--space-s);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}

:root[data-theme="dark"] .document img,
:root[data-theme="dark"] .document object,
:root[data-theme="dark"] .document embed {
  padding: var(--space-xs);
  border-radius: var(--radius);
  background: #fdf6e3;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { background: var(--surface); color: var(--accent-bright); }

@media print {
  :root[data-theme], :root {
    color-scheme: light;
    --paper: #fff;
    --surface: #fff;
    --paper-light: #fff;
    --paper-shade: #eee;
    --ink: #000;
    --ink-soft: #333;
    --accent: #000;
    --rule: #aaa;
  }
  .theme-toggle, .terminal-nav, .footer-links { display: none; }
  .page { padding: 0; }
}
