/* Nervous System Theology — Church of NORMAL · Normal Like Peter */
/* Light/cream accessible theme for trauma-informed reading */

:root {
  --bg-deep: #faf7f2;
  --bg-surface: #f2ede5;
  --bg-card: #ebe5db;
  --bg-hover: #e3dcd1;
  --text-primary: #2c2420;
  --text-secondary: #5e544a;
  --text-muted: #8a7f73;
  --accent: #8b5a3c;
  --accent-dim: #b08060;
  --accent-glow: rgba(139, 90, 60, 0.08);
  --accent-warm: #7a4a2c;
  --border: #d8d0c4;
  --code-bg: #f5f1ea;
  --link: #7a4a2c;
  --link-hover: #5c3520;
  --serif: 'Georgia', 'Palatino Linotype', 'Palatino', serif;
  --sans: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Consolas', 'Fira Code', 'Courier New', monospace;
  --max-width: 720px;
  --sidebar-width: 280px;
  --topbar-height: 62px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 17px;
}

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--serif);
  line-height: 1.85;
  min-height: 100vh;
}

/* Layout */
.book-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2rem 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-title {
  font-family: var(--sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.sidebar-subtitle {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--text-primary);
  font-style: italic;
  line-height: 1.4;
}

.sidebar nav {
  padding: 0 0.75rem;
}

.sidebar nav .part-label {
  display: block;
  padding: 0.8rem 0.75rem 0.3rem;
  color: var(--accent-dim);
  font-family: var(--sans);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.sidebar nav a {
  display: block;
  padding: 0.45rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.82rem;
  border-radius: 6px;
  transition: all 0.2s;
  line-height: 1.4;
}

.sidebar nav a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar nav a.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.sidebar nav .chapter-num {
  display: inline-block;
  width: 1.8rem;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.sidebar-footer .sig {
  color: var(--accent-dim);
  font-style: italic;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.chapter {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
}

/* Typography */
h1 {
  font-family: var(--serif);
  font-size: 2.2rem;
  color: var(--accent);
  margin-bottom: 0.3rem;
  line-height: 1.2;
  font-weight: 400;
}

h2 {
  font-family: var(--serif);
  font-size: 1.4rem;
  color: var(--text-primary);
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  font-style: italic;
}

h3 {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--accent);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

p {
  margin-bottom: 1.25rem;
}

.subtitle {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-style: italic;
}

.meta {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.8;
}

/* Section breaks */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* Blockquotes */
blockquote {
  border-left: 3px solid var(--accent-dim);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--bg-card);
  border-radius: 0 6px 6px 0;
  font-style: italic;
  color: var(--text-primary);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Emphasis */
strong {
  color: var(--text-primary);
  font-weight: 700;
}

em {
  font-style: italic;
}

/* Lists */
ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.35rem;
}

li ul, li ol {
  margin-top: 0.35rem;
  margin-bottom: 0.5rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

th, td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  text-align: left;
}

th {
  background: var(--bg-card);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

td {
  background: var(--bg-deep);
}

/* Chapter end note */
.chapter-end {
  text-align: center;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.chapter-end .next-hint {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--accent-dim);
  margin-top: 1rem;
}

/* Chapter navigation */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-family: var(--sans);
}

.chapter-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all 0.2s;
  text-decoration: none;
}

.chapter-nav a:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent-dim);
}

.chapter-nav .label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.chapter-nav .next { text-align: right; margin-left: auto; }
.chapter-nav .prev { text-align: left; }

/* Cover page */
.cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 4rem 2rem;
}

.cover h1 {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
  line-height: 1.15;
}

.cover .working-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 0.75rem;
}

.cover .author {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 1rem;
  letter-spacing: 0.05em;
}

.cover .epigraph {
  max-width: 460px;
  margin-top: 3rem;
  font-style: italic;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.8;
}

.cover .divider {
  width: 60px;
  height: 1px;
  background: var(--accent-dim);
  margin: 2rem auto;
}

/* TOC */
.toc-section {
  max-width: 540px;
  margin: 0 auto;
  text-align: left;
}

.toc-section h2 {
  text-align: center;
  border: none;
  margin-bottom: 2rem;
}

.toc-part {
  font-family: var(--sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-dim);
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.toc-part:first-of-type {
  border-top: none;
  margin-top: 0;
}

.toc-entry {
  display: flex;
  align-items: baseline;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: all 0.2s;
  color: inherit;
}

.toc-entry:hover {
  background: var(--bg-card);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  border-radius: 4px;
}

.toc-num {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--accent-dim);
  width: 2.2rem;
  flex-shrink: 0;
}

