/* Marginalia: one column of text, with dates, notes and links in the margin. */
:root {
  --ground: #fdfefd;
  --ink: #1d211e;
  --quiet: #5a625c;
  --link: #2f5fb3;      /* Wikipedia blue, a little softer */
  --accent: #3d7246;    /* LessWrong green, darkened so it passes contrast */
  --missing: #b32424;   /* a link to something not written yet */
  --rule: #dfe5e0;
  --wash: #f2f6f2;
  --text: 620px;
  --margin: 240px;
  --gap: 56px;
  --serif: 'Libertinus Serif', 'Linux Libertine', 'Linux Libertine O', Palatino, 'Palatino Linotype', Georgia, serif;
  --display: 'Libertinus Serif Display', var(--serif);
  --mono: ui-monospace, 'SF Mono', Menlo, 'DejaVu Sans Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 20px/1.56 var(--serif); font-variant-numeric: oldstyle-nums; overflow-wrap: break-word; }
[hidden] { display: none !important; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 1px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; background: var(--ground); padding: 6px 12px; z-index: 10; }

.page { max-width: calc(var(--text) + var(--gap) + var(--margin) + 48px); margin: 0 auto; padding: 88px 24px 112px; }
.home main { display: flex; flex-direction: column; gap: 64px; margin-top: 64px; }
.post .page, .index .page { padding-top: 36px; }

.row, .masthead { display: grid; grid-template-columns: minmax(0, var(--text)) minmax(0, var(--margin)); column-gap: var(--gap); row-gap: 4px; align-items: baseline; }
.row p { margin: 0; }
.margin { font-size: 16px; line-height: 1.42; color: var(--quiet); }

h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 50px; line-height: 1.08; text-wrap: balance; }
.home h1 { font-size: 56px; margin-bottom: 22px; }
.index h1 { margin-bottom: 36px; }
h2 { font-weight: 400; font-size: 24px; line-height: 1.3; font-variant-caps: all-small-caps; letter-spacing: 0.045em; color: var(--accent); }
section > h2 { margin: 0 0 14px; }

.masthead { align-items: end; }
.masthead.has-photo { align-items: start; }
.has-photo .photo-box { grid-column: 2; grid-row: 1; }
.has-photo .text { grid-column: 1; grid-row: 1; }
/* A 4:5 frame; the photo inside is placed by its saved position (src/photo.mjs uses the same ratio) */
.photo-frame { position: relative; overflow: hidden; width: 176px; aspect-ratio: 4 / 5; margin-top: 8px; background: var(--wash); }
.photo-frame .photo { position: absolute; display: block; max-width: none; margin: 0; }
/* On a post: your name, leading back to the home page */
.topnav { display: flex; font-size: 17px; margin-bottom: 64px; }
.topnav a { padding: 10px 0; }

.projects .row + .row { margin-top: 20px; }
.sec-list .row + .row { margin-top: 12px; }
/* A picture in the margin beside a section */
/* A picture in the margin: centered on the section's title and text together. When it is taller than they
   are, the extra room is shared above the title and below the text, so nothing overlaps. */
