/* ============================================================
   Base — typography, layout primitives, focus, links
   ============================================================ */

html {
  background: var(--bg);
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-relaxed);
  color: var(--fg);
  background: var(--bg);
  font-feature-settings: "ss01", "cv11";
}

/* ---------- Headings ---------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--tr-tight);
  color: var(--fg);
  text-wrap: balance;
  font-variation-settings: "SOFT" 50, "opsz" 144;
}

h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-tight);
}

h2 {
  font-size: var(--fs-h2);
}

h3 {
  font-size: var(--fs-h3);
  font-weight: var(--fw-medium);
}

h4 {
  font-size: var(--fs-body-lg);
  font-family: var(--font-sans);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tr-normal);
}

.display {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: var(--fw-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-tight);
  text-wrap: balance;
  font-variation-settings: "SOFT" 30, "opsz" 144;
}

/* ---------- Body text ---------- */

p {
  max-width: 68ch;
  color: var(--fg);
}

.lead {
  font-size: var(--fs-body-lg);
  line-height: var(--lh-relaxed);
  color: var(--fg-muted);
  max-width: 60ch;
}

small,
.text-small {
  font-size: var(--fs-small);
  line-height: var(--lh-normal);
}

.text-caption {
  font-size: var(--fs-caption);
  line-height: var(--lh-normal);
  color: var(--fg-muted);
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tr-eyebrow);
  text-transform: uppercase;
  color: var(--accent);
}

.muted { color: var(--fg-muted); }
.subtle { color: var(--color-text-subtle); }

/* ---------- Links ---------- */

a {
  color: var(--fg);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover { color: var(--accent-hover); }

.link {
  color: var(--accent-hover);
  text-decoration: underline;
  text-decoration-color: rgba(122, 74, 46, 0.35);
  text-underline-offset: 4px;
  transition: text-decoration-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.link:hover {
  text-decoration-color: var(--accent-hover);
}

/* ---------- Selection ---------- */

::selection {
  background: var(--color-dune);
  color: var(--color-obsidian);
}

/* ---------- Layout primitives ---------- */

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

.container--narrow { max-width: var(--container-narrow); }
.container--wide   { max-width: var(--container-wide); }

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

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

.section--dark {
  background: var(--bg-inverse);
  color: var(--fg-on-dark);
}

.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4 { color: var(--fg-on-dark); }

.section--dark p,
.section--dark .lead { color: var(--fg-on-dark-muted); }

.section--dark a:hover { color: var(--color-sand); }

/* ---------- Stack: vertical rhythm helper ---------- */

.stack > * + * { margin-top: var(--stack-gap, var(--space-md)); }
.stack-xs > * + * { margin-top: var(--space-2xs); }
.stack-sm > * + * { margin-top: var(--space-sm); }
.stack-md > * + * { margin-top: var(--space-md); }
.stack-lg > * + * { margin-top: var(--space-lg); }
.stack-xl > * + * { margin-top: var(--space-xl); }

/* ---------- Cluster: horizontal flex helper ---------- */

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cluster-gap, var(--space-sm));
  align-items: center;
}

/* ---------- Visually hidden (a11y) ---------- */

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

/* Skip-to-content: hidden until keyboard-focused. */
a.visually-hidden:focus,
a.visually-hidden:focus-visible {
  position: fixed !important;
  inset: var(--space-sm) auto auto var(--space-sm);
  width: auto; height: auto;
  padding: var(--space-2xs) var(--space-md);
  margin: 0;
  overflow: visible;
  clip: auto;
  background: var(--color-obsidian);
  color: var(--color-ivory);
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  z-index: var(--z-overlay);
}

/* ---------- Focus polish (works on top of reset) ---------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
