/* Tokens. Contrast against --paper: ink 13.5:1, spruce 9.1:1, stone 5.5:1, amber 3.4:1 (a graphic, not text). */
:root {
  color-scheme: light dark;
  --paper: oklch(97.1% 0.004 135);
  --ink: oklch(27.7% 0.02 206);
  --spruce: oklch(37.5% 0.059 190);
  --spruce-strong: oklch(30% 0.055 190);
  --stone: oklch(49.8% 0.02 210);
  --rule: oklch(85.9% 0.01 181);
  --amber: oklch(60.5% 0.123 75);
  --tint: oklch(92.5% 0.009 170);
  --mark: oklch(48.3% 0.186 349);
  --mark-tint: oklch(94.5% 0.03 349);

  --text: Charter, "Bitstream Charter", "Sitka Text", "Charis SIL", Cambria, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Sizes from the book scale: 14, 16–19, 20, 24–28, 30–36, 36–60 px. */
  --size-small: 0.875rem;
  --size-body: clamp(1rem, 0.9rem + 0.4vw, 1.1875rem);
  --size-h3: 1.25rem;
  --size-h2: clamp(1.5rem, 1.35rem + 0.6vw, 1.75rem);
  --size-h1: clamp(1.875rem, 1.5rem + 1.5vw, 2.25rem);
  --size-display: clamp(2.25rem, 1.5rem + 3.2vw, 3.75rem);

  /* Spacing on an 8 px grid. */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-6: 3rem;
  --space-10: 5rem;

  --measure: 31em; /* about 66–70 characters of Charter */
  --side-head: 13rem;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: oklch(23.7% 0.023 181);
    --ink: oklch(92.8% 0.009 161);
    --spruce: oklch(80.4% 0.078 182);
    --spruce-strong: oklch(88% 0.06 182);
    --stone: oklch(73.4% 0.023 182);
    --rule: oklch(36.1% 0.026 185);
    --amber: oklch(79.7% 0.143 79);
    --tint: oklch(29.5% 0.026 181);
    --mark: oklch(76.4% 0.141 344);
    --mark-tint: oklch(30% 0.07 344);
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: var(--size-body);
  line-height: 1.6;
  font-kerning: normal;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.15;
  font-weight: 700;
  text-wrap: balance;
  hyphens: manual;
}

p, ul, ol, dl, address, figure, .table-wrap { margin: 0; }

p, li, dd { text-wrap: pretty; }

a { color: var(--spruce); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--spruce-strong); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--spruce); outline-offset: 2px; border-radius: 2px; }

strong { font-weight: 700; }
address { font-style: normal; }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--tint);
  padding: 0.08em 0.3em;
  border-radius: 3px;
  overflow-wrap: anywhere;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  padding: var(--space-1) var(--space-2);
  background: var(--paper);
  font-family: var(--ui);
}
.skip:focus { top: var(--space-1); }

/* Header and footer */
.bar {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: var(--space-4);
}

.site-header { border-bottom: 1px solid var(--rule); }

.wordmark {
  display: inline-block;
  padding: var(--space-2) 0;
  color: var(--ink);
  font-size: 1.3125rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  text-decoration: none;
}

.site-header nav, .site-footer nav { display: flex; flex-wrap: wrap; column-gap: var(--space-3); }

.site-header nav a, .site-footer nav a {
  display: inline-block;
  padding: 0.75rem 0;
  font-family: var(--ui);
  font-size: 0.9375rem;
}
.site-header nav a { color: var(--ink); text-decoration: none; }
.site-header nav a:hover { color: var(--spruce); text-decoration: underline; }
.site-header nav a[aria-current="page"] { color: var(--spruce); text-decoration: underline; text-decoration-thickness: 2px; }

