/*
  VOICE   : intime, nocturne, élégant — une liseuse de roman, rien d'autre.
  IDEA    : un livre relié du Douro : couverture couleur vin, pages calmes.
  PICTURE : la couverture pleine largeur, titre en grand, sans image.
  COLOUR  : vin profond (couverture), papier ou nuit pour le texte, bleu azulejo en accent.
  TYPE    : serif de lecture système (Charter / Iowan / Georgia), aucune police externe.
*/

:root {
  color-scheme: light dark;
  --taille: 19px;
  --vin: #5e1530;
  --vin-fonce: color-mix(in srgb, var(--vin) 55%, #12040a);
  --vin-clair: #8a2a4c;
  --bleu: #1f4f8f;
  --fond: light-dark(#fbfaf8, #121014);
  --encre: light-dark(#1f1a1d, #e9e3dc);
  --doux: light-dark(#6d6468, #a59ca0);
  --filet: light-dark(#e6e0dc, #2a2429);
  --accent: light-dark(#8a2a4c, #e39ab4);
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
:root[data-theme="clair"] { color-scheme: light; }
:root[data-theme="sombre"] { color-scheme: dark; }
:root[data-theme="sepia"] {
  color-scheme: light;
  --fond: #f3e9d7;
  --encre: #3b2f25;
  --doux: #7a6a5a;
  --filet: #e2d5bd;
  --accent: #7c2a3e;
}

* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 17px/1.6 var(--serif);
  overflow-x: clip;
  transition: background-color .3s, color .3s;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--bleu); outline-offset: 3px; border-radius: 4px; }

.bouton {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 26px;
  background: #f4e4d6; color: var(--vin);
  font: 600 16px/1 var(--sans); text-decoration: none;
  border: 0; border-radius: 999px; cursor: pointer;
}
.bouton:hover { background: #fff; }
.bouton-discret { background: transparent; color: #f4e4d6; box-shadow: inset 0 0 0 1.5px rgba(244,228,214,.55); }
.bouton-discret:hover { background: rgba(255,255,255,.08); }

/* ---------- Avertissement ---------- */
.porte {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: rgba(18, 8, 12, .86); backdrop-filter: blur(6px);
}
.porte[hidden] { display: none; }
.porte-boite {
  max-width: 440px; padding: 32px 28px;
  background: var(--vin); color: #f4e4d6; border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.porte-boite h2 { margin: 0 0 12px; font-size: 26px; line-height: 1.15; }
.porte-boite p { margin: 0 0 24px; font-size: 17px; }
.porte-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Accueil ---------- */
.couverture {
  background:
    radial-gradient(120% 90% at 85% 0%, rgba(255,200,140,.22), transparent 55%),
    radial-gradient(90% 70% at 0% 100%, rgba(31,79,143,.35), transparent 60%),
    linear-gradient(170deg, var(--vin) 0%, var(--vin-fonce) 75%);
  color: #f4e4d6;
  padding: clamp(64px, 12vw, 140px) max(6vw, 20px) clamp(56px, 9vw, 110px);
  min-height: 72vh;
  display: flex; align-items: flex-end;
}
.couverture-int { max-width: 760px; }
.genre { margin: 0 0 18px; font: 500 15px/1.3 var(--sans); color: #e7c9b3; }
.couverture h1 {
  margin: 0; font-weight: 400; letter-spacing: -.01em;
  font-size: clamp(48px, 10vw, 112px); line-height: .98; text-wrap: balance;
}
.accroche { margin: 26px 0 36px; font-size: clamp(18px, 2.2vw, 22px); line-height: 1.5; max-width: 34em; color: #f0dccd; font-style: italic; }
.couverture-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.sommaire { max-width: 760px; margin: 0 auto; padding: clamp(40px, 6vw, 80px) max(6vw, 20px) 40px; }
.sommaire h2 { margin: 0 0 8px; font-size: 36px; font-weight: 400; }
.sommaire h3 {
  margin: 40px 0 6px; font: 600 14px/1.3 var(--sans); color: var(--accent);
  padding-bottom: 10px; border-bottom: 1px solid var(--filet);
}
.sommaire ol { list-style: none; margin: 0; padding: 0; }
.sommaire li a {
  display: flex; gap: 16px; align-items: baseline;
  min-height: 48px; padding: 12px 4px;
  color: var(--encre); text-decoration: none;
  border-bottom: 1px solid var(--filet);
}
.sommaire li a:hover .nom { color: var(--accent); }
.sommaire .num { flex: none; width: 7.2em; font: 14px/1.3 var(--sans); color: var(--doux); }
.sommaire .nom { font-size: 20px; line-height: 1.3; }
.sommaire a.en-cours .num::after { content: " · en cours"; color: var(--accent); }
.pied { max-width: 760px; margin: 0 auto; padding: 24px max(6vw, 20px) 56px; font: 14px/1.5 var(--sans); color: var(--doux); }

/* ---------- Lecture ---------- */
.barre { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20; }
.barre-int { height: 100%; width: 0; background: var(--accent); }

.haut {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px max(4vw, 12px);
  background: color-mix(in srgb, var(--fond) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--filet);
}
.haut-titre { font-size: 18px; color: var(--encre); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reglages { display: flex; gap: 4px; flex: none; }
.reglages button {
  min-width: 44px; min-height: 44px; padding: 0 8px;
  background: transparent; color: var(--encre);
  border: 1px solid var(--filet); border-radius: 10px;
  font: 600 15px/1 var(--sans); cursor: pointer;
}
.reglages button:hover { border-color: var(--accent); color: var(--accent); }

.lecture { max-width: 40em; margin: 0 auto; padding: clamp(40px, 8vw, 96px) 22px 64px; }
:root[data-police="sans"] .texte { font-family: var(--sans); }

.chap-tete { text-align: center; margin-bottom: clamp(36px, 6vw, 64px); }
.chap-partie { margin: 0 0 22px; font: 600 14px/1.3 var(--sans); color: var(--accent); }
.chap-num { margin: 0; font: 15px/1.3 var(--sans); color: var(--doux); }
.chap-tete h1 { margin: 8px 0 14px; font-weight: 400; font-size: clamp(34px, 6vw, 50px); line-height: 1.08; text-wrap: balance; }
.chap-duree { margin: 0; font: 14px/1.3 var(--sans); color: var(--doux); }
.chap-tete::after { content: ""; display: block; width: 48px; height: 2px; margin: 28px auto 0; background: var(--accent); opacity: .6; }

.texte { font-size: var(--taille); line-height: 1.7; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
.texte p { margin: 0; text-indent: 1.5em; }
.texte p + p { margin-top: .15em; }
.texte > p:first-child { text-indent: 0; }
.texte > p:first-child::first-letter { float: left; font-size: 3.4em; line-height: .85; padding: .06em .08em 0 0; color: var(--accent); }
.texte p.dialogue { text-indent: 1.5em; }
.texte .pause { text-indent: 0; text-align: center; margin: 1.6em 0; color: var(--accent); letter-spacing: .3em; }
.texte .pause + p { text-indent: 0; }
.texte ul { margin: .8em 0 1em; padding-left: 1.2em; }
.texte li { margin: .3em 0; }
.texte em { font-style: italic; }

.suite {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px;
  margin-top: clamp(48px, 8vw, 88px); padding-top: 28px; border-top: 1px solid var(--filet);
}
.suite-lien {
  display: flex; flex-direction: column; gap: 4px; min-height: 48px;
  padding: 14px 16px; border-radius: 12px; border: 1px solid var(--filet);
  color: var(--encre); text-decoration: none; font-size: 17px; line-height: 1.3;
}
.suite-lien span { font: 600 13px/1.2 var(--sans); color: var(--accent); }
.suite-lien:hover { border-color: var(--accent); }
.suite-droite { text-align: right; align-items: flex-end; }

@media (max-width: 600px) {
  .sommaire .num { width: 6.4em; font-size: 13px; }
  .sommaire .nom { font-size: 18px; }
  .suite { grid-template-columns: minmax(0, 1fr); }
  .suite-droite { grid-row: 1; }
  .haut-titre { font-size: 16px; }
  .texte p { text-indent: 1.2em; }
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
}

/* ---------- Bibliothèque ---------- */
.entete-biblio {
  background:
    radial-gradient(110% 120% at 90% 0%, rgba(255,200,140,.18), transparent 55%),
    linear-gradient(170deg, #5e1530 0%, #2a0816 100%);
  color: #f4e4d6;
  padding: clamp(56px, 10vw, 120px) max(6vw, 20px) clamp(40px, 6vw, 72px);
}
.entete-biblio h1 { margin: 0; font-weight: 400; font-size: clamp(40px, 7vw, 76px); line-height: 1.02; text-wrap: balance; max-width: 16ch; }
.entete-biblio p { margin: 18px 0 0; font-size: clamp(17px, 2vw, 21px); font-style: italic; color: #f0dccd; max-width: 36em; }
.biblio { max-width: 1180px; margin: 0 auto; padding: clamp(32px, 5vw, 64px) max(5vw, 16px); }
.rayon { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 28px; }
.livre { display: flex; flex-direction: column; height: 100%; color: var(--encre); text-decoration: none; }
.livre-couv {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px;
  aspect-ratio: 3 / 4; padding: 24px; border-radius: 4px 14px 14px 4px;
  color: #f4e4d6;
  background:
    linear-gradient(90deg, rgba(0,0,0,.28) 0, rgba(0,0,0,0) 14px, rgba(255,255,255,.08) 15px, rgba(0,0,0,0) 22px),
    radial-gradient(120% 80% at 80% 0%, rgba(255,210,160,.22), transparent 60%),
    linear-gradient(165deg, var(--vin), color-mix(in srgb, var(--vin) 50%, #0d0306));
  box-shadow: 0 18px 40px -18px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.15);
  transition: transform .25s ease, box-shadow .25s ease;
}
.livre:hover .livre-couv { transform: translateY(-4px); box-shadow: 0 26px 50px -18px rgba(0,0,0,.6), 0 2px 6px rgba(0,0,0,.15); }
.livre-genre { font: 500 14px/1.3 var(--sans); color: #e7c9b3; }
.livre-titre { font-size: clamp(30px, 3.4vw, 40px); line-height: 1.02; text-wrap: balance; }
.pastille { position: absolute; top: 18px; right: 18px; font: 700 13px/1 var(--sans); padding: 7px 9px; border-radius: 999px; background: rgba(0,0,0,.35); color: #fff; }
.livre-info { display: flex; flex-direction: column; gap: 6px; padding: 16px 4px 0; }
.livre-accroche { font-size: 17px; line-height: 1.45; font-style: italic; }
.livre-meta { font: 14px/1.3 var(--sans); color: var(--doux); }
.vide, .message { font-size: 19px; color: var(--doux); }
.retour { display: inline-block; margin-bottom: 28px; font: 500 15px/1.3 var(--sans); color: #e7c9b3; text-decoration: none; }
.retour:hover { color: #fff; }
.apercu { position: sticky; top: 0; z-index: 30; padding: 10px 16px; background: #ffb400; color: #1a1200; font: 600 14px/1.4 var(--sans); text-align: center; }
.apercu a { color: inherit; }
.vue-chapitre .pied { max-width: 40em; }
@media (prefers-reduced-motion: reduce) { .livre-couv { transition: none; } }

/* ---------- Couvertures illustrées ---------- */
.livre-couv.avec-image { padding: 0; overflow: hidden; background: #1a0a10; aspect-ratio: 2 / 3; }
.livre-couv.avec-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.livre-couv.avec-image::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.35) 0, rgba(0,0,0,0) 10px, rgba(255,255,255,.10) 12px, rgba(0,0,0,0) 20px);
}
.livre-couv .pastille { z-index: 1; }
.livre-nom { font-size: 22px; line-height: 1.2; }
.livre-auteur { font: 500 15px/1.3 var(--sans); color: var(--doux); }

.couverture .auteur { margin: 14px 0 0; font: 500 clamp(16px, 1.8vw, 19px)/1.3 var(--sans); color: #e7c9b3; letter-spacing: .02em; }
.couverture .editeur { margin: 26px 0 0; font: 14px/1.3 var(--sans); color: #d6b5a2; }
.couverture.avec-image { align-items: center; min-height: 0; }
.couverture.avec-image .couverture-int {
  max-width: 1100px; width: 100%; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: clamp(28px, 5vw, 72px); align-items: center;
}
.couverture.avec-image .retour { grid-column: 1 / -1; margin-bottom: 0; }
.couv-image {
  width: 100%; height: auto; display: block; border-radius: 3px 10px 10px 3px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.7), 0 4px 12px rgba(0,0,0,.35);
}
.couverture.avec-image h1 { font-size: clamp(42px, 6.5vw, 84px); }

.resume { max-width: 40em; margin: 0 auto; padding: clamp(40px, 6vw, 72px) 22px 0; text-align: center; font-size: clamp(18px, 2vw, 20px); line-height: 1.6; }
.resume p { margin: 0 0 1em; }
.resume p:first-child { font-size: 1.2em; font-style: italic; color: var(--accent); line-height: 1.4; }
.resume p:last-child em { color: var(--accent); }
.resume + .sommaire { padding-top: clamp(28px, 4vw, 48px); }

@media (max-width: 700px) {
  .couverture.avec-image .couverture-int { grid-template-columns: minmax(0, 1fr); text-align: center; }
  .couv-image { max-width: 240px; margin: 0 auto; }
  .couverture.avec-image .couverture-actions { justify-content: center; }
  .couverture.avec-image .retour { text-align: left; }
}
.livre-couv.avec-image .pastille { top: auto; bottom: 14px; right: 14px; }
