/* ============================================================================
   web.css — l'habillage du livre feuilletable. Ne touche JAMAIS à la page
   elle-même (c'est book.css qui la définit, à l'identique du PDF) : ici on ne
   fait que le meuble autour — barre, pilotage, sommaire, ombre du livre.
   ========================================================================== */

:root {
  --fond-app: #EDE3D0;
  --fond-app-creux: #E4D7C0;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--fond-app);
  color: var(--encre);
  font-family: var(--font-texte, Georgia, serif);
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
  overflow: hidden;
}

/* --------------------------------------------------------------- barre --- */

.barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(0.8rem, 3vw, 1.6rem);
  background: color-mix(in srgb, var(--fond-app) 70%, var(--papier-creuse));
  border-bottom: 1px solid color-mix(in srgb, var(--encre) 12%, transparent);
}

.barre__titre {
  font-family: var(--font-titre, Georgia, serif);
  font-size: clamp(0.95rem, 2.4vw, 1.25rem);
  color: var(--indigo);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.barre__actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.btn {
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--indigo) 30%, transparent);
  background: transparent;
  color: var(--indigo);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn:hover { background: color-mix(in srgb, var(--indigo) 10%, transparent); }
.btn:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

.btn--pdf { background: var(--indigo); color: var(--papier); border-color: var(--indigo); }
.btn--pdf:hover { background: var(--indigo-clair); }

/* --------------------------------------------------------------- livre --- */

.livre {
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 2vw, 1.5rem);
  overflow: hidden;
  outline: none;
}

.planche {
  --page-size: min(86vw, calc(100dvh - 11rem));
  display: flex;
  gap: 0;
  filter: drop-shadow(0 1.2rem 2.5rem rgba(42, 33, 24, 0.28));
  transition: none;
}

/* Double page : deux pages côte à côte, contraintes pour tenir dans la hauteur. */
.planche--double {
  --page-size: min(46vw, calc(100dvh - 11rem));
}

.page { display: none; }
.page.visible { display: block; }

/* La pliure centrale : un dégradé discret, pas une ligne dure. */
.planche--double .page.left {
  box-shadow: inset -0.6rem 0 1.1rem -0.7rem rgba(42, 33, 24, 0.4);
}
.planche--double .page:not(.left) {
  box-shadow: inset 0.6rem 0 1.1rem -0.7rem rgba(42, 33, 24, 0.4);
}

/* ------------------------------------------------------------- pilotage -- */

.pilote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.8rem, 4vw, 2rem);
  padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--fond-app) 70%, var(--papier-creuse));
  border-top: 1px solid color-mix(in srgb, var(--encre) 12%, transparent);
}

.pilote__fleche {
  cursor: pointer;
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--indigo) 25%, transparent);
  background: transparent;
  color: var(--indigo);
  transition: background 0.15s ease, opacity 0.15s ease;
}
.pilote__fleche:hover:not(:disabled) { background: color-mix(in srgb, var(--indigo) 12%, transparent); }
.pilote__fleche:disabled { opacity: 0.28; cursor: default; }
.pilote__fleche:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

.pilote__compteur {
  font-size: 0.85rem;
  color: var(--encre-douce);
  letter-spacing: 0.03em;
  min-width: 11rem;
  text-align: center;
}

/* ------------------------------------------------------------- sommaire -- */

.sommaire {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  padding: clamp(1.5rem, 6vw, 4rem);
  background: color-mix(in srgb, var(--fond-app) 96%, var(--papier-creuse));
}
.sommaire[hidden] { display: none; }

.sommaire h2 {
  font-family: var(--font-titre, Georgia, serif);
  color: var(--indigo);
  margin: 0 0 1.5rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.sommaire ul { list-style: none; margin: 0 auto; padding: 0; max-width: 44rem; }

.sommaire button {
  cursor: pointer;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0.5rem;
  font: inherit;
  font-size: 1rem;
  text-align: left;
  color: var(--encre);
  background: transparent;
  border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--encre) 12%, transparent);
}
.sommaire button:hover { background: color-mix(in srgb, var(--indigo) 7%, transparent); }
.sommaire button span { color: var(--encre-douce); font-size: 0.85rem; }

/* -------------------------------------------------------------- mobile --- */

@media (max-width: 899px) {
  .planche { --page-size: min(92vw, calc(100dvh - 10rem)); }
  .pilote__compteur { min-width: 8rem; font-size: 0.78rem; }
  .barre__titre { font-size: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Le bouton annonce le poids réel du fichier : télécharger 129 Mo sans le savoir,
   sur un téléphone, c'est une mauvaise surprise. */
.btn__detail { opacity: 0.75; font-size: 0.9em; }

/* --------------------------------------------------- petits écrans -------- */
/* Sur un téléphone, « Sommaire » + « PDF prêt à imprimer · 123 Mo » + le titre
   font 441 px de large pour 390 px d'écran : la barre déborde et décale toute
   la page. Le titre est déjà sur la couverture, et le poids du fichier n'a pas
   à tenir dans la barre — on les retire là où la place manque. */
@media (max-width: 560px) {
  .barre__titre { display: none; }
  .btn__detail { display: none; }
  .barre { justify-content: flex-end; }
  .btn { font-size: 0.8rem; padding: 0.4rem 0.75rem; }
}

/* Garde-fou : rien ne doit pouvoir élargir la page au-delà de l'écran. */
html, body { max-width: 100%; overflow-x: hidden; }
.barre, .pilote { max-width: 100vw; }
.barre__actions { min-width: 0; flex-shrink: 1; }
