/* Le Grimoire du Passeur de Savoirs — feuille du livre.
   Mise en page : un livre de nuit. Une colonne de lecture étroite ; les planches et les séquences de cases
   débordent de la colonne, comme dans un album. Une seule lumière : l'or. */
:root {
  --nuit: #0e1828;
  --nuit-2: #152338;
  --texte: #ece0c8;
  --brume: #9eafc2;
  --or: #e9a94c;
  --sarcelle: #3b7c80;
  --rouge: #d9785a;
  --trait: rgba(236, 224, 200, .16);
  --papier: #f3e7cd;
  --encre: #1a2332;
  --or-encre: #7a5317;
  --ombre-img: 0 18px 40px -18px rgba(0, 0, 0, .7);
  --f-titre: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --f-texte: "Alegreya", "Iowan Old Style", Georgia, serif;
  --f-etiq: "Alegreya Sans SC", "Gill Sans", "Trebuchet MS", sans-serif;
  --col: 36rem;
  --large: 64rem;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --nuit: #efe4cc; --nuit-2: #e5d6b8; --texte: #1d2636; --brume: #566275;
    --or: #9b5a10; --sarcelle: #2c6164; --rouge: #a0432a; --trait: rgba(29, 38, 54, .18);
    --ombre-img: 0 18px 36px -20px rgba(30, 30, 40, .55);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --nuit: #efe4cc; --nuit-2: #e5d6b8; --texte: #1d2636; --brume: #566275;
  --or: #9b5a10; --sarcelle: #2c6164; --rouge: #a0432a; --trait: rgba(29, 38, 54, .18);
  --ombre-img: 0 18px 36px -20px rgba(30, 30, 40, .55);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: calc(100% * var(--echelle, 1)); }
body {
  margin: 0;
  background: var(--nuit);
  color: var(--texte);
  font-family: var(--f-texte);
  font-size: 1.15rem;
  line-height: 1.62;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: env(safe-area-inset-top, 0px) calc(4rem + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--nuit); }
a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--or); outline-offset: 3px; }

.progres { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 3px; z-index: 11; }
.progres span { display: block; height: 100%; width: 0; background: var(--or); transition: width .1s linear; }

.livre { max-width: var(--large); margin: 0 auto; display: flex; flex-direction: column; }
.col { width: 100%; max-width: var(--col); margin-inline: auto; }

.etiq { font-family: var(--f-etiq); font-weight: 500; letter-spacing: .08em; font-size: .82rem; color: var(--brume); text-transform: lowercase; }
.etiq b { color: var(--or); font-weight: 700; }

/* En-tête de chapitre */
.tete { padding-block: 3rem 1.5rem; display: grid; gap: .5rem; }
.tete .livre-titre { font-family: var(--f-titre); font-style: italic; font-size: 1.1rem; color: var(--brume); margin: 0; text-decoration: none; }
.tete .livre-titre:hover { color: var(--texte); }
.tete h1 { font-family: var(--f-titre); font-weight: 400; font-size: clamp(2.6rem, 11vw, 5rem); line-height: .98; margin: .3rem 0 .4rem; text-wrap: balance; }
.tete .meta { font-family: var(--f-etiq); font-size: .85rem; letter-spacing: .06em; color: var(--brume); }

/* Planches */
.planche { margin: .6rem 0 2.4rem; }
.planche img { display: block; width: 100%; height: auto; border-radius: 3px; box-shadow: var(--ombre-img); }
.legende { font-family: var(--f-etiq); font-size: .8rem; letter-spacing: .05em; color: var(--brume); margin-top: .6rem; }

/* Texte */
.texte { display: flow-root; }
.texte > * { margin: 0 0 1.05rem; }
.texte > *:last-child { margin-bottom: 0; }
.texte b { font-weight: 600; }
.lettrine::first-letter { font-family: var(--f-titre); float: left; font-size: 4.1em; line-height: .82; padding: .08em .1em 0 0; color: var(--or); }

