/* ==========================================================================
   SOLUM — liseuse de l'essai
   Pages tournées comme sur une liseuse : le texte est mis en colonnes
   de la hauteur de l'écran, et l'on glisse d'une page (ou double page)
   à l'autre.
   ========================================================================== */

.reader {
  --r-bg: #f4f3ee;
  --r-fg: #1f1b16;
  --r-muted: #6b645a;
  --r-line: rgba(31, 27, 22, .14);
  --r-chrome: rgba(244, 243, 238, .92);
  --r-accent: #46592c;

  --r-size: 20px;
  --r-leading: 1.6;
  --r-font: "Spectral", Georgia, "Times New Roman", serif;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --bar: 52px;
}
.reader[data-theme="sepia"] {
  --r-bg: #f0e5cd;
  --r-fg: #4a3826;
  --r-muted: #6e5a45;
  --r-line: rgba(74, 56, 38, .18);
  --r-chrome: rgba(240, 229, 205, .92);
  --r-accent: #7a4a1c;
}
.reader[data-theme="nuit"] {
  --r-bg: #161412;
  --r-fg: #d9d2c5;
  --r-muted: #8f877a;
  --r-line: rgba(217, 210, 197, .14);
  --r-chrome: rgba(22, 20, 18, .92);
  --r-accent: #a9c07f;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body.reader {
  margin: 0;
  background: var(--r-bg);
  color: var(--r-fg);
  font-family: var(--r-font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

button { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--r-accent); outline-offset: 2px; border-radius: 3px; }

/* ----------------------------------------------------------- Barres */

.r-top, .r-bottom {
  position: fixed;
  left: 0; right: 0;
  z-index: 20;
  height: var(--bar);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  padding: 0 clamp(.9rem, 3vw, 1.6rem);
  font-family: var(--display);
  font-size: .82rem;
  color: var(--r-muted);
  background: var(--r-chrome);
  transition: opacity .25s ease, transform .25s ease;
}
.r-top { top: 0; padding-top: env(safe-area-inset-top); height: calc(var(--bar) + env(safe-area-inset-top)); }
.r-bottom { bottom: 0; padding-bottom: env(safe-area-inset-bottom); height: calc(var(--bar) + env(safe-area-inset-bottom)); }

.reader.is-immersive .r-top { opacity: 0; transform: translateY(-100%); pointer-events: none; }
.reader.is-immersive .r-bottom { opacity: 0; transform: translateY(100%); pointer-events: none; }

.r-brand {
  justify-self: start;
  font-weight: 800;
  font-variation-settings: "wdth" 125;
  letter-spacing: .3em;
  font-size: .9rem;
  color: var(--r-fg);
  text-decoration: none;
}
.r-where {
  margin: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variation-settings: "wdth" 100;
}
.r-tools { justify-self: end; display: flex; gap: .4rem; }
.r-tool {
  background: none;
  border: 1px solid var(--r-line);
  border-radius: 999px;
  padding: .35rem .8rem;
  font-family: var(--display);
  font-weight: 600;
  font-size: .82rem;
  color: var(--r-fg);
  cursor: pointer;
}
.r-tool:hover, .r-tool[aria-expanded="true"] { border-color: var(--r-fg); }
.r-tool--aa { font-family: var(--r-font); font-size: .95rem; padding: .25rem .75rem; }

.r-page, .r-left { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-feature-settings: "tnum"; }
.r-left { text-align: right; }
.r-progress {
  height: 3px;
  border-radius: 2px;
  background: var(--r-line);
  overflow: hidden;
}
.r-progress span { display: block; height: 100%; width: 0; background: var(--r-fg); opacity: .55; transition: width .3s ease; }

/* ---------------------------------------------------------- Pages */

.r-stage {
  position: fixed;
  inset: calc(var(--bar) + env(safe-area-inset-top)) 0 calc(var(--bar) + env(safe-area-inset-bottom)) 0;
}
.r-pages {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: default;
  touch-action: pan-y;
}
.r-window {
  position: absolute;
  overflow: hidden;
}
.r-flow {
  position: absolute;
  top: 0;
  left: 0;
  column-fill: auto;
  font-size: var(--r-size);
  line-height: var(--r-leading);
  font-family: var(--r-font);
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  font-feature-settings: "kern", "liga", "onum";
  widows: 2;
  orphans: 2;
  will-change: transform;
}
.r-flow.is-turning { transition: transform .32s cubic-bezier(.3, .1, .2, 1); }

.r-flow p { margin: 0; text-indent: 1.4em; }
.r-flow h2 + p,
.r-flow .chap-head + p,
.r-flow blockquote + p,
.r-flow .chap-first { text-indent: 0; }

.r-flow h2 {
  margin: 2.2em 0 1.1em;
  font-family: var(--r-font);
  font-size: .86em;
  font-weight: 500;
  font-variant-caps: all-small-caps;
  letter-spacing: .07em;
  line-height: 1.4;
  text-align: center;
  -webkit-hyphens: none;
  hyphens: none;
  break-after: avoid;
}

.r-flow blockquote {
  margin: 1.2em 1.4em;
  text-align: center;
  -webkit-hyphens: none;
  hyphens: none;
  break-inside: avoid;
}
.r-flow blockquote p { text-indent: 0; }

/* Ouverture de chapitre : un blanc en haut de page, comme dans un livre */
.chap-head {
  padding-top: calc(var(--page-h, 600px) * .12);
  margin-bottom: 2.4em;
  text-align: left;
  -webkit-hyphens: none;
  hyphens: none;
  break-inside: avoid;
}
.chap-part {
  margin: 0 0 1.6em !important;
  font-size: .78em;
  font-variant-caps: all-small-caps;
  letter-spacing: .08em;
  color: var(--r-muted);
  text-indent: 0 !important;
}
.chap-num {
  margin: 0 0 .5em !important;
  font-size: .82em;
  font-variant-caps: all-small-caps;
  letter-spacing: .12em;
  color: var(--r-muted);
  text-indent: 0 !important;
}
.chap-title {
  margin: 0;
  font-family: var(--r-font);
  font-size: 1.75em;
  font-weight: 500;
  line-height: 1.12;
  text-align: left;
  letter-spacing: -.005em;
}
.chap-epigraph {
  margin: 1.6em 0 0 !important;
  max-width: 26em;
  font-size: .9em;
  font-style: italic;
  line-height: 1.5;
  color: var(--r-muted);
  text-indent: 0 !important;
  text-align: left;
}

.chap-first::first-letter {
  float: left;
  font-size: 3.2em;
  line-height: .82;
  padding: .07em .08em 0 0;
  font-weight: 500;
}

/* Fin du livre */
.r-endcard {
  break-before: column;
  padding-top: calc(var(--page-h, 600px) * .3);
  text-align: center;
  -webkit-hyphens: none;
  hyphens: none;
}
.r-endcard p { text-indent: 0; margin: 0 0 .8em; }
.r-endcard .mark {
  font-family: var(--display);
  font-weight: 800;
  font-variation-settings: "wdth" 125;
  letter-spacing: .3em;
  font-size: .8em;
  margin-bottom: 1.6em;
}
.r-endcard a { color: var(--r-accent); }

/* Boutons latéraux, visibles sur grand écran */
.r-turn {
  position: absolute;
  top: 50%;
  z-index: 5;
  width: 44px;
  height: 88px;
  margin-top: -44px;
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: var(--r-muted);
  cursor: pointer;
  opacity: .45;
  transition: opacity .2s ease;
}
.r-turn:hover, .r-turn:focus-visible { opacity: 1; }
.r-turn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.r-turn--prev { left: 6px; }
.r-turn--next { right: 6px; }
.r-turn[disabled] { visibility: hidden; }
@media (min-width: 900px) and (hover: hover) { .r-turn { display: flex; } }

/* --------------------------------------------------------- Couverture */

.r-cover {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background: var(--r-bg);
  overflow-y: auto;
}
.reader:not([data-state="cover"]):not([data-state="loading"]) .r-cover { display: none; }

.r-cover__inner { max-width: 30rem; text-align: center; }
.r-cover__mark {
  margin: 0 0 3rem;
  font-family: var(--display);
  font-weight: 800;
  font-variation-settings: "wdth" 125;
  letter-spacing: .4em;
  font-size: .95rem;
}
.r-cover h1 {
  margin: 0;
  font-family: var(--r-font);
  font-weight: 500;
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  line-height: 1.05;
}
.r-cover__sub {
  margin: 1rem 0 2.6rem;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--r-muted);
}
.r-cover__epigraph {
  margin: 0 auto 2.8rem;
  max-width: 24rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--r-line);
  border-bottom: 1px solid var(--r-line);
  font-size: 1.05rem;
  line-height: 1.5;
}
.r-cover__actions { display: grid; gap: .7rem; justify-items: center; margin-bottom: 1.6rem; }
.r-cover__meta, .r-cover__status { margin: 0 0 .4rem; font-size: .95rem; color: var(--r-muted); }
.r-cover__status:empty { display: none; }
.r-cover__back {
  display: inline-block;
  margin-top: 2rem;
  font-family: var(--display);
  font-size: .85rem;
  color: var(--r-muted);
}

