@import url('https://fonts.googleapis.com/css2?family=Literata:ital,opsz,wght@0,7..72,400;0,7..72,500;0,7..72,600;1,7..72,400;1,7..72,500&family=Cormorant+Garamond:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --display: 'Cormorant Garamond', 'Literata', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --content-width: 40rem;
  --reader-font-size: 1.15rem;
}

/* ---------- themes ---------- */
body.theme-sepia {
  --bg: #f2e9d8;
  --bg-raised: #ece0c9;
  --text: #3a2f22;
  --text-dim: #6f6250;
  --accent: #8a4a3a;
  --rule: #d8c8a8;
}
body.theme-light {
  --bg: #fbfaf7;
  --bg-raised: #f1efe9;
  --text: #23201b;
  --text-dim: #6a655c;
  --accent: #8a4a3a;
  --rule: #e2ded3;
}
body.theme-dark {
  --bg: #171512;
  --bg-raised: #201d19;
  --text: #e9e3d6;
  --text-dim: #a89f8d;
  --accent: #d69a72;
  --rule: #34302a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  transition: background .25s ease, color .25s ease;
  min-height: 100vh;
}

/* ---------- global anti-copy behaviour ---------- */
body, p, h1, h2, span, em, strong, div, li, a {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
img { pointer-events: none; }
::selection { background: transparent; }
::-moz-selection { background: transparent; }

/* Paragraph text is never real DOM text: it lives in data-t and is
   painted by generated content, which browsers exclude from
   selection, copy and (mostly) view-source text extraction. */
.tx { display: inline; }
.tx::before { content: attr(data-t); }
.tx:empty::before { white-space: pre-wrap; }

/* ---------- chrome / top bar ---------- */
.chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.progress-track {
  flex: 1;
  height: 3px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .1s linear;
}
.font-controls { display: flex; gap: .35rem; }
.icon-btn {
  font-family: var(--sans);
  font-size: .95rem;
  line-height: 1;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: .5rem;
  padding: .5rem .65rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- cover / index ---------- */
.cover {
  max-width: var(--content-width);
  margin: 4rem auto 2rem;
  padding: 0 1.25rem;
  text-align: center;
}
.kicker {
  font-family: var(--sans);
  letter-spacing: .18em;
  font-size: .75rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 1.5rem;
}
.book-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.8rem, 9vw, 4.5rem);
  letter-spacing: .04em;
  margin: 0;
}
.book-genre {
  font-style: italic;
  color: var(--text-dim);
  margin: .25rem 0 1.75rem;
}
.book-author {
  font-family: var(--sans);
  font-size: 1rem;
  letter-spacing: .06em;
  margin: 0 0 3rem;
}
.epigraph { margin: 0 auto 2rem; max-width: 30rem; }
.epigraph-line {
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.7;
  margin: .2rem 0;
}
.part-sub {
  font-family: var(--sans);
  letter-spacing: .12em;
  font-size: .8rem;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 2rem;
}

.toc {
  max-width: var(--content-width);
  margin: 0 auto 4rem;
  padding: 0 1.25rem;
}
.toc-heading {
  font-family: var(--sans);
  font-size: .8rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--rule);
  padding-bottom: .75rem;
  margin-bottom: .5rem;
}
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-item { border-bottom: 1px solid var(--rule); }
.toc-link {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: .85rem .25rem;
  text-decoration: none;
  color: var(--text);
}
.toc-link:hover { color: var(--accent); }
.toc-link:hover .toc-title::before { text-decoration: underline; }
.toc-num {
  font-family: var(--sans);
  font-size: .78rem;
  color: var(--text-dim);
  min-width: 8.5rem;
  letter-spacing: .04em;
}
.toc-title { font-size: 1.02rem; }

/* ---------- chapter page ---------- */
.chapter {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 3rem 1.25rem 2rem;
}
.chapter-head { text-align: center; margin-bottom: 3rem; }
.chapter-num {
  font-family: var(--sans);
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: .78rem;
  color: var(--accent);
  margin: 0 0 .5rem;
}
.chapter-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  margin: 0;
}
.chapter-body {
  font-size: var(--reader-font-size);
  line-height: 1.85;
}
.p { margin: 0 0 1.15em; text-indent: 1.4em; }
.p:first-of-type { text-indent: 0; }
.scene-break {
  text-align: center;
  text-indent: 0;
  margin: 2em 0;
  color: var(--text-dim);
  letter-spacing: .3em;
}

.chapter-nav {
  max-width: var(--content-width);
  margin: 2rem auto 3rem;
  padding: 1.5rem 1.25rem 0;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--sans);
}
.nav-btn {
  font-size: .9rem;
  color: var(--text);
  text-decoration: none;
  padding: .5rem 0;
}
.nav-btn:hover { color: var(--accent); }
.nav-btn.disabled { color: var(--text-dim); opacity: .4; }
.nav-btn.next { margin-left: auto; }

.site-footer {
  text-align: center;
  font-family: var(--sans);
  font-size: .75rem;
  color: var(--text-dim);
  padding: 2rem 1rem 3rem;
}

@media (max-width: 480px) {
  .cover { margin-top: 2.5rem; }
  .chapter { padding-top: 2rem; }
  .toc-num { min-width: 6.5rem; }
}

@media print {
  body::before {
    content: "Lecture protégée — l'impression est désactivée.";
    display: block;
    text-align: center;
    padding: 4rem 1rem;
    font-family: var(--sans);
  }
  .chrome, .chapter, .cover, .toc, .chapter-nav, .site-footer { display: none !important; }
}
