/* Documentation pages (web/docs/): the same notebook, with the contents in the margin.
   Values come from tokens.css; the header, footer, buttons and ruling come from app.css. */

.docs {
  max-width: var(--page);
}

/* The title and the introduction come first in the reading order, on every screen. */
.doc-intro {
  min-width: 0;
  max-width: 48rem;
}
.doc-intro p {
  max-width: var(--measure);
}

/* Contents: a folded ruled list after the introduction on narrow screens, open in the margin
   column on wide ones (docs.js keeps it open there). */
.toc summary {
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.5rem;
  letter-spacing: -0.01em;
}
.toc ol {
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: 0;
  border-top: 1px solid var(--rule-major);
}
.toc li {
  border-bottom: 1px solid var(--rule-major);
}
.toc a {
  display: flex;
  align-items: center;
  min-height: var(--target);
  padding: var(--space-1) 0;
  color: var(--ink);
  text-decoration: none;
}
.toc a:hover {
  color: var(--accent-hover);
  text-decoration: underline 1px;
  text-underline-offset: 0.18em;
}
@media (max-width: 63.99rem) {
  .toc-fold {
    margin: 0 0 var(--space-4);
  }
  .toc-fold[open] summary {
    margin-bottom: var(--space-1);
  }
  .toc-fold ol {
    margin-bottom: 0;
  }
}
@media (min-width: 64rem) {
  .docs {
    display: grid;
    grid-template-columns: calc(var(--margin) - 1.5rem) minmax(0, 1fr);
    column-gap: calc(var(--gutter) + 0.5rem);
    margin-left: calc(1rem - var(--margin) - var(--gutter));
  }
  .doc-intro,
  .doc {
    grid-column: 2;
  }
  .doc-intro {
    grid-row: 1;
  }
  .doc {
    grid-row: 2;
  }
  .toc {
    grid-column: 1;
    grid-row: 1 / span 2;
    position: sticky;
    top: var(--space-4);
    align-self: start;
    max-height: calc(100vh - var(--space-6));
    overflow-y: auto;
  }
  /* In the margin the contents are always shown: the summary is a plain title, not a toggle. */
  .toc summary {
    display: block;
    min-height: 0;
    margin: 0 0 var(--space-2);
    list-style: none;
    cursor: default;
    color: var(--pencil);
  }
  .toc summary::-webkit-details-marker {
    display: none;
  }
  .toc-fold::details-content {
    content-visibility: visible;
    block-size: auto;
  }
  .toc a {
    min-height: 2rem;
    font-size: var(--text-xs);
    line-height: 1.25rem;
  }
  .toc ol {
    margin-bottom: 0;
  }
}

/* The reading column. */
.doc {
  min-width: 0;
  max-width: 48rem;
}
.doc p,
.doc li,
.doc dd {
  max-width: var(--measure);
}
.doc section {
  margin-bottom: var(--space-6);
}
.doc h2 {
  margin-top: var(--space-6);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--accent);
}
.doc section:first-of-type h2 {
  margin-top: var(--space-5);
}
.doc h3 {
  margin-top: var(--space-5);
}
/* Headings link to themselves; they read as headings until hovered or focused. */
.doc h2 a,
.doc h3 a {
  color: inherit;
  text-decoration: none;
}
.doc h2 a:hover,
.doc h3 a:hover {
  color: var(--accent-hover);
  text-decoration: underline 2px;
  text-underline-offset: 0.18em;
}
:target {
  scroll-margin-top: var(--space-4);
}
.doc ul,
.doc ol {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-4);
}
.doc li {
  margin-bottom: var(--space-2);
}
.doc code {
  overflow-wrap: anywhere;
}

/* Commands are white slips with a Copy button; output is written on the page. */
.doc pre {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--rule-major);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.doc pre code {
  font-size: inherit;
}
.doc pre.command {
  border-color: var(--border);
  background: var(--field);
}
.command-block {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}
.command-block pre.command {
  flex: 1 1 18rem;
  min-width: 0;
  min-height: var(--target);
  margin: 0;
  padding-block: 9px;
}

/* Tables: ruled rows, no zebra, headers in pencil over a blue rule. */
.doc table {
  width: 100%;
  margin: 0 0 var(--space-4);
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.doc th,
.doc td {
  text-align: left;
  vertical-align: baseline;
  padding: var(--space-2);
  border-bottom: 1px solid var(--rule-major);
}
.doc th:first-child,
.doc td:first-child {
  padding-left: 0;
}
.doc thead th {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--pencil);
  border-bottom-color: var(--accent);
}
.doc tbody th {
  font-weight: 700;
}
.doc td.num {
  width: 4rem;
}
.ref td:first-child {
  white-space: nowrap;
}
/* Flags stay whole on wide screens; on a phone they may break anywhere rather than overflow. */
@media (min-width: 40rem) {
  .doc td code {
    white-space: nowrap;
  }
}
@media (max-width: 39.99rem) {
  .ref td:first-child {
    white-space: normal;
  }
  .doc th,
  .doc td {
    padding: var(--space-2) var(--space-1);
  }
}

/* The modules of the guide, as a ruled list of destinations. */
.doc .module-list {
  list-style: none;
  padding: 0;
  columns: 2 14rem;
  column-gap: var(--space-5);
}
.module-list li {
  break-inside: avoid;
  margin: 0;
}
/* The rule sits on the link; border-box counts it, so it is added back to keep the row height. */
.module-list a {
  display: flex;
  align-items: center;
  min-height: calc(var(--target) + 1px);
  border-bottom: 1px solid var(--rule-major);
}

/* Error messages and what to do about them. */
.faq {
  margin: 0 0 var(--space-4);
}
.faq dt {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule-major);
  font-weight: 700;
}
.faq dt:first-child {
  margin-top: 0;
}
.faq dt code {
  font-weight: 400;
}
.faq dd {
  margin: var(--space-1) 0 0;
}

@media print {
  .toc,
  .copy-btn {
    display: none;
  }
  .docs {
    display: block;
    margin: 0;
  }
}
