/* ==========================================================================
   MergeGrid Design System — Base / Reset
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  font-weight: var(--font-weight-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Media elements stay inside their containers */
img,
picture,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

/* Form controls inherit typography */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* Remove default margins on content elements */
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd,
ul, ol {
  margin: 0;
}

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

/* Headings use a tighter line-height and tracking */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  font-weight: var(--font-weight-bold);
  color: var(--text);
  text-wrap: balance;
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-md); }
h6 { font-size: var(--font-size-base); }

p {
  text-wrap: pretty;
}

a {
  color: var(--primary);
  text-decoration-color: color-mix(in srgb, var(--primary) 40%, transparent);
  text-underline-offset: 0.2em;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--primary-hover);
  text-decoration-color: currentColor;
}

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

code, kbd, samp, pre {
  font-family: var(--font-family-mono);
  font-size: 0.925em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin-block: var(--space-8);
}

/* ---------- Focus: visible, consistent, high contrast ---------- */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ---------- Selection ---------- */
::selection {
  background: var(--primary);
  color: var(--on-primary);
}

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

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-semibold);
  transform: translateY(-200%);
  transition: transform var(--duration-base) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

.container {
  width: min(100% - (var(--layout-gutter) * 2), var(--layout-max-width));
  margin-inline: auto;
}

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

.section {
  padding-block: clamp(var(--space-12), 8vw, var(--space-24));
}

.section-head {
  max-width: 48rem;
  margin-bottom: var(--space-10);
}

.section-head h2 {
  margin-bottom: var(--space-3);
}

.section-head p {
  color: var(--text-muted);
  font-size: var(--font-size-md);
}

.eyebrow {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: var(--space-3);
}

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

.numeric {
  font-family: var(--font-family-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- High contrast ---------- */
@media (prefers-contrast: more) {
  :root {
    --border: var(--neutral-400);
    --border-strong: var(--neutral-600);
    --text-muted: var(--neutral-700);
  }

  [data-theme="dark"] {
    --border: var(--neutral-500);
    --border-strong: var(--neutral-300);
  }
}
