:root {
  --text: #1d1d1f;
  --muted: #6e6e73;
  --rule: #e5e5ea;
  --accent: #1f4fb4;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fff;
  color: var(--text);
  font: 20px/1.6 var(--serif);
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 24px; }

main { padding: 40px 0 64px; }

h1 { font-size: 34px; line-height: 1.2; margin: 0 0 24px; font-weight: 400; }
h2 { font-size: 26px; line-height: 1.3; margin: 40px 0 12px; font-weight: 400; }

a { color: var(--accent); text-underline-offset: 0.16em; text-decoration-thickness: 1px; }
a:visited { color: #5b4f96; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.masthead { padding: 40px 0 20px; border-bottom: 1px solid var(--rule); }

.masthead .name, .masthead .name:visited { font-size: 32px; line-height: 1.2; color: var(--text); text-decoration: none; }
.masthead .tagline { margin: 4px 0 0; font-size: 17px; color: var(--muted); }

.site-nav { display: flex; gap: 28px; border-bottom: 1px solid var(--rule); font-size: 17px; }
.site-nav a, .site-nav a:visited {
  margin-bottom: -1px;
  padding: 12px 0 10px;
  border-bottom: 2px solid transparent;
  color: var(--text);
  text-decoration: none;
}
.site-nav a:hover { color: var(--accent); }
.site-nav a[aria-current] { color: var(--accent); border-bottom-color: var(--accent); }

@media (max-width: 640px) {
  body { font-size: 18px; }
  .masthead { padding-top: 28px; }
  .site-nav { gap: 20px; overflow-x: auto; }
}

main > :is(ul, ol):not([class]) > li + li { margin-top: 0.4em; }

/* Details (dates, meta lines, captions, tables, side note labels) are set in sans so the serif is left for reading. */
.project-meta, .post-meta, .post-list time, .post-list .meta, .projects time, .projects .meta, .toc .stats,
figcaption, table, main > aside > p:first-child { font-family: var(--sans); }

img {
  display: block;
  max-width: 100%;
  margin: 24px auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

img.portrait {
  float: right;
  max-width: 40%;
  height: auto;
  margin: 0 0 16px 24px;
  border: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

th, td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

th { font-weight: 600; border-bottom: 2px solid var(--rule); }

code {
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f5f5f7;
  padding: 1px 5px;
  border-radius: 4px;
}

pre {
  background: #f5f5f7;
  padding: 14px 16px;
  border-radius: 6px;
  overflow-x: auto;
}

pre code { padding: 0; background: none; }

.katex { font-size: 1.1em; }
td .katex { white-space: nowrap; }
.katex-display { margin: 20px 0; padding: 8px 0; overflow-x: auto; overflow-y: hidden; }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  font-size: 15px;
}

.pager a { text-decoration: none; }

.columns { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 40px; align-items: start; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.section-head h1, .section-head h2 { margin: 0; font-size: 28px; }
.section-head + .projects li:first-child { border-top: 0; }
.columns > div > section + section { margin-top: 48px; }
.section-head a { font-size: 16px; white-space: nowrap; }

.card { margin-bottom: 20px; padding: 18px 20px; border: 1px solid var(--rule); border-radius: 4px; font-size: 16px; line-height: 1.55; }
.card h2 { margin: 0 0 10px; font-size: 20px; }
.card p { margin: 0 0 10px; }
.card p:last-child { margin-bottom: 0; }
figure { margin: 0 0 16px; }
blockquote { margin: 0; font-style: italic; }
figcaption { margin-top: 4px; font-size: 14px; color: var(--muted); }

.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 24px 0; }
.gallery figure { position: relative; margin: 0; }
.gallery figcaption {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  margin: 0;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text);
}
.gallery img { width: 100%; height: auto; margin: 0; }
.gallery .tall { grid-row: span 2; display: flex; flex-direction: column; }
.gallery .tall img { flex: 1; height: 0; min-height: 0; object-fit: cover; }

/* Side notes: an <aside> in a post or page floats right and the text flows round it. Its first line is the label. */
main > aside {
  float: right;
  width: 240px;
  max-width: 45%;
  margin: 6px 0 16px 28px;
  padding-left: 16px;
  border-left: 2px solid var(--rule);
  font-size: 15px;
  line-height: 1.5;
  color: #3a3a3c;
}
main > aside p { margin: 0 0 8px; }
main > aside > p:first-child { margin-bottom: 6px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
main > aside ul { margin: 0; padding-left: 18px; }
main > aside li + li { margin-top: 4px; }
main > h2 { clear: both; }

@media (max-width: 640px) {
  main > aside { float: none; width: auto; max-width: none; margin: 0 0 20px; }
}

figure.pull {
  float: right;
  width: 300px;
  max-width: 40%;
  position: relative;
  margin: 4px 0 16px 32px;
  padding: 18px 20px 16px 54px;
  background: #f5f5f7;
  border-radius: 6px;
}
figure.pull blockquote::before {
  content: "\201C";
  position: absolute;
  top: 10px;
  left: 14px;
  font: 64px/1 var(--serif);
  color: #a1a1a6;
}

@media (max-width: 640px) {
  figure.pull { float: none; width: auto; max-width: none; margin: 0 0 20px; }
}

@media (max-width: 760px) {
  .columns { grid-template-columns: minmax(0, 1fr); }
}

.projects { list-style: none; padding: 0; margin: 0; }
.projects li { display: flex; padding: 16px 0 18px; border-top: 1px solid var(--rule); }
.projects li > div { flex: 1; min-width: 0; }
.projects .num { min-width: 44px; padding-top: 3px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.projects li:last-child { border-bottom: 1px solid var(--rule); }
.projects .head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.projects .head a { font-size: 19px; font-weight: 600; }
.projects p { margin: 2px 0 0; font-size: 17px; line-height: 1.5; }
.projects time, .projects .meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.projects time { white-space: nowrap; }
.projects .thumb { flex: none; width: 96px; height: 96px; margin: 2px 20px 0 0; border: 1px solid var(--rule); border-radius: 4px; }
.projects .soon { display: flex; align-items: center; justify-content: center; background: #f5f5f7; font-size: 13px; color: var(--muted); }

.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
}
.post-list time { padding-top: 3px; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.post-list .title { font-size: 20px; line-height: 1.35; }
.post-list p { margin: 4px 0 0; line-height: 1.5; }
.post-list .excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 16px;
  color: #3a3a3c;
}
.post-list .meta { font-size: 14px; color: var(--muted); }

@media (max-width: 520px) {
  .post-list li { grid-template-columns: 1fr; gap: 2px; }
  .projects .thumb { width: 64px; height: 64px; margin-right: 14px; }
}

@media print {
  body { font-size: 11pt; }
  .masthead, .site-nav, .pager { display: none; }
  .wrap, main { max-width: none; padding: 0; }
  a, a:visited { color: #000; }
  .projects li, img, table { break-inside: avoid; }
}

.project-meta, .post-meta { margin: -16px 0 20px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.toc { list-style: none; padding: 0; margin: 32px 0; }
.toc li { border-bottom: 1px solid var(--rule); }
.toc a { display: flex; align-items: baseline; padding: 10px 0; color: var(--text); text-decoration: none; }
.toc .stats { margin-left: auto; padding-left: 16px; font-size: 14px; font-weight: 400; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.toc a:hover { color: var(--accent); }
.toc .chapter a { font-weight: 600; padding-top: 18px; }
.toc .section a { padding-left: 28px; }
.toc .num { display: inline-block; min-width: 44px; color: var(--muted); font-variant-numeric: tabular-nums; }
