/* ============================================================
   CHAPTER LAYOUT — Sidebar TOC + Reading Pane
   ============================================================ */

/* --- Layout Container --- */
.chapter-layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--nav-height);
  position: relative;
  z-index: 1;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  bottom: 0;
  width: 300px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(-260px);
  transition: transform 0.35s ease, background 0.4s ease, border-color 0.4s ease;
}

.sidebar.open {
  transform: translateX(0);
}

/* Toggle button always visible */
.sidebar-toggle {
  position: absolute;
  top: 1rem;
  right: -44px;
  width: 36px;
  height: 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 101;
}

.sidebar-toggle svg {
  stroke: var(--text-muted);
  transition: stroke 0.3s ease;
}

.sidebar-toggle:hover {
  background: var(--bg-card-hover);
}

.sidebar-toggle:hover svg {
  stroke: var(--gold);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-content::-webkit-scrollbar {
  width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.sidebar-header {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* TOC Sections */
.toc-section {
  margin-bottom: 1.25rem;
}

.toc-part-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  padding-top: 0.5rem;
}

.toc-link {
  display: block;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text-secondary);
  padding: 0.3rem 0.5rem;
  margin: 0.1rem 0;
  border-radius: 3px;
  text-decoration: none;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.toc-link:hover {
  color: var(--gold);
  background: var(--border-gold);
}

.toc-link.active {
  color: var(--gold);
  background: var(--border-gold);
  font-weight: 500;
}

.toc-num {
  display: inline-block;
  width: 1.4em;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.toc-link.active .toc-num {
  color: var(--gold-dim);
}

/* --- Chapter Main Content --- */
.chapter-main {
  flex: 1;
  margin-left: 40px;
  transition: margin-left 0.35s ease;
  min-width: 0;
}

.sidebar.open ~ .chapter-main {
  margin-left: 300px;
}

.chapter-content {
  max-width: 740px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

/* Chapter Navigation (top and bottom) */
.chapter-nav-top,
.chapter-nav-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

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

.chapter-nav-label {
  color: var(--text-muted);
}

.chapter-nav-links {
  display: flex;
  gap: 1.5rem;
}

.chapter-nav-link {
  color: var(--gold);
  text-decoration: none;
  transition: color 0.3s ease;
}

.chapter-nav-link:hover {
  color: var(--gold-light);
}

.chapter-nav-disabled {
  color: var(--text-muted);
  opacity: 0.4;
}

/* Chapter Title */
.chapter-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--cream);
  line-height: 1.2;
  margin-bottom: 2rem;
}

/* Chapter Body Text */
.chapter-content p {
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 1.2rem;
}

.chapter-content em {
  font-style: italic;
}

.chapter-content strong {
  color: var(--cream);
  font-weight: 600;
}

/* Chapter Headings */
.chapter-content h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--cream);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.chapter-content h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--cream);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

/* Scripture Block Quotes */
.scripture-block {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--cream-dim);
  border-left: 2px solid var(--gold-dim);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--glow-gold);
  border-radius: 0 3px 3px 0;
  line-height: 1.7;
  transition: background 0.4s ease, border-color 0.4s ease;
}

/* Closing Scripture */
.chapter-closing-scripture {
  text-align: center;
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--cream-dim);
  margin-top: 3rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .sidebar {
    width: 280px;
    transform: translateX(-240px);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }

  .chapter-main {
    margin-left: 40px;
  }

  /* On mobile, sidebar overlays content instead of pushing it */
  .sidebar.open ~ .chapter-main {
    margin-left: 40px;
  }

  .chapter-title {
    font-size: 1.7rem;
  }

  .chapter-content {
    padding: 2rem 1.25rem 3rem;
  }
}

@media (max-width: 600px) {
  .sidebar-toggle {
    right: -40px;
    width: 32px;
    height: 32px;
  }

  .chapter-main {
    margin-left: 8px;
  }

  .sidebar.open ~ .chapter-main {
    margin-left: 8px;
  }

  .chapter-nav-top,
  .chapter-nav-bottom {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .chapter-nav-links {
    gap: 1rem;
  }
}
