/**
 * 10gital Flipbook — styles.
 *
 * Nommage BEM. Tout ce qui est couleur, rayon ou espacement passe par une
 * variable CSS : on surcharge depuis ACSS ou le thème sans toucher au plugin.
 */

.dixgital-flipbook {
	--dixgital-backdrop: rgba( 22, 24, 28, 0.92 );
	--dixgital-bar-bg: rgba( 255, 255, 255, 0.96 );
	--dixgital-bar-fg: #1a1c20;
	--dixgital-accent: currentColor;
	--dixgital-radius: 4px;
	--dixgital-gap: 0.5rem;
	--dixgital-page-bg: #fff;
	--dixgital-z: 99999;
}

/* --- Déclencheur ------------------------------------------------------- */

.dixgital-flipbook__trigger {
	cursor: pointer;
}

/* --- Viewer ------------------------------------------------------------ */

.dixgital-viewer {
	display: flex;
	flex-direction: column;
	background: var( --dixgital-backdrop, rgba( 22, 24, 28, 0.92 ) );
}

.dixgital-viewer--lightbox {
	position: fixed;
	inset: 0;
	z-index: var( --dixgital-z, 99999 );
}

.dixgital-viewer--inline {
	position: relative;
	width: 100%;
	min-height: min( 78vh, 720px );
	border-radius: var( --dixgital-radius, 4px );
	overflow: hidden;
}

.dixgital-noscroll {
	overflow: hidden;
}

/* --- Scène ------------------------------------------------------------- */

/*
 * Le livre est centré par `margin: auto` et non par `justify-content`.
 * Un élément flex centré qui dépasse son conteneur déborde des deux côtés, et
 * aucun navigateur ne rend défilable ce qui déborde en haut et à gauche : au
 * zoom, la moitié de la page devenait inatteignable. `margin: auto` centre tant
 * qu'il reste de la place et cède proprement dès qu'il n'y en a plus.
 */
.dixgital-viewer__stage {
	position: relative;
	flex: 1 1 auto;
	display: flex;
	align-items: flex-start;
	justify-content: flex-start;
	overflow: hidden;
	min-height: 0;
}

.dixgital-viewer__stage.is-zoomed {
	overflow: auto;
	overscroll-behavior: contain;
	cursor: grab;
}

.dixgital-viewer__stage.is-panning {
	cursor: grabbing;
	user-select: none;
}

.dixgital-viewer__stage:focus-visible {
	outline: 2px solid var( --dixgital-accent, currentColor );
	outline-offset: -2px;
}

/* Boîte de mise en page : porte la taille zoomée, donc la zone défilable. */
.dixgital-viewer__book {
	position: relative;
	margin: auto;
	flex: 0 0 auto;
}

/* Calque d'échelle : ne participe pas à la mise en page. */
.dixgital-viewer__scale {
	transform-origin: top left;
	transition: transform 0.2s ease;
	will-change: transform;
}

.dixgital-viewer__status {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var( --dixgital-gap, 0.5rem );
	color: #fff;
	font-size: 0.95rem;
	text-align: center;
	padding: 1rem;
}

.dixgital-viewer__status-text {
	opacity: 0.85;
}

.dixgital-viewer__btn--retry {
	border: 1px solid currentColor;
	font-size: 0.9rem;
}

/* Annonces destinées aux lecteurs d'écran uniquement. */
.dixgital-viewer__live {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	clip-path: inset( 50% );
	white-space: nowrap;
	border: 0;
}

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

.dixgital-flipbook__page {
	position: relative;
	background: var( --dixgital-page-bg, #fff );
	overflow: hidden;
}

/* Prend le pas sur `.stf__parent canvas` fourni par StPageFlip. */
.dixgital-viewer .dixgital-flipbook__page canvas.dixgital-flipbook__canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

.dixgital-flipbook__ph {
	position: absolute;
	inset: 0;
	background:
		linear-gradient( 100deg, rgba( 0, 0, 0, 0 ) 20%, rgba( 0, 0, 0, 0.04 ) 40%, rgba( 0, 0, 0, 0 ) 60% )
		#f2f2f2;
	background-size: 200% 100%;
	animation: dixgital-shimmer 1.4s linear infinite;
}

@keyframes dixgital-shimmer {
	to {
		background-position: -200% 0;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.dixgital-flipbook__ph {
		animation: none;
	}

	.dixgital-viewer__scale {
		transition: none;
	}
}

/* --- Barre d'outils ---------------------------------------------------- */

.dixgital-viewer__bar {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var( --dixgital-gap, 0.5rem );
	padding: 0.5rem 0.75rem;
	background: var( --dixgital-bar-bg, rgba( 255, 255, 255, 0.96 ) );
	color: var( --dixgital-bar-fg, #1a1c20 );
	flex-wrap: wrap;
}

.dixgital-viewer__title {
	margin-inline-end: auto;
	font-weight: 600;
	font-size: 0.95rem;
}

.dixgital-viewer__pager {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.9rem;
	font-variant-numeric: tabular-nums;
}

.dixgital-viewer__input {
	width: 4.5ch;
	min-height: 44px;
	padding: 0 0.25rem;
	border: 1px solid rgba( 0, 0, 0, 0.25 );
	border-radius: var( --dixgital-radius, 4px );
	background: transparent;
	color: inherit;
	font: inherit;
	font-variant-numeric: tabular-nums;
	text-align: center;
	/* Les flèches natives réduisent la zone de saisie sans rien apporter ici. */
	-moz-appearance: textfield;
	appearance: textfield;
}

.dixgital-viewer__input::-webkit-outer-spin-button,
.dixgital-viewer__input::-webkit-inner-spin-button {
	margin: 0;
	appearance: none;
}

.dixgital-viewer__input:focus-visible {
	outline: 2px solid var( --dixgital-accent, currentColor );
	outline-offset: 1px;
}

.dixgital-viewer__total {
	opacity: 0.7;
}

.dixgital-viewer__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0 0.6rem;
	border: 0;
	border-radius: var( --dixgital-radius, 4px );
	background: transparent;
	color: inherit;
	font-size: 1.15rem;
	line-height: 1;
	cursor: pointer;
	text-decoration: none;
}

.dixgital-viewer__btn:hover,
.dixgital-viewer__btn:focus-visible {
	background: rgba( 0, 0, 0, 0.08 );
}

.dixgital-viewer__btn:focus-visible {
	outline: 2px solid var( --dixgital-accent, currentColor );
	outline-offset: 2px;
}

.dixgital-viewer__btn[disabled] {
	opacity: 0.35;
	cursor: default;
}

/*
 * La croix se détache du fond du document, dont la couleur est surchargeable :
 * l'ombre portée garantit sa lisibilité même sur un fond clair.
 */
.dixgital-viewer__close {
	position: absolute;
	top: 0.5rem;
	inset-inline-end: 0.5rem;
	z-index: 2;
	color: #fff;
	font-size: 1.4rem;
	background: rgba( 0, 0, 0, 0.45 );
	text-shadow: 0 1px 2px rgba( 0, 0, 0, 0.8 );
}

.dixgital-viewer__close:hover,
.dixgital-viewer__close:focus-visible {
	background: rgba( 0, 0, 0, 0.7 );
}

/* --- États vides ------------------------------------------------------- */

.dixgital-flipbook--empty {
	margin: 0;
	opacity: 0.8;
}
