/* MPLink site-wide mobile safety net (loaded by the shared Header, so every page gets it).
   Cause it fixes: on phones the layouts collapse to `grid-template-columns:1fr`, and in CSS that means minmax(auto,1fr) - one long email address,
   URL, table or code line then stretches the whole column wider than the screen and the page scrolls sideways.
   Everything here only applies on phones/tablets (<= 980px); desktop is untouched. */
@media (max-width: 980px) {
  html, body { max-width: 100%; overflow-x: clip; }

  /* 1) single-column grids must be allowed to shrink below their content */
  main [style*="grid-template-columns"]:not([style*="auto-fit"]):not([style*="auto-fill"]),
  .xp-hero__grid, .xp-split, .lg-layout, .lg-groups, .lg-groups > *, .lg-groups ul,
  .mg-grid, .mg-split { grid-template-columns: minmax(0, 1fr) !important; }
  main [style*="grid-template-columns"] > *, .xp-hero__grid > *, .xp-split > *, .lg-layout > *, .lg-body, .lg-toc { min-width: 0; }
  main [style*="display:flex"] > *, main [style*="display: flex"] > * { min-width: 0; }

  /* 2) text: long words, emails and URLs wrap instead of pushing the page wider */
  main p, main li, main dd, main dt, main td, main th, main h1, main h2, main h3, main h4, main h5, main h6, main a, main label, main figcaption, main blockquote, main small, main strong, main em,
  .lg-body, .lg-body * { overflow-wrap: anywhere; word-break: normal; hyphens: auto; }
  main h1 { font-size: clamp(26px, 8vw, 40px); line-height: 1.15; }
  main h2 { font-size: clamp(22px, 6.4vw, 32px); line-height: 1.2; }

  /* 3) media never wider than the screen */
  main img, main video, main iframe, main embed, main object { max-width: 100%; height: auto; }
  main iframe { aspect-ratio: 16 / 9; width: 100%; }

  /* 4) code and tables scroll inside their own box */
  main pre, main .code, main [class*="code"] pre { max-width: 100%; overflow-x: auto; white-space: pre-wrap; word-break: break-word; -webkit-overflow-scrolling: touch; }
  main :not(.lg-table):not(.lg-table-wrap) > table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .lg-table { max-width: 100%; -webkit-overflow-scrolling: touch; }

  /* 5) comfortable side padding that respects phone notches */
  .wrap, .xp-wrap, .lg-wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

  /* 6) buttons in rows wrap and fill nicely instead of overflowing */
  .xp-btn, .btn { max-width: 100%; white-space: normal; text-align: center; }
}
@media (max-width: 480px) {
  main [style*="padding: 80px"], main [style*="padding:80px"] { padding-top: 48px !important; padding-bottom: 48px !important; }
  .xp-btn, .btn-purple, .btn-outline { padding-left: 16px; padding-right: 16px; }
}

/* 1b) other grid classes in the site's stylesheets that collapse to a plain 1fr on phones (found automatically; tablets keep their own layout) */
@media (max-width: 760px) {
  .cmp-head,
  .cmp-row,
  .everything-band .grid,
  .ft-news,
  .lang-list,
  .mpo-dl div,
  .mpo-grid,
  .mpo-preview,
  .mpo-summary dl div,
  .mpt-grid,
  .mpt-grid--4,
  .nav-panel-grid,
  .nav-panel-grid--sidebar,
  .rv-gbox,
  .rv-hero-in,
  .svc-split { grid-template-columns: minmax(0, 1fr) !important; }
  .cmp-head > *,
  .cmp-row > *,
  .everything-band .grid > *,
  .ft-news > *,
  .lang-list > *,
  .mpo-dl div > *,
  .mpo-grid > *,
  .mpo-preview > *,
  .mpo-summary dl div > *,
  .mpt-grid > *,
  .mpt-grid--4 > *,
  .nav-panel-grid > *,
  .nav-panel-grid--sidebar > *,
  .rv-gbox > *,
  .rv-hero-in > *,
  .svc-split > * { min-width: 0; }
}
