/* ════════════════════════════════════════════════════════════════════════
   Liseuse v2 — readers.css : viewers AUDIO + CBZ (+ TXT/DOCX/DJVU)
   ────────────────────────────────────────────────────────────────────────
   « Bibliothèque de verre, pages de papier ». Uniquement des tokens :root
   de v2.css (var(--acc), --glass-*, --stroke, --r-*, --shadow-*, --display…).
   - Audio  : objet-livre en verre, pochette, gros bouton dégradé
   - CBZ    : planche centrée sur fond profond, HUD flottant
   - TXT/DOCX : héritent de .paper-page (déjà dans v2.css) + typo document
   - DJVU   : bloc de dégradation propre, centré
   ════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════ PLAYER AUDIO ═══════════════════════════ */
.audio-player {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: clamp(16px, 3vh, 30px);
  padding: clamp(18px, 4vh, 44px) 20px;
  overflow-y: auto;
  text-align: center;
}

/* pochette */
.audio-cover {
  position: relative; flex-shrink: 0;
  width: min(46vh, 320px); aspect-ratio: 1 / 1; max-width: 86vw;
  border-radius: var(--r-l); overflow: hidden;
  background: linear-gradient(155deg, #4c3a86, #232047 72%);
  box-shadow: var(--shadow-3), 0 24px 60px rgba(139, 92, 246, .2);
  display: grid; place-items: center;
}
.audio-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.audio-cover__ph {
  position: absolute; inset: 0; display: grid; place-items: center;
}
.audio-cover.has-img .audio-cover__ph { display: none; }
/* disque vinyle stylisé (repli quand pas de pochette) */
.audio-cover__disc {
  width: 42%; aspect-ratio: 1; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.9) 0 8%, transparent 8.5%),
    repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,.05) 0 3px, rgba(0,0,0,.14) 3px 6px);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.12), var(--shadow-2);
}
/* rotation lente pendant la lecture (coupée si mouvement réduit) */
.audio-player.is-playing .audio-cover__disc { animation: audioSpin 8s linear infinite; }
@keyframes audioSpin { to { transform: rotate(360deg); } }

/* méta */
.audio-meta { max-width: 640px; }
.audio-title {
  font-family: var(--display); font-weight: 600; font-size: clamp(21px, 3.4vw, 30px);
  line-height: 1.2; margin: 0; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.audio-author { margin: 8px 0 0; color: var(--text-2); font-size: 15px; }

/* barre de progression cliquable */
.audio-scrub { width: min(560px, 92vw); }
.audio-bar {
  position: relative; height: 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .1); cursor: pointer;
  touch-action: none; /* le pointer-capture gère le drag */
  margin: 6px 0;
}
.audio-bar::before { /* zone tactile élargie (≥ 44 px de haut) sans agrandir le visuel */
  content: ''; position: absolute; left: 0; right: 0; top: -18px; bottom: -18px;
}
.audio-bar__buffered {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: rgba(255, 255, 255, .14); border-radius: 999px;
}
.audio-bar__fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: var(--grad-acc); border-radius: 999px;
}
.audio-bar__knob {
  position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-1), 0 0 0 4px rgba(139, 92, 246, .28);
  transition: transform .12s var(--spring);
}
.audio-bar:hover .audio-bar__knob, .audio-bar:focus-visible .audio-bar__knob { transform: translate(-50%, -50%) scale(1.18); }
.audio-bar:focus-visible { outline: 2px solid var(--acc); outline-offset: 6px; }

.audio-times {
  display: flex; justify-content: space-between;
  color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums;
}

/* commandes centrales */
.audio-controls {
  display: flex; align-items: center; justify-content: center; gap: clamp(18px, 5vw, 34px);
}
.audio-skip {
  position: relative;
  width: 54px; height: 54px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--glass-2); border: 1px solid var(--stroke); color: var(--text-2);
  transition: all .2s var(--ease);
}
.audio-skip:hover { color: var(--text); border-color: var(--stroke-lit); transform: translateY(-1px); background: var(--glass-3); }
.audio-skip:active { transform: scale(.94); }
.audio-skip svg { width: 26px; height: 26px; }
.audio-skip__n {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 9.5px; font-weight: 800; color: var(--text-3); pointer-events: none;
  padding-top: 1px;
}
.audio-skip:hover .audio-skip__n { color: var(--text-2); }

.audio-play {
  width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad-acc); color: #fff; border: 0;
  box-shadow: var(--shadow-acc), var(--shadow-2);
  transition: transform .18s var(--spring), filter .18s var(--ease);
}
.audio-play:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.08); }
.audio-play:active { transform: scale(.96); }
.audio-play svg { width: 30px; height: 30px; }

/* vitesse + volume */
.audio-extra {
  display: flex; align-items: center; justify-content: center; gap: clamp(14px, 4vw, 30px);
  flex-wrap: wrap;
}
.audio-speed {
  display: inline-flex; gap: 3px; padding: 4px;
  background: rgba(0, 0, 0, .26); border: 1px solid var(--stroke); border-radius: 999px;
}
.audio-speed__btn {
  min-width: 44px; min-height: 34px; padding: 0 10px; border-radius: 999px;
  color: var(--text-2); font-weight: 600; font-size: 12.5px;
  font-variant-numeric: tabular-nums; transition: all .16s var(--ease);
}
.audio-speed__btn:hover { color: var(--text); }
.audio-speed__btn.is-active { background: var(--acc-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(139, 92, 246, .5); }

.audio-volume { display: inline-flex; align-items: center; gap: 8px; }
.audio-vol-btn { width: 40px; height: 40px; }
.audio-vol-btn svg { width: 20px; height: 20px; }
.audio-vol-range {
  -webkit-appearance: none; appearance: none;
  width: 108px; height: 6px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); cursor: pointer;
}
.audio-vol-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-1), 0 0 0 3px rgba(139, 92, 246, .25);
}
.audio-vol-range::-moz-range-thumb {
  width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-1), 0 0 0 3px rgba(139, 92, 246, .25);
}
.audio-vol-range:focus-visible { outline: 2px solid var(--acc); outline-offset: 4px; }