.site-footer {
  margin-top: var(--space-10);
  border-top: 1px solid var(--rule);
  color: var(--stone);
  font-family: var(--ui);
  font-size: var(--size-small);
}
.site-footer .bar { justify-content: flex-start; padding-top: var(--space-2); padding-bottom: var(--space-3); align-items: baseline; }
@media (min-width: 40rem) { .site-footer nav { margin-left: auto; } }
.site-footer p { padding: 0.75rem 0; }
.site-footer .partner { flex-basis: 100%; padding-top: 0; }

/* Running text */
main {
  display: block;
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-6) var(--gutter) 0;
}

article > * + *, section > * + * { margin-top: var(--space-2); }
article > h2, section > h2 { margin-top: var(--space-6); font-size: var(--size-h2); }
article > h3 { margin-top: var(--space-4); font-size: var(--size-h3); }
article > h2 + *, article > h3 + *, section > h2 + * { margin-top: var(--space-2); }
h1 { font-size: var(--size-h1); letter-spacing: -0.01em; }
h1 + * { margin-top: var(--space-3); }

article { max-width: var(--measure); }

ul, ol { padding-left: 1.25em; }
li + li { margin-top: var(--space-1); }
li > p + p { margin-top: var(--space-1); }

.lead { font-size: 1.1875em; line-height: 1.5; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375em;
  line-height: 1.5;
  font-variant-numeric: lining-nums tabular-nums;
}
th, td { padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
th:last-child, td:last-child { padding-right: 0; }
th { font-family: var(--ui); font-size: var(--size-small); font-weight: 700; color: var(--stone); border-bottom-color: var(--ink); }
td { min-width: 7rem; }

@media (max-width: 40rem) {
  article, section { hyphens: auto; hyphenate-limit-chars: 6 3 3; }
}

/* Home */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6) var(--space-10);
  align-items: start;
}
.hero h1 { font-size: var(--size-display); line-height: 1.05; letter-spacing: -0.02em; max-width: 12em; }
.hero .lead { max-width: 30em; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-4); }
.actions a:not(.button) { font-family: var(--ui); font-size: 1rem; padding: 0.75rem 0; }

.button {
  display: inline-block;
  padding: 0.75rem 1.25rem;
  border-radius: 4px;
  background: var(--spruce);
  color: var(--paper);
  font-family: var(--ui);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}
.button:hover { background: var(--spruce-strong); color: var(--paper); }

@media (min-width: 64rem) {
  .hero { grid-template-columns: minmax(0, 1fr) 19rem; }
}

/* The page history in the hero: what a rule keeps above the amber line, what it would act on below it. */
.history { max-width: 22rem; font-variant-numeric: lining-nums tabular-nums; }
.history figcaption { font-family: var(--ui); font-size: var(--size-small); line-height: 1.4; color: var(--stone); }
.history ol { list-style: none; padding: 0; margin-top: var(--space-1); }
.history li {
  display: flex;
  gap: var(--space-2);
  margin: 0;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 1.0625rem;
}
.history li b { min-width: 5ch; text-align: right; }
.history li span { font-family: var(--ui); font-size: var(--size-small); color: var(--stone); align-self: center; }
.history .kept li:last-child { border-bottom: 0; }
.history .cut {
  margin: 0;
  padding-top: 0.6rem;
  border-top: 4px solid var(--amber);
  font-family: var(--ui);
  font-size: var(--size-small);
  font-weight: 700;
}
.history .due { margin-top: 0; }
.history .due li { color: var(--stone); }
.history .due b { font-weight: 400; text-decoration: line-through; text-decoration-color: var(--stone); }

.home > section:not(.hero) { max-width: var(--measure); }
.home > section + section { margin-top: var(--space-10); }
.home > section > h2 { margin-top: 0; }

.rules { display: grid; gap: var(--space-2); }
.rules > div { padding-top: var(--space-2); border-top: 1px solid var(--rule); }
.rules dt { font-weight: 700; }
.rules dd { margin: 0; }
@media (min-width: 40rem) {
  .rules > div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); column-gap: var(--space-3); }
}

.home ul:not(.contacts) li strong { font-weight: 700; }
.contacts { list-style: none; padding: 0; }

