/* MEM Studios — typography and pagination safeguards (21 Oct 2026)
   Use CSS line balancing instead of altering authored copy or inserting NBSPs.
   Scope to reading copy so navigation, financial figures and form controls retain
   their original wrapping. Unsupported text-wrap values fail gracefully. */

/* A few display lines should share their words more evenly. */
:where(.ws-shell, .mem-client-portal) :is(
  .ws-page-head h1, .ws-page-head h2,
  .ws-section__head h2, .cp-head h1,
  .sp-head h1, .cp-main h2, .cp-main h3,
  .ws-card h2, .ws-card h3
),
.client-proposal :is(
  .proposal-hero h1, .proposal-section h2, .proposal-section h3,
  .proposal-end h2, .pp-card strong, .pp-option__title
) {
  text-wrap: balance;
}

/* Better paragraph endings; particularly useful for narrow mobile columns.
   Do not apply to prices, table cells, buttons, labels or editable fields. */
:where(.ws-shell, .mem-client-portal) :is(
  .ws-page-head__lede, .ws-card p, .ws-section p,
  .cp-main p, .cp-main .proposal-multiline,
  .cp-main .sp-description
),
.client-proposal :is(
  .proposal-lead, .proposal-multiline p, .proposal-multiline li,
  .pp-text-card p, .pp-option__summary, .proposal-end__lead,
  .proposal-note, .pp-card p
) {
  text-wrap: pretty;
}

/* In browser print, keep an isolated line away from the top or bottom
   of a page and keep short headings attached to the text that follows. */
@media print {
  :where(.ws-shell, .mem-client-portal, .client-proposal) :is(
    p, li, .proposal-multiline, .proposal-lead, .proposal-note
  ) {
    orphans: 3;
    widows: 3;
  }
  :where(.ws-shell, .mem-client-portal, .client-proposal) :is(h1, h2, h3, h4) {
    break-after: avoid;
    page-break-after: avoid;
  }
}
