/* ============================================================
   Lecteur (manga + novel) — chargé par layout_reader.ejs à la place des CSS de page
   Sobre et sans distraction : fond noir, barre compacte masquée au défilement.
   ============================================================ */
.reader-body { background: #07060B; }
.reader-body .site-main { padding: 0; }

/* ── Barre ── */
.rbar {
  position: sticky; top: 0; z-index: var(--z-header);
  display: flex; align-items: center; gap: var(--s-2);
  height: 52px; padding: 0 var(--s-3);
  background: rgba(10, 8, 16, .94); border-bottom: 1px solid var(--line-soft);
  transition: transform var(--d) var(--ease);
}
.rbar.is-hidden { transform: translateY(-100%); }
.rbar__btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--r-2); color: var(--text-2);
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}
.rbar__btn:hover { background: var(--surface-2); color: var(--text); }
.rbar__btn[aria-expanded="true"] { background: var(--violet-tint); color: var(--violet); }
.rbar__btn.is-disabled { opacity: .3; pointer-events: none; }
.rbar__title { display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; flex: 1; font-family: var(--font-body); font-size: var(--fs-md); font-weight: 600; letter-spacing: 0; }
.rbar__series { color: var(--text); max-width: 34ch; }
.rbar__series:hover { color: var(--violet-light); }
.rbar__chapter { color: var(--text-3); font-weight: 500; white-space: nowrap; }
.rbar__chapter--mobile { display: none; }
.rbar__nav { display: flex; align-items: center; gap: 2px; }
.rbar__select {
  height: 32px; padding: 0 28px 0 10px; border-radius: var(--r-2);
  background: var(--surface-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23847D9C' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: 1px solid var(--line); color: var(--text); font-size: var(--fs-sm); appearance: none; cursor: pointer;
}
.rbar__select option { background: var(--surface-2); }
.rbar__tools { display: flex; align-items: center; gap: 2px; }
.rbar__pop { position: relative; }
.rbar__progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.rbar__progress span { display: block; height: 100%; width: 0; background: var(--violet); transition: width 120ms linear; }

@media (max-width: 719px) {
  .rbar { gap: 2px; padding: 0 var(--s-1); }
  .rbar__title { flex-direction: column; gap: 0; line-height: 1.2; font-size: var(--fs-sm); }
  .rbar__chapter { font-size: var(--fs-xs); }
  .rbar__select { display: none; }
  .rbar__home { display: none; }
}

/* Réglages (popover) */
.rpanel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--z-menu);
  width: min(340px, calc(100vw - 16px)); padding: var(--s-4);
  display: grid; gap: var(--s-3);
  background: var(--surface-2); border-radius: var(--r-3); box-shadow: var(--sh-pop);
}
.rpanel__row { display: grid; gap: 6px; }
.rpanel__label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-3); }
.rpanel .seg { width: 100%; }
.rpanel .seg__btn { flex: 1; justify-content: center; }
.rpanel__keys { display: grid; gap: 4px; margin-top: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--text-3); }
.rpanel__keys div { display: flex; align-items: center; gap: var(--s-3); }
.rpanel__keys dt { display: flex; gap: 3px; min-width: 52px; }
.rpanel__keys dd { margin: 0; }

/* ── Pages ── */
.reader__pages {
  --reader-w: 800px; --reader-gap: 0px;
  display: flex; flex-direction: column; align-items: center; gap: var(--reader-gap);
  margin: 0 auto; padding-bottom: var(--s-6);
}
.reader__page { width: 100%; max-width: var(--reader-w); margin: 0; }
.reader__page img { width: 100%; height: auto; background: #111; user-select: none; -webkit-user-drag: none; }
@media (max-width: 719px) { .reader__pages { --reader-w: 100% !important; } }
.reader__empty { margin: var(--s-12) var(--gutter); max-width: 560px; }

/* Mode page par page */
.reader__pages.is-paged {
  flex-direction: row; justify-content: center; align-items: center; gap: 0;
  height: calc(100dvh - 52px); padding: 0; overflow: hidden; cursor: pointer; user-select: none;
}
.reader__pages.is-paged .reader__page { width: auto; max-width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.reader__pages.is-paged .reader__page img { width: auto; height: auto; max-height: calc(100dvh - 52px); max-width: 100%; object-fit: contain; }
.reader__pages.is-paged .reader__page.is-left,
.reader__pages.is-paged .reader__page.is-right { max-width: 50%; }
.reader__pages.is-paged .reader__page.is-left { justify-content: flex-end; order: 1; }
.reader__pages.is-paged .reader__page.is-right { justify-content: flex-start; order: 2; }
.reader__page[hidden] { display: none !important; }
body.is-paged .rend { display: none; }
body.is-paged { overflow: hidden; }

.pnav {
  position: fixed; left: 50%; bottom: var(--s-4); transform: translateX(-50%); z-index: var(--z-sticky);
  display: flex; align-items: center; gap: 4px; padding: 4px;
  background: rgba(20, 17, 31, .92); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--sh-2);
  opacity: .35; transition: opacity var(--d) var(--ease);
}
.pnav:hover, .pnav:focus-within { opacity: 1; }
@media (hover: none) { .pnav { opacity: 1; } }
.pnav__btn { display: grid; place-items: center; width: 40px; height: 36px; border-radius: var(--r-2); color: var(--text); }
.pnav__btn:hover { background: var(--surface-3); }
.pnav__btn.is-chapter { background: var(--violet-strong); color: #fff; }
.pnav__btn:disabled { opacity: .3; }
.pnav__btn--util { color: var(--text-2); width: 36px; }
.pnav__btn.is-on { color: var(--violet); }
.pnav__count { min-width: 70px; text-align: center; font-size: var(--fs-sm); color: var(--text-2); }

/* ── Fin de chapitre ── */
.rend {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-4);
  max-width: 640px; margin: var(--s-10) auto var(--s-16); padding: var(--s-8) var(--gutter);
  text-align: center; border-top: 1px solid var(--line-soft);
}
.rend .btn-group { justify-content: center; }
.rend__uptodate { color: var(--text-2); }
.rend .breadcrumb { margin-top: var(--s-4); }
.rend .breadcrumb ol { justify-content: center; }

.to-top {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: var(--z-sticky);
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); box-shadow: var(--sh-2);
}
.to-top:hover { background: var(--surface-3); color: var(--violet); }

