/* ─────────────────────────────────────────────────────────────
   « L'enfant qui entendait la mémoire des objets »
   Lecteur web — habillage façon vieux livre illustré, chaleureux.
   ───────────────────────────────────────────────────────────── */

:root {
  --paper:      #f7efe0;
  --paper-2:    #f0e5d1;
  --paper-edge: #e6d8bd;
  --ink:        #3c3126;
  --ink-soft:   #6f6150;
  --gold:       #b3863a;
  --gold-deep:  #936922;
  --dusk:       #3a4a63;
  --bg:         #211c16;
  --bg-2:       #2d2618;
  --turn-ms:    720ms;

  --serif-display: 'Cormorant Garamond', Cormorant, Georgia, 'Times New Roman', serif;
  --serif-body:    'EB Garamond', Garamond, Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(120% 120% at 50% 35%, var(--bg-2) 0%, var(--bg) 60%, #161208 100%);
  color: var(--ink);
  font-family: var(--serif-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Écran d'accueil ─────────────────────────────────────────── */
.splash {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 120% at 50% 40%, var(--bg-2) 0%, var(--bg) 70%, #14110a 100%);
  transition: opacity .7s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; color: #f3e9d6; padding: 2rem; }
.splash-mark { font-size: 2.4rem; color: var(--gold); opacity: .9; margin-bottom: 1.2rem; }
.splash-title {
  font-family: var(--serif-display);
  font-weight: 500; font-size: clamp(1.7rem, 4.5vw, 3rem);
  line-height: 1.15; margin: 0; letter-spacing: .01em;
}
.splash-sub {
  font-family: var(--serif-display); font-style: italic;
  color: var(--gold); font-size: clamp(1rem, 2.4vw, 1.4rem);
  margin: .6rem 0 2rem; letter-spacing: .12em;
}
.splash-load { width: 180px; height: 2px; margin: 0 auto; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; }
.splash-load span { display: block; height: 100%; width: 40%; background: var(--gold); animation: load 1.1s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-120%); } 100% { transform: translateX(360%); } }

/* ── Scène & livre ───────────────────────────────────────────── */
.app { position: fixed; inset: 0; display: grid; place-items: center; }

.stage {
  position: relative;
  width: min(94vw, 1180px);
  aspect-ratio: 8 / 5;
  max-height: 86vh;
  perspective: 2400px;
}

.book {
  position: absolute; inset: 0;
  display: flex;
  border-radius: 6px;
  box-shadow:
    0 30px 70px rgba(0,0,0,.55),
    0 6px 18px rgba(0,0,0,.4);
  background: var(--paper);
  overflow: hidden;
}

/* Les deux pages d'une double-page */
.page {
  position: relative;
  width: 50%; height: 100%;
  background: var(--paper);
  overflow: hidden;
}
.page-left  { border-right: 1px solid rgba(120,90,40,.10); }
/* Ombre de reliure (pli central) */
.book::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  width: 60px; transform: translateX(-50%); pointer-events: none; z-index: 4;
  background: linear-gradient(90deg,
    rgba(60,40,15,0) 0%, rgba(60,40,15,.12) 42%,
    rgba(60,40,15,.20) 50%, rgba(60,40,15,.12) 58%, rgba(60,40,15,0) 100%);
}

/* Texture papier discrète */
.page::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background:
    radial-gradient(140% 120% at 30% 20%, rgba(255,255,255,.35), rgba(255,255,255,0) 55%),
    radial-gradient(120% 120% at 80% 100%, rgba(120,90,40,.07), rgba(120,90,40,0) 60%);
}

/* ── Page illustration ───────────────────────────────────────── */
.illus { display: block; }
.illus img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
}
/* léger fondu vers le papier sur le bord intérieur */
.illus::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 60px rgba(40,28,10,.18);
}

