/* ==========================================================================
   PDF flipbook popup (template-parts/popup-flipbook.php, assets/js/flipbook.js)
   Centred white lightbox, as the original DearFlip popups.
   ========================================================================== */

.o-popup--book .o-popup__panel {
	top: 50%;
	right: auto;
	bottom: auto;
	left: 50%;
	width: min(1560px, 96vw);
	max-height: 96vh;
	padding: 56px 24px 18px;
	overflow: hidden;
	box-sizing: border-box;
	border-radius: 14px;
	background: #fff;
	color: #1b1e25;
	opacity: 0;
	transform: translate(-50%, -46%) scale(0.98);
	transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.o-popup--book.is-open .o-popup__panel {
	opacity: 1;
	transform: translate(-50%, -50%);
}
.o-popup--book .o-popup__close {
	top: 10px;
	right: 10px;
	width: 40px;
	height: 40px;
	background: #1b1e25;
	color: #fff;
}
.o-book {
	display: grid;
	gap: 14px;
	background: #fff;
}
.o-book:fullscreen {
	padding: 24px;
	background: #2b2d31;
}
.o-book__stage {
	position: relative;
	display: grid;
	place-items: center;
	height: min(calc(96vh - 150px), 980px);
	border-radius: 10px;
	background: radial-gradient(70% 80% at 50% 40%, #8a8a8a, #6f6f6f);
	cursor: pointer;
	overflow: hidden;
	perspective: 2200px;
	user-select: none;
}
/* Documents made of landscape pages (slides): the stage follows the page shape, the whole page
   always visible and as large as the screen allows. */
.o-book.is-slides .o-book__stage {
	--o-book-maxh: min(calc(96vh - 236px), 980px);
	justify-self: center; /* centred in the popup when the height limit makes it narrower */
	/* Exactly the page: full width, or narrower when the screen height is the limit. */
	width: min(100%, calc(var(--o-book-maxh) / var(--o-book-ratio, 0.5625)));
	height: auto;
	aspect-ratio: 1 / var(--o-book-ratio, 0.5625);
	/* Room left for the panel padding, the controls and the "Télécharger" button. */
	max-height: var(--o-book-maxh);
}
/* Same space above and below the document: it sits exactly in the middle of the popup. */
.o-popup--book .o-popup__panel:has(.o-book.is-slides) .o-book__cta {
	margin: 16px 0 0;
}
.o-popup--book .o-popup__panel:has(.o-book.is-slides) {
	padding-bottom: 56px;
}
.o-book.is-slides .o-book__stage > * {
	margin-inline: auto;
}
.o-book:fullscreen .o-book__stage,
.o-book.is-slides:fullscreen .o-book__stage {
	justify-self: stretch;
	width: auto;
	height: calc(100vh - 110px);
	aspect-ratio: auto;
	max-height: none;
}
.o-book__loading {
	margin: 0;
	color: #fff;
	font-size: 15px;
}
.o-book__spread {
	position: relative;
	display: flex;
	box-shadow: 0 30px 50px -24px rgba(0, 0, 0, 0.6);
	transform-style: preserve-3d;
}
.o-book__page {
	width: var(--pw);
	height: var(--ph);
	background: #fff;
	overflow: hidden;
}
.o-book__page img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	pointer-events: none;
}
.o-book__page.is-blank {
	background: transparent;
}
/* Fold shading in the middle of a double page. */
.o-book__page--left {
	background-image: linear-gradient(270deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0) 8%);
}
.o-book__page--left img {
	mask-image: linear-gradient(270deg, rgba(0, 0, 0, 0.82), #000 6%);
}
.o-book__page--right img {
	mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.82), #000 6%);
}
/* The turning leaf. */
.o-book__leaf {
	position: absolute;
	top: 0;
	width: var(--pw);
	height: var(--ph);
	transform-style: preserve-3d;
	transition: transform 0.7s cubic-bezier(0.45, 0.05, 0.25, 1);
}
.o-book__leaf--next {
	left: 50%;
	transform-origin: left center;
}
.o-book__leaf--prev {
	left: 0;
	transform-origin: right center;
}
.o-book__leaf--next.is-turning {
	transform: rotateY(-180deg);
}
.o-book__leaf--prev.is-turning {
	transform: rotateY(180deg);
}
.o-book__leaf .o-book__page {
	position: absolute;
	inset: 0;
	backface-visibility: hidden;
}
.o-book__leaf .o-book__page--back {
	transform: rotateY(180deg);
}
.o-book__bar {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 6px;
}
.o-book__bar button,
.o-book__bar a {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: #f1f1f1;
	color: #1b1e25;
	cursor: pointer;
	transition: background-color 0.3s, color 0.3s;
}
.o-book__bar button:hover,
.o-book__bar a:hover {
	background: #1b1e25;
	color: #fff;
}
.o-book__bar button:focus-visible,
.o-book__bar a:focus-visible,
.o-book__download:focus-visible {
	outline: 2px solid #fc9d21;
	outline-offset: 2px;
}
.o-book__bar svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
}
.o-book__count {
	min-width: 84px;
	font-family: "Red Hat Display", sans-serif;
	font-size: 14px;
	font-weight: 700;
	text-align: center;
	font-variant-numeric: tabular-nums;
}
.o-book__sep {
	width: 1px;
	height: 24px;
	margin: 0 6px;
	background: #ddd;
}
.o-book__cta {
	margin: 16px 0 0;
	text-align: center;
}
.o-book__download {
	display: inline-block;
	padding: 13px 34px;
	border: 0;
	border-radius: 4px;
	background: #1b1e25;
	color: #fff;
	font-family: "Red Hat Display", sans-serif;
	font-size: 14px;
	font-weight: 700;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.3s;
}
.o-book__download:hover {
	background: #fc9d21;
}
@media (max-width: 767px) {
	.o-popup--book .o-popup__panel {
		padding: 52px 12px 16px;
	}
	.o-book__stage {
		height: min(72vh, calc(100svh - 170px));
	}
	.o-popup--book .o-popup__panel:has(.o-book.is-slides) {
		padding-bottom: 52px;
	}
}
@media (prefers-reduced-motion: reduce) {
	.o-book__leaf,
	.o-popup--book .o-popup__panel {
		transition: none;
	}
}

