/* ============================================================
   CALL MARLIN — BASE
   Reset, document typography, layout primitives, a11y utilities.
   References layer-2 semantic tokens only.
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + var(--space-4));
}

body {
  margin: 0;
  background: var(--surface-default);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--type-body-size);
  line-height: var(--type-body-lh);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  margin: 0;
  text-wrap: balance;
  letter-spacing: -0.02em;
}

h1 { font-size: var(--type-hero-size); line-height: var(--type-hero-lh); font-weight: var(--weight-extrabold); letter-spacing: -0.035em; }
h2 { font-size: var(--type-h2-size);   line-height: var(--type-h2-lh);   font-weight: var(--weight-bold); }
h3 { font-size: var(--type-h3-size);   line-height: var(--type-h3-lh);   font-weight: var(--weight-bold); letter-spacing: -0.015em; }
h4 { font-size: var(--type-body-size); line-height: var(--type-body-lh); font-weight: var(--weight-semibold); letter-spacing: -0.005em; }

p { margin: 0; max-width: var(--measure-prose); text-wrap: pretty; }

a {
  color: var(--text-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--text-link-hover); }

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

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

button { font: inherit; color: inherit; }

strong, b { font-weight: var(--weight-semibold); }

/* ---------- Focus: one visible treatment everywhere, validated light + dark ---------- */
:focus { outline: none; }
:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--space-1);
}

/* ---------- Layout primitives ---------- */
.shell {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

.section { padding-block: var(--section-pad-y); }
.section--tight { padding-block: calc(var(--section-pad-y) * 0.65); }
.section--subtle { background: var(--surface-subtle); }
.section--ice { background: var(--cm-ice); }
.section--inverse { background: var(--surface-inverse); }
.section--inverse-deep { background: var(--surface-inverse-deep); }

/* 12-column desktop / 4-column mobile */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--grid-gutter);
}
@media (min-width: 768px)  { .grid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(12, minmax(0, 1fr)); } }

.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--stack-gap, var(--space-4)); }
.stack--2 { --stack-gap: var(--space-2); }
.stack--3 { --stack-gap: var(--space-3); }
.stack--6 { --stack-gap: var(--space-6); }
.stack--8 { --stack-gap: var(--space-8); }
.stack--12 { --stack-gap: var(--space-12); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.row--between { justify-content: space-between; }

/* ---------- Section heading block ---------- */
.section-head { max-width: 46rem; margin-bottom: var(--space-12); }
.section-head--centred { margin-inline: auto; text-align: center; }
.section-head--centred p { margin-inline: auto; }
.section-head > p {
  margin-top: var(--space-4);
  font-size: var(--type-lead-size);
  line-height: var(--type-lead-lh);
  color: var(--text-secondary);
  max-width: var(--measure-lead);
}

/* Eyebrow. Specified in master prompt §7A; used only where the brief calls for it. */
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--type-meta-size);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-on-light);
  margin: 0 0 var(--space-4);
}

.lead {
  font-size: var(--type-lead-size);
  line-height: var(--type-lead-lh);
  color: var(--text-secondary);
  max-width: var(--measure-lead);
}

.meta {
  font-size: var(--type-meta-size);
  line-height: var(--type-meta-lh);
  color: var(--text-secondary);
}

/* ---------- Accessibility utilities ---------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-2);
  z-index: 200;
  transform: translateY(-160%);
  background: var(--cm-white);
  color: var(--cm-navy);
  font-weight: var(--weight-semibold);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-overlay);
  text-decoration: none;
  transition: transform var(--motion-fast) var(--motion-ease);
}
.skip-link:focus-visible { transform: translateY(0); }

/* ---------- Motion preference ----------
   Master prompt §11: respect reduced motion, no continuous decorative motion. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Print ----------
   The only deliberate raw-hex exception in the codebase. Print wants true
   black on true white for ink and toner, not the brand navy on off-white,
   so these two values are intentionally outside the token system. Every
   other rule in every other file must go through a semantic token. */
@media print {
  .site-nav, .site-footer, .demo-module { display: none; }
  body { color: #000; background: #fff; }
}
