/* ==========================================================================
   Rapport — sommaire, barre de lecture collante (mobile), feuille « Sommaire »,
   sommaire collant de la marge (desktop), grille de lecture.
   Référence : design/maquettes/rapport/02-sommaire.html et 03-chapitre.html.
   ========================================================================== */

/* Page « Sommaire » */
.toc { padding: 36px 16px 40px; max-width: 760px; margin: 0 auto; }
.toc__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.toc__head h2 { font: 500 40px/1 var(--font-display); }
.toc__head .meta { white-space: nowrap; }
.toc__who { margin-bottom: 6px; }
.toc__intro { margin-top: 14px; font: 450 19px/1.5 var(--font-display); color: var(--ink-2); max-width: 30em; }
.resume { margin-top: 20px; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 16px 16px 16px 18px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); }
.resume[hidden] { display: none; }
.resume .kicker { font-size: 11px; }
.resume strong { display: block; margin-top: 4px; font: 600 21px/1.15 var(--font-display); }
.resume .bar { margin-top: 10px; height: 4px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.resume .bar span { display: block; width: 40%; height: 100%; background: var(--accent); }
.resume .meta { margin-top: 6px; font-size: 12.5px; }

.toc__part { margin-top: 30px; }
.toc__part-head { display: flex; align-items: baseline; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line-strong); }
.toc__part-head .roman, .toc__fold .roman { font: italic 400 22px/1 var(--font-display); color: var(--accent-ink); }
.toc__part-head h3 { font: 600 25px/1.1 var(--font-display); }
.toc__part-head .meta { margin-left: auto; font-size: 12.5px; }
.toc__item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: var(--ink); }
.toc__num { font: italic 400 20px/1 var(--font-display); color: var(--ink-3); }
.toc__title { font: 450 20px/1.2 var(--font-display); }
.toc__title small { display: block; font: 400 12.5px/1.4 var(--font-ui); color: var(--ink-3); margin-top: 2px; }
.toc__time { font-size: 13px; color: var(--ink-3); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.toc__state { width: 18px; height: 18px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; }
.toc__state--read { background: var(--wood-soft); color: var(--wood-ink); }
.toc__state .i { width: 11px; height: 11px; }
.toc__state--cur { border: 2px solid var(--line-strong); border-top-color: var(--accent); }
.is-read .toc__title { color: var(--ink-2); }
li.is-current .toc__item, .toc__item[aria-current] { background: linear-gradient(90deg, var(--accent-soft), transparent 85%); border-radius: 8px; margin: 0 -8px; padding: 8px; }
.is-current .toc__num { color: var(--accent-ink); font-weight: 600; }
.is-current .toc__title { font-weight: 600; }
.toc__extra { margin-top: 22px; display: grid; gap: 8px; }
.toc__extra a { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px dashed var(--line-strong); text-decoration: none; color: var(--ink); font-size: 14.5px; font-weight: 550; }
.toc__extra a span:last-child { color: var(--ink-3); font-weight: 400; font-size: 13px; }

/* Grille de lecture : le sommaire et la marge n'existent qu'à partir de 1024 px */
.reader { position: relative; }
.reader__nav, .reader__margin { display: none; }
.reader__main { min-width: 0; padding: 0; }

/* Barre de lecture collante (mobile) : progression 3 px, partie, n° / total, titre, bouton */
.readbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 92%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-soft); }
.readbar__progress { height: 3px; background: var(--line-soft); }
.readbar__progress span { display: block; height: 100%; background: var(--accent); width: 1%; }
.readbar__row { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px; min-height: 56px; }
.readbar__where { flex: 1; min-width: 0; }
.readbar__where .kicker { font-size: 11px; letter-spacing: 0.16em; display: block; }
.readbar__where strong { display: block; font: 600 19px/1.15 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readbar__toc { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; }

/* Feuille « Sommaire » (mobile) */
.sheet-scrim { position: fixed; inset: 0; background: color-mix(in srgb, var(--ink-block) 45%, transparent); z-index: 40; }
.sheet-scrim[hidden], .sheet[hidden] { display: none; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 82vh; max-height: 82svh; display: flex; flex-direction: column; background: var(--paper); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-2); padding: 10px 16px 14px; outline: none; }
.sheet__grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 0 auto 12px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; }
.sheet__head h2 { font: 600 28px/1.1 var(--font-display); }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
.sheet .toc__part { margin-top: 14px; }
.sheet .toc__part-head { padding-bottom: 6px; }
.sheet .toc__part-head h3 { font-size: 20px; }
.sheet .toc__item { min-height: 48px; padding: 4px 0; }
.sheet .toc__title { font-size: 18px; }
.sheet li.is-current .toc__item, .sheet .toc__item[aria-current] { padding: 4px 8px; }
.sheet .toc__part.is-folded .toc__part-head, .sheet .toc__part.is-folded ol { display: none; }
.toc__fold { width: 100%; display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; min-height: 56px; margin-top: 14px; padding: 6px 0; border: 0; border-bottom: 1px solid var(--line-strong); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.toc__fold[hidden] { display: none; }
.toc__fold strong { display: block; font: 600 20px/1.15 var(--font-display); }
.toc__fold small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.toc__fold .tick, .toc__fold .toc__state { background: var(--wood-soft); color: var(--wood-ink); width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; }
.sheet__actions { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet__actions .btn { min-height: 48px; padding: 0 12px; }

@media (min-width: 1024px) {
  .toc { max-width: 1240px; padding: 56px 40px 64px; display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); column-gap: 80px; grid-template-areas: "head list" "intro list" "resume list" "extra list"; align-content: start; }
  .toc__head { grid-area: head; flex-direction: column; align-items: flex-start; gap: 6px; }
  .toc__head h2 { font-size: 64px; }
  .toc__head .meta { order: -1; }
  .toc__intro { grid-area: intro; }
  .resume { grid-area: resume; max-width: 560px; }
  .toc__list { grid-area: list; }
  .toc__list .toc__part:first-child { margin-top: 0; }
  .toc__extra { grid-area: extra; max-width: 400px; align-self: start; }

  .readbar, .sheet, .sheet-scrim { display: none !important; }
  .reader { display: grid; grid-template-columns: 250px minmax(0, 1fr) 240px; gap: 48px; max-width: 1320px; margin: 0 auto; padding: 0 40px; }
  .reader__nav { display: block; position: sticky; top: 24px; align-self: start; padding-top: 56px; max-height: 100vh; overflow-y: auto; }
  .reader__main { max-width: 650px; justify-self: center; width: 100%; }
  .reader__margin { display: block; }

  .navtoc .kicker { font-size: 11px; }
  .navtoc__who { font: 600 24px/1.1 var(--font-display); margin-top: 6px; }
  .navtoc__who .ko-b { font-size: 0.85em; color: var(--el-ink, var(--wood-ink)); }
  .navtoc__bar { margin-top: 14px; height: 3px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
  .navtoc__bar span { display: block; height: 100%; width: 1%; background: var(--accent); }
  .navtoc .meta { margin-top: 6px; font-size: 12.5px; }
  .navtoc__part { margin-top: 22px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
  .navtoc ol { margin: 6px 0 0; padding: 0; list-style: none; }
  .navtoc li a { display: grid; grid-template-columns: 26px 1fr; gap: 6px; padding: 6px 8px; margin: 0 -8px; border-radius: 6px; text-decoration: none; font: 450 17px/1.25 var(--font-display); color: var(--ink-2); }
  .navtoc li a span:first-child { font-style: italic; color: var(--ink-3); }
  .navtoc li.is-read a { color: var(--ink-3); }
  .navtoc li.is-current a { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
  .navtoc li.is-current a span:first-child { color: var(--accent-ink); }
  .navtoc__tools { margin-top: 26px; display: flex; gap: 8px; }
}