.r-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15rem;
  padding: .85rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--r-fg);
  font-family: var(--display);
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
}
.r-btn--solid { background: var(--r-fg); color: var(--r-bg); }
.r-btn--solid:disabled { opacity: .4; cursor: progress; }
.r-btn--ghost { background: none; }
.r-btn--ghost:hover { background: var(--r-line); }

/* ---------------------------------------------------------- Panneaux */

.r-scrim {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(0, 0, 0, .25);
}
.r-panel {
  position: fixed;
  z-index: 30;
  top: 0;
  bottom: 0;
  width: min(380px, 92vw);
  padding: calc(1.2rem + env(safe-area-inset-top)) 1.4rem 1.4rem;
  background: var(--r-bg);
  color: var(--r-fg);
  box-shadow: 0 0 40px rgba(0, 0, 0, .18);
  overflow-y: auto;
  font-family: var(--display);
}
.r-panel[hidden] { display: none; }
.r-toc { left: 0; }
.r-settings { right: 0; }

.r-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}
.r-panel h2 { margin: 0; font-size: 1.15rem; font-weight: 700; font-variation-settings: "wdth" 110; }
.r-close {
  background: none;
  border: 1px solid var(--r-line);
  border-radius: 999px;
  padding: .3rem .8rem;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}

.r-toc__list { list-style: none; margin: 0; padding: 0; }
.r-toc__part {
  margin: 1.4rem 0 .4rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--r-muted);
}
.r-toc__list button {
  width: 100%;
  display: grid;
  grid-template-columns: 1.8rem minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: baseline;
  padding: .6rem .4rem;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--r-line);
  text-align: left;
  cursor: pointer;
  font-family: var(--r-font);
  font-size: 1rem;
  line-height: 1.3;
}
.r-toc__list button:hover { background: var(--r-line); }
.r-toc__list button[aria-current="true"] { font-weight: 600; }
.r-toc__list button[aria-current="true"] .n { color: var(--r-accent); }
.r-toc__list .n { font-family: var(--display); font-size: .8rem; color: var(--r-muted); font-feature-settings: "tnum"; }
.r-toc__list .m { font-family: var(--display); font-size: .75rem; color: var(--r-muted); white-space: nowrap; }

