/* Eliminate horizontal scrolling in content sections.
   The recurring cause is data tables landing a few pixels wider than the (TOC-narrowed)
   content column, which triggers Material's horizontal scrollbar on .md-typeset__scrollwrap.
   Tighten cell padding and let cells wrap so those modest-overflow tables fit the column
   instead of scrolling. Genuinely huge tables still scroll (the graceful fallback). */

/* Cover ALL content tables (classed or not) and beat Material's specificity (extra.css
   loads after the theme; the extra :where keeps specificity low only where harmless). */
.md-typeset .md-typeset__table th,
.md-typeset .md-typeset__table td,
.md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
  padding: 0.45em 0.6em;          /* was ~0.94em 1.25em — reclaims the px that force a scrollbar */
  overflow-wrap: anywhere;        /* long tokens/URLs in cells break instead of widening the table */
}

/* Material's table wrapper can report a phantom ~14px horizontal overflow even when the table
   itself fits the column (the inline-block .md-typeset__table measured slightly wide). Letting
   the table fill the wrapper exactly removes that spurious scrollbar without clipping anything. */
.md-typeset__scrollwrap > .md-typeset__table {
  display: block;   /* block (not inline-block) measures to the column, not slightly wider */
}

/* Long unbroken strings (URLs, IDs) in prose must never force a horizontal scrollbar. */
.md-typeset p,
.md-typeset li {
  overflow-wrap: break-word;
}

/* Make glossary codes (abbr, from includes/abbreviations.md) visibly tappable — a dotted
   underline + accent tint signals "there's a definition here." Material's content.tooltips
   shows the definition on TAP on touch devices (not just hover), so this is the mobile
   affordance: the crew can decode P1/P2/P3, W-* and T-* on a phone on deck. The full list
   is the Decoder page. */
.md-typeset abbr[title] {
  text-decoration: underline dotted var(--md-accent-fg-color, #4051b5);
  text-underline-offset: 2px;
  cursor: help;
}

/* Phones: dense multi-column tables — the brief model tables (period · code · conf · GFS ·
   ECMWF · ICON), polars, sail inventory, the in-race log — shrink to fit the narrow column
   instead of forcing a sideways swipe. Numbers stay legible; the overflow-x:auto fallback
   above still catches anything genuinely too wide. */
@media screen and (max-width: 44.9375em) {
  .md-typeset .md-typeset__table th,
  .md-typeset .md-typeset__table td,
  .md-typeset table:not([class]) th,
  .md-typeset table:not([class]) td {
    font-size: 0.68rem;
    padding: 0.32em 0.42em;
  }
}

/* ── Print: one-page laminated onboard cards (US Letter, portrait) ──────────────────────
   Goal: open a card → Cmd-P → Save as PDF → print + laminate, one card = one page. Strips all
   site chrome (header, tabs, both sidebars/TOC, footer, search) so ONLY the card content
   prints, then compacts type so a trimmed card fits a single Letter page. Applies to every
   page on print (harmless — reference docs just paginate); the onboard cards are trimmed to
   actually fit at this size. */
@media print {
  /* Goal: every onboard card prints on ONE Letter page. Tuned to fit the
     densest cards (05/08/09/10/11) while staying legible at arm's length. */
  @page { size: Letter portrait; margin: 0.3in; }

  .md-header, .md-tabs, .md-sidebar, .md-footer, .md-content__button,
  .md-search, .md-banner, [data-md-component="announce"], [data-md-component="skip"],
  .md-typeset .headerlink, .md-source { display: none !important; }

  .md-container, .md-main, .md-main__inner, .md-content, .md-content__inner,
  .md-grid { display: block !important; margin: 0 !important; max-width: none !important; }

  html, body { background: #fff !important; }
  /* Per-card sizing: every length unit is em-relative to one base, scaled by
     --pscale, so a card can be enlarged to fill its page just by raising --pscale
     (set per card via the h1 .pf* class below, or per card in the print-deck).
     --pscale:1 = the densest-card fit, so nothing ever overflows. */
  .md-typeset { color: #000; font-size: calc(8.6pt * var(--pscale, 1)); line-height: 1.16; }
  .md-typeset h1 { font-size: 1.5em; margin: 0 0 .14em; padding: 0; }
  .md-typeset h2 { font-size: 1.16em; margin: .26em 0 .07em; }
  .md-typeset h3 { font-size: 1.05em; margin: .2em 0 .05em; }
  .md-typeset h1, .md-typeset h2, .md-typeset h3 { page-break-after: avoid; }
  .md-typeset p, .md-typeset ul, .md-typeset ol { margin: .08em 0; }
  .md-typeset li { margin: 0; }
  .md-typeset hr { margin: .14em 0; }

  /* Dense tables (e.g. card_05's 9-col crossing log) — tight cells, never split a row/table. */
  .md-typeset table:not([class]) { font-size: .87em; page-break-inside: avoid; }
  .md-typeset table:not([class]) th,
  .md-typeset table:not([class]) td { padding: .08em .28em; line-height: 1.1; }

  .md-typeset .admonition, .md-typeset details {
    margin: .22em 0; padding: .12em .45em; page-break-inside: avoid; font-size: .93em;
  }

  /* Per-card enlargement buckets — the h1 carries .pfNN; bump font to fill the
     page. Values sit a few % under each card's measured max for printer cushion. */
  .md-typeset:has(> h1.pf10) { --pscale: 1.08; }
  .md-typeset:has(> h1.pf20) { --pscale: 1.17; }
  .md-typeset:has(> h1.pf30) { --pscale: 1.27; }
  .md-typeset:has(> h1.pf40) { --pscale: 1.37; }
  .md-typeset:has(> h1.pf55) { --pscale: 1.50; }

  /* Print-the-whole-deck page: each card in its own .deck-card box, one per page,
     carrying the same per-card scale class. The on-screen intro is print-hidden so
     the PDF is purely the 11 cards (no leading text page pushing card 01 to spill). */
  .deck-intro { display: none !important; }
  .deck-card { page-break-after: always; font-size: calc(8.6pt * var(--pscale, 1)); }
  .deck-card:last-child { page-break-after: auto; }
  .deck-card.pf10 { --pscale: 1.08; }
  .deck-card.pf20 { --pscale: 1.17; }
  .deck-card.pf30 { --pscale: 1.27; }
  .deck-card.pf40 { --pscale: 1.37; }
  .deck-card.pf55 { --pscale: 1.50; }
  .md-typeset details[open] > summary ~ * { /* keep collapsibles readable in print */ }
  details:not([open]) { display: block; }            /* print collapsed blocks too */
  details:not([open]) > *:not(summary) { display: revert; }

  a[href]::after { content: "" !important; }          /* no inline URL litter */
  iframe, .leaflet-container { display: none !important; }  /* maps don't print */
  img { max-width: 100% !important; }
}
