/* ── RESIDUAL DRIFT — shared styles ── */

:root {
  --bg:        #0f0e0c;
  --surface:   #171613;
  --border:    #2a2720;
  --text:      #d4c9b0;
  --muted:     #7a7060;
  --accent:    #c97a3a;
  --accent-dim:#7a4820;
  --fg-bright: #ede3cc;
}

body.light {
  --bg:        #f5f0e8;
  --surface:   #ede8df;
  --border:    #d0c8b8;
  --text:      #2e2a22;
  --muted:     #7a7060;
  --accent:    #b56a28;
  --accent-dim:#c97a3a;
  --fg-bright: #1a1714;
}

body.light nav {
  background: rgba(245,240,232,0.9);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Lora', Georgia, serif;
  font-size: 18px;
  line-height: 1.75;
  min-height: 100vh;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
  transition: background 0.3s, color 0.3s;
}

/* ── NAV ── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2.5rem;
  background: rgba(15,14,12,0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: background 0.3s;
}

.nav-title a {
  color: var(--fg-bright);
  text-decoration: none;
  font-weight: 400;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-links a:hover { color: var(--accent); }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.35em 0.75em;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  line-height: 1;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

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

/* ── HOME PAGE ── */
.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 4rem 2rem;
  animation: fadeUp 0.9s ease both;
}

.home-eyebrow {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.home h1 {
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  font-weight: 400;
  color: var(--fg-bright);
  line-height: 1.1;
  margin-bottom: 0.3em;
  letter-spacing: -0.01em;
}

.home-sub {
  font-style: italic;
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 3rem;
  max-width: 38ch;
}

.home-divider {
  width: 40px;
  height: 1px;
  background: var(--accent-dim);
  margin: 0 auto 3rem;
}

.btn-start {
  display: inline-block;
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  padding: 0.85em 2.2em;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
}

.btn-start:hover {
  background: #e08840;
  transform: translateY(-1px);
}

/* ── TABLE OF CONTENTS ── */
.toc-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 6rem 2rem 6rem;
  animation: fadeUp 0.7s ease both;
}

.toc-wrap h2 {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2.5rem;
}

.toc-list {
  list-style: none;
  border-top: 1px solid var(--border);
}

.toc-item {
  border-bottom: 1px solid var(--border);
}

.toc-item a {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  padding: 1.1rem 0;
  text-decoration: none;
  color: var(--text);
  transition: color 0.2s;
}

.toc-item a:hover { color: var(--fg-bright); }
.toc-item a:hover .toc-num { color: var(--accent); }

.toc-num {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  min-width: 2.5rem;
  transition: color 0.2s;
}

.toc-title { font-size: 1rem; }

.toc-note {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.4em;
}

/* ── CHAPTER PAGE ── */
.chapter-wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 6rem 2rem 5rem;
  animation: fadeUp 0.7s ease both;
}

.chapter-meta {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.2rem;
}

.chapter-wrap h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 400;
  color: var(--fg-bright);
  line-height: 1.2;
  margin-bottom: 0.2em;
}

.chapter-tagline {
  font-style: italic;
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 2.8rem;
}

.chapter-divider {
  width: 30px;
  height: 1px;
  background: var(--accent-dim);
  margin-bottom: 2.8rem;
}

.chapter-body p {
  margin-bottom: 1.5em;
  color: var(--text);
}

.chapter-body p:first-child::first-letter {
  font-size: 3.2em;
  line-height: 0.8;
  float: left;
  margin-right: 0.08em;
  margin-top: 0.06em;
  color: var(--accent);
  font-weight: 500;
}

/* ── CHAPTER NAV ── */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  font-family: 'Josefin Sans', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.chapter-nav.top {
  border-top: none;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.chapter-nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.chapter-nav a:hover { color: var(--accent); }
.chapter-nav a.disabled { opacity: 0.2; pointer-events: none; }

/* ── RESPONSIVE ── */
@media (max-width: 500px) {
  nav { padding: 0.9rem 1.2rem; }
  .chapter-nav { flex-direction: column; gap: 1.2rem; text-align: center; }
}
