/* You own every line of this. Change anything.
   Design goals: readable measure, quiet chrome, works in light + dark. */

:root {
  /* Follow the OS by default. The toggle overrides this by setting
     color-scheme on the <html> element (see [data-theme] rules below),
     which flips every light-dark() value at once. */
  color-scheme: light dark;

  --measure: 42rem;
  --bg:      light-dark(#ffffff, #111214);
  --fg:      light-dark(#1a1a1a, #e7e7e8);
  --muted:   light-dark(#6b7280, #9aa0a6);
  --accent:  light-dark(#4338ca, #a5b4fc);
  --border:  light-dark(#e5e7eb, #2a2c30);
  --code-bg: light-dark(#f6f7f9, #1b1d21);
}

/* Manual override set by the toggle (and restored from localStorage). */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

/* ---- layout ---- */
.site-header,
main,
.site-footer {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 2rem;
  padding-bottom: 1.5rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg);
  text-decoration: none;
}

.site-header nav { display: flex; gap: 1rem; align-items: center; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.site-header nav a:hover { color: var(--accent); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 1rem; height: 1rem; }

main { padding-block: 1rem 3rem; }

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.5rem 3rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---- typography ---- */
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 0.5rem; }
h2 { font-size: 1.35rem; margin: 2.2rem 0 0.6rem; }
h3 { font-size: 1.1rem; margin: 1.8rem 0 0.5rem; }

/* break long/bare URLs so they can never push the page sideways on mobile */
a { color: var(--accent); overflow-wrap: break-word; }

p, ul, ol { margin: 0 0 1.1rem; }

.lede { color: var(--muted); font-size: 1.05rem; }
.post-date { color: var(--muted); font-size: 0.9rem; margin-top: 0; }

/* ---- home post list ---- */
.post-list { list-style: none; padding: 0; }
.post-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.post-list time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- content bits ---- */
img, video { max-width: 100%; height: auto; border-radius: 6px; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
}
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; }

blockquote {
  margin: 0 0 1.1rem;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}
pre {
  background: var(--code-bg);
  padding: 0.9rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
}
pre code { background: none; padding: 0; }

/* side-by-side code comparison (two approaches, left vs right) */
.compare { table-layout: fixed; margin: 0 0 1.2rem; }
.compare td { border: none; padding: 0 0.4rem; vertical-align: top; width: 50%; }
.compare td:first-child { padding-left: 0; }
.compare td:last-child { padding-right: 0; }
.compare pre { margin: 0; font-size: 0.82em; }
@media (max-width: 34rem) {
  .compare, .compare tbody, .compare tr, .compare td { display: block; width: auto; }
  .compare td { padding: 0; }
  .compare td + td { margin-top: 0.6rem; }
}

/* footnotes */
.footnotes { font-size: 0.9rem; color: var(--muted); border-top: 1px solid var(--border); margin-top: 2.5rem; }

/* let wide math scroll instead of breaking the layout */
.katex-display { overflow-x: auto; overflow-y: hidden; padding-block: 0.25rem; }