/* ── Tiroir des chapitres ── */
.cdrawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-drawer);
  width: min(380px, 92vw); display: flex; flex-direction: column;
  background: var(--surface-1); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform var(--d) var(--ease);
}
.cdrawer.is-open { transform: none; }
.cdrawer__scrim { position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--scrim); }
.cdrawer__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5); border-bottom: 1px solid var(--line-soft); }
.cdrawer__title { flex: 1; font-size: var(--fs-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cdrawer__list { flex: 1; overflow-y: auto; padding: var(--s-2); list-style: none; }
.cdrawer .ch-row.is-current { background: var(--violet-tint); }
.cdrawer .ch-row.is-current .ch-row__num { color: var(--violet-light); }

/* ── Novel ── */
.novel { --novel-bg: #0C0A14; --novel-fg: #DAD6E6; --novel-muted: #847D9C; background: var(--novel-bg); min-height: calc(100vh - 52px); }
body[data-novel-theme="sepia"] { background: #F3EAD7; }
body[data-novel-theme="sepia"] .novel { --novel-bg: #F3EAD7; --novel-fg: #3B2F22; --novel-muted: #7A6A55; }
body[data-novel-theme="light"] { background: #FAFAFC; }
body[data-novel-theme="light"] .novel { --novel-bg: #FAFAFC; --novel-fg: #1F1B2B; --novel-muted: #6B6680; }
body[data-novel-theme="sepia"] .rend, body[data-novel-theme="light"] .rend { color: var(--novel-fg); border-color: rgba(0, 0, 0, .1); }
body[data-novel-theme="sepia"] .rend .caps, body[data-novel-theme="light"] .rend .caps,
body[data-novel-theme="sepia"] .rend .breadcrumb, body[data-novel-theme="light"] .rend .breadcrumb { color: var(--novel-muted); }
body[data-novel-theme="sepia"] .rend .breadcrumb a, body[data-novel-theme="light"] .rend .breadcrumb a { color: var(--novel-fg); }
body[data-novel-theme="sepia"] .rend .btn:not(.btn--primary), body[data-novel-theme="light"] .rend .btn:not(.btn--primary) { background: transparent; color: var(--novel-fg); border-color: rgba(0, 0, 0, .18); }

.novel__article { --novel-size: 1; max-width: 680px; margin: 0 auto; padding: var(--s-12) var(--gutter) var(--s-6); color: var(--novel-fg); }
.novel__article[data-width="narrow"] { max-width: 580px; }
.novel__article[data-width="wide"] { max-width: 820px; }
.novel__head { margin-bottom: var(--s-8); padding-bottom: var(--s-5); border-bottom: 1px solid color-mix(in srgb, var(--novel-fg) 14%, transparent); }
.novel__head .caps { color: var(--novel-muted); }
.novel__title { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: 800; line-height: 1.1; margin-top: var(--s-2); letter-spacing: -.02em; }
.novel__body { font-family: var(--font-read); font-size: calc(1.1875rem * var(--novel-size)); line-height: 1.8; hyphens: auto; overflow-wrap: break-word; }
.novel__article[data-font="sans"] .novel__body { font-family: var(--font-body); font-size: calc(1.0625rem * var(--novel-size)); line-height: 1.75; }
.novel__body > * + * { margin-top: 1.1em; }
.novel__body h2, .novel__body h3, .novel__body h4 { font-family: var(--font-display); margin-top: 1.8em; line-height: 1.25; }
.novel__body blockquote { border-left: 2px solid var(--violet); padding-left: 1em; font-style: italic; opacity: .9; }
.novel__body hr { border-color: color-mix(in srgb, var(--novel-fg) 18%, transparent); margin: 2em auto; width: 40%; }
.novel__body a { color: var(--violet); }
.novel__body img { margin: 1.5em auto; border-radius: var(--r-2); }
.novel__body code { background: color-mix(in srgb, var(--novel-fg) 8%, transparent); padding: .1em .3em; border-radius: 3px; }
.novel__body ul, .novel__body ol { padding-left: 1.4em; }
