/* ==========================================================================
   andrewshaw.nl — typography, layout & themes
   Three themes: light (default), dark (off-brown), system (auto). Colours are
   tokens; the base stays conservative so old browsers fall back to a clean page.
   ========================================================================== */

@font-face {
  font-family: "Maple Mono";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/maple-mono-latin-400-normal.woff2") format("woff2"),
       url("../fonts/maple-mono-latin-400-normal.woff") format("woff");
}
@font-face {
  font-family: "Maple Mono";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/maple-mono-latin-700-normal.woff2") format("woff2"),
       url("../fonts/maple-mono-latin-700-normal.woff") format("woff");
}

/* --- Theme tokens --------------------------------------------------------- */
/* Light is the default; every colour below is read through var() with a
   hard-coded fallback, so browsers without custom properties still get it. */
:root {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Maple Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  --bg:#fdfdfb;
  --text:#1a1a1a;
  --heading:#1a1a1a;
  --muted:#777777;
  --link:#0b5fa5;
  --link-visited:#6b4ea5;
  --link-hover:#c0392b;
  --surface:#f4f3ee;
  --surface-border:#e4e2d8;
  --rule:#e4e2d8;
  --quote:#555555;
  --ink-glow:none;
  --title-shadow:none;
}

/* Dark — warm "off-brown" */
:root[data-theme="dark"] {
  --bg:#211b15;
  --text:#ece3d5;
  --heading:#f3ebdd;
  --muted:#a99a86;
  --link:#e3a45c;
  --link-visited:#cba879;
  --link-hover:#f6c98a;
  --surface:#2b231b;
  --surface-border:#3c3127;
  --rule:#352b22;
  --quote:#bcae9a;
}

/* System — follow the OS when no explicit choice (or "system" chosen) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]),
  :root[data-theme="system"] {
    --bg:#211b15;
    --text:#ece3d5;
    --heading:#f3ebdd;
    --muted:#a99a86;
    --link:#e3a45c;
    --link-visited:#cba879;
    --link-hover:#f6c98a;
    --surface:#2b231b;
    --surface-border:#3c3127;
    --rule:#352b22;
    --quote:#bcae9a;
  }
}

/* --- Reset ---------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  color: var(--text, #1a1a1a);
  background: var(--bg, #fdfdfb);
  text-shadow: var(--ink-glow, none);
  transition: background-color .4s ease, color .4s ease;
}

/* the centred reading column */
.page {
  max-width: 40em;
  margin: 0 auto;
  padding: 2em 1.25em 3em;
}

/* --- Typography ----------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-mono);
  line-height: 1.25;
  margin: 1.6em 0 0.5em;
  font-weight: 700;
  color: var(--heading, #1a1a1a);
  text-shadow: var(--title-shadow, none);
}
h1 { font-size: 1.9em; margin-top: 0; }
h2 { font-size: 1.45em; }
h3 { font-size: 1.2em; }
h4, h5, h6 { font-size: 1em; }

p, ul, ol, dl, blockquote, pre, table { margin: 0 0 1em; }
ul, ol { padding-left: 1.4em; }
li { margin: 0.2em 0; }
li::marker { color: var(--link, #0b5fa5); }

a            { color: var(--link, #0b5fa5); }
a:visited    { color: var(--link-visited, #6b4ea5); }
a:hover,
a:focus      { color: var(--link-hover, #c0392b); }

blockquote {
  margin-left: 0;
  padding-left: 1em;
  border-left: 3px solid var(--link-hover, #ddd);
  color: var(--quote, #555);
  font-style: italic;
}

hr { border: 0; border-top: 1px solid var(--rule, #ddd); margin: 2em 0; }

img { max-width: 100%; height: auto; }

/* --- Monospace ------------------------------------------------------------ */
code, pre, kbd, samp, tt, var {
  font-family: var(--font-mono);
}
code, kbd, samp { font-size: 0.9em; }

pre {
  font-size: 0.85em; line-height: 1.5; overflow-x: auto;
  padding: 0.9em 1em;
  background: var(--surface, #f4f3ee);
  border: 1px solid var(--surface-border, #e4e2d8);
  border-radius: 6px;
}
pre code { font-size: inherit; background: none; padding: 0; border: 0; }

:not(pre) > code {
  padding: 0.1em 0.3em;
  background: var(--surface, #f4f3ee);
  border: 1px solid var(--surface-border, #e4e2d8);
  border-radius: 4px;
}

/* --- Page furniture ------------------------------------------------------- */
header.site {
  position: relative;
  margin-bottom: 2em;
  padding-bottom: 1em;
  border-bottom: 1px solid var(--surface-border, #e4e2d8);
  text-align: center;
}
header.site .wordmark {
  font-family: var(--font-mono);
  font-weight: 700; font-size: 1.35em; font-style: italic; text-decoration: none;
  color: var(--heading, #1a1a1a);
  text-shadow: var(--title-shadow, none);
}
header.site nav { margin-top: 0.5em; }
header.site nav a {
  text-decoration: none;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

article header {
  border-bottom: 0; padding-bottom: 0; margin-bottom: 1.5em;
}
article time { color: var(--muted, #777); font-size: 0.9em; }

/* --- threads: named reading collections ---------------------------------- */
.muted { color: var(--muted, #777); }
.thread-subtitle { color: var(--quote, #555); font-style: italic; margin-top: -0.3em; }
.thread-desc { margin: 1em 0 2em; }
.thread-list, .thread-index { list-style: none; padding-left: 0; }
.thread-list > li, .thread-index > li {
  padding: 0.7em 0; border-bottom: 1px solid var(--rule, #e4e2d8);
}
.thread-list { counter-reset: thread; }
.thread-list > li { counter-increment: thread; }
.thread-list > li::before {
  content: counter(thread, decimal-leading-zero);
  font-family: var(--font-mono); color: var(--muted, #777);
  font-size: 0.8em; margin-right: 0.8em;
}
.thread-item { font-weight: 700; text-decoration: none; }
.thread-item-sub { display: block; color: var(--quote, #555); font-size: 0.95em; margin: 0.15em 0; }
.thread-list time { display: inline-block; margin-top: 0.1em; }
