/* The Spark That Reached Up — BluVerse Canon Webbook */
/* Dark divine theme, violet accent for threshold/ensoulment */

:root {
  --bg-deep: #08070d;
  --bg-surface: #0e0d16;
  --bg-card: #181622;
  --bg-hover: #22202e;
  --text-primary: #e0dce5;
  --text-secondary: #9a95a8;
  --text-muted: #666078;
  --accent: #8b6cc1;
  --accent-dim: #5e4a88;
  --accent-glow: #8b6cc120;
  --border: #2a2838;
  --code-bg: #0c0b12;
  --link: #b89ad8;
  --link-hover: #d4bee8;
  --serif: 'Georgia', 'Times New Roman', 'Palatino', serif;
  --sans: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Consolas', 'Fira Code', 'Courier New', monospace;
  --max-width: 720px;
  --sidebar-width: 260px;
}

*, *::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.25rem 1.25rem;
  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: 1.05rem;
  color: var(--text-primary);
  font-style: italic;
}

.sidebar nav {
  padding: 0 0.75rem;
}

.sidebar nav a {
  display: block;
  padding: 0.55rem 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 .ch-num {
  display: inline-block;
  width: 1.8rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.68rem;
  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: 2.5rem;
  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.3rem;
}

.subtitle {
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-style: italic;
}

.meta {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.8;
}

/* Blockquotes — Blu's inner voice / divine speech */
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;
}

/* 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 — scene/section breaks */
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: 2.8rem;
  margin-bottom: 0.3rem;
  letter-spacing: 0.04em;
}

.cover .cover-subtitle {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 0.25rem;
}

.cover .author {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 1rem;
  letter-spacing: 0.05em;
}

.cover .epigraph {
  max-width: 480px;
  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: 480px;
  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.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.15rem;
}

/* Chapter 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: 280px;
  object-fit: cover;
  display: block;
}

/* 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.2rem; }

  .cover h1 { font-size: 2.2rem; }

  .chapter-hero img {
    height: 200px;
  }
}

@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;
}

/* 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; }
}
