:root{
  --bg: #08070b;

  --paper: #e0c27d;
  --paper-2: #ead08f;

  --cover-base: #2a1d14;
  --cover-deep: #120b08;

  --gold-1: rgba(210, 170, 80, .95);
  --gold-2: rgba(255, 220, 150, .78);
  --gold-3: rgba(120, 80, 25, .85);

  /* Portrait (tu dis qu’il est parfait: on touche plus) */
  --portrait-scale: 1.75;
  --portrait-shift-y: -6px;

  --paperScale: 1;
}

*{ box-sizing: border-box; }
html, body { height: 100%; }

html{
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body{
  margin: 0;
  background:
    radial-gradient(1200px 700px at 50% 35%, rgba(90,60,140,.16), transparent 60%),
    radial-gradient(900px 600px at 60% 60%, rgba(0,0,0,.65), transparent 55%),
    var(--bg);
  overflow: hidden;
  user-select: none;
}

#stage{
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}

#book-wrap{
  width: min(1400px, 98vw);
  height: min(840px, 90vh);
  padding: 10px;
}

#book{ width: 100%; height: 100%; }
.page{ background: transparent; }

.page-inner{
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  overflow: hidden;
}

/* ---------------- Couvertures ---------------- */
.cover .page-inner{
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}

.cover-surface{
  background:
    radial-gradient(900px 620px at 40% 35%, rgba(255,255,255,.06), transparent 60%),
    radial-gradient(900px 720px at 78% 78%, rgba(0,0,0,.45), transparent 65%),
    linear-gradient(145deg, var(--cover-base), var(--cover-deep));
}

.front-cover .page-inner::before{
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.05),
    inset 10px 0 0 rgba(0,0,0,.30);
  pointer-events: none;
}

.back-cover .page-inner.back{
  background:
    radial-gradient(900px 720px at 50% 40%, rgba(255,255,255,.05), transparent 60%),
    radial-gradient(900px 720px at 70% 80%, rgba(0,0,0,.55), transparent 65%),
    linear-gradient(145deg, #24170f, #0f0907);
}

.back-ornament{
  position: absolute;
  inset: 22px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
  opacity: .55;
}

/* plaque dorée */
.plaque-wrap{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -155%);
  width: min(460px, 82%);
  pointer-events: none;
}

.plaque{
  height: 140px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.20), transparent 42%),
    linear-gradient(180deg, rgba(0,0,0,.35), transparent 45%),
    linear-gradient(120deg, var(--gold-1), var(--gold-2) 40%, var(--gold-3));
  box-shadow:
    0 12px 34px rgba(0,0,0,.60),
    inset 0 0 0 1px rgba(255,255,255,.22),
    inset 0 -12px 20px rgba(0,0,0,.32);
  position: relative;
}

.plaque-inner{
  position: absolute;
  inset: 10px;
  border-radius: 12px;
  background:
    radial-gradient(280px 110px at 30% 30%, rgba(255,255,255,.28), transparent 60%),
    linear-gradient(180deg, rgba(0,0,0,.18), transparent 55%);
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.25),
    inset 0 0 16px rgba(255,255,255,.10);
}

.plaque-text{
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: .10em;
  color: rgba(30,18,8,.92);
  text-shadow:
    0 1px 0 rgba(255,255,255,.22),
    0 -1px 0 rgba(0,0,0,.28);
}

/* intérieurs couverture */
.inner-cover .page-inner{
  background:
    radial-gradient(900px 620px at 40% 35%, rgba(255,255,255,.06), transparent 60%),
    radial-gradient(900px 720px at 78% 78%, rgba(0,0,0,.45), transparent 65%),
    linear-gradient(145deg, #2a1d14, #130c09);
}

/* ---------------- Papier ---------------- */
.paper .page-inner{
    padding:
    clamp(44px, calc(56px * var(--paperScale)), 56px)
    clamp(42px, calc(54px * var(--paperScale)), 54px)
    clamp(140px, calc(170px * var(--paperScale)), 170px); /* marge basse + safe numéro */
  user-select: text;

  color: #120b08;
  font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(12.5px, calc(15px * var(--paperScale)), 15px);
  line-height: 1.52;

  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='700' height='1000'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' seed='7'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E"),
    radial-gradient(900px 700px at 30% 15%, rgba(255,255,255,.25), transparent 60%),
    radial-gradient(900px 800px at 80% 85%, rgba(0,0,0,.12), transparent 55%),
    linear-gradient(180deg, var(--paper-2), var(--paper));
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.10),
    inset 0 0 26px rgba(0,0,0,.12);
}

/* ---------------- Contenu ---------------- */
.sheet-title{
  margin: 0;
  text-align: center;
  font-size: 26px;
  letter-spacing: .04em;
}

.rule{
  height: 1px;
  width: 70%;
  margin: 10px auto 18px;
  background: rgba(0,0,0,.22);
}

.sheet p{
  margin: 0 0 12px;
  text-align: justify;
  text-indent: 1.4em;
}
.sheet p:first-of-type{ text-indent: 0; }

.sheet-section{
  margin: 6px 0 10px;
  font-size: 16px;
  letter-spacing: .02em;
  opacity: .95;
}

/* Sommaire */
.toc{
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 12px;
}
.toc li{
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 16px;
}
.toc-dots{
  border-bottom: 1px dotted rgba(0,0,0,.45);
  height: 0;
  transform: translateY(2px);
}
.toc-page{ font-weight: 700; }

/* Fiche portrait */
.meta{
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 22px;
}
.meta > div{
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
}
.meta dt{ font-weight: 700; opacity: .9; }
.meta dd{ margin: 0; }

/* ---------------- Numéros ROMAINS ---------------- */
.page-number{
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .14em;
  color: #000;
  z-index: 50;
  pointer-events: none;
  background: rgba(255,255,255,.22);
  padding: 3px 10px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.10);
}

/* ---------------- Portrait final ---------------- */
.p-portrait .page-inner{
  padding: 56px 54px 170px;
}

.portrait-frame{
  width: 100%;
  height: calc(100% - 96px);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.portrait-img{
  width: min(640px, 92%);
  height: auto;
  max-height: 100%;
  object-fit: contain;
  transform: translateY(var(--portrait-shift-y)) scale(var(--portrait-scale));
  transform-origin: 50% 45%;
}

/* Bouton audio */
.audio-btn{
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 9999;

  width: 44px;
  height: 44px;
  border-radius: 12px;

  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.40);
  color: rgba(255,255,255,.85);
  cursor: pointer;

  backdrop-filter: blur(6px);
}

.audio-btn:hover{ background: rgba(0,0,0,.55); }
