/* PDF FLIPBOOK ONE — visionneuse */
:root {
	--pfo-bg: #e9edf2;
	--pfo-bar: #fff;
	--pfo-text: #1f2937;
	--pfo-accent: #2563eb;
	--pfo-icon: 20px;
	--pfo-bg-image: none;
	--pfo-hover: color-mix(in srgb, var(--pfo-text) 12%, transparent);
	--pfo-line: color-mix(in srgb, var(--pfo-text) 14%, transparent);
	--pfo-panel-w: 270px;
	--pfo-btn: calc(var(--pfo-icon) + 16px);
}
*, *::before, *::after { box-sizing: border-box; }
html.pfo-html, .pfo-body { height: 100%; margin: 0; }
.pfo-body {
	overflow: hidden;
	font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--pfo-text);
	background: var(--pfo-bg);
	-webkit-tap-highlight-color: transparent;
}
.pfo-body.pfo-nocopy { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.pfo-app {
	position: fixed; inset: 0;
	display: flex; flex-direction: column;
	background: var(--pfo-bg) var(--pfo-bg-image) center / cover no-repeat;
}

/* ---------- Barre d'outils ---------- */
.pfo-toolbar {
	position: relative; z-index: 20;
	display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
	min-height: calc(var(--pfo-btn) + 12px);
	padding: 6px 10px;
	background: var(--pfo-bar); color: var(--pfo-text);
	box-shadow: 0 1px 0 var(--pfo-line), 0 2px 10px rgba(0,0,0,.06);
}
.pfo-bar-bottom .pfo-toolbar { order: 2; box-shadow: 0 -1px 0 var(--pfo-line), 0 -2px 10px rgba(0,0,0,.06); }
.pfo-bar-top-center .pfo-toolbar,
.pfo-bar-bottom-center .pfo-toolbar {
	position: absolute; left: 50%; transform: translateX(-50%);
	display: flex; width: max-content; max-width: calc(100% - 20px);
	border-radius: 999px; padding: 4px 10px;
	box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.pfo-bar-top-center .pfo-toolbar { top: 10px; }
.pfo-bar-bottom-center .pfo-toolbar { bottom: 12px; }
.pfo-bar-top-center .pfo-main { padding-top: calc(var(--pfo-btn) + 22px); }
.pfo-bar-bottom-center .pfo-main { padding-bottom: calc(var(--pfo-btn) + 24px); }

.pfo-tb { display: flex; align-items: center; gap: 2px; min-width: 0; }
.pfo-tb--left { justify-self: start; }
.pfo-tb--right { justify-self: end; gap: 6px; }
.pfo-tb__group { display: flex; align-items: center; gap: 2px; }
.pfo-tb__group + .pfo-tb__group { padding-left: 6px; border-left: 1px solid var(--pfo-line); }

.pfo-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	width: var(--pfo-btn); height: var(--pfo-btn); padding: 0;
	border: 0; border-radius: 8px; background: transparent; color: inherit;
	cursor: pointer; text-decoration: none; flex: none;
	transition: background .15s, opacity .15s;
}
.pfo-btn svg { width: var(--pfo-icon); height: var(--pfo-icon); }
.pfo-btn:hover, .pfo-btn:focus-visible { background: var(--pfo-hover); outline: none; }
.pfo-btn.is-active { background: var(--pfo-hover); color: var(--pfo-accent); }
.pfo-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.pfo-return { width: auto; padding: 0 10px 0 6px; font-weight: 500; white-space: nowrap; }
.pfo-logo { display: inline-flex; align-items: center; margin: 0 6px; }
.pfo-logo img { max-height: calc(var(--pfo-icon) + 6px); width: auto; display: block; }
.pfo-title { margin-left: 6px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }

.pfo-pagenum { display: inline-flex; align-items: center; gap: 4px; margin: 0 4px; font-variant-numeric: tabular-nums; }
.pfo-pagenum__input {
	min-width: 3ch; height: calc(var(--pfo-btn) - 6px); padding: 0 6px;
	border: 1px solid var(--pfo-line); border-radius: 6px;
	background: color-mix(in srgb, var(--pfo-bar) 85%, var(--pfo-text) 4%); color: inherit;
	font: inherit; text-align: center; box-sizing: content-box;
}
.pfo-pagenum__input:focus { outline: 2px solid var(--pfo-accent); outline-offset: 0; }
.pfo-pagenum__total { opacity: .8; white-space: nowrap; }

@media (max-width: 760px) {
	.pfo-toolbar { display: flex; overflow-x: auto; scrollbar-width: none; gap: 4px; }
	.pfo-toolbar::-webkit-scrollbar { display: none; }
	.pfo-tb { flex: none; }
	.pfo-tb--center { margin: 0 auto; }
	.pfo-title, .pfo-return__text, .pfo-btn--first, .pfo-btn--last, .pfo-btn--zoomfit { display: none; }
	.pfo-return { padding: 0; width: var(--pfo-btn); }
}

/* ---------- Zone principale ---------- */
.pfo-main { position: relative; flex: 1; min-height: 0; display: flex; }
.pfo-stage {
	position: relative; flex: 1; min-width: 0;
	display: flex; overflow: auto; outline: none;
	touch-action: pan-y pinch-zoom;
	overscroll-behavior: contain;
}
.pfo-app.is-zoomed .pfo-stage, .pfo-layout-scroll .pfo-stage { touch-action: auto; }
.pfo-app.is-zoomed .pfo-stage { cursor: grab; }
.pfo-app.is-grabbing .pfo-stage { cursor: grabbing; }

/* ---------- Livre ---------- */
.pfo-book {
	position: relative; margin: auto; flex: none;
	perspective: 2600px;
	cursor: pointer;
}
.pfo-app.is-zoomed .pfo-book { cursor: inherit; }
.pfo-page {
	position: absolute; top: 0; height: 100%;
	background: #fff; overflow: hidden;
}
.pfo-page.is-empty { background: transparent; box-shadow: none !important; }
.pfo-page__canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.pfo-page__links { position: absolute; inset: 0; pointer-events: none; }
.pfo-link { position: absolute; pointer-events: auto; border-radius: 2px; }
.pfo-link:hover { background: color-mix(in srgb, var(--pfo-accent) 18%, transparent); }
.pfo-page__spin { display: none; }
.pfo-page.is-loading .pfo-page__spin {
	display: block; position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px;
	border: 3px solid rgba(0,0,0,.1); border-top-color: var(--pfo-accent); border-radius: 50%;
	animation: pfo-spin .8s linear infinite;
}
.pfo-shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; }

