/* Lex Bellator | Balanced overviews, v121.
   Headings precede the overview rather than occupying a mostly empty column.
   Complete paragraphs share two readable columns on wide screens. The
   DOM, paragraph order, heading levels, links, notes, and motion hooks remain
   unchanged except for presentational wrappers/classes. No text is hidden,
   shortened, or reduced in size. These rules do not affect preparation cards,
   planners, use cases, forms, topic navigation, or the v120 page-width fixes. */

main .duo.overview-balanced {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(24px, 2.4vw, 36px);
  align-items: start;
}

main .overview-balanced > :is(.overview-heading, .overview-copy) {
  min-inline-size: 0;
  max-inline-size: none;
  inline-size: 100%;
  overflow-wrap: anywhere;
}

main .overview-balanced > .overview-heading {
  margin-block: 0;
}

main .overview-heading > h2 {
  max-inline-size: none;
}

main .overview-prose {
  min-inline-size: 0;
  max-inline-size: none;
}

main .overview-prose > p {
  max-inline-size: none;
  /* Preserve natural paragraph flow, but avoid stranded first/last lines. */
  orphans: 3;
  widows: 3;
}

main .overview-prose > p:first-child {
  margin-block-start: 0;
}

/* Notes and links follow the complete overview, not a single text column. */
main .overview-prose + .note {
  margin-block-start: 24px;
}
main .overview-copy > .text-link {
  max-inline-size: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media screen and (min-width: 1100px) {
  main .overview-prose:not(.overview-prose--short) {
    --overview-gap: clamp(32px, 4vw, 64px);
    display: grid;
    /* At most two columns. The font-relative minimum automatically falls
       back to one column when enlarged text needs more reading room. */
    grid-template-columns: repeat(auto-fit,
      minmax(min(100%, max(26rem, calc((100% - var(--overview-gap)) / 2))), 1fr));
    gap: 24px var(--overview-gap);
    align-items: start;
  }
  main .overview-balanced .overview-copy .overview-prose > p,
  body[data-page="about"] #chapter-6 .overview-prose > p + p {
    min-inline-size: 0;
    margin-block: 0;
  }
  /* With three paragraphs, the last fills the next row rather than leaving
     an empty half-row. Sentences are never split between desktop columns. */
  main .overview-prose > p:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media print {
  main .duo.overview-balanced {
    display: block;
  }
  main .overview-balanced > .overview-copy {
    margin-block-start: 24px;
  }
  main .overview-prose {
    display: block;
  }
}
