/*
 * assets/css/layout.css
 * Container, grid utilities, section spacing
 * Source: MDN CSS Grid, CSS Tricks — Complete Guide to CSS Grid
 *
 * LOAD ORDER: Must be loaded after variables.css (references spacing + layout tokens).
 *
 * ANTI-PATTERNS AVOIDED:
 * - No fixed width (e.g., width: 1200px) — causes horizontal overflow at narrow viewports.
 *   Always use max-width + width: 100%.
 * - Grid columns use min(100%, Npx) inside minmax() to prevent overflow at 320px viewport.
 *   Plain minmax(280px, 1fr) would cause overflow if viewport < 280px + container padding.
 */

/* ==========================================================================
   CONTAINER
   Constrains max-width and centers content with responsive inline padding.
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}


/* ==========================================================================
   GRID UTILITIES
   Responsive content grids using CSS Grid auto-fit.
   Columns collapse to a single column on narrow viewports without media queries.
   ========================================================================== */

.grid {
  display: grid;
  gap: var(--space-8);
}

/* 2-column grid: collapses to 1 column below ~600px */
.grid--2col {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

/* 3-column grid: collapses to 1 column below ~480px */
.grid--3col {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}


/* ==========================================================================
   SECTION SPACING
   Full-bleed section with vertical rhythm from spacing tokens.
   ========================================================================== */

.section {
  padding-block: var(--space-section);
}

/* Elevated variant — alternating section backgrounds (slightly lighter navy) */
.section--elevated {
  background-color: var(--color-bg-elevated);
}

/* Accent variant — final CTA block */
.section--accent {
  background-color: var(--color-bg-card);
  border-top: 1px solid var(--color-border-accent);
}

/* Hero viewport — fills visible viewport minus sticky header on load */
.hero {
  min-height: calc(100svh - var(--header-height));
  display: flex;
  align-items: center;
}

/* svh fallback for pre-2023 browsers */
@supports not (min-height: 100svh) {
  .hero {
    min-height: calc(100vh - var(--header-height));
  }
}


/* ==========================================================================
   SCREEN READER UTILITY
   Visually hidden but accessible to screen readers.
   Defined here (layout concern) since it's used by layout components.
   Also duplicated in utilities.css for convenience.
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
