/* ============================================================
   Lecteur du livre — texte blanc sur fond noir.

   Le livre était lu jusqu'ici sous forme d'images de pages scannées : blanc
   éclatant, texte fixe, illisible sur un téléphone. En texte, la page se plie
   à l'écran et au lecteur : taille de police, fond noir reposant le soir,
   coupure des mots. C'est le même livre, débarrassé du papier.
   ============================================================ */
*{box-sizing:border-box;margin:0;padding:0}

html,body{height:100%}
body{
  background:#000;color:#e9e4da;
  font:16px/1.6 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  overflow:hidden;                      /* c'est #texte qui défile, pas la page */
  -webkit-text-size-adjust:100%;
}

/* ---------- attente et refus ---------- */
#attente{position:fixed;inset:0;display:grid;place-items:center}
#attente span{width:30px;height:30px;border:3px solid #2a2a2a;border-top-color:#c8a45c;
  border-radius:50%;animation:tourne .9s linear infinite}
@keyframes tourne{to{transform:rotate(360deg)}}
#attente[hidden]{display:none}

#cadenas{max-width:460px;margin:14vh auto 0;text-align:center;
  background:#12100c;border:1px solid #3a3222;border-radius:16px;padding:28px 24px;color:#e8dcc0}
#cadenas[hidden]{display:none}
#cadenas .ic{font-size:44px;margin-bottom:12px}
#cadenas h2{font-size:19px;color:#e6c67a;margin-bottom:8px}
#cadenas p{font-size:14px;line-height:1.6;margin-bottom:18px;color:#c9c0ae}
#cadenas a{display:inline-block;font-size:14px;font-weight:700;color:#171308;
  background:#e6c67a;border-radius:10px;padding:10px 18px;text-decoration:none}

/* ---------- charpente ---------- */
#lecteur{position:fixed;inset:0;display:flex;flex-direction:column}
#lecteur[hidden]{display:none}

#haut,#bas{flex:0 0 auto;display:flex;align-items:center;gap:10px;
  padding:9px calc(12px + env(safe-area-inset-left)) 9px calc(12px + env(safe-area-inset-right));
  background:#0a0a0b;border-color:#1c1c20;border-style:solid;border-width:0}
#haut{border-bottom-width:1px}
#bas{border-top-width:1px;padding-bottom:calc(9px + env(safe-area-inset-bottom))}

#haut .gauche,#haut .droite{display:flex;gap:6px;align-items:center;flex:0 0 auto}
#haut .milieu{flex:1 1 auto;min-width:0;text-align:center;line-height:1.25}
#haut .milieu b{display:block;font-size:14px;color:#e6c67a;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#haut .milieu span{display:block;font-size:11.5px;color:#8e8778;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

button,.lien{font:600 13px/1 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  color:#d8d2c6;background:#16161a;border:1px solid #2a2a30;border-radius:9px;
  padding:9px 11px;cursor:pointer;text-decoration:none;white-space:nowrap}
button:hover,.lien:hover{background:#22222a;border-color:#3c3c46}
button:disabled{opacity:.3;cursor:default}
button:disabled:hover{background:#16161a;border-color:#2a2a30}

/* ---------- le texte ---------- */
#texte{
  flex:1 1 auto;overflow-y:auto;overscroll-behavior:contain;
  padding:min(6vh,42px) 20px min(9vh,64px);
  font-family:Georgia,"Times New Roman",serif;
  font-size:var(--taille,18px);
  line-height:1.78;
  text-align:justify;
  hyphens:auto;                         /* sans coupure, le justifié creuse des rivières */
  -webkit-hyphens:auto;
  scroll-behavior:smooth;
}
#texte > div{max-width:38em;margin:0 auto}
#texte p{margin:0 0 1.05em;text-indent:1.5em}
/* Le premier paragraphe d'une page ne s'indente pas : rien ne le précède. */
#texte p:first-child{text-indent:0}
/* En-tête de chapitre : c'est le seul élément qui change de ton, il annonce
   une rupture dans la lecture. */
#texte h2{font-size:1.05em;letter-spacing:.06em;color:#e6c67a;font-weight:700;
  text-align:center;text-indent:0;margin:.2em 0 1.9em;line-height:1.5}
#texte .dial{text-indent:0;padding-left:1.4em;text-indent:-1.4em}

/* ---------- bas de page ---------- */
#bas button{min-width:104px}
#bas .centre{flex:1 1 auto;text-align:center;line-height:1.3}
#pos{display:block;font-size:13px;color:#cdc6b8;font-variant-numeric:tabular-nums}
#orig{display:block;font-size:11px;color:#6f6a5e}

