/* Rapport à feuilleter. Les tailles de page (--pw, --ph, --fs) sont calculées par book.js selon l'écran. */
.book-wrap { --pw: 400px; --ph: 566px; --fs: 13px; background: var(--bg-2); padding: 16px var(--gutter) 28px; display: flex; flex-direction: column; align-items: center; gap: 14px; min-height: calc(100dvh - 72px); }
.book-wrap.is-full { background: #1b1f24; color: #e7e9ec; justify-content: center; padding: 12px; }
.book-bar { width: min(100%, 1200px); display: flex; align-items: center; gap: 12px; }
.book-back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; font-size: .92rem; white-space: nowrap; }
.book-back .icon { width: 18px; height: 18px; transform: scaleX(-1); }
[dir="rtl"] .book-back .icon { transform: none; }
.book-title { flex: 1; min-width: 0; text-align: center; font-family: var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-tools { display: flex; gap: 8px; align-items: center; }
.book-tools .icon-btn { width: 40px; height: 40px; }
.is-full .book-back, .is-full .book-title { color: #e7e9ec; }
.book-viewport { width: min(100%, 1200px); display: flex; justify-content: center; }
.book-nav { display: flex; align-items: center; gap: 14px; }
.book-nav .icon-btn:disabled { opacity: .35; cursor: default; }
[dir="rtl"] .book-nav .icon { transform: scaleX(-1); }
.book-count { min-width: 88px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.book-help { margin: 0; font-size: .82rem; color: var(--ink-3); text-align: center; }
.is-full .book-help { display: none; }
.book-wrap:not(.is-ready) .book-stage { visibility: hidden; }

/* --- Page --- */
.bpage { position: relative; width: var(--pw); height: var(--ph); background: #fff; color: var(--ink); font-size: var(--fs); line-height: 1.5; overflow: hidden; flex: none; }
.bp-in { position: absolute; inset: 0; padding: 7% 8% 9%; overflow-y: auto; scrollbar-width: thin; overscroll-behavior: contain; }
.bpage h1 { font-size: 2.3em; line-height: 1.08; margin: 0 0 .4em; color: #fff; }
.bpage h2 { font-size: 1.6em; line-height: 1.15; margin: 0 0 .6em; padding-bottom: .35em; border-bottom: 2px solid var(--brand); }
.bpage h3 { font-size: 1.1em; margin: 1em 0 .4em; }
.bpage p { margin: 0 0 .7em; }
.bp-kicker { font-size: .78em; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin: 0 0 .5em; }
.bp-num { position: absolute; bottom: 3.2%; font-size: .78em; color: var(--ink-3); inset-inline-end: 8%; }
.bp-small { font-size: .82em; color: var(--ink-3); }

/* Couverture */
.bp-cover .bp-in { padding: 0; overflow: hidden; background: #111418; color: #fff; }
.bp-cover-img { position: absolute; inset: 0; }
.bp-cover-img img { width: 100%; height: 100%; object-fit: cover; opacity: .72; }
.bp-cover-text { position: absolute; inset: auto 0 0 0; padding: 30% 8% 9%; background: linear-gradient(to top, rgb(17 20 24 / 96%) 55%, rgb(17 20 24 / 0%)); }
.bp-cover-text p { color: #d7dade; }
.bp-cover .bp-kicker { color: var(--brand-on-dark); }
.bp-org { display: flex; align-items: center; gap: .6em; margin-top: 1.2em !important; font-weight: 600; color: #fff !important; }
.bp-org img { width: 2.2em; height: 2.2em; border-radius: 6px; background: #fff; }
.bp-hint { position: absolute; top: 4%; inset-inline-end: 5%; margin: 0; display: inline-flex; gap: .4em; align-items: center; padding: .4em .8em; border-radius: 999px; background: rgb(255 255 255 / 92%); color: var(--ink); font-size: .85em; font-weight: 600; transition: opacity .3s; animation: bp-nudge 1.6s ease-in-out 3; }
.bp-hint .icon { width: 1.1em; height: 1.1em; }
[dir="rtl"] .bp-hint .icon { transform: scaleX(-1); }
.bp-hint.is-hidden { opacity: 0; pointer-events: none; }
@keyframes bp-nudge { 50% { transform: translateX(6px); } }

/* Sommaire */
.bp-toc { list-style: none; padding: 0; margin: 0 0 1em; counter-reset: toc; }
.bp-toc li { counter-increment: toc; }
.bp-toc a { display: flex; align-items: baseline; gap: .5em; padding: .55em 0; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.bp-toc a::before { content: counter(toc, decimal-leading-zero); color: var(--brand); font-weight: 700; font-size: .85em; }
.bp-toc a span { min-width: 0; }
.bp-toc a i { flex: 1; border-bottom: 1px dotted var(--ink-3); transform: translateY(-.3em); min-width: 1em; }
.bp-toc a b { font-variant-numeric: tabular-nums; }
.bp-toc a:hover span { color: var(--brand); text-decoration: underline; }
.bp-photo-band { border-radius: 6px; overflow: hidden; aspect-ratio: 16 / 9; margin-top: 1em; }
.bp-photo-band.tall { aspect-ratio: 4 / 3; }
.bp-photo-band img { width: 100%; height: 100%; object-fit: cover; }

/* Textes et chiffres */
.bp-prose { font-size: 1em; }
.bp-prose h2 { margin-top: 0; }
.bp-prose ul { padding-inline-start: 1.2em; }
.bp-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: .7em; }
.bp-kpis div { padding: .9em; border-radius: 6px; background: var(--bg-2); }
.bp-kpis b { display: block; font: 700 1.7em/1.1 var(--display); color: var(--brand); }
.bp-kpis span { font-size: .82em; color: var(--ink-3); }
.bp-opener { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 10% 9%; background: var(--dark); color: #d7dade; }
.bp-opener h2 { color: #fff; font-size: 2.1em; border-color: var(--brand-on-dark); }
.bp-opener .bp-kicker { color: var(--brand-on-dark); }
.bp-mini { list-style: none; padding: 0; margin: 1em 0 0; display: grid; gap: .5em; }
.bp-mini li { display: flex; gap: .5em; align-items: center; color: #fff; }
.bp-mini .icon { width: 1.1em; height: 1.1em; color: var(--brand-on-dark); flex: none; }
.bp-progress { display: flex; align-items: center; gap: .7em; margin: .2em 0 .8em; font-size: .85em; color: var(--ink-3); }
.bp-progress progress { flex: 1; height: 6px; appearance: none; border: 0; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.bp-progress progress::-webkit-progress-bar { background: var(--bg-3); }
.bp-progress progress::-webkit-progress-value { background: var(--ok); }
.bp-progress progress::-moz-progress-bar { background: var(--ok); }
.bp-actions { list-style: none; padding: 0; margin: 0 0 .8em; }
.bp-actions li { padding: .5em 0; border-bottom: 1px solid var(--line); display: grid; gap: .1em; }
.bp-actions span { font-size: .84em; color: var(--ink-3); }
.bp-play-inline { justify-self: start; display: inline-flex; gap: .35em; align-items: center; margin-top: .2em; padding: .25em .7em; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--brand); font: inherit; font-size: .82em; font-weight: 600; cursor: pointer; }
.bp-play-inline .icon { width: 1.2em; height: 1.2em; }
.bp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5em; margin-top: .6em; }
.bp-grid.g1 { grid-template-columns: 1fr; }
.bp-ph { padding: 0; border: 0; background: var(--bg-3); border-radius: 5px; overflow: hidden; aspect-ratio: 4 / 3; cursor: zoom-in; display: block; }
.bp-ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.bp-ph:hover img { transform: scale(1.04); }
.bp-videos { display: grid; gap: .6em; margin-bottom: .8em; }
.bp-video { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--dark); cursor: pointer; color: #fff; font: inherit; }
.bp-video img { width: 100%; height: 100%; object-fit: cover; opacity: .7; }
.bp-video-play { position: absolute; inset: 0; display: grid; place-items: center; }
.bp-video-play .icon { width: 3.4em; height: 3.4em; filter: drop-shadow(0 2px 6px rgb(0 0 0 / 50%)); transition: transform .2s; }
.bp-video:hover .bp-video-play .icon { transform: scale(1.1); }
.bp-video-cap { position: absolute; inset: auto 0 0 0; padding: .5em .8em; background: linear-gradient(to top, rgb(0 0 0 / 75%), transparent); font-size: .85em; font-weight: 600; text-align: start; }
.bp-note { font-size: .9em; }
.bp-fin { display: grid; grid-template-columns: 1fr 1fr; gap: 1em; }
.bp-fin table { width: 100%; border-collapse: collapse; font-size: .85em; }
.bp-fin td { padding: .35em 0; border-bottom: 1px solid var(--line); }
.bp-fin td:last-child { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bp-fin .tot td { font-weight: 700; border-bottom: 0; }
.bp-vol { list-style: none; padding: 0; margin: 0 0 .8em; }
.bp-vol li { display: flex; justify-content: space-between; gap: 1em; padding: .4em 0; border-bottom: 1px solid var(--line); }
.bp-thanks { display: flex; flex-direction: column; justify-content: center; min-height: 100%; text-align: center; font-size: 1.15em; font-family: var(--display); }
.bp-back .bp-in { background: var(--dark); color: #d7dade; display: flex; }
.bp-backcover { margin: auto 0; }
.bp-backcover img { width: 4em; height: 4em; border-radius: 10px; background: #fff; margin-bottom: 1.2em; }
.bp-backcover h2 { color: #fff; border-color: var(--brand-on-dark); }
.bp-backcover a { color: #fff; }
.bp-backcover .btn { color: #fff; font-size: .95em; }
.bp-cta { margin-top: 1.4em !important; }

/* --- Mode livre : feuilles qui se tournent --- */
.book-stage.is-flip { position: relative; width: calc(var(--pw) * 2); height: var(--ph); perspective: 2600px; transition: transform .6s cubic-bezier(.3, .7, .3, 1); }
.book-stage.is-flip.at-start { transform: translateX(calc(var(--pw) * -.5)); }
.book-stage.is-flip.at-end { transform: translateX(calc(var(--pw) * .5)); }
.sheet { position: absolute; top: 0; left: 50%; width: 50%; height: 100%; transform-origin: left center; transform-style: preserve-3d; transition: transform .85s cubic-bezier(.45, .05, .25, 1); }
.sheet.no-anim { transition: none; }
.sheet.flipped { transform: rotateY(-180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.face.back { transform: rotateY(180deg); }
.face .bpage { width: 100%; height: 100%; }
.face.front { box-shadow: 0 1px 0 var(--line), 0 12px 30px rgb(17 20 24 / 14%); border-radius: 0 4px 4px 0; }
.face.back { box-shadow: 0 1px 0 var(--line), 0 12px 30px rgb(17 20 24 / 14%); border-radius: 4px 0 0 4px; }
/* Ombre de reliure */
.face.front::after, .face.back::after { content: ""; position: absolute; top: 0; bottom: 0; width: 7%; pointer-events: none; }
.face.front::after { left: 0; background: linear-gradient(to right, rgb(0 0 0 / 12%), transparent); }
.face.back::after { right: 0; background: linear-gradient(to left, rgb(0 0 0 / 12%), transparent); }
.book-stage.is-flip .bpage { cursor: pointer; }
.book-stage.is-flip .bpage a, .book-stage.is-flip .bpage button { cursor: pointer; }

/* Arabe : le livre s'ouvre de droite à gauche */
[dir="rtl"] .book-stage.is-flip.at-start { transform: translateX(calc(var(--pw) * .5)); }
[dir="rtl"] .book-stage.is-flip.at-end { transform: translateX(calc(var(--pw) * -.5)); }
[dir="rtl"] .sheet { left: 0; transform-origin: right center; }
[dir="rtl"] .sheet.flipped { transform: rotateY(180deg); }
[dir="rtl"] .face.back { transform: rotateY(-180deg); }
[dir="rtl"] .face.front { border-radius: 4px 0 0 4px; }
[dir="rtl"] .face.back { border-radius: 0 4px 4px 0; }
[dir="rtl"] .face.front::after { left: auto; right: 0; background: linear-gradient(to left, rgb(0 0 0 / 12%), transparent); }
[dir="rtl"] .face.back::after { right: auto; left: 0; background: linear-gradient(to right, rgb(0 0 0 / 12%), transparent); }

/* --- Mode téléphone : une page à la fois, défilement au doigt --- */
.book-stage.is-swipe { display: flex; width: var(--pw); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: 6px; box-shadow: 0 10px 28px rgb(17 20 24 / 14%); overscroll-behavior-x: contain; }
.book-stage.is-swipe::-webkit-scrollbar { display: none; }
.book-stage.is-swipe .bpage { scroll-snap-align: start; scroll-snap-stop: always; }

/* --- Photo / vidéo en grand --- */
.book-dialog { width: min(96vw, 1100px); max-height: 92dvh; padding: 0; border: 0; border-radius: 10px; background: #0b0d10; overflow: hidden; }
.book-dialog::backdrop { background: rgb(11 13 16 / 82%); }
.book-dialog form { position: absolute; top: 8px; inset-inline-end: 8px; z-index: 2; margin: 0; }
.book-close { background: rgb(255 255 255 / 92%); width: 40px; height: 40px; }
.book-dialog-body img { display: block; max-width: 100%; max-height: 92dvh; margin: auto; object-fit: contain; }
.book-dialog-body iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }

@media (max-width: 899px) {
  .book-wrap { padding: 10px 12px 20px; min-height: auto; }
  .book-title { display: none; }
  .book-bar { justify-content: space-between; }
  .bp-in { padding: 8% 7% 11%; }
  .bp-kpis b { font-size: 1.5em; }
}
@media (prefers-reduced-motion: reduce) { .bp-hint { animation: none; } }
@media print { .book-bar, .book-nav, .book-help { display: none; } }
