/* Element defaults and layout primitives. Every value comes from tokens.css.
 * Spec: feature/crm-website/DESIGN.md. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--fw-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* AC6 is enforced by the check suite measuring documentElement.scrollWidth, NOT by
 * hiding overflow here. `overflow-x: hidden` on body was masking a real 16px overflow
 * from the hero mockup's bleed while html kept scrolling — the page looked fine and
 * violated AC6. Overflow is contained where it is created (see .hero), so a new
 * overflow bug stays visible instead of being swallowed globally. */

/* Display line-heights tighten at display sizes and relax on narrow viewports, where
 * the clamp floor makes the H1 wrap to several lines.
 * A `clamp(1.05, 1.35 - 0.5vw, 1.15)` on line-height is INVALID — it mixes a unitless
 * number with a length, so the whole declaration is dropped and the element silently
 * inherits body's 1.6. That shipped in the first build and made the hero worse than the
 * bug it was meant to fix. Media queries, not clamp, for unitless line-height. */
@media (max-width: 40rem) {
  h1 {
    line-height: 1.15;
  }
  h2 {
    line-height: 1.25;
  }
}

img,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Diagrams draw with currentColor / custom properties only — no baked fills (AC18). */
svg {
  fill: none;
  stroke-width: var(--stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-display-1);
  line-height: var(--lh-display-1);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--fs-display-2);
  line-height: var(--lh-display-2);
  font-weight: var(--fw-bold);
  letter-spacing: -0.015em;
}

h3 {
  font-size: var(--fs-heading-3);
}

h4 {
  font-size: var(--fs-heading-4);
}

p {
  margin: 0;
}

a {
  color: var(--accent-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* AC5: every interactive element has a visible focus state. Never outline:none. */
:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: var(--w-content);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--wide {
  max-width: var(--w-wide);
}
.container--prose {
  max-width: var(--w-prose);
}

.section {
  padding-block: var(--section-y);
}
.section--raised {
  background: var(--bg-raised);
}
.section--inverse {
  background: var(--bg-page); /* remapped to --bg-inverse by [data-surface] */
}

/* One 12-column grid underneath every layout, with 7/5 as the recurring proportion.
 * Twelve unrelated asymmetries read as arbitrary; one recurring ratio reads as authored. */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-6);
}
/* Grid children default to min-width:auto and refuse to shrink below their content's
 * intrinsic width. The hero mockup measured 471px inside a 437px column because of it,
 * overflowing the track while the track itself was correctly sized. minmax(0,1fr) on the
 * columns is not enough — the item needs this too. */
.grid > * {
  min-width: 0;
}
.col-7 {
  grid-column: span 12;
}
.col-5 {
  grid-column: span 12;
}
@media (min-width: 64rem) {
  .col-7 {
    grid-column: span 7;
  }
  .col-5 {
    grid-column: span 5;
  }
}

/* ── Type utilities ──────────────────────────────────────────────────────────── */

.eyebrow {
  font-size: var(--fs-label);
  line-height: 1.4;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.lede {
  font-size: var(--fs-lede);
  line-height: var(--lh-lede);
  color: var(--text-secondary);
  max-width: 34ch;
}

.small {
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* Tabular figures are a design element here, not a detail — §5's entire visual idea. */
.figure {
  font-size: var(--fs-figure);
  line-height: 1;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.prose > * + * {
  margin-top: var(--space-4);
}

/* ── Skip link (AC16) ────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--accent);
  color: var(--accent-label);
  border-radius: var(--radius-md);
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transition: top 120ms ease;
}
.skip-link:focus {
  top: var(--space-4);
}

/* ── Motion (AC14) ───────────────────────────────────────────────────────────────
 * One guarded block, not per-component opt-outs — so this stays true when someone
 * adds a transition later. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
