/* The public pages' one stylesheet, in the page's own colours. System fonts only; light
   and dark by the system's choice. */

:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --hover: rgb(31 30 29 / 0.06);
  --active: rgb(31 30 29 / 0.1);
  --line: rgb(31 30 29 / 0.12);
  --text: #1f1e1d;
  --dim: #73726c;
  --link: #1f1e1d;
  --serif: "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1e1d;
    --surface: #2a2927;
    --hover: rgb(240 238 230 / 0.07);
    --active: rgb(240 238 230 / 0.12);
    --line: rgb(240 238 230 / 0.13);
    --text: #f0eee6;
    --dim: #a3a29b;
    --link: #f0eee6;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
}

a { color: var(--link); }

/* The bar: the wordmark, search, and the way to Theorem. */
.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}
.bar .word { color: var(--text); font: 400 20px/1 var(--serif); text-decoration: none; white-space: nowrap; }
.bar .word span { color: var(--dim); margin-inline-start: 5px; }
.bar .open { margin-inline-start: auto; }
.bar .search { width: 260px; }
.bar input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 14px var(--sans);
}
.bar input::placeholder { color: var(--dim); }
.bar .open { color: var(--dim); font-size: 14px; text-decoration: none; white-space: nowrap; }
.bar .open:hover { color: var(--text); }

/* The index at the left, the page, and its headings on a wide window. */
.frame {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 190px;
  gap: 0 36px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 20px 64px;
  align-items: start;
}

.index { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 22px 0; font-size: 14px; }
.index h2, .index-narrow h2 {
  margin: 20px 0 4px;
  padding: 0 10px;
  color: var(--text);
  font: 600 13px/1.4 var(--sans);
  letter-spacing: 0.01em;
}
.index h2:first-child, .index-narrow h2:first-child { margin-top: 0; }
.index ul, .index-narrow ul, .headings ul { list-style: none; margin: 0; padding: 0; }
.index li a, .index-narrow li a {
  display: block;
  padding: 4px 10px;
  border-radius: 8px;
  color: var(--dim);
  text-decoration: none;
}
.index li a:hover, .index-narrow li a:hover { background: var(--hover); color: var(--text); }
.index li a[aria-current="page"], .index-narrow li a[aria-current="page"] { background: var(--active); color: var(--text); }

.headings { position: sticky; top: 0; padding: 26px 0; font-size: 13px; }
.headings h2 { margin: 0 0 6px; color: var(--dim); font: 500 12px/1.4 var(--sans); }
.headings li a { display: block; padding: 3px 0; color: var(--dim); text-decoration: none; }
.headings li a:hover { color: var(--text); }
.headings li.level-3 a { padding-inline-start: 12px; }

.index-narrow { display: none; }

/* The page. */
main { min-width: 0; max-width: 720px; padding-top: 24px; }
/* The title, and "Copy as Markdown" at the right end of its line. */
.title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
main .title h1 { margin: 0; font: 400 32px/1.2 var(--serif); letter-spacing: -0.01em; }
main a.copy {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--dim);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
main a.copy:hover { background: var(--hover); color: var(--text); }
main a.copy svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
main .lead { margin: 0 0 24px; color: var(--dim); font-size: 17px; }
main h2 { margin: 36px 0 10px; font: 600 18px/1.35 var(--sans); }
main h3 { margin: 26px 0 8px; font: 600 15px/1.4 var(--sans); }
main p, main ul, main ol { margin: 0 0 14px; }
main li { margin: 4px 0; }
main a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
main a:hover { text-decoration-color: currentColor; }
main code { font: 13px/1.4 var(--mono); }
main :not(pre) > code { padding: 1px 5px; border-radius: 4px; background: var(--hover); }
main pre {
  margin: 8px 0 16px;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font: 13px/1.55 var(--mono);
}
main table { display: block; overflow-x: auto; width: 100%; margin: 6px 0 16px; border-collapse: collapse; font-size: 14px; }
main th { padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line); color: var(--dim); font-size: 13px; font-weight: 500; text-align: start; }
main td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
main blockquote { margin: 0 0 14px; padding: 2px 14px; border-inline-start: 3px solid var(--line); color: var(--dim); }
main figure.example { margin: 8px 0 16px; }
main figure.example figcaption { margin-bottom: 4px; color: var(--dim); font: 12px/1.4 var(--mono); }
main figure.example pre { margin: 0; }

/* Search results, and the page that is not there. */
.results { list-style: none; margin: 0; padding: 0; }
.results li { margin: 0 0 20px; }
.results .where { display: block; color: var(--dim); font-size: 13px; }
.results p { margin: 2px 0 0; }

@media (max-width: 1100px) {
  .frame { grid-template-columns: 200px minmax(0, 1fr); }
  .headings { display: none; }
}

@media (max-width: 760px) {
  .bar { flex-wrap: wrap; height: auto; padding: 12px 16px; row-gap: 10px; }
  .bar .search { order: 3; width: 100%; }
  .frame { display: block; padding: 0 16px 48px; }
  .index { display: none; }
  .index-narrow { display: block; padding: 0 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
  .index-narrow summary { padding: 10px 0; color: var(--dim); cursor: pointer; }
  .index-narrow nav { padding-bottom: 12px; }
  .title { flex-direction: column; align-items: flex-start; gap: 8px; }
  main .title h1 { font-size: 26px; }
}