.r-set { margin-bottom: 1.5rem; }
.r-set__label { margin: 0 0 .55rem; font-size: .82rem; font-weight: 600; color: var(--r-muted); }
.r-stepper {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 3rem;
  align-items: center;
  border: 1px solid var(--r-line);
  border-radius: 10px;
  overflow: hidden;
}
.r-stepper button {
  height: 2.8rem;
  background: none;
  border: 0;
  font-family: var(--r-font);
  font-size: 1.05rem;
  cursor: pointer;
}
.r-stepper button:hover { background: var(--r-line); }
.r-stepper output { text-align: center; font-size: .9rem; font-feature-settings: "tnum"; }

.r-seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--r-line);
  border-radius: 10px;
}
.r-seg button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem .4rem;
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: .88rem;
  cursor: pointer;
}
.r-seg button:hover { background: var(--r-line); }
.r-seg button[aria-pressed="true"] { background: var(--r-fg); color: var(--r-bg); }
.f-spectral { font-family: "Spectral", serif !important; font-size: 1rem !important; }
.f-literata { font-family: "Literata", serif !important; font-size: .95rem !important; }
.f-archivo { font-family: "Archivo", sans-serif !important; }
.sw { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .25); }
.sw--jour { background: #f4f3ee; }
.sw--sepia { background: #f0e5cd; }
.sw--nuit { background: #161412; border-color: rgba(255, 255, 255, .3); }
.r-set__hint { margin: 1.6rem 0 0; font-size: .82rem; line-height: 1.5; color: var(--r-muted); }

.r-noscript { position: fixed; inset: 40% 1rem auto; text-align: center; }

/* ---------------------------------------------------------- Mobile */

@media (max-width: 640px) {
  .reader { --bar: 46px; }
  .r-top { grid-template-columns: auto minmax(0, 1fr) auto; }
  .r-where { font-size: .78rem; }
  .r-tool { padding: .3rem .65rem; }
  .r-bottom { grid-template-columns: auto minmax(0, 1fr) auto; font-size: .76rem; }
  .r-left .long, .r-page .long { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .r-flow.is-turning { transition: none; }
  body.reader, .r-top, .r-bottom { transition: none; }
}

.r-pages:focus { outline: none; }
.r-btn[hidden] { display: none; }
.r-cover__notice {
  margin: -1.4rem auto 2.4rem;
  max-width: 26rem;
  font-family: var(--display);
  font-size: .9rem;
  line-height: 1.5;
  color: var(--r-muted);
}
.r-cover__legal { display: flex; justify-content: center; gap: 1.2rem; margin: .4rem 0 0; font-family: var(--display); font-size: .8rem; }
.r-cover__legal a, .r-cover__back { display: inline-flex; align-items: center; min-height: 44px; color: var(--r-muted); }

/* Zones tactiles d'au moins 44 × 44 px */
.r-tool, .r-close, .r-seg button { min-height: 44px; }
.r-brand { display: inline-flex; align-items: center; min-height: 44px; }
.r-toc__list button { min-height: 44px; }
.r-tool--aa { min-width: 44px; }
