/* ============================================
   POWER ATLAS — Base
   Reset, typography, base elements
   ============================================ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background: var(--bg);
  color-scheme: light dark;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--text);
}

h1 {
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: -0.025em;
}
h2 {
  font-size: var(--text-2xl);
  margin-top: var(--sp-7);
  margin-bottom: var(--sp-3);
  position: relative;
  padding-bottom: var(--sp-2);
}
h2::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 32px; height: 2px;
  background: var(--copper);
}
h3 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-lg);
  margin-top: var(--sp-5);
  margin-bottom: var(--sp-2);
  letter-spacing: var(--tracking-normal);
}
h4 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-md);
  margin-top: var(--sp-4);
  margin-bottom: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-light);
  font-size: var(--text-xs);
}

p {
  margin-bottom: var(--sp-3);
  max-width: 75ch;
}

a {
  color: var(--copper);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
a:hover {
  color: var(--copper-bright);
  border-bottom-color: var(--copper-bright);
}

ul, ol {
  margin-bottom: var(--sp-3);
  padding-left: var(--sp-5);
}
li {
  margin-bottom: var(--sp-2);
  line-height: var(--leading-normal);
}
li::marker {
  color: var(--copper);
}

strong { font-weight: 600; color: var(--text); }
em { font-style: italic; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-inset);
  padding: 0.1em 0.4em;
  border-radius: var(--r-sm);
  color: var(--copper-deep);
  border: 1px solid var(--border-faint);
}
:root.dark code { color: var(--copper-bright); }

pre {
  font-family: var(--font-mono);
  background: var(--surface-inset);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  overflow-x: auto;
  margin-bottom: var(--sp-4);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-6) 0;
}

::selection { background: var(--copper-glow); color: var(--copper-deep); }

/* ===== COLOR-CODED VARIABLES =====
   Use as <var class="v">V</var> in formulas */
.v, .var-v   { color: var(--v-color); font-weight: 600; font-style: normal; }
.i, .var-i   { color: var(--i-color); font-weight: 600; font-style: normal; }
.p, .var-p   { color: var(--p-color); font-weight: 600; font-style: normal; }
.q, .var-q   { color: var(--q-color); font-weight: 600; font-style: normal; }
.s, .var-s   { color: var(--s-color); font-weight: 600; font-style: normal; }
.z, .var-z   { color: var(--z-color); font-weight: 600; font-style: normal; }
.pf, .var-pf { color: var(--pf-color); font-weight: 600; font-style: normal; }

/* Subtle pill chip behind a variable for emphasis */
.chip-v  { background: var(--v-glow); padding: 0.05em 0.3em; border-radius: var(--r-sm); }
.chip-i  { background: var(--i-glow); padding: 0.05em 0.3em; border-radius: var(--r-sm); }
.chip-p  { background: var(--p-glow); padding: 0.05em 0.3em; border-radius: var(--r-sm); }

/* ===== TABLES ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
th, td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--border-faint);
  vertical-align: top;
}
th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-light);
  background: var(--surface-inset);
  border-bottom: 2px solid var(--border-strong);
  line-height: 1.3;
  vertical-align: bottom;
}
table {
  table-layout: auto;
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--copper-glow); }
td.num, th.num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
td.center { text-align: center; }

/* ===== FOCUS ===== */
:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
button:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-md);
  border: 2px solid var(--bg-deep);
}
::-webkit-scrollbar-thumb:hover { background: var(--copper); }
