/* ==========================================================================
   Personal site — single stylesheet, no web fonts, no framework.
   Edit the tokens in :root to retheme.
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --surface: #f3f1ec;
  --text: #1d1d1f;
  --muted: #6b6a66;
  --faint: #d9d6cf;
  --accent: #9a3b1f;        /* rust */
  --accent-soft: #9a3b1f1a;
  --code-bg: #f1efe9;

  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Iowan Old Style", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --measure: 40rem;
  --radius: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a; --surface: #1e1f23; --text: #e6e4df; --muted: #9b9890;
    --faint: #33343a; --accent: #e8916f; --accent-soft: #e8916f1f; --code-bg: #1c1d21;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16171a; --surface: #1e1f23; --text: #e6e4df; --muted: #9b9890;
  --faint: #33343a; --accent: #e8916f; --accent-soft: #e8916f1f; --code-bg: #1c1d21;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.125rem/1.65 var(--serif);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: calc(var(--measure) + 2rem); margin: 0 auto; padding: 0 1rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--bg); padding: .5rem 1rem; z-index: 10; }

h1, h2, h3, h4 { line-height: 1.2; font-weight: 600; letter-spacing: -0.012em; text-wrap: balance; }
h1 { font-size: 2.1rem; margin: 0 0 .4rem; }
h2 { font-size: 1.45rem; margin: 2.4rem 0 .6rem; }
h3 { font-size: 1.15rem; margin: 1.8rem 0 .4rem; }
p, ul, ol, blockquote, figure, pre, table { margin: 0 0 1.15rem; }
img, video { max-width: 100%; height: auto; display: block; }
hr { border: 0; border-top: 1px solid var(--faint); margin: 2.5rem 0; }

