/* Divine SuperCluster — Book of Computational Theology */
/* Dark cosmic theme, clean typography, book-like reading */

:root {
  --bg-deep: #0a0a0f;
  --bg-surface: #12121a;
  --bg-card: #1a1a26;
  --bg-hover: #222233;
  --text-primary: #e0ddd5;
  --text-secondary: #9995a0;
  --text-muted: #66636e;
  --accent: #c8a86e;
  --accent-dim: #8a7244;
  --accent-glow: #d4b87830;
  --border: #2a2a3a;
  --code-bg: #0e0e16;
  --link: #a8c4e0;
  --link-hover: #c8daf0;
  --serif: 'Georgia', 'Times New Roman', 'Palatino', serif;
  --sans: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Consolas', 'Fira Code', 'Courier New', monospace;
  --max-width: 780px;
  --sidebar-width: 280px;
}

*, *::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.75;
  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.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.sidebar-subtitle {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--text-primary);
  font-style: italic;
}

.sidebar nav {
  padding: 0 0.75rem;
}

.sidebar nav a {
  display: block;
  padding: 0.6rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.85rem;
  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.75rem;
}

.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.5rem;
  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: 1rem;
  color: var(--accent);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

h4 {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

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;
}

/* 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;
}

/* Code */
code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--accent);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-family: var(--sans);
  font-size: 0.85rem;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

tr:hover td {
  background: var(--bg-hover);
}

/* Lists */
ul, ol {
  margin: 1rem 0 1.25rem 1.5rem;
}

li {
  margin-bottom: 0.4rem;
}

li::marker {
  color: var(--accent-dim);
}

/* Links */
a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--link-hover);
}

/* Horizontal rules */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* Strong / emphasis */
strong {
  color: var(--text-primary);
  font-weight: 700;
}

em {
  font-style: italic;
}

/* 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;
  align-items: center;
  gap: 0.5rem;
  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;
}

.chapter-nav a:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent-dim);
}

.chapter-nav .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.chapter-nav .title {
  font-size: 0.85rem;
}

.chapter-nav .prev { text-align: left; }
.chapter-nav .next { text-align: right; }

/* 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: 3rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.08em;
}

.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: 500px;
  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-section {
  max-width: 500px;
  margin: 0 auto;
  text-align: left;
}

.toc-section h2 {
  text-align: center;
  border: none;
  margin-bottom: 2rem;
}

.toc-entry {
  display: flex;
  align-items: baseline;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: all 0.2s;
}

.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.8rem;
  color: var(--accent-dim);
  width: 2.5rem;
  flex-shrink: 0;
}

.toc-title {
  color: var(--text-primary);
  font-size: 1.05rem;
}

.toc-sub {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.15rem;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }

  .menu-toggle {
    display: flex;
  }

  .main-content {
    margin-left: 0;
  }

  .chapter {
    padding: 4rem 1.25rem 4rem;
  }

  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.3rem; }

  .cover h1 { font-size: 2.2rem; }

  table { font-size: 0.8rem; }
  th, td { padding: 0.5rem 0.6rem; }
}

@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.6);
  z-index: 90;
}

.sidebar-overlay.show {
  display: block;
}

/* =========================================================
   Back-of-Book 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;
}

/* Jump bar — letter navigation */
.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);
}

/* Two-column layout for the index body */
.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;
  }
}

/* Letter block — starts on its own (avoids mid-block break) */
.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;
}

/* Individual term entry */
.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 Index link — subtle separator before it */
.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);
  font-style: italic;
}

.sidebar nav a[href="reference-index.html"]:hover,
.sidebar nav a[href="reference-index.html"].active {
  color: var(--accent);
}

/* Chapter Illustrations */
.chapter-illustration {
  width: 100%;
  margin: 2rem 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.chapter-illustration img {
  width: 100%;
  height: auto;
  display: block;
}

.chapter-illustration figcaption {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  font-style: italic;
  text-align: center;
}

.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;
  }
}

/* Print */
@media print {
  .sidebar, .menu-toggle, .chapter-nav { display: none; }
  .main-content { margin-left: 0; }
  body { background: white; color: black; }
  h1, h2, h3, .accent { color: #333; }
  blockquote { border-left-color: #999; background: #f5f5f5; }
}
