/* Manual pages written by tools/make-man.py, laid out like man(1) output but reflowed by the
 * browser. Widths are in ch so they read as terminal columns: at most 100 per line, sections
 * indented 7 and subsections 3, as man indents them. */

.man-page,
header,
footer {
  max-width: calc(100ch + 3rem);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.man-bar {
  display: flex;
  justify-content: space-between;
  gap: 2ch;
  color: var(--fg-dim);
}

header .man-bar {
  padding-top: 1.5rem;
}

footer .man-bar {
  margin-bottom: 1rem;
}

.man-bar a,
footer a {
  color: var(--chrome);
}

/* The site's footer text is smaller, which would narrow its ch-based width. */
footer {
  font-size: inherit;
}

/* --line is a line of man output, so blocks are a blank line apart. Unbreakable hyphens can
 * leave a long path or option without a break, so a word may break anywhere as a last resort. */
.man-page {
  --line: 1.55em;
  padding-bottom: 2rem;
  overflow-wrap: break-word;
}

.man-page .nobr {
  white-space: nowrap;
}

.man-page b {
  color: var(--fg-bright);
}

/* Source Code Pro ships no italic here; man in a terminal underlines instead. */
.man-page i {
  font-style: normal;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.man-page a b {
  color: inherit;
}

.man-page section {
  margin-top: var(--line);
}

.man-page h2,
.man-page h3 {
  margin: 0;
  font-size: 1em;
  color: var(--fg-bright);
}

.man-page h2 a,
.man-page h3 a {
  color: inherit;
}

.man-page section > * {
  margin: 0 0 0 7ch;
}

.man-page section > h2 {
  margin-left: 0;
}

.man-page section > h3 {
  margin-left: 3ch;
}

.man-page section > * + * {
  margin-top: var(--line);
}

.man-page section > :is(h2, h3) + * {
  margin-top: 0;
}

/* Inherit the page font: the UA's monospace default would shrink code against the prose. */
.man-page pre {
  font: inherit;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5em 2ch;
  overflow-x: auto;
}

.man-page dl > div {
  display: grid;
  grid-template-columns: var(--tag-width) minmax(0, 1fr);
}

.man-page dl > div + div {
  margin-top: var(--line);
}

.man-page dt.wide {
  grid-column: 1 / -1;
}

.man-page dd {
  grid-column: 2;
  margin: 0;
}

.man-page ul,
.man-page ol {
  padding-left: 0;
}

.man-page ul {
  list-style: "•";
}

.man-page li {
  margin-left: 2ch;
  padding-left: 1ch;
}

.man-page ol li {
  margin-left: 3ch;
}

.man-page li::marker {
  color: var(--fg-dim);
}

.man-page li + li {
  margin-top: var(--line);
}

.man-page .compact > * + * {
  margin-top: 0;
}

/* Too narrow for tags beside their text: every tag takes its own line, and indents shrink to
 * leave the text room. */
@media (max-width: 640px) {
  .man-page section > * {
    margin-left: 2ch;
  }

  .man-page section > h3 {
    margin-left: 1ch;
  }

  .man-page dl > div {
    display: block;
  }

  .man-page dd {
    margin-left: 2ch;
  }

  .man-page pre {
    padding: 0.5em 1ch;
  }
}

@media (max-width: 480px) {
  .man-page,
  header,
  footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* The page name already starts the bar. */
  .man-bar span:last-child {
    display: none;
  }
}

@media (max-width: 420px) {
  body {
    font-size: 14px;
  }

  .man-page,
  header,
  footer {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}
