/*
 * The docs: the Markdown of docs/, read on the site's near-black greys in
 * its type, after styles.css, whose tokens, app bar, buttons and footer
 * they share. Colour stays where the home page keeps it: the brand pink of
 * the mark, the download button and the links.
 */

.docs {
  --prose: #cfcfcf;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: clamp(32px, 5vw, 64px) var(--gutter) 0;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: start;
}

/* The docs, and the sections of the one shown. */

.docs-nav {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.docs-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.docs-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-chip);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.35;
  text-decoration: none;
  transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.docs-nav a:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.docs-nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.docs-nav .docs-toc { margin: 6px 0 10px 12px; padding-left: 0; box-shadow: inset 1px 0 0 var(--outline); }
.docs-nav .docs-toc a { padding: 6px 12px; font-weight: 500; font-size: 0.875rem; border-radius: 0 var(--radius-chip) var(--radius-chip) 0; }

/* A doc. */

.prose {
  min-width: 0;
  max-width: 46rem;
  color: var(--prose);
  font-size: 1.0625rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}
.prose > :first-child { margin-top: 0; }
.prose :is(p, ul, ol, dl, pre, table, blockquote, figure) { margin: 0 0 1.15em; }
.prose h1 {
  margin-bottom: 0.7em;
  color: var(--ink);
  font-size: clamp(2.25rem, 4.6vw, 3.25rem);
  font-weight: 850;
  line-height: 1.04;
  letter-spacing: -0.035em;
}
.prose h2 {
  margin: 2.3em 0 0.6em;
  color: var(--ink);
  font-size: clamp(1.5rem, 2.6vw, 1.875rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
}
.prose h3 {
  margin: 1.9em 0 0.5em;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.prose h4 { margin: 1.6em 0 0.4em; color: var(--ink); font-size: 1.0625rem; font-weight: 700; }

/* Headings link to themselves; the mark shows on hover. */
.prose .anchor { color: inherit; text-decoration: none; }
.prose .anchor:hover { color: inherit; }
.prose .anchor::after {
  content: "#";
  margin-left: 0.3em;
  color: var(--ink-2);
  font-weight: 600;
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}
.prose .anchor:hover::after,
.prose .anchor:focus-visible::after { opacity: 1; }

.prose strong { color: var(--ink); font-weight: 700; }
.prose :is(ul, ol) { padding-left: 1.4em; }
.prose li + li,
.prose li > :is(ul, ol) { margin-top: 0.4em; }
.prose li > :is(p, pre, ul, ol):last-child { margin-bottom: 0; }
.prose li > pre { margin-top: 0.6em; }
.prose li::marker { color: var(--ink-2); }
.prose hr { margin: 2.5em 0; border: 0; border-top: 1px solid var(--outline); }

.prose code { color: var(--ink); font-size: 0.85em; }
.prose pre {
  padding: 16px 20px;
  border-radius: var(--radius-card);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--outline);
  overflow-x: auto;
  overflow-wrap: normal;
  color: var(--ink);
  font: 400 0.875rem/1.55 var(--mono);
  tab-size: 2;
  scrollbar-width: thin;
}
.prose pre code { padding: 0; border-radius: 0; background: none; font: inherit; }

.prose kbd {
  display: inline-block;
  min-width: 0;
  height: auto;
  padding: 0.05em 0.5em;
  font-size: 0.8125em;
  line-height: 1.5;
  vertical-align: 0.05em;
}

/* Tables scroll inside their own box when they cannot fit, never the page;
   a header row with nothing in it is left out. */
.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.55;
  scrollbar-width: thin;
}
.prose :is(th, td) { padding: 10px 20px 10px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--outline); }
.prose :is(th, td):last-child { padding-right: 0; }
.prose th { color: var(--ink); font-weight: 700; border-bottom-color: var(--outline-strong); }
.prose thead:not(:has(th:not(:empty))) { display: none; }
.prose td:first-child { color: var(--ink); }

.prose blockquote {
  padding: 2px 0 2px 20px;
  box-shadow: inset 3px 0 0 var(--outline-strong);
  color: var(--ink-2);
}
.prose blockquote > :last-child { margin-bottom: 0; }
.prose img { border-radius: var(--radius-card); box-shadow: 0 0 0 1px var(--outline); background: var(--surface-2); }

/* The way on: the next and previous docs, and the doc's file. */

.docs-foot { margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--outline); display: grid; gap: 24px; }
.docs-pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.docs-pager a {
  display: grid;
  gap: 2px;
  padding: 16px 20px;
  border-radius: var(--radius-card);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--outline);
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--fast) var(--ease);
}
.docs-pager a:hover { color: var(--ink); background: var(--surface-2); }
.docs-pager span { color: var(--ink-2); font-size: 0.875rem; font-weight: 600; }
.docs-pager strong { font-size: 1.125rem; font-weight: 750; letter-spacing: -0.015em; }
.docs-next { grid-column: 2; text-align: right; }
.docs-source { color: var(--ink-2); font-size: 0.875rem; line-height: 1.55; }

/* The docs' first page: what each doc is about. */

.docs-intro { color: var(--ink-2); font-size: 1.125rem; }
.prose .docs-list { list-style: none; margin: 40px 0 0; padding: 0; border-top: 1px solid var(--outline); }
.prose .docs-list li { margin: 0; border-bottom: 1px solid var(--outline); }
.docs-list a {
  display: grid;
  gap: 4px;
  margin: 0 -16px;
  padding: 20px 16px;
  border-radius: var(--radius-chip);
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--fast) var(--ease);
}
.docs-list a:hover { color: var(--ink); background: var(--surface-1); }
.docs-list strong { font-size: 1.3125rem; font-weight: 750; letter-spacing: -0.015em; }
.docs-list span { color: var(--ink-2); font-size: 1rem; line-height: 1.55; }

.docs-missing { grid-template-columns: minmax(0, 1fr); }

/* Smaller windows: the docs line up as chips over the doc. */

@media (max-width: 900px) {
  .docs { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-top: 24px; }
  .docs-nav { position: static; max-height: none; overflow: visible; }
  .docs-nav > ul { display: flex; flex-wrap: wrap; gap: 8px; }
  .docs-nav > ul > li > a {
    padding: 7px 14px;
    box-shadow: inset 0 0 0 1px var(--outline-strong);
    font-size: 0.875rem;
  }
  .docs-nav > ul > li > a[aria-current="page"] { box-shadow: none; background: var(--surface-3); }
  .docs-nav .docs-toc { display: none; }
}

@media (max-width: 760px) {
  .prose { font-size: 1rem; }
  .prose pre { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); padding: 14px var(--gutter); border-radius: 0; box-shadow: inset 0 1px 0 var(--outline), inset 0 -1px 0 var(--outline); }
  .prose li > pre { margin-left: 0; margin-right: 0; padding: 14px 16px; border-radius: var(--radius-card); box-shadow: inset 0 0 0 1px var(--outline); }
  .docs-pager { grid-template-columns: minmax(0, 1fr); }
  .docs-next { grid-column: auto; }
}
