/* Sibuna's body text on the web, set as in the PDF: justified, hyphenated in the page's
   language (the html element's lang), and broken a paragraph at a time. Typst breaks
   every paragraph of the PDF with the Knuth-Plass algorithm. In the browser,
   typography.js (from the CCM documentation) does the same for English paragraphs, list
   items, definitions and admonitions, links and inline code included; the rest, and every
   other language, gets the browser's own hyphenation and text-wrap: pretty. As in the PDF,
   headings, code, tables, captions and footnotes stay ragged. The book and the whitepaper
   keep identical copies of this file. */

.gd-article :is(p, li, dd) {
  -webkit-hyphens: auto;
  hyphens: auto;
  /* Hyphenate only words of six letters or more, keeping three on each side. */
  hyphenate-limit-chars: 6 3 3;
  text-wrap: pretty;
}

/* Headings, titles, captions and code keep their words whole. */
.gd-article :is(h1, h2, h3, h4, h5, h6, .admonition-title, caption, figcaption),
.gd-article :is(code, pre, kbd, samp),
.gd-article .toctree-wrapper :is(p, li) {
  -webkit-hyphens: manual;
  hyphens: manual;
}

/* A narrow column justifies into wide gaps, so phones keep ragged text. */
@media (min-width: 40rem) {
  .gd-article :is(p, li, dd) { text-align: justify; text-justify: inter-word; }
  .gd-article :is(table, figcaption, aside.footnote, .toctree-wrapper) :is(p, li, dd) {
    text-align: start;
  }
}

/* typography.js sets each line of a broken paragraph as its own span. Every line but the
   last is justified on its own, so it meets the right margin exactly, and a line that
   ends inside a word shows a hyphen. The space a line ends at is kept for copying but
   takes no room. */
.gd-typeset-line { display: block; white-space: nowrap; text-wrap: nowrap; }
.gd-typeset-line:not(:last-child) { text-align: justify; text-align-last: justify; }
.gd-typeset-line[data-hyphen]::after { content: "\2010"; }
.gd-line-space { font-size: 0; }
.gd-typeset-line code.gd-code-cut-end {
  padding-right: 0; border-right-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0;
}
.gd-typeset-line code.gd-code-cut-start {
  padding-left: 0; border-left-width: 0; border-top-left-radius: 0; border-bottom-left-radius: 0;
}
.gd-article [data-layout="knuth-plass"] { -webkit-hyphens: manual; hyphens: manual; text-align: left; }

/* On a phone the other paragraphs are ragged, so typeset ones keep their breaks but
   are ragged too. */
@media (max-width: 39.99rem) {
  .gd-typeset-line:not(:last-child) { text-align: start; text-align-last: start; }
}
