/**
 * Dowin — liseuse EPUB (1.168.0).
 *
 * <p>La fenêtre de lecture suit le modèle des autres fenêtres de l'application
 * (`.modal`, ici `wide`) et n'ajoute que la surface de lecture. Sur 369 px de
 * large, la barre de navigation passe sur deux lignes si besoin ; les boutons
 * gardent une cible tactile de 40 px minimum. Seule la zone `.epub__corps`
 * défile : l'en-tête et la barre restent visibles pendant la lecture.</p>
 *
 * <p>Les couleurs viennent d'`app.css` (`--green`, `--panel`, `--panel-2`,
 * `--text`, `--border`, `--text-meta`) : le thème sombre et la couleur d'accent
 * choisie par l'utilisateur suivent sans règle supplémentaire.</p>
 */

/* -------------------------------- Fenêtre --------------------------------- */

.epub .modal__body {
  display: flex;
  min-height: 0;
  padding: 10px 12px 12px;
  overflow: hidden;
}

.epub__lecteur {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

/* -------------------------------- En-tête --------------------------------- */

.epub__entete {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.epub__titre {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.epub__auteur {
  margin: 0;
  color: var(--text-meta, var(--muted, #6b7280));
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* --------------------------------- Barre ---------------------------------- */

.epub__barre {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.epub__sommaire-btn,
.epub__precedent,
.epub__suivant,
.epub__taille {
  min-width: 40px;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.epub__sommaire-btn {
  flex: 0 1 auto;
}

.epub__precedent,
.epub__suivant {
  flex: 0 0 auto;
}

/*
 * La taille courante s'affiche dans le bouton lui-même : le cycle se comprend
 * sans libellé supplémentaire, et le bouton reste lisible à 369 px.
 */
.epub__taille {
  flex: 0 0 auto;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.epub__taille[data-taille='grand'] {
  font-size: 14px;
}

.epub__taille[data-taille='tresgrand'] {
  font-size: 15px;
  font-weight: 600;
}

.epub__position {
  flex: 1 1 auto;
  min-width: 76px;
  color: var(--text-meta, var(--muted, #6b7280));
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.epub__barre button:hover:not(:disabled) {
  background: var(--hover, var(--panel-3));
}

.epub__barre button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.epub__barre button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ------------------------------- Sommaire --------------------------------- */

.epub__sommaire {
  max-height: min(40vh, 320px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

.epub__sommaire-item {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.epub__sommaire-item:last-child {
  border-bottom: 0;
}

.epub__sommaire-item:hover {
  background: var(--hover, var(--panel-3));
}

.epub__sommaire-item:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: -2px;
}

.epub__sommaire-item.is-actif {
  color: var(--green);
  font-weight: 600;
  background: color-mix(in srgb, var(--green) 9%, transparent);
}

/* -------------------------------- Lecture --------------------------------- */

.epub__corps {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  -webkit-overflow-scrolling: touch;
}

.epub__corps[data-taille='grand'] {
  font-size: 1.08rem;
}

.epub__corps[data-taille='tresgrand'] {
  font-size: 1.25rem;
}

.epub__corps:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: -2px;
}

.epub__bloc {
  margin: 0 0 0.9em;
}

.epub__bloc:last-child {
  margin-bottom: 0;
}

.epub__bloc--titre {
  margin: 1.2em 0 0.5em;
  font-size: 1.12em;
  font-weight: 700;
  line-height: 1.3;
}

.epub__bloc--titre:first-child {
  margin-top: 0;
}

/* -------------------------- Chargement et erreur -------------------------- */

.epub__chargement {
  margin: 0;
  padding: 28px 8px;
  color: var(--text-meta, var(--muted, #6b7280));
  font-size: 13px;
  text-align: center;
}

.epub__erreur {
  margin: 0;
  padding: 18px 8px;
  color: var(--text-meta, var(--muted, #6b7280));
  font-size: 13px;
  line-height: 1.5;
}

.epub__note {
  margin: 0;
  color: var(--text-meta, var(--muted, #6b7280));
  font-size: 11.5px;
  line-height: 1.45;
}

/* ----------------------------- Grands écrans ------------------------------ */

@media (min-width: 480px) {
  .epub .modal__body {
    padding: 14px 16px 16px;
  }

  .epub__sommaire {
    max-height: min(42vh, 360px);
  }

  .epub__corps {
    padding: 16px 20px;
  }
}