/* Side heads on wide screens: the h2 of the home, support and privacy pages hangs left of the text. */
@media (min-width: 72rem) {
  .home > section:not(.hero), .page article.sided {
    max-width: none;
    padding-left: calc(var(--side-head) + var(--space-6));
  }
  .home > section:not(.hero) { display: flow-root; }
  .rules > div { display: block; }
  .home > section:not(.hero) > *, .page article.sided > * { max-width: var(--measure); }
  .home > section:not(.hero) > h2, .page article.sided > h2 {
    float: left;
    clear: left;
    width: var(--side-head);
    margin-left: calc(-1 * (var(--side-head) + var(--space-6)));
    padding-top: 0.1em;
    font-size: var(--size-h3);
    line-height: 1.3;
  }
  .home > section:not(.hero) > h2, .home > section:not(.hero) > h2 + * { margin-top: 0; }
  .page article.sided > h2, .page article.sided > h2 + * { margin-top: var(--space-6); }
  .page article.sided > h1 { margin-left: calc(-1 * (var(--side-head) + var(--space-6))); max-width: none; }
}

/* Documentation */
.docs { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.docs-nav { font-family: var(--ui); font-size: 0.9375rem; line-height: 1.4; }
.docs-nav p a { color: var(--ink); font-weight: 700; text-decoration: none; }
.docs-nav ol { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); margin-top: var(--space-1); padding-left: 0; list-style: none; counter-reset: page; }
.docs-nav li { margin: 0; counter-increment: page; }
.docs-nav li a { display: inline-block; padding: 0.5rem 0; text-decoration: none; }
.docs-nav li a:hover { text-decoration: underline; }
.docs-nav li a::before { content: counter(page) " "; color: var(--stone); font-variant-numeric: tabular-nums; }
.docs-nav a[aria-current="page"] { color: var(--ink); font-weight: 700; text-decoration: none; }

.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-4); max-width: var(--measure); padding-top: var(--space-3); border-top: 1px solid var(--rule); }
.pager a { display: block; padding: var(--space-1) 0; font-size: 1.0625rem; }
.pager a[rel="next"] { margin-left: auto; text-align: right; }
.pager span { display: block; font-family: var(--ui); font-size: var(--size-small); color: var(--stone); }

@media (min-width: 60rem) {
  .docs { grid-template-columns: 14rem minmax(0, 1fr); column-gap: var(--space-6); }
  .docs-nav { position: sticky; top: var(--space-3); grid-row: 1 / span 2; }
  .docs-nav ol { display: block; }
  .docs-nav li a { display: block; padding: 0.45rem 0 0.45rem 0.75rem; border-left: 3px solid transparent; }
  .docs-nav li a[aria-current="page"] { border-left-color: var(--spruce); }
}

.docs-index { list-style: none; padding: 0; counter-reset: page; }
.docs-index li { counter-increment: page; padding: var(--space-3) 0; border-top: 1px solid var(--rule); }
.docs-index li + li { margin-top: 0; }
.docs-index h2 { font-size: var(--size-h3); }
.docs-index h2::before { content: counter(page) " "; color: var(--stone); font-weight: 400; }
.docs-index p { margin-top: var(--space-1); }

/* A value that waits for a decision. Nothing is published while one is left. */
.placeholder {
  background: var(--mark-tint);
  outline: 2px dashed var(--mark);
  outline-offset: 2px;
}

@media print {
  @page { margin: 2cm 2.2cm; }
  .site-header nav, .docs-nav, .pager, .skip, .site-footer nav { display: none; }
  :root { --paper: #fff; --ink: #000; --spruce: #000; --stone: #333; --rule: #999; --amber: #000; }
  body { font-size: 11pt; }
  main { padding-top: 0; }
  .docs { display: block; }
  article > h2, article > h3 { break-after: avoid; }
  tr { break-inside: avoid; }
  p { orphans: 3; widows: 3; }
}