/* Passelume qui parle */
.texte > .guide { display: grid; grid-template-columns: 4.2rem 1fr; gap: .9rem; align-items: start; margin-block: .4rem 1.8rem; }
.guide img { width: 4.2rem; height: 4.2rem; border-radius: 50%; object-fit: cover; border: 2px solid var(--or); }
.guide .bulle { position: relative; background: var(--papier); color: var(--encre); padding: .85rem 1.05rem; border-radius: 1.1rem; font-size: 1.04rem; line-height: 1.5; min-width: 0; }
.guide .bulle::before { content: ""; position: absolute; left: -.55rem; top: 1.3rem; border: .55rem solid transparent; border-left: 0; border-right-color: var(--papier); }
.guide .qui { display: block; font-family: var(--f-etiq); font-size: .75rem; letter-spacing: .08em; color: var(--or-encre); margin-bottom: .15rem; }

/* Les questions du lecteur */
.texte > .question { background: var(--nuit-2); border-radius: 4px; padding: 1.05rem 1.15rem 1.15rem; display: grid; gap: .55rem; margin-block: 1.4rem; clear: both; }
.question .q { display: flex; align-items: center; gap: .6rem; font-family: var(--f-etiq); font-size: .8rem; letter-spacing: .07em; color: var(--or); }
.question .q img { width: 1.9rem; height: 1.9rem; border-radius: 50%; object-fit: cover; }
.question p { margin: 0; font-size: 1.06rem; }

/* Encadrés : à essayer, le piège, ce qui peut sauver une vie */
.texte > .encadre { border: 1px solid var(--trait); border-left: 3px solid var(--sarcelle); border-radius: 3px; padding: .95rem 1.1rem 1.05rem; margin-block: 1.4rem; clear: both; display: grid; gap: .4rem; }
.encadre .titre-encadre { font-family: var(--f-etiq); font-weight: 700; letter-spacing: .06em; font-size: .86rem; text-transform: lowercase; color: var(--sarcelle); }
.encadre.piege { border-left-color: var(--rouge); }
.encadre.piege .titre-encadre { color: var(--rouge); }
.encadre.vie { border-left-color: var(--or); }
.encadre.vie .titre-encadre { color: var(--or); }
.encadre p { margin: 0; font-size: 1.05rem; }

/* Petit dessin de marge */
.texte > .marge { margin: .3rem auto 1.3rem; width: min(62%, 15rem); }
@media (min-width: 60rem) { .texte > .marge { float: right; width: 13rem; margin: .2rem -7rem .8rem 1.4rem; shape-outside: circle(50%); } }
.marge img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 50%; box-shadow: var(--ombre-img); }

/* Schémas */
.texte > .schema { margin-block: 1.4rem; clear: both; }
.schema .defile { overflow-x: auto; }
.schema svg { display: block; width: 100%; min-width: 20rem; height: auto; }
.schema .sol { stroke: var(--brume); stroke-width: 1; }
.schema .forme { fill: var(--sarcelle); }
.schema .tour { fill: var(--or); }
.schema .hypo { fill: none; stroke: var(--or); stroke-width: 1.2; stroke-dasharray: 4 3; }
.schema text { fill: var(--texte); font-family: var(--f-etiq); font-size: 12px; letter-spacing: .03em; }
.schema text.petit { fill: var(--brume); font-size: 11px; }

/* Les deux familles de mots */
.texte > .langues { display: grid; grid-template-columns: 1fr; gap: .8rem; margin-block: 1.4rem; clear: both; }
@media (min-width: 34rem) { .texte > .langues { grid-template-columns: 1fr 1fr; } }
.langues section { background: var(--nuit-2); border-radius: 4px; padding: .9rem 1rem 1rem; display: grid; gap: .55rem; align-content: start; min-width: 0; }
.langues h3 { margin: 0; font-family: var(--f-etiq); font-weight: 700; font-size: .82rem; letter-spacing: .07em; text-transform: lowercase; }
.langues .sud h3 { color: var(--or); }
.langues .nord h3 { color: var(--sarcelle); }
.langues ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.langues li { border: 1px solid var(--trait); border-radius: 999px; padding: .1rem .65rem; font-size: 1rem; }
.langues li span { font-family: var(--f-etiq); font-size: .72rem; letter-spacing: .05em; color: var(--brume); margin-left: .3rem; }
.langues .sud li { border-color: color-mix(in srgb, var(--or) 45%, transparent); }

