/* css/layout.css - DSP layout primitives: container, stack, grids, safe overflow, responsive collapse.
   Loaded third on every page (after tokens.css, typography.css). Presentation only. */
*, *::before, *::after { box-sizing: border-box; }
img, svg, video, canvas { max-width: 100%; }
img, video { height: auto; }

.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }
.container-wide { max-width: 1440px; }

.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { gap: var(--s-2); }
.stack-lg { gap: var(--s-6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.cluster-center { justify-content: center; }
.cluster-between { justify-content: space-between; }

/* min(…, 100%) lets a column track shrink below its nominal width instead of overflowing a narrow screen */
.grid-auto { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(var(--col, 240px), 100%), 1fr)); }

/* Wide data tables scroll inside their own box, never the page */
.scroll-x { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }

/* Collapse a multi-column grid/flex row to one column on tablets and phones (beats inline grid-template-columns) */
@media (max-width: 768px) {
  .u-stack-md { grid-template-columns: minmax(0, 1fr) !important; gap: var(--s-6) !important; }
  .u-stack-md-flex { flex-direction: column !important; align-items: stretch !important; }
}

@media (max-width: 480px) {
  .u-pad-md { padding: var(--s-6) var(--s-5) !important; }
}

/* Long button labels wrap instead of pushing the page wider than the screen */
.btn { max-width: 100%; }
@media (max-width: 480px) {
  .btn-lg { white-space: normal; text-align: center; }
}

/* Long unbroken strings (emails, URLs, IDs) wrap instead of widening their box; `anywhere` also lowers min-content so flex/grid items can shrink */
p, h1, h2, h3, h4, h5, h6, li, dd, label { overflow-wrap: anywhere; }

/* Installed app (standalone window) on a device with a notch: keep content out of the side cut-outs in landscape. Needs viewport-fit=cover (every page). */
@media (display-mode: standalone) { body { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); } }