.is-double .pfo-page--left { left: 0; width: 50%; }
.is-double .pfo-page--right { left: 50%; width: 50%; }
.is-single .pfo-page--main { left: 0; width: 100%; }

.pfo-shadows .pfo-page:not(.is-empty):not(.pfo-face) { box-shadow: 0 10px 30px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.12); }
.pfo-shadows .is-double .pfo-page--left:not(.is-empty) { box-shadow: -8px 10px 30px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.1); }
.pfo-shadows .is-double .pfo-page--right:not(.is-empty) { box-shadow: 8px 10px 30px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.1); }

/* Pli central */
.pfo-fold { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; z-index: 3; pointer-events: none; }
.pfo-shadows .pfo-fold::before {
	content: ""; position: absolute; top: 0; bottom: 0; left: -40px; width: 80px;
	background: linear-gradient(90deg, transparent 0, rgba(0,0,0,.04) 30%, rgba(0,0,0,.16) 48%, rgba(0,0,0,.2) 50%, rgba(0,0,0,.08) 54%, rgba(255,255,255,.06) 62%, transparent 100%);
}

.pfo-book.is-lone .pfo-fold { display: none; }

/* Coin qui se soulève au survol */
.pfo-shadows .pfo-page--right:not(.is-empty)::after,
.pfo-shadows .pfo-page--left:not(.is-empty)::after,
.pfo-shadows .pfo-page--main:not(.is-empty)::after {
	content: ""; position: absolute; bottom: 0; width: 0; height: 0; z-index: 2;
	transition: width .25s ease, height .25s ease; pointer-events: none;
}
.pfo-page--right::after, .pfo-page--main::after { right: 0; background: linear-gradient(315deg, var(--pfo-bg) 45%, rgba(0,0,0,.18) 50%, #f4f4f4 56%, #fff 80%); }
.pfo-page--left::after { left: 0; background: linear-gradient(45deg, var(--pfo-bg) 45%, rgba(0,0,0,.18) 50%, #f4f4f4 56%, #fff 80%); }
@media (hover: hover) {
	.pfo-app:not(.is-zoomed) .pfo-book:not(.is-flipping) .pfo-page--right:hover::after,
	.pfo-app:not(.is-zoomed) .pfo-book:not(.is-flipping) .pfo-page--left:hover::after,
	.pfo-app:not(.is-zoomed) .pfo-book:not(.is-flipping) .pfo-page--main:hover::after { width: 46px; height: 46px; }
}

/* Feuille qui tourne */
.pfo-leaf {
	position: absolute; top: 0; height: 100%; z-index: 10;
	transform-style: preserve-3d; will-change: transform;
	pointer-events: none;
}
.pfo-leaf--right { left: 50%; width: 50%; transform-origin: 0 50%; }
.pfo-leaf--left { left: 0; width: 50%; transform-origin: 100% 50%; }
.pfo-leaf--single { left: 0; width: 100%; transform-origin: 0 50%; }
.pfo-face { left: 0; width: 100%; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.pfo-face--back { transform: rotateY(180deg); }
.pfo-face.is-paper { background: linear-gradient(90deg, #ececec, #fafafa 30%, #f3f3f3); }
.pfo-face.is-empty { background: #fff; }
.pfo-leaf .pfo-shade { transition: opacity var(--pfo-dur, 800ms) ease; }
.pfo-leaf--right .pfo-face--front .pfo-shade, .pfo-leaf--single .pfo-face--front .pfo-shade { background: linear-gradient(90deg, rgba(0,0,0,.25), rgba(0,0,0,0) 30%, rgba(0,0,0,.35)); }
.pfo-leaf--right .pfo-face--back .pfo-shade { background: linear-gradient(270deg, rgba(0,0,0,.25), rgba(0,0,0,0) 30%, rgba(0,0,0,.35)); }
.pfo-leaf--left .pfo-face--front .pfo-shade { background: linear-gradient(270deg, rgba(0,0,0,.25), rgba(0,0,0,0) 30%, rgba(0,0,0,.35)); }
.pfo-leaf--left .pfo-face--back .pfo-shade { background: linear-gradient(90deg, rgba(0,0,0,.25), rgba(0,0,0,0) 30%, rgba(0,0,0,.35)); }
.pfo-leaf.is-start .pfo-face--front .pfo-shade { opacity: 0; }
.pfo-leaf.is-start .pfo-face--back .pfo-shade { opacity: .9; }
.pfo-leaf.is-run .pfo-face--front .pfo-shade { opacity: .9; }
.pfo-leaf.is-run .pfo-face--back .pfo-shade { opacity: 0; }
.pfo-shadows .pfo-leaf .pfo-face { box-shadow: 0 0 20px rgba(0,0,0,.15); }

/* ---------- Défilement ---------- */
.pfo-scroll { display: flex; flex-direction: column; align-items: center; gap: 18px; margin: 0 auto; padding-bottom: 24px; }
.pfo-page--scroll { position: relative; flex: none; }
.pfo-shadows .pfo-page--scroll { box-shadow: 0 4px 18px rgba(0,0,0,.14); }

/* ---------- Flèches latérales ---------- */
.pfo-side {
	position: absolute; top: 50%; z-index: 6; transform: translateY(-50%);
	width: 44px; height: 64px; border: 0; border-radius: 10px;
	background: color-mix(in srgb, var(--pfo-bar) 80%, transparent); color: var(--pfo-text);
	box-shadow: 0 2px 10px rgba(0,0,0,.12);
	display: flex; align-items: center; justify-content: center;
	cursor: pointer; opacity: 0; transition: opacity .2s, background .15s;
}
.pfo-side svg { width: 26px; height: 26px; }
.pfo-side--prev { left: 10px; }
.pfo-side--next { right: 10px; }
.has-panel .pfo-side--prev { left: calc(var(--pfo-panel-w) + 10px); }
.pfo-main:hover .pfo-side:not(:disabled), .pfo-side:focus-visible { opacity: 1; }
.pfo-side:disabled { opacity: 0 !important; pointer-events: none; }
.pfo-layout-scroll .pfo-side { display: none; }
@media (hover: none) { .pfo-side { display: none; } }

/* ---------- Panneau latéral ---------- */
.pfo-panel {
	position: absolute; top: 0; left: 0; bottom: 0; z-index: 15;
	width: var(--pfo-panel-w); max-width: 86vw;
	display: flex; flex-direction: column;
	background: var(--pfo-bar); color: var(--pfo-text);
	box-shadow: 1px 0 0 var(--pfo-line), 4px 0 18px rgba(0,0,0,.08);
	transform: translateX(-105%); transition: transform .25s ease, visibility .25s;
	visibility: hidden;
}
.has-panel .pfo-panel { transform: none; visibility: visible; }
@media (min-width: 800px) {
	.has-panel .pfo-stage { margin-left: var(--pfo-panel-w); }
	.pfo-stage { transition: margin-left .25s ease; }
}
.pfo-panel__head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--pfo-line); }
.pfo-panel__body { flex: 1; overflow: auto; padding: 12px; position: relative; }
.pfo-empty { opacity: .75; }

.pfo-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pfo-thumb {
	display: flex; flex-direction: column; align-items: center; gap: 4px;
	padding: 6px; border: 2px solid transparent; border-radius: 8px;
	background: transparent; color: inherit; cursor: pointer; font: inherit; font-size: 12px;
}
.pfo-thumb canvas { width: 100%; height: auto; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); display: block; }
.pfo-thumb:hover { background: var(--pfo-hover); }
.pfo-thumb.is-current { border-color: var(--pfo-accent); }

.pfo-outline { list-style: none; margin: 0; padding: 0; }
.pfo-outline .pfo-outline { padding-left: 14px; border-left: 1px solid var(--pfo-line); margin-left: 8px; }
.pfo-outline__item {
	display: block; width: 100%; text-align: left; padding: 6px 8px; border: 0; border-radius: 6px;
	background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.pfo-outline__item:hover { background: var(--pfo-hover); }

.pfo-search__input {
	width: 100%; padding: 8px 10px; border: 1px solid var(--pfo-line); border-radius: 8px;
	background: transparent; color: inherit; font: inherit;
}
.pfo-search__input:focus { outline: 2px solid var(--pfo-accent); }
.pfo-search__status { margin: 8px 2px; font-size: 12px; opacity: .8; }
.pfo-results { list-style: none; margin: 0; padding: 0; }
.pfo-result {
	display: block; width: 100%; text-align: left; padding: 8px; border: 0; border-radius: 6px;
	background: transparent; color: inherit; font: inherit; font-size: 13px; cursor: pointer;
}
.pfo-result:hover { background: var(--pfo-hover); }
.pfo-result__page { display: block; font-weight: 600; font-size: 12px; color: var(--pfo-accent); }
.pfo-result mark { background: color-mix(in srgb, var(--pfo-accent) 30%, transparent); color: inherit; border-radius: 2px; }

/* ---------- Menu des modes ---------- */
.pfo-menu {
	position: fixed; z-index: 50; min-width: 180px; padding: 6px;
	background: var(--pfo-bar); color: var(--pfo-text); border-radius: 10px;
	box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 0 0 1px var(--pfo-line);
}
.pfo-menu__item {
	display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
	border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: left;
}
.pfo-menu__item svg { width: 18px; height: 18px; }
.pfo-menu__item:hover { background: var(--pfo-hover); }
.pfo-menu__item.is-active { color: var(--pfo-accent); font-weight: 600; }

/* ---------- Chargement / erreurs ---------- */
.pfo-loader {
	position: absolute; inset: 0; z-index: 40;
	display: flex; align-items: center; justify-content: center;
	background: var(--pfo-bg); transition: opacity .35s ease;
}
.pfo-loader.is-hidden { opacity: 0; pointer-events: none; }
.pfo-loader__box {
	min-width: 240px; max-width: 90vw; padding: 24px 28px; text-align: center;
	background: var(--pfo-bar); color: var(--pfo-text); border-radius: 14px;
	box-shadow: 0 10px 40px rgba(0,0,0,.12);
}
.pfo-spinner {
	width: 38px; height: 38px; margin: 0 auto 12px;
	border: 3px solid var(--pfo-line); border-top-color: var(--pfo-accent); border-radius: 50%;
	animation: pfo-spin .8s linear infinite;
}
.pfo-progress { height: 4px; border-radius: 4px; background: var(--pfo-line); overflow: hidden; }
.pfo-progress i { display: block; height: 100%; width: 0; background: var(--pfo-accent); transition: width .2s; }
.pfo-error__title { font-weight: 600; margin: 0 0 6px; }
.pfo-error__detail { font-size: 12px; opacity: .7; margin: 0 0 12px; word-break: break-word; }
.pfo-error__link, .pfo-pass__btn {
	display: inline-block; padding: 8px 16px; border: 0; border-radius: 8px;
	background: var(--pfo-accent); color: #fff; text-decoration: none; font: inherit; cursor: pointer;
}
.pfo-pass input { display: block; width: 100%; margin: 10px 0; padding: 8px 10px; border: 1px solid var(--pfo-line); border-radius: 8px; font: inherit; }
@keyframes pfo-spin { to { transform: rotate(360deg); } }

.pfo-toast {
	position: absolute; left: 50%; bottom: 24px; z-index: 45;
	transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
	padding: 8px 14px; border-radius: 999px;
	background: rgba(17,20,24,.88); color: #fff; font-size: 13px;
	transition: opacity .2s, transform .2s;
}
.pfo-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Pages hors visionneuse (mot de passe WP, pas de PDF) ---------- */
.pfo-password { max-width: 420px; margin: 12vh auto; padding: 28px; background: var(--pfo-bar); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.1); }
.pfo-password h1 { font-size: 20px; margin-top: 0; }
.pfo-password input[type="password"] { width: 100%; padding: 8px; margin: 6px 0 10px; }
.pfo-noscript { padding: 20px; text-align: center; }

/* ---------- Impression ---------- */
.pfo-print { display: none; }
@media print {
	@page { margin: 0; }
	html.pfo-html, .pfo-body { height: auto; overflow: visible; background: #fff; }
	.pfo-body.pfo-printing > *:not(.pfo-print) { display: none !important; }
	.pfo-body.pfo-printing .pfo-print { display: block; }
	.pfo-print img { display: block; width: 100%; height: auto; page-break-after: always; break-after: page; }
	.pfo-print img:last-child { page-break-after: auto; break-after: auto; }
	.pfo-body:not(.pfo-printing) .pfo-app { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.pfo-panel, .pfo-stage, .pfo-loader, .pfo-toast { transition: none; }
}
