/* =========================================================================
   Base — reset + typography + layout primitives
   ========================================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--ribbon-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Text base */
p { margin: 0 0 var(--sp-4); max-width: var(--prose); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--primary-300);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--accent-400); }
a:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--sp-4);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1 {
  font-size: var(--fs-hero);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
h2 {
  font-size: var(--fs-h2);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-top: var(--sp-16);
}
h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: 1.3;
  margin-top: var(--sp-10);
}
h4 {
  font-size: var(--fs-xl);
  font-weight: 600;
  margin-top: var(--sp-6);
}

/* Lists */
ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.25rem; max-width: var(--prose); }
ul li, ol li { margin-bottom: var(--sp-2); }

/* Code / mono */
code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
code {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: var(--r-sm);
  color: var(--accent-300);
}

/* Selection */
::selection {
  background: var(--accent-500);
  color: var(--primary-900);
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  background: var(--accent-500);
  color: var(--primary-900);
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-weight: 600;
  z-index: 10000;
  transition: top var(--dur-fast);
}
.skip-link:focus { top: 8px; }

/* Layout containers */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--sp-6);
}
.container-wide {
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: var(--sp-6);
}
.container-prose {
  max-width: var(--prose);
  margin-inline: auto;
  padding-inline: var(--sp-6);
}
@media (max-width: 640px) {
  .container, .container-wide, .container-prose { padding-inline: var(--sp-4); }
}

/* Section spacing */
.section {
  padding-block: var(--sp-20);
}
.section-sm { padding-block: var(--sp-12); }
.section-lg { padding-block: var(--sp-24); }
@media (max-width: 640px) {
  .section    { padding-block: var(--sp-12); }
  .section-sm { padding-block: var(--sp-8); }
  .section-lg { padding-block: var(--sp-16); }
}

/* Grids */
.grid { display: grid; gap: var(--sp-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Utility */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-accent { color: var(--accent-400); }
.text-serif { font-family: var(--font-serif); }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: var(--fs-sm); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.mono-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-400);
  font-weight: 500;
}

/* Divider */
hr, .divider {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: var(--sp-12) 0;
}

/* Images */
img, svg, video { max-width: 100%; display: block; }

/* Fade-in on load */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fadeup { animation: fadeUp 500ms var(--ease-out) both; }

/* Focus visibility for buttons */
button { font-family: inherit; }
button:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}
