/* The browser chooses the theme before the first paint. */
:root {
  color-scheme: light dark;
  --background: #faf9f6;
  --text: #292e2c;
  --muted: #646a66;
  --accent: #205d51;
  --border: #dedfd7;
  --surface: #efefe9;
  --code: #78432e;
  --syntax: #68437b;
  --string: #37604c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 100%;
  line-height: 1.7;
  color: var(--text);
  background: var(--background);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #171919;
    --text: #e3e6df;
    --muted: #a4ada7;
    --accent: #8fc8b4;
    --border: #353b37;
    --surface: #222725;
    --code: #e6b29a;
    --syntax: #c8a6df;
    --string: #a1c9af;
  }
}

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

body { margin: 0; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
  border-radius: 2px;
}

::selection { background: var(--accent); color: var(--background); }

.shell {
  width: min(100% - 3rem, 46rem);
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 1;
  top: 1rem;
  left: 1rem;
  padding: 0.5rem 1rem;
  background: var(--background);
  transform: translateY(-200%);
}

.skip-link:focus { transform: translateY(0); }

.site-header,
.site-header nav,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.site-header {
  padding-block: 2.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.site-header a { text-decoration: none; }

.site-header a:hover { text-decoration: underline; }

.site-name { font-weight: 650; color: var(--text); }

.site-header nav a { color: var(--muted); }

.site-header nav a[aria-current] { color: var(--accent); }

main { min-height: 55vh; }

h1, h2, h3, h4 { line-height: 1.25; text-wrap: balance; }

h1 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(2.4rem, 5.5vw, 3.5rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.eyebrow {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.intro { padding-block: 5.5rem 1.5rem; }

.lede {
  max-width: 35rem;
  margin-block: 1.5rem 0;
  color: var(--muted);
  font-size: 1.125rem;
}

.intro-links { margin-block: 1rem 0; font-size: 0.875rem; }

.section-heading { padding-bottom: 1rem; }

.section-heading h2 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.section-heading > span { font-size: 0.75rem; color: var(--muted); }

.post-list { margin: 0; padding: 0; list-style: none; }

.post-list a {
  display: block;
  padding-block: 1.5rem;
  color: inherit;
  text-decoration: none;
}

.post-list h3 { margin: 0; font-size: 1.125rem; font-weight: 550; }

.post-list a:hover h3 { color: var(--accent); text-decoration: underline; text-underline-offset: 0.2em; }

.post-list p { max-width: 31rem; margin: 0.5rem 0 0; color: var(--muted); font-size: 0.875rem; }

.post-list time { display: block; margin-top: 0.5rem; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.page-header { padding-block: 4.5rem 2.5rem; }

.page-header h1 + .eyebrow { margin: 1.25rem 0 0; }

.topics { margin-block: 1.5rem 0; font-size: 0.875rem; color: var(--muted); }

.prose { font-size: 1.0625rem; overflow-wrap: break-word; }

.prose > :first-child { margin-top: 0; }

.prose p, .prose ul, .prose ol { margin-block: 1.5rem; }

.prose h2 { margin-block: 3rem 1rem; font-size: 1.65rem; font-weight: 600; letter-spacing: -0.025em; }

.prose h3 { margin-block: 2.25rem 1rem; font-size: 1.25rem; font-weight: 600; }

.prose h4 { margin-block: 2rem 1rem; font-size: 1.0625rem; }

.prose li { padding-left: 0.25rem; }

.prose li + li { margin-top: 0.35rem; }

.prose li > ul, .prose li > ol { margin-block: 0.5rem; }

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2rem auto;
  border-radius: 4px;
}

.prose .diagram {
  padding: 1rem;
  background: #fff;
  max-width: min(100%, 28rem);
}

.prose figure { margin: 2rem 0; }

.prose figcaption { margin-top: 0.75rem; color: var(--muted); font-size: 0.875rem; text-align: center; }

hr { border: 0; border-top: 1px solid var(--border); margin-block: 2.5rem; }

code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 0.875em; }

:not(pre) > code {
  padding: 0.15em 0.35em;
  border-radius: 3px;
  color: var(--code);
  background: var(--surface);
  overflow-wrap: anywhere;
}

pre {
  padding: 1.5rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  line-height: 1.65;
  tab-size: 4;
}

pre code { font-size: 1em; }

.hljs-keyword, .hljs-built_in, .hljs-selector-tag { color: var(--syntax); }
.hljs-title, .hljs-attribute, .hljs-number, .hljs-literal { color: var(--code); }
.hljs-string, .hljs-doctag { color: var(--string); }
.hljs-comment { color: var(--muted); font-style: italic; }

.prose .katex-display { margin-block: 2rem; padding-block: 0.5rem; overflow-x: auto; overflow-y: hidden; }
.prose .katex { font-size: 1.08em; }
.prose .katex-display > .katex { text-align: center; }

.post-end { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 0.875rem; }

@media (max-width: 40rem) {
  .site-header { padding-block: 1.5rem; }
  .site-header nav { gap: 1rem; }
  .intro { padding-block: 3.5rem 1.5rem; }
  .page-header { padding-top: 3rem; }
  .desktop-break { display: none; }
  .post-list a { padding-block: 1.25rem; }
  pre { padding: 1rem; }
}

@media print {
  :root {
    color-scheme: light;
    --background: #fff;
    --text: #000;
    --muted: #444;
    --accent: #000;
    --border: #bbb;
    --surface: #f5f5f5;
    --code: #000;
    --syntax: #000;
    --string: #000;
  }
  .shell { width: 100%; }
  .site-header, .post-end, .skip-link { display: none; }
  .page-header { padding-top: 0; }
  pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  .prose .katex-display { overflow: visible; }
  h2, h3 { break-after: avoid; }
}