/* Single-page mode: the page swings in from its spine. */
.o-book__spread.is-enter-next {
	transform-origin: left center;
	animation: o-book-in-next 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.o-book__spread.is-enter-prev {
	transform-origin: right center;
	animation: o-book-in-prev 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes o-book-in-next {
	from {
		opacity: 0.4;
		transform: rotateY(-70deg);
	}
}
@keyframes o-book-in-prev {
	from {
		opacity: 0.4;
		transform: rotateY(70deg);
	}
}

/* Dark variant (Catalogue page): black panel, light controls. */
.o-popup--dark.o-popup--book .o-popup__panel {
	background: #000;
	color: #fff;
}
.o-popup--dark .o-book__stage {
	background: radial-gradient(70% 80% at 50% 40%, #2a2a2a, #121212);
}
.o-popup--dark .o-popup__close {
	background: #fff;
	color: #000;
}
.o-popup--dark .o-book__bar button,
.o-popup--dark .o-book__bar a {
	background: #1c1c1c;
	color: #fff;
}
.o-popup--dark .o-book__bar button:hover,
.o-popup--dark .o-book__bar a:hover {
	background: #fff;
	color: #000;
}
.o-popup--dark .o-book__sep {
	background: rgba(255, 255, 255, 0.2);
}
.o-popup--dark .o-book__download {
	background: #fff;
	color: #000;
}
.o-popup--dark .o-book__download:hover {
	background: #e3c27a;
	color: #000;
}
.o-popup--dark .o-book {
	background: transparent;
}