/* ---------- message passager ---------- */
#toast{position:fixed;left:50%;bottom:86px;transform:translateX(-50%) translateY(12px);
  background:#1c1a14;border:1px solid #3a3222;color:#e8dcc0;border-radius:10px;
  padding:10px 16px;font-size:13px;opacity:0;pointer-events:none;
  transition:opacity .2s ease,transform .2s ease;z-index:20}
#toast.on{opacity:1;transform:translateX(-50%) translateY(0)}

@media (max-width:640px){
  #haut .milieu span{display:none}      /* l'auteur passe à la trappe avant le titre */
  #bas button{min-width:0;padding:10px 14px}
  #texte{padding-left:16px;padding-right:16px}
}
@media (prefers-reduced-motion:reduce){
  #texte{scroll-behavior:auto}
  #attente span{animation-duration:2s}
}

/* ============================================================
   Couverture, signets et glossaire — ajoutés le 12/08/2026.
   ============================================================ */

/* ---------- la couverture ----------
   Elle prend la place du texte, jamais un écran de plus : on tourne la page
   et elle disparaît, comme un vrai livre qu'on ouvre. */
#portada{flex:1 1 auto;overflow-y:auto;display:flex;align-items:center;justify-content:center;
  padding:24px 20px}
#portada[hidden]{display:none}
.pbloc{max-width:520px;width:100%;text-align:center}
#pimg{display:block;width:100%;height:auto;border-radius:6px;
  box-shadow:0 18px 50px rgba(0,0,0,.8), 0 0 0 1px rgba(233,228,218,.12)}
#ptitre{margin:26px 0 6px;font:700 clamp(21px,4.6vw,31px)/1.2 Georgia,"Times New Roman",serif;
  letter-spacing:.01em;color:#e9e4da}
#pauteur{font-size:14px;color:#9d968a;letter-spacing:.06em;text-transform:uppercase}
.pboutons{margin-top:26px;display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
.pboutons button{font:700 14px/1 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  padding:13px 22px;border-radius:11px;border:1px solid #3a3222;background:#1c1a14;color:#e8dcc0}
.pboutons button:hover{background:#2a2620;border-color:#5a4e34}
#pcommencer{background:#e6c67a !important;color:#171308 !important;border-color:#e6c67a !important}
#pcommencer:hover{background:#f0d492 !important}

/* ---------- signets ---------- */
/* Le bouton dit d'un coup d'œil si la page porte déjà un signet : plein pour
   « posé », creux pour « à poser ». */
#signet.on{background:#3a2f16;border-color:#a98a3f;color:#ffd98a}
#signets{position:fixed;inset:0;z-index:30;background:rgba(0,0,0,.72);
  display:flex;align-items:center;justify-content:center;padding:20px}
#signets[hidden]{display:none}
.sbloc{width:100%;max-width:400px;max-height:70vh;overflow:auto;background:#14130f;
  border:1px solid #2f2a1e;border-radius:14px;padding:16px 18px}
.stete{display:flex;align-items:center;gap:10px;margin-bottom:12px}
.stete b{flex:1;font-size:15px;color:#e6c67a}
.stete button{padding:5px 11px;font-size:16px;line-height:1}
#sliste{display:flex;flex-direction:column;gap:7px}
#sliste button{width:100%;text-align:left;padding:11px 13px;font-weight:600}
#sliste .vide{color:#8a8478;font-size:13.5px;font-style:italic;line-height:1.6;
  font-family:Georgia,serif}

/* ---------- glossaire ---------- */
/* Un mot expliqué se signale par un souligné discontinu : assez visible pour
   qu'on sache qu'on peut cliquer, assez léger pour ne pas hacher la lecture. */
#texte .mot{border-bottom:1px dotted #b09a63;cursor:help;color:#f2e6c8}
#texte .mot:hover{border-bottom-style:solid;color:#ffe6a8}
#glosa{position:absolute;z-index:40;max-width:min(340px,86vw);max-height:66vh;overflow:auto;background:#181611;
  border:1px solid #4a412c;border-radius:12px;padding:13px 34px 13px 15px;
  box-shadow:0 16px 40px rgba(0,0,0,.75)}
#glosa[hidden]{display:none}
#glosa b{display:block;font-size:14px;color:#e6c67a;margin-bottom:5px}
#glosa p{font:14px/1.55 Georgia,"Times New Roman",serif;color:#ded7c9;text-align:left;
  text-indent:0;margin:0}
#glosaFerme{position:absolute;top:7px;right:7px;padding:3px 8px;font-size:15px;line-height:1;
  background:transparent;border-color:transparent;color:#8a8478}
#glosaFerme:hover{background:#26231a;border-color:#3a3427}
