/* ============================================================================
   layout.css — PLW LAYOUT PRIMITIVES (Foundation 03)
   Loads AFTER primitives.css (which provides the doc chrome + shell). This file
   only adds the layout primitive classes and the demo helpers that visualize
   them. Every .c-* reads tokens; container widths are component constants.
   ============================================================================ */

/* ---- container widths (component-level; not part of the color/space token
   contract, but expressed in rem so they scale with the user's root size) --- */
:root { --container-narrow: 46rem; --container-default: 72rem; --container-wide: 88rem; }

/* ============================================================================
   PRIMITIVE: CONTAINER  — constrained max-width + consistent gutters
   ============================================================================ */
.c-container { width: 100%; margin-inline: auto; padding-inline: var(--space-6); max-width: var(--container-default); }
.c-container--narrow { max-width: var(--container-narrow); }
.c-container--wide { max-width: var(--container-wide); }
.c-container--full { max-width: none; }
@media (max-width: 560px) { .c-container { padding-inline: var(--space-4); } }

/* ============================================================================
   PRIMITIVE: SECTION  — vertical rhythm + optional tone
   ============================================================================ */
.c-section { padding-block: var(--space-16); }
.c-section--compact { padding-block: var(--space-10); }
.c-section--generous { padding-block: var(--space-24); }
.c-section--surface { background: var(--color-surface); }
.c-section--accent { background: var(--color-accent); color: var(--color-accent-fg); }
/* inverted tone: dark ground, light text. The BAND keeps its own tokens un-remapped
   (so background: var(--color-fg) stays the real dark fg, never self-shadowed), and
   derives dark-tinted surface/bg from it. Children get --color-fg:#fff for light text,
   inheriting the already-computed dark surfaces. */
.c-section--inverted {
  background: var(--color-fg); color: #fff;
  --color-surface: color-mix(in srgb, var(--color-fg) 80%, #fff);
  --color-bg: color-mix(in srgb, var(--color-fg) 88%, #fff);
  --color-border: color-mix(in srgb, #fff 22%, transparent);
  --color-muted: color-mix(in srgb, #fff 66%, transparent);
}
.c-section--inverted > * { --color-fg: #fff; }

/* ============================================================================
   PRIMITIVE: STACK  — vertical rhythm primitive
   ============================================================================ */
.c-stack { display: flex; flex-direction: column; gap: var(--space-6); }
.c-stack--xs { gap: var(--space-2); }
.c-stack--sm { gap: var(--space-3); }
.c-stack--lg { gap: var(--space-10); }
.c-stack--xl { gap: var(--space-16); }
.c-stack[data-align="center"] { align-items: center; text-align: center; }
.c-stack[data-align="end"] { align-items: flex-end; }

/* ============================================================================
   PRIMITIVE: INLINE  — horizontal rhythm primitive (wraps)
   ============================================================================ */
.c-inline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
.c-inline--sm { gap: var(--space-2); }
.c-inline--lg { gap: var(--space-8); }
.c-inline[data-justify="between"] { justify-content: space-between; }
.c-inline[data-justify="center"] { justify-content: center; }
.c-inline[data-align="start"] { align-items: flex-start; }

/* ============================================================================
   PRIMITIVE: GRID  — 12-col responsive
   ============================================================================ */
.c-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--space-6); }
.c-grid--tight { gap: var(--space-3); }
.c-grid--loose { gap: var(--space-10); }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
/* responsive collapse: stack toward single column as space tightens */
@media (max-width: 720px) {
  .col-8, .col-6, .col-4, .col-3, .col-2 { grid-column: span 6; }
}
@media (max-width: 460px) {
  .col-12, .col-8, .col-6, .col-4, .col-3, .col-2 { grid-column: span 12; }
}
/* when the live stage is in mobile mode, mirror the collapse regardless of viewport */
.stagewrap[data-vp="mobile"] .col-8,
.stagewrap[data-vp="mobile"] .col-6,
.stagewrap[data-vp="mobile"] .col-4,
.stagewrap[data-vp="mobile"] .col-3,
.stagewrap[data-vp="mobile"] .col-2 { grid-column: span 12; }

/* ============================================================================
   DEMO HELPERS — visualize the structure (these are NOT the primitives)
   ============================================================================ */
.ph {
  background: var(--color-surface); border: var(--border-thin) solid var(--color-border);
  border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); color: var(--color-muted);
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: .04em;
  display: flex; align-items: center; justify-content: center; min-height: 52px; text-align: center;
}
.ph--tall { min-height: 120px; }
.ph--accent { background: color-mix(in srgb, var(--color-accent) 16%, var(--color-bg)); border-color: color-mix(in srgb, var(--color-accent) 30%, var(--color-border)); color: color-mix(in srgb, var(--color-accent) 72%, var(--color-fg)); }
.ph--solid { background: var(--color-accent); color: var(--color-accent-fg); border-color: transparent; }
.ph--ghost { background: transparent; }
.ph b { color: var(--color-fg); font-weight: 600; }

/* gutter visualizer for container */
.gutterbox { position: relative; background: repeating-linear-gradient(45deg, color-mix(in srgb,var(--color-accent) 10%, transparent), color-mix(in srgb,var(--color-accent) 10%, transparent) 8px, transparent 8px, transparent 16px); }
.measure { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-muted); }

/* a heading specimen used inside section demos */
.demo-h { font-family: var(--font-display); font-weight: 700; font-size: var(--text-3xl); color: var(--color-fg); margin: 0; line-height: var(--leading-tight); letter-spacing: -0.01em; }
[data-type="anton"] .demo-h, [data-type="archivo"] .demo-h { text-transform: uppercase; font-weight: 400; }
[data-type="dmserif"] .demo-h { font-weight: 400; }
.demo-p { font-family: var(--font-body); font-size: var(--text-base); color: var(--color-muted); margin: 0; line-height: var(--leading-normal); max-width: 54ch; }
.demo-eyebrow { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--color-muted); margin: 0; }

/* section-tone strip wrapper so the demo shows the band edge-to-edge */
.toneband { border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
