/* assets/reader.css — Immortal Soul Reader */

/* ── LAYOUT ─────────────────────────────────────────────── */
.reader-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.reader-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-mid);
  display: flex;
  flex-direction: column;
}

.reader-sidebar-top {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.reader-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1rem;
  transition: color 0.15s;
}
.reader-back:hover { color: var(--amber); text-decoration: none; }

.reader-book-title {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
}

.reader-book-sub {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

.reader-chapter-list {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.reader-ch-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 1.25rem;
  text-decoration: none;
  transition: background 0.1s;
  border-left: 2px solid transparent;
}

.reader-ch-item:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.reader-ch-item.active {
  background: var(--amber-dim);
  border-left-color: var(--amber);
}

.reader-ch-num {
  font-family: var(--sans);
  font-size: 0.65rem;
  color: var(--text-dim);
  min-width: 16px;
  text-align: right;
  flex-shrink: 0;
}

.reader-ch-name {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.reader-ch-item.active .reader-ch-name { color: var(--amber); }
.reader-ch-item.active .reader-ch-num  { color: var(--amber); }

.reader-sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.reader-admin-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
}
.reader-admin-link:hover { color: var(--amber); text-decoration: none; }

/* ── MAIN READING COLUMN ─────────────────────────────────── */
.reader-main {
  padding: 0;
  overflow-x: hidden;
}

.reader-empty {
  max-width: 640px;
  margin: 4rem auto;
  padding: 0 2rem;
  font-family: var(--sans);
  color: var(--text-muted);
}

/* ── CHAPTER ─────────────────────────────────────────────── */
.reader-chapter {
  max-width: 680px;
  margin: 0 auto;
  padding: 5rem 2.5rem 4rem;
  border-bottom: 1px solid var(--border);
}

.reader-chapter:last-child { border-bottom: none; }

/* Chapter header */
.reader-chapter-header {
  margin-bottom: 3rem;
  text-align: center;
}

.reader-chapter-eyebrow {
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.reader-chapter-number {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 0.5rem;
}

.reader-chapter-title {
  font-size: 2rem;
  font-weight: normal;
  color: var(--text);
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

.reader-chapter-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Chapter body prose */
.reader-chapter-body {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text);
}

.reader-chapter-body p {
  margin-bottom: 1.4em;
  text-indent: 0;
}

/* Drop cap on first paragraph */
.reader-chapter-body > p:first-of-type::first-letter {
  font-size: 3.6rem;
  font-weight: 500;
  float: left;
  line-height: 0.78;
  padding-right: 0.08em;
  padding-top: 0.08em;
  color: var(--amber);
  font-family: var(--serif);
}

/* Section breaks — *** becomes a decorative divider */
.reader-chapter-body .section-break {
  text-align: center;
  color: var(--text-dim);
  margin: 2.5rem 0;
  letter-spacing: 0.35em;
  font-size: 0.75rem;
  user-select: none;
}

/* Inline emphasis and special formatting */
.reader-chapter-body em { font-style: italic; }
.reader-chapter-body strong { font-weight: 600; color: var(--text); }

/* Dialogue — no extra styling, just the prose */

/* Block quotes (for epigraphs or key lines) */
.reader-chapter-body blockquote {
  border-left: 2px solid var(--amber-border);
  margin: 2rem 0 2rem 1rem;
  padding: 0.5rem 0 0.5rem 1.5rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Chapter nav */
.reader-chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

.reader-nav-btn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-decoration: none;
  max-width: 45%;
}
.reader-nav-btn:hover { text-decoration: none; }

.reader-nav-prev { align-items: flex-start; }
.reader-nav-next { align-items: flex-end; text-align: right; }

.reader-nav-label {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.reader-nav-title {
  font-size: 0.88rem;
  color: var(--amber);
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
.reader-sidebar::-webkit-scrollbar { width: 4px; }
.reader-sidebar::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

/* ── READER TOPBAR (tablet / phone) ─────────────────────── */
.reader-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--reader-topbar-h);
  padding: env(safe-area-inset-top) max(0.75rem, env(safe-area-inset-right)) 0 max(0.75rem, env(safe-area-inset-left));
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-mid);
}

.reader-topbar-title {
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-topbar-theme {
  flex-shrink: 0;
}

.reader-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--reader-topbar-h);
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 80;
}

.reader-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 1100px), ((pointer: coarse) and (max-width: 1400px)) {
  .reader-topbar { display: flex; }

  .reader-overlay { display: block; }

  .reader-layout {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - var(--reader-topbar-h));
  }

  .reader-sidebar {
    position: fixed;
    top: var(--reader-topbar-h);
    left: 0;
    bottom: 0;
    width: min(92vw, 320px);
    max-width: 92vw;
    height: auto;
    z-index: 100;
    transform: translateX(-110%);
    transition: transform 0.2s ease, visibility 0.2s;
    visibility: hidden;
    pointer-events: none;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
    -webkit-overflow-scrolling: touch;
  }

  body.reader-panel-open .reader-sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .reader-sidebar-theme { display: none; }

  .reader-main {
    padding-top: 0;
  }

  .reader-chapter {
    padding: 2rem max(1.25rem, env(safe-area-inset-right)) 2rem max(1.25rem, env(safe-area-inset-left));
  }

  .read-progress--viewport {
    top: var(--reader-topbar-h);
  }
}
