/* ==========================================================================
   layout.css — container, grid system, breakpoints (spec §8.1, §12.8)
   Breakpoints: ≤599 (4col / 16px gutter) · 600–1023 (8col / 24px)
                1024–1439 (12col / 24px) · ≥1440 (12col / 32px, centered)
   ========================================================================== */

/* ---- Grid gutter per breakpoint (design D7: 16/24/24/32) ----------- */
@media (max-width: 599px) {
  :root {
    --grid-gutter: 16px;
  }
}

@media (min-width: 1440px) {
  :root {
    --grid-gutter: 32px;
  }
}

/* ---- Container (spec §8.1) ----------------------------------------- */
.container {
  width: min(var(--container-max), calc(100% - 96px));
  margin-inline: auto;
}

/* BELOW 1024px the container follows the same gutter as .shell-wide, so a
   header, a hero and a wide scene all start on the same vertical line. The
   two values this replaces (16px at <=599px, 32px at 600-1023px) were the
   other half of the two-indents-in-one-viewport problem. */
@media (max-width: 1023px) {
  .container {
    width: calc(100% - (var(--page-gutter) * 2));
  }
}

/* ---- Grid system: 4 → 8 → 12 columns ----------------------------------
   Base capacity grows with the viewport; sections pick columns with
   span utilities or equal-card helpers below. */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--grid-gutter);
}

@media (min-width: 600px) {
  .grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }
}

/* Equal-card helpers (sections land in batch 2/3). */
.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 599px) {
  .grid--2,
  .grid--3 {
    grid-template-columns: 1fr;
  }
}

/* Span utilities (valid on the 12-col desktop grid). */
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
.col-span-5 { grid-column: span 5; }
.col-span-6 { grid-column: span 6; }
.col-span-7 { grid-column: span 7; }
.col-span-8 { grid-column: span 8; }
.col-span-10 { grid-column: span 10; }
.col-span-12 { grid-column: span 12; }

/* ---- Editorial shells (redesign §28) --------------------------------
   Content = .container (1200px). Wide editorial = large homepage statements,
   capability index and selected-work rails. Full bleed = 100vw backgrounds.
   Three distinct widths are what stops every scene reading as the same box. */
.shell-wide {
  width: var(--shell-wide);
  margin-inline: auto;
}

/* BELOW 1024px there is ONE gutter, shared by both shells.
   The audit found .container at 16px and .shell-wide at 32px on the same
   phone screen — two different indents visible within one scroll, which reads
   as a mistake rather than as hierarchy. The desktop difference (96px vs
   64px) is a wide-screen gesture that does not survive the shrink; on a
   phone the content column is simply the viewport minus the gutter.
   The flat 64px also overflowed at 320px: see --page-gutter in tokens.css. */
@media (max-width: 1023px) {
  .shell-wide {
    width: calc(100% - (var(--page-gutter) * 2));
  }
}

/* ---- Anchored sections clear the sticky header ----------------------
   The offset is derived from the header token, not hard-coded: the bar is
   104px on desktop and 64px below 1024px, so a literal 128px would leave 64px
   of dead space above every anchor target on a phone. The 24px is the same
   breathing room the value always carried. */
/* The sticky bar is reserved on the SCROLLPORT (B11, WCAG 2.4.11): with
   scroll-padding-top every scroll the browser makes on the reader's behalf
   (anchor jumps, focus moving to an element above the fold, find-in-page)
   stops below the header instead of under it. Elements only add their own
   breathing room, or the height of a second sticky rail, as scroll-margin. */
html {
  scroll-padding-top: var(--header-h);
}

[id] {
  scroll-margin-top: 24px;
}

@media (max-width: 1023px) {
  html {
    scroll-padding-top: var(--header-h-mobile);
  }

  [id] {
    scroll-margin-top: 16px;
  }
}

/* ---- No horizontal scroll at any width ----------------------------- */
html,
body {
  overflow-x: clip;
}

/* ---- Scroll lock while the mobile nav panel is open ---------------- */
body.is-locked {
  overflow: hidden;
}