/* ---------- Header ---------- */
.site-header { padding: 2.5rem 0 1.25rem; border-bottom: 1px solid var(--faint); margin-bottom: 2.5rem; }
.masthead { display: flex; justify-content: space-between; align-items: center; }
.name {
  color: var(--text); text-decoration: none;
  font-size: 1.35rem; font-weight: 600; letter-spacing: -0.01em;
}
.theme-toggle {
  background: none; border: 1px solid var(--faint); color: var(--muted);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

.site-nav ul { list-style: none; padding: 0; margin: .75rem 0 0; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.site-nav a {
  font: 500 .82rem/1 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); text-decoration: none; padding: .35rem 0; display: inline-block;
  border-bottom: 1.5px solid transparent;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 5rem; padding: 1.5rem 0 3rem; border-top: 1px solid var(--faint);
  font: .85rem/1.6 var(--sans); color: var(--muted);
}
.site-footer a { color: inherit; }

/* ---------- Small UI text ---------- */
.meta, .eyebrow, .post-list time, .post-nav span, figcaption, .tag-cloud, .badge {
  font-family: var(--sans);
}
.meta { color: var(--muted); font-size: .88rem; margin: 0; }
.meta .tag { color: var(--muted); }
.eyebrow {
  font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 3rem 0 1rem;
}

/* ---------- Home ---------- */
.intro { font-size: 1.22rem; line-height: 1.6; }
.hero-img { border-radius: var(--radius); margin: 1.75rem 0; }
.hero-img img { border-radius: var(--radius); width: 100%; }

.cards { list-style: none; padding: 0; display: grid; gap: .75rem; }
.cards li {
  border: 1px solid var(--faint); border-radius: var(--radius); padding: .9rem 1.1rem;
  transition: border-color .15s, background .15s;
}
.cards li:hover { border-color: var(--accent); background: var(--accent-soft); }
.cards a { font-weight: 600; text-decoration: none; }
.cards a::after { content: " ↗"; font-family: var(--sans); font-size: .85em; }
.cards p { margin: .15rem 0 0; color: var(--muted); font-size: 1rem; }

.links { list-style: none; padding: 0; font-family: var(--sans); font-size: .95rem; }
.links li { display: flex; gap: 1rem; padding: .45rem 0; border-bottom: 1px dashed var(--faint); }
.links li span { color: var(--muted); min-width: 5.5rem; }

/* ---------- Post list ---------- */
.post-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.post-list li {
  display: grid; grid-template-columns: 4.25rem 1fr; gap: 1rem; align-items: baseline;
  padding: .55rem 0;
}
.post-list.dated li { grid-template-columns: 6.75rem 1fr; }
.post-list time { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.post-list a { color: var(--text); text-decoration: none; font-weight: 500; }
.post-list a:hover { color: var(--accent); text-decoration: underline; }
.post-list .excerpt { display: block; color: var(--muted); font-size: .97rem; line-height: 1.5; margin-top: .15rem; }
.year { font: 600 .8rem/1 var(--sans); color: var(--muted); letter-spacing: .08em; margin: 2.25rem 0 .5rem; }
.year:first-of-type { margin-top: 0; }

/* Featured (latest) post on the blog index */
.featured { margin-bottom: 2.5rem; }
.featured h2 { margin: .25rem 0 .5rem; font-size: 1.6rem; }
.featured h2 a { color: var(--text); text-decoration: none; }
.featured h2 a:hover { color: var(--accent); }
.featured img { border-radius: var(--radius); margin-bottom: 1rem; aspect-ratio: 16 / 9; object-fit: cover; width: 100%; }
.featured p { color: var(--muted); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; list-style: none; font-size: .82rem; }
.tag-cloud a {
  display: inline-block; padding: .2rem .65rem; border: 1px solid var(--faint);
  border-radius: 999px; color: var(--muted); text-decoration: none;
}
.tag-cloud a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Article ---------- */
.post-header { margin-bottom: 2rem; }
.post-header h1 { font-size: 2.35rem; }
.draft-badge { background: var(--accent); color: var(--bg); padding: 0 .4rem; border-radius: 3px; font-size: .75rem; margin-left: .3rem; }
.cover { margin: 0 0 2rem; }
.cover img { border-radius: var(--radius); width: 100%; }

.prose { hyphens: auto; -webkit-hyphens: auto; }
.prose p, .prose li { text-wrap: pretty; }
.prose > p:first-child::first-letter {
  float: left; font-size: 3.4em; line-height: .85; padding: .08em .1em 0 0; font-weight: 600; color: var(--accent);
}
.prose h2 a, .prose h3 a { color: inherit; text-decoration: none; }
.prose h2 a:hover::after, .prose h3 a:hover::after { content: " #"; color: var(--muted); font-weight: 400; }
.prose li + li { margin-top: .3rem; }
.prose blockquote {
  margin-left: 0; padding: .1rem 0 .1rem 1.25rem; border-left: 3px solid var(--accent);
  color: var(--muted); font-style: italic;
}
.prose figure { margin: 2rem 0; }
.prose img { border-radius: var(--radius); margin: 0 auto; }
/* Wide images: put an image in a <figure class="wide"> to break out of the text column */
.prose figure.wide { margin-left: min(-8vw, -4rem); margin-right: min(-8vw, -4rem); }
@media (max-width: 52rem) { .prose figure.wide { margin-left: 0; margin-right: 0; } }
figcaption { color: var(--muted); font-size: .85rem; text-align: center; margin-top: .6rem; }

.prose table { width: 100%; border-collapse: collapse; font: .92rem/1.45 var(--sans); display: block; overflow-x: auto; }
.prose th, .prose td { padding: .5rem .75rem; border-bottom: 1px solid var(--faint); text-align: left; }
.prose th { font-weight: 600; border-bottom-width: 2px; }
.prose td { font-variant-numeric: tabular-nums; }

/* Aside / callout: <aside class="note">…</aside> */
.prose aside, .note {
  background: var(--surface); border-radius: var(--radius); padding: 1rem 1.25rem;
  font: .98rem/1.55 var(--sans); margin: 1.5rem 0;
}

/* Footnotes */
.footnotes-sep { margin: 3rem 0 1rem; }
.footnotes { font-size: .92rem; color: var(--muted); }
.footnote-ref a { text-decoration: none; font-family: var(--sans); font-size: .75em; }

.post-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
  margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--faint);
}
.post-nav span { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.post-nav a { text-decoration: none; font-weight: 500; }
.post-nav .right { text-align: right; }

/* ---------- Reading list ---------- */
.books { list-style: none; padding: 0; }
.books li { padding: .5rem 0; border-bottom: 1px dashed var(--faint); }
.books .author { color: var(--muted); }
.books .note-text { display: block; font-size: .97rem; color: var(--muted); font-style: italic; }
.stars { color: var(--accent); font-family: var(--sans); font-size: .8rem; letter-spacing: .1em; margin-left: .35rem; }

/* ---------- Code ---------- */
code, pre { font-family: var(--mono); font-size: .86em; }
:not(pre) > code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre {
  background: var(--code-bg); padding: 1rem 1.15rem; border-radius: var(--radius);
  overflow-x: auto; line-height: 1.55; tab-size: 2;
  border: 1px solid var(--faint);
}
/* Prism tokens (build-time highlighted, no JS) */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--muted); font-style: italic; }
.token.punctuation, .token.operator { color: var(--muted); }
.token.keyword, .token.atrule, .token.important, .token.selector { color: var(--accent); }
.token.string, .token.char, .token.attr-value, .token.regex, .token.inserted { color: #4d7a3a; }
.token.number, .token.boolean, .token.constant, .token.symbol { color: #8a5a00; }
.token.function, .token.class-name, .token.tag { color: #2f5f9a; }
.token.property, .token.attr-name, .token.variable { color: #7a3d8a; }
.token.deleted { color: #b3261e; }
:root[data-theme="dark"] .token.string { color: #9fcb85; }
:root[data-theme="dark"] .token.number, :root[data-theme="dark"] .token.boolean { color: #e5c07b; }
:root[data-theme="dark"] .token.function, :root[data-theme="dark"] .token.tag, :root[data-theme="dark"] .token.class-name { color: #8ab4f8; }
:root[data-theme="dark"] .token.property, :root[data-theme="dark"] .token.attr-name { color: #d2a8ff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .token.string { color: #9fcb85; }
  :root:not([data-theme="light"]) .token.number, :root:not([data-theme="light"]) .token.boolean { color: #e5c07b; }
  :root:not([data-theme="light"]) .token.function, :root:not([data-theme="light"]) .token.tag, :root:not([data-theme="light"]) .token.class-name { color: #8ab4f8; }
  :root:not([data-theme="light"]) .token.property, :root:not([data-theme="light"]) .token.attr-name { color: #d2a8ff; }
}

/* ---------- Small screens ---------- */
@media (max-width: 34rem) {
  body { font-size: 1.06rem; }
  h1, .post-header h1 { font-size: 1.8rem; }
  .intro { font-size: 1.12rem; }
  .post-list li { grid-template-columns: 1fr; gap: 0; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .right { text-align: left; }
}

@media print {
  .site-nav, .theme-toggle, .post-nav, .site-footer { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}
