/* =============================================================
   Base & Reset
   ============================================================= */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-base);
  min-height: 100vh;
  transition: background-color var(--transition-slow), color var(--transition-slow);
  overflow-x: hidden;
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semi);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--text-3xl); margin-bottom: var(--space-6); }
h2 { font-size: var(--text-2xl); margin-top: var(--space-10); margin-bottom: var(--space-4); }
h3 { font-size: var(--text-xl);  margin-top: var(--space-8);  margin-bottom: var(--space-3); }
h4 { font-size: var(--text-lg);  margin-top: var(--space-6);  margin-bottom: var(--space-2); }

p { margin-bottom: var(--space-4); }
p.lead {
  font-size: var(--text-lg);
  font-weight: var(--weight-light);
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
  line-height: var(--leading-loose);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast), opacity var(--transition-fast);
}
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

strong, b { font-weight: var(--weight-semi); }
em, i { font-style: italic; }

ul, ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
}
li { margin-bottom: var(--space-2); }
li:last-child { margin-bottom: 0; }

/* ── Code ── */
code, kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  color: var(--accent);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  overflow-x: auto;
  margin-bottom: var(--space-6);
  line-height: var(--leading-loose);
}
pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-8);
  font-size: var(--text-sm);
}
thead { background: var(--bg-elevated); }
th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--weight-semi);
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }
tbody tr:nth-child(even) td { background: var(--bg-elevated); }
tbody tr:nth-child(even):hover td { background: var(--bg-hover); }

/* ── Horizontal Rule ── */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-8) 0;
}

/* ── Skip Link ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
  font-weight: var(--weight-semi);
  z-index: 9999;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: var(--space-4); }

/* ── Selection ── */
::selection {
  background: var(--accent-dim);
  color: var(--text-primary);
}
