/* Monospace, dark-first, single narrow column. Inspired by terminal-style personal sites. */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&display=swap");

/* Dark is the default. Light swaps background and text; grey is the same in
   both modes; purple is a step darker on light so it keeps its contrast on white. */
:root {
  --bg: #0f0f0f;
  --text: #f5f5f5;
  --heading: #ffffff;
  --muted: #7c7c7c;
  --link: #9b72f7;
  --rule: #3a3a3a;
  --code-bg: #1f1f1f;
  --pre-bg: #181818;
  --measure: 62ch;
}
:root[data-theme="light"] {
  --bg: #fdfdfd;
  --text: #0f0f0f;
  --heading: #000000;
  --link: #8b5cf6;
  --rule: #cfcfcf;
  --code-bg: #ececec;
  --pre-bg: #f1f1f1;
}

* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
body {
  margin: 0 auto; padding: 2.5rem 1.25rem 4rem; max-width: 72rem;
  font-family: "JetBrains Mono", "JetBrainsMono Nerd Font", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px; line-height: 1.7; color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

/* ---- site header ---- */
.site-header {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1.5rem;
  max-width: calc(var(--measure) + 16rem); margin: 0 auto 3.5rem;
}
.site-name { font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--heading); text-decoration: none; font-size: 15px; }
.site-name::after { content: "\2588"; margin-left: .15em; animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .site-name::after { animation: none; } }
.site-sub { color: var(--muted); font-size: 12px; margin-top: .25rem; }
.site-nav { display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; font-size: 12px; }
.site-nav a { color: var(--text); text-decoration: none; text-transform: uppercase; letter-spacing: .06em; }
.site-nav a::before { content: "[ "; color: var(--muted); }
.site-nav a::after { content: " ]"; color: var(--muted); }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--link); }
.theme-toggle { font: inherit; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: none; border: 0; padding: 0; margin-top: .6rem; cursor: pointer; }
.theme-toggle::before { content: "[ "; } .theme-toggle::after { content: " ]"; }
.theme-toggle:hover { color: var(--link); }

/* ---- layout: optional sticky TOC + narrow column ---- */
.layout { display: flex; gap: 3rem; justify-content: center; align-items: flex-start; }
.toc {
  position: sticky; top: 1.5rem; width: 14rem; flex: none; max-height: calc(100vh - 3rem); overflow-y: auto;
  font-size: 12px; line-height: 1.45;
}
.toc .label, .kicker { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.toc .back { display: inline-block; margin-bottom: 2rem; }
.toc .toc-title { color: var(--heading); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: .4rem 0 1.5rem; font-size: 13px; }
.toc ul { list-style: none; margin: .5rem 0 0; padding: 0; }
.toc ul ul { padding-left: 1rem; margin-top: 0; }
.toc li { margin: .45rem 0; }
main { width: 100%; max-width: var(--measure); min-width: 0; }
/* Dividing line between sidebar and text: takes the text colour, so white on dark, black on light. */
.layout:has(.toc) { gap: 0; align-items: stretch; }
.toc { align-self: flex-start; padding-right: 2.5rem; }
.toc + main { max-width: calc(var(--measure) + 3rem); padding-left: 3rem; border-left: 1px solid var(--text); }

/* ---- type ---- */
h1, h2, h3, h4 { color: var(--heading); text-transform: uppercase; line-height: 1.35; }
h1 { font-size: 20px; font-weight: 700; letter-spacing: .02em; margin: .5rem 0 1rem; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: .02em; margin: 3rem 0 1rem; }
h3 { font-size: 14px; font-weight: 600; letter-spacing: .04em; margin: 2.25rem 0 .75rem; }
.hero { font-size: clamp(22px, 4.2vw, 30px); line-height: 1.3; letter-spacing: .03em; margin: .75rem 0 1.5rem; }
.crumbs, .meta { font-size: 12px; color: var(--muted); }
.crumbs a, .meta a { color: var(--muted); }
.lede { color: var(--muted); margin: 1.25rem 0; }
.sep { color: var(--muted); margin: 2rem 0; letter-spacing: .2em; }
.sep::before { content: "~~~"; }
hr { border: 0; margin: 2.5rem 0; color: var(--muted); }
hr::before { content: "~~~"; letter-spacing: .2em; }
p, ul, ol { margin: 1.1rem 0; }
li { margin: .35rem 0; }
ul { list-style: "\2013\00a0\00a0"; padding-left: 1.6rem; }
strong { color: var(--heading); font-weight: 600; }
blockquote { margin: 1.5rem 0; padding: .1rem 0 .1rem 1.1rem; border-left: 2px solid var(--rule); color: var(--muted); }
img, svg, video { max-width: 100%; height: auto; }
figure { margin: 2rem 0; }
figcaption { font-size: 12px; color: var(--muted); margin-top: .5rem; }

code { font: inherit; font-size: .9em; font-weight: 600; background: var(--code-bg); border: 1px solid var(--rule); padding: 0 .3em; border-radius: 2px; }
pre { background: var(--pre-bg); padding: 1rem; overflow-x: auto; font-size: 12.5px; line-height: 1.65; border-radius: 2px; }
pre code { background: none; border: 0; padding: 0; font-weight: 400; }
table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 13px; }
th, td { border-bottom: 1px solid var(--rule); padding: .4rem .9rem .4rem 0; text-align: left; vertical-align: top; }
th { color: var(--heading); text-transform: uppercase; font-size: 11px; letter-spacing: .08em; }
math { font-size: 1.1em; }

/* footnotes + references (pandoc) */
.footnotes, #refs { font-size: 12.5px; color: var(--muted); }
.footnotes hr { display: none; }
.footnotes::before, #refs::before { content: "~~~"; letter-spacing: .2em; display: block; margin: 2.5rem 0 1rem; }
.csl-entry { margin: .7rem 0; padding-left: 1.6rem; text-indent: -1.6rem; }
sup { line-height: 0; }

/* ---- garden ---- */
.stub { color: var(--muted); border-bottom: 1px dashed var(--muted); cursor: help; }
.backlinks { margin-top: 3rem; font-size: 12.5px; color: var(--muted); }
.backlinks::before { content: "~~~"; letter-spacing: .2em; }
.backlinks h3 { font-size: 11px; color: var(--muted); letter-spacing: .1em; margin-top: 1rem; }

/* ---- lists of entries (writing index, publications) ---- */
.entries { list-style: none; padding: 0; }
.entries li { display: grid; grid-template-columns: 7.5rem 1fr; gap: .25rem 1rem; margin: .9rem 0; }
.entries time, .entries .when { color: var(--muted); font-size: 12px; padding-top: .1rem; }
.entries .desc { grid-column: 2; color: var(--muted); font-size: 12.5px; }

.site-footer { max-width: calc(var(--measure) + 16rem); margin: 5rem auto 0; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; }
.site-footer a { color: var(--muted); }

@media (max-width: 860px) {
  .layout { display: block; }
  .toc + main { padding-left: 0; border-left: 0; }
  .toc { position: static; padding-right: 0; width: auto; max-height: none; margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px dashed var(--rule); }
  .toc .toc-title { display: none; }
  .site-nav { align-items: flex-start; flex-direction: row; flex-wrap: wrap; gap: .25rem 1rem; }
  .entries li { grid-template-columns: 1fr; }
  .entries .desc { grid-column: 1; }
}
