/* One column, system fonts. Everything tunable lives in :root. */
:root {
  --bg: #fdfdfc;
  --fg: #1b1b1a;
  --muted: #6f6e69;
  --rule: #e6e5e1;
  --subtle: #f4f3f0;
  --accent: #1b1b1a;
  --measure: 36rem;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark tokens: follow the system unless the visitor picked light, or force when they picked dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --fg: #e8e7e3;
    --muted: #8f8e88;
    --rule: #2a2a28;
    --subtle: #1a1a19;
    --accent: #e8e7e3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111110;
  --fg: #e8e7e3;
  --muted: #8f8e88;
  --rule: #2a2a28;
  --subtle: #1a1a19;
  --accent: #e8e7e3;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}

main, header, footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.25rem;
}

header { padding-top: 4rem; }
footer { padding-bottom: 4rem; color: var(--muted); font-size: .875rem; }

h1, h2, h3 { font-weight: 500; line-height: 1.3; margin: 0; text-wrap: balance; }
h1 { font-size: 1rem; }
h2 {
  font-size: .8125rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 3rem 0 1rem;
}

p { margin: 0 0 1rem; text-wrap: pretty; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: .2em;
  text-decoration-thickness: 1px;
  transition: text-decoration-color .15s;
}
a:hover { text-decoration-color: currentColor; }

.muted { color: var(--muted); }

nav { display: flex; gap: 1.25rem; margin-top: .25rem; font-size: .9375rem; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover, nav a[aria-current="page"] { color: var(--fg); }

/* Lists of posts / projects: title left, meta right. */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .35rem 0;
}
.list .meta {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: .9375rem;
}
.list .desc { display: block; color: var(--muted); font-size: .9375rem; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0 1.5rem; }

/* Footer: copyright left, theme switcher right. */
.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
footer a { color: var(--muted); }
.theme-switch { display: flex; gap: .125rem; }
.theme-switch[hidden] { display: none; }
.theme-switch button {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 4px;
  padding: .125rem .5rem;
  cursor: pointer;
}
.theme-switch button:hover { color: var(--fg); }
.theme-switch button[aria-pressed="true"] { color: var(--fg); background: var(--subtle); }
.theme-switch button:focus-visible { outline: 1px solid var(--muted); outline-offset: 1px; }

/* ---------- Article ---------- */

.crumbs { display: flex; gap: .5rem; font-size: .9375rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--fg); }

article { font-size: 1.0625rem; line-height: 1.75; }
article > header { padding: 0; max-width: none; margin: 3.5rem 0 2.5rem; }
article h1 {
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
}
article .byline {
  margin: .75rem 0 0;
  color: var(--muted);
  font-size: .9375rem;
  font-variant-numeric: tabular-nums;
}
article .lead { font-size: 1.1875rem; line-height: 1.6; color: var(--muted); margin-bottom: 2rem; }

article h2, article h3 {
  position: relative;
  color: var(--fg);
  text-transform: none;
  letter-spacing: -.01em;
  scroll-margin-top: 2rem;
}
article h2 { font-size: 1.25rem; font-weight: 600; margin: 3rem 0 .75rem; }
article h3 { font-size: 1.0625rem; font-weight: 600; margin: 2rem 0 .5rem; }

/* "#" link appears in the margin on hover. */
.anchor {
  position: absolute;
  right: 100%;
  padding-right: .4em;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity .15s;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }

article ul, article ol { padding-left: 1.25rem; margin: 0 0 1.25rem; }
article li { margin: .3rem 0; padding-left: .25rem; }
article li::marker { color: var(--muted); }

article blockquote {
  margin: 1.75rem 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--fg);
  font-style: italic;
}
article blockquote p:last-child { margin: 0; }

article figure { margin: 2rem 0; }
article figure > * { display: block; max-width: 100%; height: auto; border-radius: 6px; }
article figcaption { margin-top: .6rem; color: var(--muted); font-size: .875rem; text-align: center; }

.table { overflow-x: auto; margin: 1.75rem 0; }
article table { width: 100%; border-collapse: collapse; font-size: .9375rem; font-variant-numeric: tabular-nums; }
article th, article td { text-align: left; padding: .5rem .75rem .5rem 0; border-bottom: 1px solid var(--rule); }
article th { font-weight: 500; color: var(--muted); }

code { font-family: var(--mono); font-size: .85em; }
:not(pre) > code { background: var(--subtle); padding: .1em .35em; border-radius: 4px; }
pre {
  font-size: .8125rem;
  line-height: 1.65;
  overflow-x: auto;
  padding: 1rem 1.125rem;
  margin: 1.75rem 0;
  background: var(--subtle);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
pre code { font-size: inherit; }

sup a { text-decoration: none; padding: 0 .1em; }
.footnotes { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: .875rem; color: var(--muted); }
.footnotes ol { padding-left: 1.25rem; }
.footnotes li:target { color: var(--fg); }
.footnotes a { color: inherit; }

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 3.5rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: .9375rem;
}
.post-nav a { text-decoration: none; display: block; }
.post-nav a:hover .title { text-decoration: underline; text-underline-offset: .2em; }
.post-nav .title { color: var(--fg); }
.post-nav .label { display: block; color: var(--muted); font-size: .8125rem; }
.post-nav .next { text-align: right; grid-column: 2; }

::selection { background: color-mix(in srgb, var(--fg) 15%, transparent); }

@media (max-width: 40rem) {
  header { padding-top: 2.5rem; }
  article h1 { font-size: 1.625rem; }
  .anchor { display: none; }
}

@media print {
  .theme-switch, nav, .crumbs, .post-nav { display: none; }
  body { background: #fff; color: #000; }
}

/* ---------- Blog engine additions ---------- */

/* Site name in the header links home without looking like a link. */
header h1 a { text-decoration: none; }

/* "All writing →" under the home page list. */
.more { margin: .75rem 0 0; font-size: .9375rem; }
.more a { color: var(--muted); }
.more a:hover { color: var(--fg); }

/* Tags in the article byline. */
.byline .tag { color: var(--muted); }

/* goldmark footnotes: <div class="footnotes"><hr><ol>…</ol></div> */
.footnotes hr { display: none; }

/* goldmark tables aren't wrapped, so let them scroll on narrow screens. */
@media (max-width: 40rem) {
  article table { display: block; overflow-x: auto; }
}

/* Home About / Now: a second paragraph is a quieter aside. */
.intro p + p { color: var(--muted); }