.side-grid { display: grid; grid-template-columns: minmax(0, var(--text)) minmax(0, var(--margin)); column-gap: var(--gap); }
.side-grid > .head { grid-column: 1; grid-row: 1; align-self: end; }
.side-grid > .head h2 { margin: 0 0 14px; }
.side-grid > .text { grid-column: 1; grid-row: 2; align-self: start; }
.side-grid > .margin { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
@media (max-width: 999px) {
  .side-grid { grid-template-columns: minmax(0, 1fr); }
  .side-grid > .margin { grid-column: 1; grid-row: 3; }
}
/* A picture above a section: centered, with the text below it using both columns */
.top-figure { width: 240px; margin: 4px auto 22px; max-width: 100%; }
.top-figure img { display: block; width: 100%; height: auto; }
.top-figure figcaption { margin-top: 8px; text-align: center; font-size: 15px; line-height: 1.4; color: var(--quiet); font-style: italic; }
.prose.wide { max-width: calc(var(--text) + var(--gap) + var(--margin)); }
.side-figure { margin: 6px 0 0; max-width: 100%; }
.side-figure img { display: block; width: 100%; height: auto; }
.side-figure figcaption { margin-top: 8px; font-size: 15px; line-height: 1.4; color: var(--quiet); font-style: italic; }
@media (max-width: 999px) { .side-figure { max-width: 260px; margin-top: 18px; } }
.post-row a, .post-row .margin { padding: 7px 0; display: inline-block; }
.post-row .summary { color: var(--quiet); font-size: 18px; line-height: 1.45; margin: -4px 0 12px; }
.quiet { color: var(--quiet); }


/* Running text */
.prose { max-width: var(--text); }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose figure, .math-block, .table-wrap { margin: 0 0 22px; }
.body { margin-top: 40px; }
.body h2 { margin: 44px 0 14px; font-size: 26px; }
.body h3 { margin: 32px 0 10px; font-weight: 400; font-style: italic; font-size: 21px; line-height: 1.3; }
.body h4, .body h5, .body h6 { margin: 26px 0 8px; font-weight: 600; font-size: 20px; line-height: 1.3; }
.prose ul, .prose ol { padding-left: 26px; }
.prose li + li { margin-top: 6px; }
.prose li::marker { color: var(--quiet); }
.prose blockquote { margin-left: 0; margin-right: 0; padding-left: 26px; color: #3f4742; font-style: italic; }
.prose blockquote em { font-style: normal; }
.prose hr { border: 0; text-align: center; margin: 36px 0; }
.prose hr::before { content: '* * *'; letter-spacing: 0.4em; color: var(--quiet); }
.prose img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
figcaption { font-size: 16px; line-height: 1.42; color: var(--quiet); margin-top: 10px; }
code { font-family: var(--mono); font-size: 0.8em; font-variant-numeric: lining-nums; }
:not(pre) > code { background: var(--wash); padding: 1px 4px; }
pre { background: var(--wash); padding: 16px 18px; overflow-x: auto; line-height: 1.5; }
pre code { font-size: 14.5px; }
.math-block { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
body .katex { font-size: 1.05em; } /* body: wins over katex.min.css, which loads later */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; font-size: 17px; line-height: 1.4; font-variant-numeric: lining-nums tabular-nums; }
th, td { text-align: left; vertical-align: top; padding: 7px 18px 7px 0; border-bottom: 1px solid var(--rule); }
th { font-weight: 600; border-bottom-color: var(--quiet); }
.hljs-comment, .hljs-quote { color: var(--quiet); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in { color: #2a5a96; }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--accent); }
.hljs-number, .hljs-deletion { color: #94491c; }
.hljs-title, .hljs-section { color: #5b3f8c; }

/* Notes */
.fn-ref { font-size: 14px; line-height: 0; font-variant-numeric: lining-nums; }
.fn-ref a, .sidenote .num { color: var(--accent); }
.sidenote { display: none; }
.footnotes { margin-top: 56px; max-width: var(--text); font-size: 17px; line-height: 1.5; }
.footnotes ol { margin: 0; padding-left: 26px; }
.footnotes li + li { margin-top: 8px; }
.footnotes p { margin: 0; }
.head-note { margin-top: 28px; max-width: var(--text); }
.head-note p { margin: 0 0 16px; }
.head-note nav { display: flex; flex-direction: column; }
.head-note nav a { padding: 4px 0; }
.backlinks { margin: 56px 0 0; max-width: var(--text); font-size: 17px; color: var(--quiet); }

.unwritten { color: var(--missing); }
.draft { font-size: 15px; font-style: normal; color: #8a4b08; background: #fbf1dd; padding: 0 6px; white-space: nowrap; }

/* Hover card for links between posts */
.card { position: absolute; z-index: 20; width: min(340px, calc(100vw - 32px)); background: #fff; border: 1px solid #c3ccc5; box-shadow: 0 6px 24px rgb(29 33 30 / 0.12); padding: 14px 18px; font-size: 16px; line-height: 1.45; color: var(--ink); pointer-events: none; }
.card strong { display: block; font-weight: 400; font-size: 20px; line-height: 1.25; margin-bottom: 5px; }

@media screen and (min-width: 1000px) {
  .sidenote, .head-note { float: right; clear: right; width: var(--margin); font-size: 16px; line-height: 1.42; color: var(--quiet); font-style: normal; font-weight: 400; text-align: left; }
  .sidenote { display: block; margin: 3px calc(-1 * (var(--margin) + var(--gap))) 18px 0; text-indent: 0; }
  .prose li .sidenote { margin-right: calc(-1 * (var(--margin) + var(--gap))); }
  .head-note { margin: 45px 0 18px; }
  .footnotes.placed, .footnotes li.placed { display: none; }
}
@media (max-width: 999px) {
  .page { max-width: calc(var(--text) + 48px); }
  .row, .masthead { grid-template-columns: minmax(0, 1fr); }
  .masthead { row-gap: 22px; }
  .masthead.has-photo { grid-template-rows: none; }
  .has-photo .photo-box, .has-photo .text { grid-column: 1; grid-row: auto; margin-top: 0; }
  .photo-frame { width: 128px; }
  .post-row { padding: 6px 0; }
  .post-row a, .post-row .margin { padding: 2px 0; }
  .post-row .summary { margin: 2px 0 6px; }
}
@media (max-width: 600px) {
  body { font-size: 18.5px; }
  .page { padding: 40px 20px 72px; }
  .home h1 { font-size: 42px; }
  h1 { font-size: 36px; }
  .topnav { margin-bottom: 36px; }
  .home main { gap: 48px; margin-top: 48px; }
}
@media print {
  .topnav, .skip { display: none; }
  body { font-size: 11pt; }
}
