/**
 * 04-layout.css — Layout Primitives
 * YDC Child Enterprise Theme
 *
 * Reusable layout building blocks.
 * No component or page-specific CSS here.
 * Sections use these primitives — never invent their own layout.
 */

/* ─── Container ──────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.container--narrow {
  max-width: 760px;
}

.container--wide {
  max-width: 1320px;
}

/* ─── Section wrapper ────────────────────────── */
/*
  .section provides:
    - consistent vertical padding
    - ambient light overlay via ::before
    - overflow hidden (no bleed)
*/
.section {
  position: relative;
  overflow: hidden;
  padding-block: var(--section-pad-y);
}

/* Ambient light layer — environment lighting, not glow */
.section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ambient-section-bottom);
  pointer-events: none;
  z-index: 0;
}

/* Ensure content sits above ambient layer */
.section > * {
  position: relative;
  z-index: 1;
}

/* Section surface variants */
.section--surface-0 { background-color: var(--surface-0); }
.section--surface-1 { background-color: var(--surface-1); }
.section--surface-2 { background-color: var(--surface-2); }

/* Section dividers via border */
.section--bordered-top    { border-top:    1px solid var(--border-subtle); }
.section--bordered-bottom { border-bottom: 1px solid var(--border-subtle); }

/* ─── Stack ──────────────────────────────────── */
/*
  Vertical flex layout with gap control.
  Usage: <div class="stack stack--lg">
*/
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.stack--xs { gap: var(--space-2); }
.stack--sm { gap: var(--space-4); }
.stack--md { gap: var(--space-6); }
.stack--lg { gap: var(--space-9); }
.stack--xl { gap: var(--space-11); }

/* ─── Grid ───────────────────────────────────── */
.grid {
  display: grid;
  gap: var(--space-6);
}

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

/* Auto-fit responsive grid */
.grid--auto-sm { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--auto-md { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--auto-lg { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }

/* ─── Flow ───────────────────────────────────── */
/*
  Vertical spacing for flowing content (e.g. blog body).
  All direct children get top margin (lobotomised owl).
*/
.flow > * + * {
  margin-top: var(--flow-space, var(--space-6));
}

.flow--sm { --flow-space: var(--space-4); }
.flow--lg { --flow-space: var(--space-9); }

/* ─── Cluster ────────────────────────────────── */
/* Horizontal flex, wraps, for tag groups / button groups */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.cluster--center { justify-content: center; }
.cluster--end    { justify-content: flex-end; }

/* ─── Divider ────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin-block: 0;
}

/* ─── Visually hidden (a11y) ─────────────────── */
.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;
}