/* Cadre d'attente quand l'image n'est pas encore là */
.placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  background:
    radial-gradient(120% 100% at 50% 30%, #f3e6cd 0%, #ead7b4 70%, #e1c99e 100%);
  color: var(--gold-deep); padding: 2rem;
}
.placeholder .pm { font-size: 2rem; opacity: .65; margin-bottom: .6rem; }
.placeholder .pt { font-family: var(--serif-display); font-size: 1.3rem; font-style: italic; opacity: .85; }
.placeholder .ps { font-size: .82rem; letter-spacing: .12em; text-transform: uppercase; opacity: .55; margin-top: .8rem; }

/* ── Page texte ──────────────────────────────────────────────── */
.text {
  display: flex; flex-direction: column; justify-content: center;
  padding: clamp(1.1rem, 2.6vw, 2.4rem) clamp(1.4rem, 3.2vw, 3rem);
  overflow: hidden;
}
.text .chapitre {
  font-family: var(--serif-display); font-style: italic;
  color: var(--gold-deep); font-size: clamp(.95rem, 1.5vw, 1.2rem);
  letter-spacing: .04em; margin: 0 0 1rem;
}
.text .chapitre::before { content: "— "; color: var(--gold); }
.prose {
  font-size: 1.2rem; /* taille de départ — ajustée automatiquement par le lecteur */
  line-height: 1.66; color: var(--ink);
  max-width: 36ch;
}
.prose p { margin: 0 0 .85em; text-wrap: pretty; }
.prose p:last-child { margin-bottom: 0; }
.prose .dialogue { color: #4a3d2c; }
/* Lettrine sur le 1er paragraphe */
.prose.lettrine > p:first-of-type::first-letter {
  font-family: var(--serif-display); font-weight: 600;
  float: left; font-size: 3.4em; line-height: .82;
  padding: .04em .12em 0 0; color: var(--gold-deep);
}

/* ── Couverture (page unique, pleine) ────────────────────────── */
.book.is-cover, .book.is-end { }
.cover {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  text-align: center; color: #fff5e2;
  padding: clamp(1.6rem, 4vw, 3.4rem);
}
.cover .cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.cover .veil {
  position: absolute; inset: 0; z-index: 1;
  background:
    linear-gradient(180deg, rgba(20,14,6,.55) 0%, rgba(20,14,6,.05) 30%, rgba(20,14,6,.12) 62%, rgba(20,14,6,.72) 100%);
}
.cover.no-img { background: radial-gradient(120% 100% at 50% 30%, #2c3850 0%, #20283a 60%, #161b28 100%); }
.cover.no-img .veil { display: none; }
.cover > * { position: relative; z-index: 2; }
.cover .titre {
  font-family: var(--serif-display); font-weight: 600;
  font-size: clamp(1.8rem, 5vw, 3.6rem); line-height: 1.08;
  margin: .2em 0 0; text-shadow: 0 2px 18px rgba(0,0,0,.5);
  text-wrap: balance;
}
.cover .soustitre {
  font-family: var(--serif-display); font-style: italic; color: #f3d79a;
  font-size: clamp(1rem, 2.6vw, 1.6rem); letter-spacing: .14em; margin-top: .5em;
  text-shadow: 0 2px 14px rgba(0,0,0,.5);
}
.cover .auteur {
  font-size: clamp(.85rem, 1.8vw, 1.05rem); letter-spacing: .2em;
  text-transform: uppercase; opacity: .9; text-shadow: 0 2px 14px rgba(0,0,0,.6);
}
.cover .ouvrir {
  display: inline-flex; align-items: center; gap: .5em;
  font-family: var(--serif-body); font-size: 1rem; letter-spacing: .04em;
  color: #2a2114; background: rgba(243,215,154,.92);
  border: none; border-radius: 999px; padding: .7em 1.5em; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: transform .2s ease, background .2s ease;
}
.cover .ouvrir:hover { transform: translateY(-2px); background: #f6e0ad; }

/* ── Page de fin / colophon ──────────────────────────────────── */
.fin {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: clamp(1.6rem, 4vw, 3rem); background: var(--paper);
}
.fin .mot { font-family: var(--serif-display); font-style: italic; color: var(--gold-deep); font-size: clamp(1.6rem, 4vw, 2.6rem); }
.fin .dedicace { color: var(--ink-soft); font-size: 1.1rem; line-height: 1.6; margin: 1.6rem 0; max-width: 30ch; }
.fin .telecharger { display: flex; gap: .8rem; flex-wrap: wrap; justify-content: center; margin-top: 1rem; }
.fin .telecharger a {
  text-decoration: none; color: var(--ink); border: 1px solid rgba(120,90,40,.35);
  border-radius: 999px; padding: .55em 1.3em; font-size: .98rem; transition: background .2s ease;
}
.fin .telecharger a:hover { background: var(--paper-2); }
.fin .credit { margin-top: 2rem; font-size: .8rem; letter-spacing: .08em; color: var(--ink-soft); opacity: .8; }

/* ── La feuille qui tourne (deux faces, pivot reliure) ───────── */
.turner {
  position: absolute; inset: 0; z-index: 6;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
}
.turner.run { transition: transform var(--turn-ms) cubic-bezier(.4,.06,.3,1); }
.turner .face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  overflow: hidden; border-radius: 6px;
  box-shadow: 0 0 40px rgba(0,0,0,.3);
}
.turner .face.back { transform: rotateY(180deg); }
.turner .face .book { box-shadow: none; }
.turner .glow {
  position: absolute; inset: 0; pointer-events: none; border-radius: 6px;
  background: linear-gradient(90deg, rgba(0,0,0,.30), rgba(0,0,0,0) 35%);
  opacity: 0; transition: opacity var(--turn-ms) ease;
}
.turner.run .glow { opacity: .8; }

/* ── Commandes ───────────────────────────────────────────────── */
.nav {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 20;
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid rgba(243,233,214,.25);
  background: rgba(33,28,22,.5); color: #f3e9d6;
  font-size: 1.8rem; line-height: 1; cursor: pointer; backdrop-filter: blur(4px);
  transition: background .2s ease, opacity .3s ease;
}
.nav:hover { background: rgba(60,50,35,.8); }
.nav:disabled { opacity: .25; cursor: default; }
.nav-prev { left: max(1rem, 3vw); }
.nav-next { right: max(1rem, 3vw); }

.toolbar {
  position: fixed; bottom: max(1rem, 2.5vh); left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: .5rem;
  background: rgba(33,28,22,.55); border: 1px solid rgba(243,233,214,.18);
  padding: .4rem .6rem; border-radius: 999px; backdrop-filter: blur(6px);
}
.tool {
  display: inline-grid; place-items: center; min-width: 38px; height: 34px; padding: 0 .6rem;
  border: none; background: transparent; color: #efe4cf; cursor: pointer;
  font-family: var(--serif-body); font-size: .95rem; border-radius: 999px; text-decoration: none;
  transition: background .2s ease;
}
.tool:hover { background: rgba(243,233,214,.14); }
.counter { color: #d9cbb1; font-size: .9rem; letter-spacing: .08em; padding: 0 .6rem; min-width: 64px; text-align: center; }

/* ── Mobile : une seule colonne, illustration en haut, texte en bas ── */
@media (max-width: 760px), (orientation: portrait) {
  .stage { width: 96vw; aspect-ratio: auto; height: 86vh; max-height: none; }
  .book { flex-direction: column; }
  .book::after { display: none; }
  .page { width: 100%; }
  .page-left { border-right: none; }
  .illus { height: 46%; flex: 0 0 46%; }
  .text { height: 54%; flex: 1 1 auto; justify-content: flex-start; padding-top: 1.4rem; }
  .prose { max-width: none; }
  .nav { width: 46px; height: 46px; font-size: 1.5rem; }
  .nav-prev { left: .5rem; } .nav-next { right: .5rem; }
}

/* moins d'animation si l'utilisateur le demande */
@media (prefers-reduced-motion: reduce) {
  .turner.run { transition: none; }
}