/* ═══════════════════════════ VIEWER CBZ / BD ═══════════════════════════ */
.cbz-host {
  position: absolute; inset: 14px 14px 76px;
  display: grid; place-items: center;
  overflow: auto; background: var(--bg-deep);
  border-radius: var(--r-m);
}
.cbz-img {
  display: block; max-width: 100%; max-height: 100%;
  width: auto; height: auto; object-fit: contain;
  border-radius: 6px; box-shadow: var(--shadow-3);
  background: #fff;
}
/* HUD flottant (reprend le langage du .pdf-hud) */
.cbz-hud {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px; padding: 7px 12px;
  background: var(--glass-3); backdrop-filter: var(--blur-3); -webkit-backdrop-filter: var(--blur-3);
  border: 1px solid var(--stroke); border-radius: 999px; box-shadow: var(--shadow-2);
  font-size: 13px; color: var(--text-2); z-index: 6; white-space: nowrap;
}
.cbz-hud .iconbtn { width: 40px; height: 40px; }
.cbz-hud__page {
  width: 56px; min-height: 40px; text-align: center;
  background: rgba(0, 0, 0, .3); border: 1px solid var(--stroke); border-radius: 9px;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.cbz-hud__count { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ═══════════════════════ DOCUMENT TXT / DOCX ═══════════════════════ */
/* .paper-page (fond papier, scroll, typo serif) est défini dans v2.css. */
.doc-page { scrollbar-width: thin; }
.doc-page p { margin: 0 0 1.1em; }
.doc-page h1, .doc-page h2, .doc-page h3, .doc-page h4 {
  font-family: var(--display); font-weight: 600; line-height: 1.25;
  margin: 1.5em 0 .5em;
}
.doc-page h1 { font-size: 1.7em; }
.doc-page h2 { font-size: 1.4em; }
.doc-page h3 { font-size: 1.18em; }
.doc-page a { color: #6d28d9; text-decoration: underline; }
body[data-reader-theme="sombre"] .doc-page a { color: var(--acc-3); }
.doc-page ul, .doc-page ol { margin: 0 0 1.1em; padding-left: 1.5em; }
.doc-page li { margin-bottom: .35em; }
.doc-page blockquote {
  margin: 1.2em 0; padding: .2em 0 .2em 1em;
  border-left: 3px solid rgba(139, 92, 246, .5);
  color: var(--paper-muted); font-style: italic;
}
body[data-reader-theme="sombre"] .doc-page blockquote { color: var(--text-2); }
.doc-page img { max-width: 100%; height: auto; border-radius: 6px; margin: .6em 0; }
.doc-page table { border-collapse: collapse; width: 100%; margin: 1.1em 0; font-size: .94em; }
.doc-page th, .doc-page td { border: 1px solid rgba(0, 0, 0, .15); padding: 6px 10px; text-align: left; }
body[data-reader-theme="sombre"] .doc-page th, body[data-reader-theme="sombre"] .doc-page td { border-color: rgba(255, 255, 255, .14); }
.doc-page pre {
  white-space: pre-wrap; word-break: break-word;
  background: rgba(0, 0, 0, .06); border-radius: var(--r-s); padding: 12px 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9em; margin: 1.1em 0;
}
body[data-reader-theme="sombre"] .doc-page pre { background: rgba(255, 255, 255, .06); }
.doc-empty { color: var(--paper-muted); font-style: italic; text-align: center; }
body[data-reader-theme="sombre"] .doc-empty { color: var(--text-3); }

/* ═══════════════════════ DÉGRADATION (DJVU…) ═══════════════════════ */
.format-fallback {
  position: absolute; inset: 14px; margin: auto;
  max-width: 460px; height: fit-content;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px;
  padding: 40px 32px;
  background: var(--glass-3); backdrop-filter: var(--blur-3); -webkit-backdrop-filter: var(--blur-3);
  border: 1px solid var(--stroke-lit); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
}
.format-fallback__icon {
  width: 66px; height: 66px; border-radius: 20px; display: grid; place-items: center;
  background: var(--acc-soft); border: 1px solid rgba(139, 92, 246, .3); color: var(--acc);
}
.format-fallback__icon svg { width: 30px; height: 30px; }
.format-fallback__title { font-family: var(--display); font-weight: 600; font-size: 22px; margin: 0; }
.format-fallback__msg { color: var(--text-2); font-size: 14.5px; line-height: 1.6; margin: 0; }
.format-fallback__dl { margin-top: 6px; }
.format-fallback__dl svg { width: 18px; height: 18px; }

/* ═══════════════════════════ RESPONSIVE ═══════════════════════════ */
@media (max-width: 640px) {
  .audio-player { justify-content: flex-start; gap: 18px; padding-top: 24px; }
  .audio-cover { width: min(58vw, 240px); }
  .audio-controls { gap: 22px; }
  .cbz-host { inset: 8px 8px 84px; }
  .cbz-hud { left: 8px; right: 8px; transform: none; justify-content: center; border-radius: 20px; }
}

/* mouvement réduit : pas de rotation de pochette (le global gère déjà les durées) */
@media (prefers-reduced-motion: reduce) {
  .audio-player.is-playing .audio-cover__disc { animation: none; }
}
