/* ══════════════════════════════════════════════════════════════
   GURPS Reference Website — Shared Base Stylesheet
   gurps-base.css

   This file contains all layout and component CSS shared across
   every chapter page. Each chapter page defines its own 9 theme
   variables in an inline <style> block:

     --ch-primary      main accent (nav active, section nums)
     --ch-secondary    hero h1, h2, table header text
     --ch-bright       chips, strong in callouts
     --ch-accent       h3 subheadings, formula text
     --ch-deep         dark decorative variant
     --ch-comp         complementary colour, tip callouts
     --ch-sidebar-bg   rgba() — sidebar tint
     --ch-glow-1       rgba() — hero radial glow 1
     --ch-glow-2       rgba() — hero radial glow 2

   Chapter-specific components (attr cards, skill cards, etc.)
   stay inline in each chapter file.
   ══════════════════════════════════════════════════════════════ */

/* ── SHARED BASE PALETTE ──────────────────────────────────────
   These never change across chapters. Defined here so chapters
   don't need to re-declare them. Chapters may override if needed.
   ──────────────────────────────────────────────────────────── */
:root {
  --bg:          #0f0e0c;
  --bg2:         #161410;
  --bg3:         #1e1b17;
  --bg4:         #252118;
  --surface:     #2a261f;
  --border:      #3a3428;
  --border2:     #4a4336;

  --gold:        #c9a84c;
  --gold2:       #e8c96a;
  --gold3:       #f5e0a0;

  --amber:       #d4763a;
  --alert-red:   #c04a3a;

  --text:        #e8e0d0;
  --text2:       #b8ad98;
  --text3:       #7a7060;

  --nav-w:       260px;
  --content-max: 860px;
  --radius:      6px;
  --radius2:     12px;
}

/* ── RESET ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 18px;
  line-height: 1.75;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ch-primary); }

/* ── TOP NAV ──────────────────────────────────────────────── */
#topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  background: rgba(15,14,12,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 16px;
  z-index: 300;
  gap: 16px;
}

#home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text2);
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 0.5px;
  transition: color 0.18s;
  flex-shrink: 0;
  white-space: nowrap;
}
#home-link:hover { color: var(--ch-secondary); }
#home-link .home-arrow {
  font-size: 14px;
  color: var(--ch-primary);
  transition: transform 0.18s;
}
#home-link:hover .home-arrow { transform: translateX(-3px); }

#topnav-chapter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  overflow: hidden;
}
.topnav-book    { color: var(--text3); white-space: nowrap; }
.topnav-divider { color: var(--border2); }
.topnav-title   { color: var(--ch-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── SIDEBAR ──────────────────────────────────────────────── */
#sidebar {
  width: var(--nav-w);
  min-width: var(--nav-w);
  height: calc(100vh - 48px);
  position: sticky;
  top: 48px;
  background: linear-gradient(180deg, var(--ch-sidebar-bg) 0%, transparent 40%), var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0 0 40px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-brand .sigil {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.7;
  display: block;
  margin-bottom: 3px;
}
.sidebar-brand h2 {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold2);
  line-height: 1.3;
}
.sidebar-brand .chapter-tag {
  display: inline-block;
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ch-secondary);
  background: var(--ch-sidebar-bg);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 2px 8px;
  border-radius: 3px;
}

.nav-section-label {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 2.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text3);
  padding: 10px 20px 4px;
  display: block;
}

#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px 6px 18px;
  font-family: 'Crimson Pro', serif;
  font-size: 14.5px;
  color: var(--text2);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.18s ease;
  line-height: 1.4;
}
#sidebar nav a:hover,
#sidebar nav a.active {
  color: var(--ch-secondary);
  border-left-color: var(--ch-primary);
  background: var(--ch-sidebar-bg);
}
#sidebar nav a.active { font-weight: 600; }
#sidebar nav a .num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  min-width: 18px;
}

/* ── MAIN CONTENT ─────────────────────────────────────────── */
#main {
  flex: 1;
  min-width: 0;
  padding: 0 48px 120px;
}
#content {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ── HERO ─────────────────────────────────────────────────── */
#hero {
  padding: 100px 0 60px;
  position: relative;
  overflow: hidden;
}
#hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 300px at 60% 40%, var(--ch-glow-1) 0%, transparent 70%),
    radial-gradient(ellipse 300px 200px at 20% 80%,  var(--ch-glow-2) 0%, transparent 60%);
  pointer-events: none;
}

.hero-eyebrow {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 4px;
  font-weight: 600;
  color: var(--ch-primary);
  text-transform: uppercase;
  margin-bottom: 16px;
  opacity: 0;
  animation: fadeUp 0.6s 0.1s forwards;
}
#hero h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(36px, 5vw, 60px);
  font-weight: 900;
  color: var(--ch-secondary);
  line-height: 1.1;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
  opacity: 0;
  animation: fadeUp 0.6s 0.2s forwards;
}
#hero h1 span { color: var(--ch-bright); }

.hero-sub {
  font-size: 19px;
  color: var(--text2);
  font-style: italic;
  max-width: 560px;
  margin-bottom: 40px;
  opacity: 0;
  animation: fadeUp 0.6s 0.35s forwards;
}
.hero-divider {
  height: 1px;
  background: linear-gradient(90deg, var(--ch-primary) 0%, rgba(0,0,0,0) 100%);
  margin-bottom: 40px;
  opacity: 0;
  animation: fadeIn 0.8s 0.5s forwards;
}

