/*
 * Shared design tokens + base layout for the "notes" visual system
 * (serif type, teal accent). Colour scheme follows the reader's OS setting
 * by default; the switch from theme.js overrides it per-visitor.
 * Used by: /, /notes/, /notes/storage/, /404.html.
 * /notes/networking/ and /notes/prompts/ carry their own layout/palette but
 * wire in the same switch (their own [data-theme] overrides + theme.js).
 *
 * New page checklist:
 *   - <link rel="stylesheet" href="/theme.css"> in <head>
 *   - reuse .wrap / .topnav / header.h / .kicker rather than redefining them
 *   - wire in the light/dark switch — the three steps in theme.js's header.
 *     For a page on this stylesheet, step 3 (the [data-theme] overrides) is
 *     already handled here; just add the two <script> tags.
 *
 * Flash-guard snippet — applies a saved choice before first paint:
 *   <script>try{var t=localStorage.getItem('theme');if(t==='light'||t==='dark')
 *   document.documentElement.dataset.theme=t}catch(e){}</script>
 */
:root {
  color-scheme: light dark;
  --bg: #faf8f4; --panel: #ffffff; --ink: #1f2328; --ink-soft: #55606b;
  --ink-faint: #636d75; --line: #e3ddd0; --line-firm: #cdc5b4;
  --accent: #0d7d78; --accent-soft: #d5ebe9; --accent-ink: #0a5c58;
  --code-bg: #f3efe6;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

/* Dark palette. Applies when the OS asks for dark and the reader hasn't forced
 * light, OR when the reader has explicitly chosen dark via the toggle.
 * The two rule bodies must stay in sync — CSS can't share one declaration list. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181c; --panel: #1e2127; --ink: #e7e3da; --ink-soft: #a9b0b8;
    --ink-faint: #878f98; --line: #2c3037; --line-firm: #3c424b;
    --accent: #4ec8c0; --accent-soft: #163d3b; --accent-ink: #8fe0da;
    --code-bg: #14161a;
  }
}
:root[data-theme="dark"] {
  --bg: #16181c; --panel: #1e2127; --ink: #e7e3da; --ink-soft: #a9b0b8;
  --ink-faint: #878f98; --line: #2c3037; --line-firm: #3c424b;
  --accent: #4ec8c0; --accent-soft: #163d3b; --accent-ink: #8fe0da;
  --code-bg: #14161a;
}

/* Keep native controls, scrollbars and form widgets matching a forced choice. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.65 var(--serif); -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 680px; margin: 0 auto; padding: 0 20px; }
.wrap.wide { max-width: 820px; }

.topnav {
  padding: 22px 0; border-bottom: 1px solid var(--line);
  font: 600 14px/1 var(--sans);
}
.topnav a { color: var(--ink-soft); text-decoration: underline; text-decoration-color: var(--line-firm); text-underline-offset: 3px; }
.topnav a:hover { color: var(--accent-ink); }
.topnav .sep { color: var(--ink-faint); margin: 0 8px; }
.topnav .here { color: var(--ink); }

header.h { padding: 56px 0 32px; border-bottom: 1px solid var(--line); }
header.h p { margin: 0; color: var(--ink-soft); }

.kicker {
  font: 600 12px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-ink); margin: 0 0 16px;
}
h1 {
  font: 700 clamp(28px, 5vw, 40px)/1.1 var(--serif); margin: 0 0 12px; letter-spacing: -0.01em;
}

/* ---- notes index list (used by /notes/ and /notes/storage/) ---- */
ul.notes { list-style: none; margin: 0; padding: 0; }
ul.notes li { border-bottom: 1px solid var(--line); }
ul.notes a {
  display: block; padding: 26px 4px; text-decoration: none; color: inherit;
  transition: padding-left .15s;
}
ul.notes a:hover { padding-left: 12px; }
ul.notes .n { font: 600 12px/1 var(--mono); color: var(--ink-faint); letter-spacing: 0.08em; }
ul.notes h2 { font: 700 22px/1.25 var(--serif); margin: 8px 0 6px; color: var(--ink); }
ul.notes a:hover h2 { color: var(--accent-ink); }
ul.notes p { margin: 0; font: 400 15px/1.55 var(--sans); color: var(--ink-faint); }
/* Countries listing (#304): each card shows its page's full intro, cut to
   three lines with an ellipsis so the list stays scannable. */
ul.notes p.clamp {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  line-clamp: 3; overflow: hidden;
}
ul.notes .tags { margin-top: 10px; }
ul.notes .tag {
  font: 600 10.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft);
  padding: 4px 7px; border-radius: 5px; margin-right: 6px;
}

/* ---- "not found" state (used by /404.html and the /notes/storage/ viewer) ---- */
.path {
  font: 500 14px/1.5 var(--mono); color: var(--ink);
  background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 10px 13px; margin: 0 0 28px;
  overflow-wrap: anywhere;
}
ul.where { list-style: none; margin: 0; padding: 0; }
ul.where li { border-bottom: 1px solid var(--line); }
ul.where a {
  display: block; padding: 22px 4px; text-decoration: none; color: inherit;
  transition: padding-left .15s;
}
ul.where a:hover { padding-left: 12px; }
ul.where h2 { font: 700 20px/1.25 var(--serif); margin: 0 0 5px; }
ul.where a:hover h2 { color: var(--accent-ink); }
ul.where p { margin: 0; font: 400 15px/1.55 var(--sans); color: var(--ink-faint); }

/* ---- footer (used site-wide) ---- */
footer { padding: 44px 0 80px; font: 500 14px/1.7 var(--sans); color: var(--ink-faint); }
footer a { color: var(--accent-ink); }

/* The light/dark switch (.theme-toggle) styles itself — theme.js injects them,
 * so every page that loads the script gets the control without any CSS here. */
