/* ==========================================================================
   Layout: container, Bootstrap grid tuned to our tokens, sections, themes.
   ========================================================================== */

/* One container width and gutter on every page */
.container,
.container-fluid {
  width: 100%;
  max-width: var(--container-max);
  padding-inline: var(--page-gutter);
  margin-inline: auto;
}
.container-fluid { max-width: none; }

/* Bootstrap grid uses our gutter */
.row { --bs-gutter-x: var(--grid-gutter); --bs-gutter-y: var(--grid-gutter); }

/* A native 12-column grid for editorial layouts that Bootstrap rows can't express */
.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--grid-gutter);
}

/* ── Sections ────────────────────────────────────────────────────────────── */
/* One rhythm: each section pads only its top, so the gap between ANY two
   neighbours is exactly --section-pad. The footer opens with its own padded
   section, so the last section needs none; sections with a background pad both sides. */
.section {
  position: relative;
  padding-block: var(--section-pad) 0;
}
.section--raised,
.section.theme-light { padding-bottom: var(--section-pad); }
.section--tight { padding-top: var(--section-pad-tight); }
.section--tight:is(.section--raised, .theme-light) { padding-bottom: var(--section-pad-tight); }
.section--raised { background: var(--c-surface-1); }
/* Content never touches a colour change: a section followed by a raised or light one keeps its bottom padding */
.section:has(+ :is(.section--raised, .theme-light)) { padding-bottom: var(--section-pad); }

.section-rule { border: 0; border-top: var(--border); margin: 0; opacity: 1; }

/* Vertical rhythm inside a block */
.stack > * + * { margin-top: var(--stack-gap); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-md > * + * { margin-top: var(--sp-3); }

/* ── Light section (same tokens, inverted) ───────────────────────────────── */
.theme-light {
  --c-bg: var(--c-paper);
  --c-surface-1: var(--c-paper-1);
  --c-surface-2: var(--c-paper-2);
  --c-surface-3: var(--c-paper-3);
  --c-line: rgb(21 17 14 / 0.12);
  --c-line-strong: rgb(21 17 14 / 0.24);
  --c-text: var(--c-ink);
  --c-text-muted: var(--c-ink-muted);
  --c-accent-text: var(--c-accent-on-paper);
  --shadow: 0 30px 60px -36px rgb(21 17 14 / 0.35);
  background: var(--c-bg);
  color: var(--c-text);
  color-scheme: light;
}

/* ── Media ratios ────────────────────────────────────────────────────────── */
.ratio-16x9 { aspect-ratio: 16 / 9; }
.ratio-9x16 { aspect-ratio: 9 / 16; }
.ratio-4x5  { aspect-ratio: 4 / 5; }
.ratio-1x1  { aspect-ratio: 1; }
.cover { width: 100%; height: 100%; object-fit: cover; }

/* Start-up only: sections off screen skip layout and paint, which is most of the work on a page
   this long. head.php adds the class; main.js removes it on the visitor's first action, so
   heights are exact before anything measures or jumps. The story is measured by its pin. */
.cv-start main > section:not(:first-child, .story),
.cv-start .site-footer { content-visibility: auto; contain-intrinsic-size: auto 800px; }

/* Sections pad their top only; the last one on a page also needs room before the footer */
#main > .section:last-child { padding-bottom: var(--section-pad); }