/* La séquence de cases */
.sequence { margin-block: 1.4rem 1.8rem; display: grid; gap: .7rem; grid-template-columns: 1fr; max-width: 26rem; margin-inline: auto; width: 100%; }
@media (min-width: 46rem) {
  .sequence.n2 { grid-template-columns: repeat(2, 1fr); max-width: 46rem; }
  .sequence.n3 { grid-template-columns: repeat(3, 1fr); max-width: var(--large); }
  .sequence.n4 { grid-template-columns: repeat(2, 1fr); max-width: 46rem; }
}
@media (min-width: 70rem) { .sequence.n4 { grid-template-columns: repeat(4, 1fr); max-width: var(--large); } }
.case { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 2px; box-shadow: var(--ombre-img); background: var(--nuit-2); margin: 0; }
.case img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recit { position: absolute; top: .55rem; left: .55rem; max-width: 78%; background: var(--papier); color: var(--encre); font-size: .95rem; line-height: 1.32; padding: .45rem .6rem; border-radius: 1px; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.recit.bas { top: auto; left: auto; bottom: .55rem; right: .55rem; max-width: 66%; }
.case .parole { position: absolute; right: .7rem; bottom: .9rem; max-width: 62%; margin: 0; background: var(--papier); color: var(--encre); font-size: .95rem; line-height: 1.3; font-style: italic; padding: .5rem .75rem; border-radius: 1rem; }
.case .parole::after { content: ""; position: absolute; left: 1.2rem; top: -.6rem; border: .35rem solid transparent; border-bottom: .6rem solid var(--papier); border-top: 0; }

/* Citations, gravure, révélation, clôture */
.texte > .vers { margin-inline: 0; padding: .9rem 0 .9rem 1.2rem; border-left: 2px solid var(--or); font-family: var(--f-titre); font-style: italic; font-size: 1.3rem; line-height: 1.45; }
.texte > .gravure { margin: 1rem 0 1.4rem; padding: 1.3rem 1rem; text-align: center; border-block: 1px solid var(--trait); font-family: var(--f-etiq); font-weight: 500; letter-spacing: .14em; font-size: 1.02rem; line-height: 1.7; color: var(--or); text-wrap: balance; }
.texte > .revelation { margin-block: 2.2rem; text-align: center; font-family: var(--f-titre); font-size: clamp(1.9rem, 7vw, 2.8rem); line-height: 1.2; text-wrap: balance; }
.revelation b { font-weight: 400; color: var(--or); }
.texte > .cloture { margin-block: 1.6rem 2rem; font-family: var(--f-titre); font-style: italic; font-size: 1.5rem; line-height: 1.4; color: var(--or); text-wrap: pretty; }

/* En une phrase */
.texte > .resume { margin-top: 1.8rem; border-left: 2px solid var(--or); padding: .3rem 0 .3rem 1rem; font-size: 1.05rem; clear: both; }
.resume .etiq { display: block; margin-bottom: .2rem; }

/* Fin de chapitre */
.texte > .suspens { margin-top: 2rem; display: grid; gap: 1rem; }
.suspens p { margin: 0; }
.chute { font-family: var(--f-titre); font-size: 1.7rem; line-height: 1.25; color: var(--or); }
.fin-planche { margin: 2rem auto 0; max-width: 30rem; width: 100%; }
.fin-planche.large { max-width: var(--large); }
.fin-planche .case { aspect-ratio: auto; }
.fin-planche .case img { height: auto; }
.a-suivre { position: absolute; bottom: .8rem; left: .8rem; right: .8rem; background: var(--papier); color: var(--encre); padding: .6rem .8rem; border-radius: 1px; text-decoration: none; display: block; }
.a-suivre .etiq { color: var(--or-encre); display: block; font-size: .75rem; }
.a-suivre strong { font-family: var(--f-titre); font-weight: 400; font-size: 1.35rem; }
a.a-suivre:hover strong { text-decoration: underline; text-underline-offset: 3px; }

/* Pied de chapitre */
.pied { margin-top: 3rem; padding-top: 1.4rem; border-top: 1px solid var(--trait); display: grid; gap: 1.2rem; }
.nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.nav a, .nav span { font-family: var(--f-etiq); font-size: .85rem; letter-spacing: .05em; color: var(--brume); text-decoration: none; max-width: 48%; }
.nav .suiv { text-align: right; margin-left: auto; }
.nav b { display: block; font-family: var(--f-titre); font-weight: 400; font-size: 1.15rem; letter-spacing: 0; color: var(--texte); }
.nav a:hover b { color: var(--or); }
.signe { font-family: var(--f-titre); font-style: italic; color: var(--brume); margin: 0; }
.retour { font-family: var(--f-etiq); font-size: .85rem; letter-spacing: .05em; color: var(--brume); }

/* Couverture et sommaire */
.couv { display: grid; gap: 2rem; padding-block: 2.5rem 1rem; }
@media (min-width: 52rem) { .couv { grid-template-columns: minmax(0, 24rem) minmax(0, 1fr); align-items: center; gap: 3rem; } }
.couv-img { margin: 0 auto; width: 100%; max-width: 24rem; border-radius: 3px; overflow: hidden; box-shadow: 0 30px 60px -25px rgba(0,0,0,.8); background: var(--papier); }
.couv-img img { width: 100%; aspect-ratio: 3 / 4; height: auto; object-fit: cover; display: block; }
.couv-img .titre-couv { padding: 1rem 1.2rem 1.2rem; text-align: center; color: var(--encre); border-top: 3px solid #c98a2e; }
.titre-couv .sur { display: block; font-family: var(--f-etiq); font-size: .76rem; letter-spacing: .14em; text-transform: lowercase; color: #5c6677; }
.titre-couv .t { display: block; font-family: var(--f-titre); font-size: 2rem; line-height: 1.05; margin-top: .35rem; }
.titre-couv .st { display: block; font-family: var(--f-titre); font-style: italic; font-size: 1.1rem; margin-top: .3rem; color: #8a5a14; }
.couv-txt { display: grid; gap: 1rem; min-width: 0; }
.couv-txt h1 { font-family: var(--f-titre); font-weight: 400; font-size: clamp(2.2rem, 8vw, 3.4rem); line-height: 1.02; margin: 0; text-wrap: balance; }
.couv-txt .chapeau { font-size: 1.2rem; margin: 0; }
.couv-txt .conseil { font-style: italic; color: var(--brume); margin: 0; }
.bouton { display: inline-flex; align-items: center; gap: .5rem; justify-self: start; background: var(--or); color: #1a1204; text-decoration: none; border-radius: 999px; padding: .7rem 1.2rem; font-family: var(--f-etiq); font-weight: 700; letter-spacing: .05em; font-size: .95rem; }
.bouton.second { background: transparent; color: var(--texte); border: 1px solid var(--trait); }
.boutons { display: flex; flex-wrap: wrap; gap: .7rem; }
.sommaire { margin-top: 2.5rem; }
.sommaire h2 { font-family: var(--f-etiq); font-weight: 700; font-size: .9rem; letter-spacing: .1em; text-transform: lowercase; color: var(--brume); margin: 0 0 .8rem; }
.sommaire ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--trait); }
.sommaire li a { display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto; gap: .8rem; align-items: baseline; padding: .8rem 0; border-bottom: 1px solid var(--trait); text-decoration: none; }
.sommaire .num { font-family: var(--f-titre); font-size: 1.5rem; color: var(--or); font-variant-numeric: tabular-nums; }
.sommaire .ti { font-family: var(--f-titre); font-size: 1.3rem; line-height: 1.2; }
.sommaire .du { font-family: var(--f-etiq); font-size: .8rem; letter-spacing: .05em; color: var(--brume); white-space: nowrap; }
.sommaire li a:hover .ti { color: var(--or); }
.sommaire li.lu .num::after { content: " ✓"; font-size: .8rem; }

/* Coulisses */
.tableau { overflow-x: auto; margin-block: 1rem 2rem; }
.tableau table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.tableau th, .tableau td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--trait); vertical-align: top; }
.tableau th { font-family: var(--f-etiq); font-weight: 700; font-size: .8rem; letter-spacing: .06em; text-transform: lowercase; color: var(--brume); }
.tableau td:first-child { font-weight: 600; width: 45%; }
.coulisses h2 { font-family: var(--f-titre); font-weight: 400; font-size: 1.7rem; margin: 2.2rem 0 .6rem; }
.coulisses p { margin: 0 0 1rem; }
.coulisses ul { margin: 0 0 1rem; padding-left: 1.2rem; display: grid; gap: .5rem; }

/* Reprendre la lecture */
.reprendre { position: fixed; z-index: 12; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); background: var(--or); color: #1a1204; border: 0; border-radius: 999px; padding: .65rem 1.1rem; font-family: var(--f-etiq); font-weight: 700; letter-spacing: .05em; font-size: .88rem; cursor: pointer; box-shadow: 0 8px 20px -8px rgba(0,0,0,.6); max-width: calc(100% - 32px); }

@media (prefers-reduced-motion: reduce) { .progres span { transition: none; } }

a.etiq { text-decoration: none; }
a.etiq:hover { color: var(--texte); }
.retour-haut { display: inline-block; margin-top: 1.6rem; }

/* ---- Fonds d'attente : une image pas encore arrivée laisse voir la nuit, pas un trou ---- */
.planche img, .case img, .marge img, .couv-img img { background: linear-gradient(160deg, #152338, #0b1320 70%); }

/* ---- Barre de lecture (chapitres) : réapparaît quand on remonte ---- */
.barre-lecture { position: fixed; z-index: 11; left: 0; right: 0; top: env(safe-area-inset-top, 0px); display: flex; align-items: center; gap: .8rem;
  padding: .55rem max(16px, env(safe-area-inset-right, 0px)) .55rem max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--nuit) 92%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--trait); transform: translateY(-110%); transition: transform .25s ease; }
.barre-lecture.visible { transform: none; }
.bl-sommaire { font-family: var(--f-etiq); font-weight: 700; font-size: .82rem; letter-spacing: .05em; text-decoration: none; color: var(--or); white-space: nowrap; padding: .35rem 0; }
.bl-titre { flex: 1; min-width: 0; font-family: var(--f-titre); font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--brume); }
.bl-reglages { display: flex; gap: .35rem; }
.bl-bouton { min-width: 2.4rem; height: 2.2rem; border-radius: 999px; border: 1px solid var(--trait); background: transparent; color: var(--texte); font-family: var(--f-titre); font-size: 1.05rem; cursor: pointer; }
.bl-bouton:hover { border-color: var(--or); color: var(--or); }
.progres { z-index: 12; }

