/* The whole theme.
 *
 * anchor emits semantic, class-light HTML, which is an obligation rather than
 * a preference: a stylesheet alone has to be able to restyle the site
 * completely. Almost every selector below is an element selector, and the one
 * class here is the .meta that anchor puts on a page's date line.
 *
 * Light and dark are the stylesheet's business. anchor states that the page
 * supports both and ships no toggle and no JavaScript for it. */

:root {
  color-scheme: light dark;

  --ink: #16181d;
  --ink-soft: #5b6270;
  --paper: #fdfdfc;
  --rule: #e2e2df;
  --accent: #1f4f8f;
  --code-bg: #f2f2ef;

  --measure: 38rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #dfe2e8;
    --ink-soft: #949cab;
    --paper: #14161a;
    --rule: #2a2e36;
    --accent: #8fb6ec;
    --code-bg: #1c1f25;
  }
}

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

body {
  margin: 0 auto;
  max-width: var(--measure);
  padding: 3.5rem 1.25rem 5rem;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.65 ui-serif, Georgia, "Times New Roman", serif;
  overflow-wrap: break-word;
}

/* Headings */

h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  font-weight: 600;
  margin: 2.25rem 0 0.75rem;
}

h1 {
  font-size: 1.75rem;
  margin-top: 0;
  letter-spacing: -0.01em;
}

h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

/* The date line anchor emits under a title, and dates in listings. */

.meta {
  margin: -0.25rem 0 2rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

time {
  font-variant-numeric: tabular-nums;
}

/* Prose */

p {
  margin: 0 0 1.15rem;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

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

strong { font-weight: 600; }

/* Lists, including the description lists this site leans on */

ul, ol {
  padding-left: 1.25rem;
  margin: 0 0 1.15rem;
}

li { margin-bottom: 0.35rem; }

dl {
  margin: 0 0 1.15rem;
}

dt {
  font-weight: 600;
  margin-top: 0.85rem;
}

dd {
  margin: 0.15rem 0 0;
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
}

/* Code and mathematics */

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
}

code {
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 0.9rem 1rem;
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.5;
}

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

/* Display mathematics. Full ink rather than the softer grey used for meta
 * text: once a renderer has typeset it, this is content and not an aside.
 * Inline stem is left alone so it sits in the line it belongs to. */

div.stem {
  display: block;
  overflow-x: auto;
  margin: 1.5rem 0;
  padding: 0.5rem 0;
  text-align: center;
}

/* Quotations and admonitions */

blockquote {
  margin: 1.5rem 0;
  padding-left: 1.1rem;
  border-left: 3px solid var(--rule);
  color: var(--ink-soft);
  font-style: italic;
}

blockquote p:last-child { margin-bottom: 0; }

.admonition {
  margin: 1.5rem 0;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--code-bg);
  font-size: 0.9375rem;
}

.admonition p:last-child { margin-bottom: 0; }

/* Figures */

figure {
  margin: 1.75rem 0;
  text-align: center;
}

img, svg {
  max-width: 100%;
  height: auto;
}

figcaption {
  margin-top: 0.5rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

/* The index: anchor emits the newest page in a section, then a nav of rows */

article > section {
  margin: 2.5rem 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

nav ul {
  list-style: none;
  padding: 0;
}

nav li {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}

nav li time {
  color: var(--ink-soft);
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* Footer */

footer {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.875rem;
}

footer p { margin: 0; }
