/* ═══════════════════════════════════════════════════
   LUMI EDITOR — Aperçu Roman
   Paper book theme · Light & typographic
   ═══════════════════════════════════════════════════ */

/* ─── Reset & Base ─────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --paper:        #f5f0e8;
  --paper-dark:   #ede8df;
  --ink:          #1a1612;
  --ink-light:    #4a4540;
  --ink-muted:    #8a8580;
  --accent:       #6e4e2a;
  --accent-light: #c4956a;
  --border:       #d8d0c4;

  --font-prose:   'Cormorant Garamond', Georgia, serif;
  --font-ui:      'Figtree', system-ui, sans-serif;

  --nav-h:        52px;
  --page-w:       680px;
}

html {
  background: var(--paper-dark);
  scroll-behavior: smooth;
}

body {
  background: var(--paper-dark);
  color: var(--ink);
  font-family: var(--font-prose);
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ─────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--paper-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

/* ─── Barre de navigation ───────────────────────── */

#nav-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 12px rgba(0,0,0,0.06);
}

.nav-back {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.nav-back:hover {
  color: var(--accent);
}

#nav-stats {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

#btn-toc {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--ink-light);
  cursor: pointer;
  transition: all 0.15s;
}

#btn-toc:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ─── En-tête flottant ──────────────────────────── */

#chapter-header {
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  z-index: 90;
  text-align: center;
  padding: 8px 32px;
  font-family: var(--font-prose);
  font-size: 12px;
  font-style: italic;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

#chapter-header.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Livre ─────────────────────────────────────── */

#book {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 60px) 48px 120px;
  background: var(--paper);
  min-height: 100vh;
  box-shadow: 0 0 60px rgba(0,0,0,0.08);
}

/* ─── Loading ───────────────────────────────────── */

#loading {
  text-align: center;
  padding: 80px 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-muted);
  font-style: italic;
}

/* ─── Titre de partie ───────────────────────────── */

.book-partie {
  margin-top: 80px;
}

.book-partie:first-child {
  margin-top: 0;
}

.partie-title {
  font-family: var(--font-prose);
  font-size: 13px;
  font-weight: 400;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-muted);
  text-align: center;
  padding: 48px 0 16px;
  border-top: 1px solid var(--border);
}

.book-partie:first-child .partie-title {
  border-top: none;
  padding-top: 0;
}

/* ─── Chapitre ──────────────────────────────────── */

.book-chapitre {
  margin-top: 64px;
  scroll-margin-top: calc(var(--nav-h) + 60px);
}

.chapitre-title {
  font-family: var(--font-prose);
  font-size: 1.6rem;
  font-weight: 600;
  font-style: italic;
  color: var(--ink);
  text-align: center;
  margin-bottom: 40px;
  letter-spacing: 0.01em;
}

/* ─── Prose ─────────────────────────────────────── */

.chapitre-body p {
  font-size: 1.05rem;
  line-height: 1.95;
  color: var(--ink);
  text-align: justify;
  hyphens: auto;
  margin-bottom: 0;
}

/* Alinéa — premier paragraphe sans indentation */
.chapitre-body p + p {
  text-indent: 2em;
}

/* Premier mot en petites capitales */
.chapitre-body p:first-child::first-letter {
  font-size: 3.2rem;
  font-weight: 600;
  float: left;
  line-height: 0.8;
  margin: 6px 8px 0 0;
  color: var(--accent);
}

/* Dialogues — tirets longs */
.chapitre-body p:has(> *:first-child) {
  text-indent: 0;
}

/* ─── Séparateur entre chapitres ────────────────── */

.chapitre-sep {
  text-align: center;
  color: var(--accent-light);
  font-size: 1.1rem;
  margin-top: 48px;
  letter-spacing: 0.3em;
  opacity: 0.6;
}

/* ─── Table des matières ────────────────────────── */

#toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 149;
  background: rgba(26, 22, 18, 0.4);
  backdrop-filter: blur(3px);
}

#toc-overlay.hidden { display: none; }

#toc-panel {
  position: fixed;
  top: 0; right: 0;
  bottom: 0;
  z-index: 150;
  width: 320px;
  background: var(--paper);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,0.12);
  animation: slide-in 0.25s ease;
}

#toc-panel.hidden { display: none; }

@keyframes slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

#toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

#toc-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  transition: background 0.15s;
}

#toc-close:hover {
  background: var(--paper-dark);
  color: var(--ink);
}

#toc-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.toc-partie {
  margin-bottom: 8px;
}

.toc-partie-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  padding: 12px 24px 6px;
}

.toc-chapitre {
  display: block;
  padding: 7px 24px 7px 32px;
  font-family: var(--font-prose);
  font-size: 14px;
  color: var(--ink-light);
  text-decoration: none;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}

.toc-chapitre:hover {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(110, 78, 42, 0.05);
  padding-left: 34px;
}

/* ─── Responsive ────────────────────────────────── */

@media (max-width: 768px) {
  #book {
    padding: calc(var(--nav-h) + 40px) 24px 80px;
  }

  .chapitre-title {
    font-size: 1.3rem;
  }

  .chapitre-body p {
    font-size: 1rem;
    text-align: left;
    hyphens: none;
  }

  #toc-panel {
    width: 100%;
  }
}