/* ---- Pied de chapitre : gros boutons faciles à toucher ---- */
.nav a { flex: 1 1 12rem; max-width: none; border: 1px solid var(--trait); border-radius: 4px; padding: .7rem .9rem; }
.nav a:hover { border-color: var(--or); }
.partager { justify-self: start; background: transparent; color: var(--texte); border: 1px solid var(--trait); border-radius: 999px; padding: .6rem 1.1rem; font-family: var(--f-etiq); font-weight: 700; letter-spacing: .05em; font-size: .88rem; cursor: pointer; }
.partager:hover { border-color: var(--or); color: var(--or); }

/* ---- Visionneuse : toucher une image pour l'agrandir ---- */
.agrandissable { cursor: zoom-in; }
.visionneuse { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; margin: 0; }
.visionneuse::backdrop { background: rgba(4, 8, 16, .92); }
.visionneuse figure { margin: 0; height: 100%; display: grid; place-content: center; gap: .8rem; padding: 3.5rem max(12px, env(safe-area-inset-right, 0px)) 2rem max(12px, env(safe-area-inset-left, 0px)); cursor: zoom-out; }
.visionneuse img { max-width: min(96vw, 1400px); max-height: 80vh; width: auto; height: auto; margin: 0 auto; border-radius: 3px; }
.visionneuse figcaption { max-width: 40rem; margin: 0 auto; text-align: center; color: #ece0c8; font-family: var(--f-texte); font-size: 1.05rem; }
.visionneuse .fermer { position: fixed; top: calc(.8rem + env(safe-area-inset-top, 0px)); right: calc(.8rem + env(safe-area-inset-right, 0px)); width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 1px solid rgba(236,224,200,.35); background: transparent; color: #ece0c8; font-size: 1.6rem; line-height: 1; cursor: pointer; }

/* ---- Couverture du livre : compteur de lecture ---- */
.compteur { font-family: var(--f-etiq); font-size: .82rem; letter-spacing: .05em; color: var(--or); }
@media (prefers-reduced-motion: reduce) { .barre-lecture { transition: none; } }