.toc-title {
  color: var(--text-primary);
  font-size: 1rem;
}

.toc-sub {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.1rem;
}

/* Status bar */
.status-bar {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 3rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
}

.status-bar strong {
  color: var(--accent);
}

/* Reading paths */
.reading-paths {
  margin-top: 3rem;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
}

.reading-paths h2 {
  text-align: center;
  border: none;
  margin-bottom: 1.5rem;
}

.path-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  transition: all 0.2s;
}

.path-card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-hover);
}

.path-card h3 {
  margin-top: 0;
  margin-bottom: 0.25rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
}

.path-card .path-desc {
  font-family: var(--serif);
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 0.5rem;
}

.path-card .path-route {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
}

/* Persistent nav (2026-07-07): sidebar stays visible while reading, desktop
   only. Sticky + own scroll, offset to clear the shared NLP topbar. The
   mobile slide-in drawer in the media query below is untouched. */
@media (min-width: 901px) {
  .sidebar {
    position: sticky;
    top: var(--topbar-height);
    left: auto;
    height: auto;
    max-height: calc(100vh - var(--topbar-height));
    align-self: flex-start;
    flex-shrink: 0;
  }

  .main-content {
    margin-left: 0;
  }
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .menu-toggle {
    display: flex;
  }
  .main-content {
    margin-left: 0;
  }
  .chapter {
    padding: 4rem 1.25rem 4rem;
  }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.2rem; }
  .cover h1 { font-size: 2rem; }
}

@media (max-width: 500px) {
  html { font-size: 16px; }
  .chapter { padding: 3.5rem 1rem 3rem; }
  .cover h1 { font-size: 1.8rem; }
}

/* Overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 90;
}
.sidebar-overlay.show {
  display: block;
}

/* ─── Reference Index ─── */

.index-page {
  max-width: 860px;
}

.index-intro {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.7;
  font-style: italic;
}

.index-jump-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 2.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.index-jump-link {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-dim);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.15s;
  letter-spacing: 0.05em;
}

.index-jump-link:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.index-columns {
  column-count: 2;
  column-gap: 3rem;
  column-rule: 1px solid var(--border);
}

@media (max-width: 700px) {
  .index-columns {
    column-count: 1;
    column-gap: 0;
    column-rule: none;
  }
}

.index-letter-block {
  break-inside: avoid-column;
  margin-bottom: 1.75rem;
}

.index-letter-heading {
  font-family: var(--serif);
  font-size: 1.4rem;
  color: var(--accent);
  font-style: italic;
  font-weight: 400;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--accent-dim);
  margin-bottom: 0.6rem;
  scroll-margin-top: 1rem;
}

.index-entry {
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.6;
  padding: 0.18rem 0;
  border-bottom: 1px solid var(--bg-card);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0;
}

.index-term {
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
}

.index-sep {
  color: var(--text-muted);
  margin: 0 0.15rem;
}

.index-chapters {
  color: var(--text-secondary);
  font-style: italic;
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

.index-chapter-link {
  color: var(--link);
  text-decoration: none;
  font-style: normal;
  transition: color 0.15s;
  white-space: nowrap;
}

.index-chapter-link:hover {
  color: var(--accent);
}

.index-no-hits {
  color: var(--text-muted);
  font-style: normal;
}

.sidebar nav a[href="reference-index.html"] {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
  color: var(--accent-dim);
}

/* Hero images */
.chapter-hero {
  width: 100%;
  margin: -1rem 0 2.5rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.chapter-hero img {
  width: 100%;
  height: 300px;
  object-fit: cover;
  display: block;
}

@media (max-width: 900px) {
  .chapter-hero img {
    height: 200px;
  }
}

/* Inline Citations */
.cite {
  font-size: 0.78em;
  color: var(--accent-dim);
  vertical-align: super;
  line-height: 0;
  padding: 0 1px;
}
.cite a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-dim);
  transition: color 0.2s;
}
.cite a:hover {
  color: var(--accent);
  border-bottom-style: solid;
}

.edition-stamp { font-family: monospace; letter-spacing: .06em; color: var(--accent-dim); }
.language-lanes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.5rem 0; }
.language-lanes > div { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
@media (max-width: 760px) { .language-lanes { grid-template-columns: 1fr; } }

/* Print */
@media print {
  .sidebar, .menu-toggle, .chapter-nav, .status-bar { display: none; }
  .main-content { margin-left: 0; }
  body { background: white; color: black; }
  h1, h2, h3 { color: #333; }
  blockquote { border-left-color: #999; background: #f5f5f5; }
}
