/* ==========================================================================
   Base + Layout Primitives  —  factory baseline
   Element defaults, layout utilities (wrapper/stack/cluster/grid), and a small
   set of components (button, card, nav). Built entirely on tokens.css.
   Load AFTER reset.css and tokens.css.
   ========================================================================== */

/* ---- Element defaults ---------------------------------------------------- */
body {
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
}

h1 { font-size: var(--step-5); font-weight: var(--weight-bold); letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--step-4); font-weight: var(--weight-bold); letter-spacing: var(--tracking-tight); }
h3 { font-size: var(--step-3); font-weight: var(--weight-semibold); }
h4 { font-size: var(--step-2); font-weight: var(--weight-semibold); }
h5 { font-size: var(--step-1); font-weight: var(--weight-semibold); }
small { font-size: var(--step--1); }

a {
  color: var(--color-brand);
  text-underline-offset: 0.15em;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-brand-strong); }

::selection { background: var(--color-brand); color: #fff; }

/* ---- Layout primitives (composable, reusable) --------------------------- */

/* Page shell with consistent gutters */
.wrapper {
  width: 100%;
  max-width: var(--wrapper-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Readable prose column */
.prose { max-width: var(--content-max); }
.prose > * + * { margin-top: var(--space-s); }

/* Vertical rhythm: consistent spacing between stacked children */
.stack > * + * { margin-top: var(--flow-space, var(--space-s)); }
.stack-l > * + * { margin-top: var(--space-l); }

/* Horizontal group that wraps gracefully */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
  align-items: center;
}

/* Responsive auto-grid: cards flow into as many columns as fit */
.grid-auto {
  display: grid;
  gap: var(--space-m);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

/* Center a thing with optional intrinsic sizing */
.center { display: grid; place-items: center; }

/* Section vertical spacing */
.section { padding-block: var(--space-3xl); }

/* Visually hidden but accessible to screen readers */
.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 link for keyboard users */
.skip-link {
  position: absolute;
  left: var(--space-s);
  top: -100%;
  z-index: 100;
  background: var(--color-brand);
  color: #fff;
  padding: var(--space-2xs) var(--space-s);
  border-radius: var(--radius-md);
}
.skip-link:focus { top: var(--space-s); }

/* ---- Components ---------------------------------------------------------- */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-m);
  min-height: 44px; /* touch target */
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast),
    box-shadow var(--transition-fast);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--color-brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--color-brand-strong); color: #fff; box-shadow: var(--shadow-md); }

.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface); }

/* Card */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* Site header / nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.site-header .wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4rem;
}
.nav-links { display: flex; gap: var(--space-m); }
.nav-links a { text-decoration: none; color: var(--color-text-muted); font-weight: var(--weight-medium); }
.nav-links a:hover { color: var(--color-text); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  padding-block: var(--space-xl);
  font-size: var(--step--1);
}

/* Hero */
.hero { padding-block: var(--space-3xl); }
.hero h1 { max-width: 18ch; }
.hero p { max-width: 52ch; color: var(--color-text-muted); font-size: var(--step-1); margin-top: var(--space-s); }

/* Eyebrow / label */
.eyebrow {
  display: inline-block;
  font-size: var(--step--1);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-brand);
}
