/* ==========================================================================
   BASE / RESET / LAYOUT PRIMITIVES
   ========================================================================== */

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

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

body {
  margin: 0;
  font-family: var(--font-family-base);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  font-weight: var(--font-weight-regular);
  letter-spacing: var(--letter-spacing-none);
  color: var(--color-text-primary);
  background: var(--color-bg-page);
  -webkit-font-smoothing: antialiased;
}

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

[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }

/* ---- Typography utility classes (map directly to type scale tokens) ---- */
.text-xs  { font-size: var(--font-size-xs);  line-height: var(--line-height-xs); }
.text-sm  { font-size: var(--font-size-sm);  line-height: var(--line-height-sm); }
.text-md  { font-size: var(--font-size-md);  line-height: var(--line-height-md); }
.text-lg  { font-size: var(--font-size-lg);  line-height: var(--line-height-lg); }
.text-xl  { font-size: var(--font-size-xl);  line-height: var(--line-height-xl); }
.text-2xl { font-size: var(--font-size-2xl); line-height: var(--line-height-2xl); }
.text-3xl { font-size: var(--font-size-3xl); line-height: var(--line-height-3xl); }
.text-4xl { font-size: var(--font-size-4xl); line-height: var(--line-height-4xl); }
.text-5xl { font-size: var(--font-size-5xl); line-height: var(--line-height-5xl); }

.font-regular  { font-weight: var(--font-weight-regular); }
.font-medium   { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold     { font-weight: var(--font-weight-bold); }

.text-primary   { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary  { color: var(--color-text-tertiary); }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: var(--font-weight-semibold); }
p { margin: 0; }

/* ---- Page / grid / container system ---- */
.page {
  width: 100%;
  max-width: var(--page-max-width);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

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

.section {
  padding-block: clamp(2rem, 4vw, 4rem);
}

.stack {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}

/* gap utilities built from spacing tokens */
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); } .gap-8 { gap: var(--space-8); }

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

/* ---- Global focus treatment (visible, consistent, non-shifting) ---- */
:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