/* ── SECTIONS ─────────────────────────────────────────────── */
.section {
  margin-bottom: 72px;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.section.visible { opacity: 1; transform: none; }

.section-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.section-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ch-primary);
  opacity: 0.8;
  flex-shrink: 0;
}
.section h2 {
  font-family: 'Cinzel', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ch-secondary);
  letter-spacing: 0.3px;
  line-height: 1.25;
}
.section h3 {
  font-family: 'Cinzel', serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--ch-accent);
  letter-spacing: 0.5px;
  margin: 32px 0 12px;
  text-transform: uppercase;
}

p { margin-bottom: 16px; color: var(--text); }
p:last-child { margin-bottom: 0; }
strong { color: var(--ch-bright); font-weight: 600; }
em { color: var(--text2); font-style: italic; }

/* ── CALLOUTS ─────────────────────────────────────────────── */
.callout {
  border-radius: var(--radius2);
  padding: 18px 22px;
  margin: 24px 0;
  position: relative;
  overflow: hidden;
}
.callout::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.callout-label {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 2.5px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.callout p { margin-bottom: 8px; }
.callout p:last-child { margin-bottom: 0; }

.callout-note {
  background: rgba(var(--ch-primary-rgb, 77,139,90), 0.07);
  border: 1px solid rgba(var(--ch-primary-rgb, 77,139,90), 0.22);
}
.callout-note::before { background: var(--ch-primary); }
.callout-note .callout-label { color: var(--ch-secondary); }
.callout-note .callout-label::before { content: '◆'; font-size: 10px; }

.callout-example {
  background: rgba(212,118,58,0.08);
  border: 1px solid rgba(212,118,58,0.25);
}
.callout-example::before { background: var(--amber); }
.callout-example .callout-label { color: var(--amber); }
.callout-example .callout-label::before { content: '⚔'; font-size: 12px; }

.callout-tip {
  background: rgba(var(--ch-comp-rgb, 112,168,144), 0.07);
  border: 1px solid rgba(var(--ch-comp-rgb, 112,168,144), 0.22);
}
.callout-tip::before { background: var(--ch-comp); }
.callout-tip .callout-label { color: var(--ch-comp); }
.callout-tip .callout-label::before { content: '✦'; font-size: 10px; }

.callout-warning {
  background: rgba(192,74,58,0.08);
  border: 1px solid rgba(192,74,58,0.25);
}
.callout-warning::before { background: var(--alert-red); }
.callout-warning .callout-label { color: #e07060; }
.callout-warning .callout-label::before { content: '▲'; font-size: 10px; }

/* ── TABLES (dark style — default for all pages) ──────────── */
.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border-radius: var(--radius2);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
thead tr { background: var(--surface); }
thead th {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 1.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ch-secondary);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.07);
}
thead th:last-child { border-right: none; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
td { padding: 10px 16px; color: var(--text2); vertical-align: top; line-height: 1.5; }
td strong { color: var(--ch-bright); }
td:first-child { color: var(--ch-secondary); font-weight: 500; }

/* ── CHIP / BADGE ─────────────────────────────────────────── */
.chip {
  display: inline-block;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--ch-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 1px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.chip-red {
  background: rgba(192,74,58,0.15);
  border-color: rgba(192,74,58,0.3);
  color: #e08070;
}
.chip-dim {
  background: rgba(122,112,96,0.12);
  border-color: rgba(122,112,96,0.2);
  color: var(--text3);
}

/* ── FORMULA / CODE BLOCK ─────────────────────────────────── */
.formula {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin: 20px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--ch-bright);
  line-height: 1.8;
}
.formula .comment {
  color: var(--text3);
  font-style: italic;
  font-family: 'Crimson Pro', serif;
  font-size: 15px;
}
.formula .success { color: #8aca8a; }
.formula .fail    { color: #e07060; }

/* ── STEP / CHECK LIST ────────────────────────────────────── */
.step-list { margin: 16px 0; list-style: none; }
.step-list li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 16.5px;
  color: var(--text2);
  line-height: 1.55;
}
.step-list li:last-child { border-bottom: none; }
.step-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ch-primary);
  min-width: 24px;
  padding-top: 3px;
  flex-shrink: 0;
}

/* ── MOBILE ───────────────────────────────────────────────── */
#menu-toggle {
  display: none;
  position: fixed;
  top: 6px; left: 14px;
  z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--ch-primary);
  width: 36px; height: 36px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
}

@media (max-width: 820px) {
  #sidebar {
    position: fixed;
    left: 0; top: 48px; bottom: 0;
    z-index: 250;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
  }
  #sidebar.open { transform: none; }
  #sidebar-overlay.open { display: block; }
  #main { padding: 0 24px 80px; }
  #menu-toggle { display: flex; }
  #topnav { padding-left: 56px; }
  #topnav-chapter { display: none; }
  #hero { padding-top: 80px; }
}
@media (max-width: 500px) {
  #main { padding: 0 16px 60px; }
}

/* ── ANIMATIONS ───────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── PRINT ────────────────────────────────────────────────── */
@media print {
  #sidebar, #menu-toggle, #topnav { display: none !important; }
  #main { padding: 0; }
  .section { opacity: 1 !important; transform: none !important; }
  body { background: white; color: black; }
}
