/**
 * County Code lists (see OutlineConverter).
 *
 * Labels ("4-101", "a)", "(1)") are literal text, so the list markers are
 * hidden and each item hangs its wrapped lines under the text that follows
 * the label. Indents approximate the label widths: sections need about
 * three and a half em ("1-1501"), subsections about two ("(a)").
 */
.code-list {
  list-style: none;
  margin-left: 0;
  padding-left: 0;
}

.code-list > li {
  padding-left: 3.5em;
  text-indent: -3.5em;
}

.code-list .code-list > li {
  padding-left: 2em;
  text-indent: -2em;
}

.code-list .code-list {
  margin-top: 0.25em;
}

/* Follow-on paragraphs and citations inside an item don't hang. */
.code-list > li > p + p,
.code-list > li > .code-list + p {
  text-indent: 0;
}

/**
 * Short labels (Finance Policy: "A.", "1.", "a.", "10.", "iv.", "(1)").
 *
 * code-list--short comes from the format's list.class, so County Code
 * lists never match these rules. Labels are inline text, so a smaller
 * indent only moves where wrapped lines start; a label is never clipped.
 */
.code-list.code-list--short > li {
  padding-left: 2em;
  text-indent: -2em;
}

/* Reflow (WCAG 1.4.10): narrow screens shrink each nested level so a deep
   list (A > 1 > a > i > (1)) keeps a usable line length at 320px. Long
   words, URLs and K.S.A. cites already break via the body field's
   overflow-wrap (dougcty_theme node-county-document.css); repeated here
   so the list holds up anywhere it renders. */
.code-list--short {
  overflow-wrap: anywhere;
}

@media screen and (max-width: 575.98px) {
  .code-list.code-list--short > li {
    padding-left: 1.75em;
    text-indent: -1.75em;
  }

  .code-list--short .code-list.code-list--short > li {
    padding-left: 1.25em;
    text-indent: -1.25em;
  }
}

/**
 * Print, all outline formats and every print style (field_print_style).
 *
 * The screen rules above already print (no @media screen), so labels and
 * indents carry over; these keep the page plain and the structure intact.
 */
@media print {
  .code-list,
  .code-list li {
    background: none;
    color: inherit;
  }

  /* An item may split across pages, but not leave a lone line behind. */
  .code-list li {
    orphans: 2;
    widows: 2;
  }

  /* A heading stays with the text after it. */
  .node--type-county-document .field--name-body :is(h2, h3, h4) {
    break-after: avoid;
    page-break-after: avoid;
    break-inside: avoid;
  }
}
