/* Site typography on top of mkdocs-material.
 *
 * The defaults are tuned for English reference text: 16px/1.5 with tight
 * heading margins. Chinese prose has no word spaces to aid scanning, so it
 * needs more line height and a shorter measure to stay readable. The rules
 * below only adjust rhythm and measure; colours and fonts come from the
 * theme so light and dark mode keep working.
 */

:root {
  /* 34 CJK characters at 16px is roughly 640px. Stated in px so the measure
   * does not drift with the theme's rem-based root font scaling. */
  --docs-measure: 40em;
}

/* Body copy: 1.5 is cramped for CJK; 1.85 is the usual comfortable range. */
.md-typeset {
  line-height: 1.85;
  font-size: 0.8rem;
}

/* Cap the measure. At 16px, 46rem is roughly 34-36 CJK characters per line,
 * instead of the ~53 the full-width column produced. */
.md-typeset > p,
.md-typeset > ul,
.md-typeset > ol,
.md-typeset > blockquote,
.md-typeset > .admonition {
  max-width: var(--docs-measure);
}

/* Tables may use the full column: they scroll horizontally rather than wrap. */
.md-typeset > table {
  max-width: 100%;
}

/* Separate sections. The theme leaves h2 margin-top at 0, which made every
 * heading sit directly on the previous paragraph. */
.md-typeset h2 {
  margin-top: 2.2em;
  margin-bottom: 0.8em;
  padding-top: 0.6em;
  border-top: 1px solid var(--md-default-fg-color--lightest);
}

.md-typeset h3 {
  margin-top: 1.7em;
  margin-bottom: 0.6em;
}

.md-typeset h1 {
  margin-bottom: 0.9em;
}

/* Paragraph spacing a little looser than the default 0.75em. */
.md-typeset p,
.md-typeset ul,
.md-typeset ol {
  margin-bottom: 1em;
}

.md-typeset li + li {
  margin-top: 0.35em;
}

/* Material renders permalink anchors inline in the heading; keep them from
 * adding width and nudging the text. */
.md-typeset .headerlink {
  margin-left: 0.3rem;
}

/* Code blocks: slightly tighter than prose, as monospace reads denser. */
.md-typeset pre > code {
  line-height: 1.6;
}

/* Long identifiers and paths must wrap instead of forcing a wide page. */
.md-typeset code {
  word-break: break-word;
}

/* Tables: keep headers from wrapping awkwardly and let cells breathe. */
.md-typeset table:not([class]) th {
  white-space: nowrap;
}

.md-typeset table:not([class]) td,
.md-typeset table:not([class]) th {
  padding: 0.6em 0.8em;
}

@media screen and (max-width: 76.1875em) {
  .md-typeset {
    font-size: 0.78rem;
  }
}

/* Material scales the root font with viewport width. On a large monitor that
 * pushes the measure back down to ~24 CJK characters, which reads as a narrow
 * ribbon. Hold a steady size once the viewport is wide. */
@media screen and (min-width: 100em) {
  html {
    font-size: 20px;
  }
}
