/* Opt-in: class on <img> or parent figure / .wp-block-image */
img.asmon-lightbox,
img.image-allow-lightbox,
.asmon-lightbox img,
.image-allow-lightbox img {
	cursor: zoom-in;
}

body.asmon-immersive > .asmon-lightbox-root {
	position: fixed !important;
	z-index: 10100 !important;
}

.asmon-lightbox-root {
	position: fixed;
	inset: 0;
	z-index: 10100;
	display: flex;
	align-items: center;
	justify-content: center;
	padding:
		clamp(2.5rem, 8vh, 4rem)
		clamp(1rem, 4vw, 2.5rem)
		clamp(1rem, 4vw, 2.5rem);
	box-sizing: border-box;
	pointer-events: none;
	visibility: hidden;
}

.asmon-lightbox-root.is-open {
	pointer-events: auto;
	visibility: visible;
}

/* Fond : même durée que le vol de l’image (ouverture + fermeture simultanées) */
.asmon-lightbox-root__backdrop {
	position: absolute;
	inset: 0;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(0, 0, 0, 0);
	cursor: zoom-out;
	transition: background 0.58s cubic-bezier(0.22, 1, 0.36, 1);
}

.asmon-lightbox-root.is-open .asmon-lightbox-root__backdrop {
	background: rgba(0, 0, 0, 0);
}

.asmon-lightbox-root.is-active:not(.is-closing) .asmon-lightbox-root__backdrop {
	background: rgba(0, 0, 0, 0.92);
}

.asmon-lightbox-root__close {
	position: absolute;
	top: clamp(3.75rem, 3vw, 1.25rem);
	right: clamp(2.75rem, 3vw, 1.25rem);
	z-index: 4;
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(201, 168, 76, 0.35);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	color: rgba(255, 255, 255, 0.92);
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 1.45rem;
	font-weight: 300;
	line-height: 1;
	cursor: pointer;
	opacity: 0;
	transform: scale(0.92);
	transition:
		opacity 0.35s ease 0.1s,
		transform 0.35s ease 0.1s,
		border-color 0.25s ease,
		background 0.25s ease;
}

.asmon-lightbox-root.is-active:not(.is-closing) .asmon-lightbox-root__close {
	opacity: 1;
	transform: scale(1);
}

.asmon-lightbox-root.is-closing .asmon-lightbox-root__close,
.asmon-lightbox-root.is-open:not(.is-active) .asmon-lightbox-root__close {
	opacity: 0;
	transition-duration: 0.12s;
}

.asmon-lightbox-root__close:hover,
.asmon-lightbox-root__close:focus-visible {
	border-color: rgba(201, 168, 76, 0.75);
	background: rgba(20, 20, 20, 0.85);
	outline: none;
}

.asmon-lightbox-root__close-icon {
	display: block;
	margin: 0;
	padding: 0;
	line-height: 1;
	transform: translateY(-0.04em);
}

.asmon-lightbox-root__stage {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	padding-bottom: clamp(0, 1vh, 4.25rem);
}

.asmon-lightbox-root__figure {
	position: relative;
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.65rem;
}

/* Cadre = taille exacte de l’image ; animation depuis / vers la vignette */
.asmon-lightbox-root__frame {
	--asmon-lb-border: 3px;
	--asmon-lb-breathe: 2.8s;
	position: relative;
	display: inline-block;
	line-height: 0;
	vertical-align: top;
	overflow: visible;
	transform: translate3d(
			var(--asmon-lb-dx, 0px),
			var(--asmon-lb-dy, 0px),
			0
		)
		scale(var(--asmon-lb-scale, 0.88));
	transform-origin: center center;
	transition: transform 0.58s cubic-bezier(0.22, 1, 0.36, 1);
	will-change: transform;
}

.asmon-lightbox-root.is-active:not(.is-closing) .asmon-lightbox-root__frame {
	transform: translate3d(0, 0, 0) scale(1);
	animation: asmon-lightbox-frame-glow var(--asmon-lb-breathe) ease-in-out infinite;
}

/* Bordure dorée + respiration */
.asmon-lightbox-root__frame::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 3;
	pointer-events: none;
	box-shadow:
		inset 0 0 0 var(--asmon-lb-border) rgba(201, 168, 76, 0.45),
		0 0 16px 2px rgba(201, 168, 76, 0.12);
	animation: asmon-lightbox-border-breathe var(--asmon-lb-breathe) ease-in-out infinite;
}

/* Halo : drop-shadow (contours adoucis) — plus de calque rectangulaire */
.asmon-lightbox-root__flow {
	display: none;
}

@keyframes asmon-lightbox-frame-glow {
	0%,
	100% {
		filter: drop-shadow(0 0 20px rgba(201, 168, 76, 0.32))
			drop-shadow(0 0 40px rgba(201, 168, 76, 0.16))
			drop-shadow(0 0 64px rgba(90, 74, 36, 0.1));
	}

	50% {
		filter: drop-shadow(0 0 28px rgba(201, 168, 76, 0.48))
			drop-shadow(0 0 52px rgba(201, 168, 76, 0.26))
			drop-shadow(0 0 80px rgba(120, 98, 48, 0.14));
	}
}

@keyframes asmon-lightbox-border-breathe {
	0%,
	100% {
		box-shadow:
			inset 0 0 0 var(--asmon-lb-border) rgba(201, 168, 76, 0.36),
			0 0 12px 2px rgba(201, 168, 76, 0.1);
	}

	50% {
		box-shadow:
			inset 0 0 0 var(--asmon-lb-border) rgba(201, 168, 76, 0.58),
			0 0 20px 3px rgba(201, 168, 76, 0.2);
	}
}

/* Reflet chrome — même réglage que le fil d’Ariane (.asmon-crumb__chrome-flare) */
.asmon-lightbox-root__chrome-flare {
	--chrome-cycle: 18s;
	position: absolute;
	inset: 0;
	z-index: 4;
	pointer-events: none;
	padding: var(--asmon-lb-border);
	-webkit-mask:
		linear-gradient(#fff 0 0) content-box,
		linear-gradient(#fff 0 0);
	-webkit-mask-composite: xor;
	mask-composite: exclude;
	overflow: hidden;
}

.asmon-lightbox-root__chrome-flare::before {
	content: "";
	position: absolute;
	inset: 0;
	background-image: linear-gradient(
		100deg,
		transparent 0%,
		rgba(255, 248, 228, 0.18) 32%,
		rgba(255, 252, 245, 0.72) 50%,
		rgba(255, 248, 228, 0.18) 68%,
		transparent 100%
	);
	background-size: 55% 100%;
	background-repeat: no-repeat;
	background-position: -55% 0;
	animation: asmon-lightbox-chrome-flare var(--chrome-cycle) linear infinite;
}

@keyframes asmon-lightbox-chrome-flare {
	0% {
		background-position: -55% 0;
	}

	38% {
		background-position: 155% 0;
	}

	76% {
		background-position: -55% 0;
	}

	76%,
	100% {
		background-position: -55% 0;
	}
}

.asmon-lightbox-root__viewport {
	position: relative;
	z-index: 1;
	display: block;
	overflow: hidden;
	line-height: 0;
	touch-action: none;
	cursor: zoom-in;
}

.asmon-lightbox-root.is-zoomed .asmon-lightbox-root__viewport {
	cursor: grab;
}

.asmon-lightbox-root.is-panning .asmon-lightbox-root__viewport {
	cursor: grabbing;
}

.asmon-lightbox-root__img {
	display: block;
	width: auto;
	height: auto;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
	vertical-align: top;
	transform: translate3d(var(--asmon-lb-pan-x, 0px), var(--asmon-lb-pan-y, 0px), 0)
		scale(var(--asmon-lb-user-zoom, 1));
	transform-origin: center center;
	will-change: transform;
	user-select: none;
	-webkit-user-drag: none;
}

.asmon-lightbox-root.is-panning .asmon-lightbox-root__img,
.asmon-lightbox-root.is-zooming .asmon-lightbox-root__img {
	transition: none;
}

.asmon-lightbox-root:not(.is-panning):not(.is-zooming) .asmon-lightbox-root__img {
	transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.asmon-lightbox-root__caption {
	max-width: min(92vw, 52rem);
	margin: 0;
	padding: 0 0.5rem;
	color: var(--asmon-text, #dbd3c7);
	font-size: 0.95rem;
	font-style: italic;
	line-height: 1.45;
	text-align: center;
	opacity: 0;
	transform: translateY(6px);
	transition:
		opacity 0.35s ease,
		transform 0.35s ease;
}

.asmon-lightbox-root.is-active:not(.is-closing) .asmon-lightbox-root__caption:not(:empty) {
	opacity: 1;
	transform: translateY(0);
}

.asmon-lightbox-root__hint {
	position: absolute;
	bottom: clamp(0.75rem, 3vw, 1.25rem);
	left: 50%;
	z-index: 4;
	transform: translateX(-50%);
	margin: 0;
	padding: 0.35rem 0.75rem;
	border: 1px solid rgba(201, 168, 76, 0.22);
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.45);
	color: rgba(255, 255, 255, 0.62);
	font-size: 0.75rem;
	letter-spacing: 0.04em;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.35s ease;
	max-width: min(92vw, 36rem);
}

.asmon-lightbox-root--has-download .asmon-lightbox-root__hint {
	bottom: clamp(0.85rem, 3vw, 1.35rem);
}

@media (max-width: 767px), (hover: none) and (pointer: coarse) {
	.asmon-lightbox-root__hint {
		white-space: normal;
		max-width: min(92vw, 18rem);
		text-align: center;
		line-height: 1.4;
	}
}

.asmon-lightbox-root.is-active:not(.is-closing) .asmon-lightbox-root__hint {
	opacity: 1;
	z-index: 6;
}

@media (prefers-reduced-motion: reduce) {
	.asmon-lightbox-root__backdrop,
	.asmon-lightbox-root__frame,
	.asmon-lightbox-root__close,
	.asmon-lightbox-root__caption,
	.asmon-lightbox-root__frame::before,
	.asmon-lightbox-root__chrome-flare::before,
	.asmon-lightbox-root__img {
		transition: none;
		animation: none;
	}

	.asmon-lightbox-root.is-active:not(.is-closing) .asmon-lightbox-root__frame {
		filter: drop-shadow(0 0 24px rgba(201, 168, 76, 0.38))
			drop-shadow(0 0 48px rgba(201, 168, 76, 0.18));
		animation: none;
	}

	.asmon-lightbox-root__frame::before {
		box-shadow: inset 0 0 0 var(--asmon-lb-border) rgba(201, 168, 76, 0.5);
	}
}

.asmon-lightbox-root--embed .asmon-lightbox-root__viewport {
	overflow: auto;
	cursor: auto;
	touch-action: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: rgba(201, 168, 76, 0.5) rgba(0, 0, 0, 0.2);
}

.asmon-lightbox-root--embed-pdf .asmon-lightbox-root__viewport {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	line-height: 0;
}

.asmon-lightbox-root__embed {
	display: block;
	width: 100%;
	min-height: 100%;
}

.asmon-lightbox-root--embed-pdf .asmon-lightbox-root__embed {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-height: 0;
	height: 100%;
}

.asmon-lightbox-root__embed-pdf {
	display: block;
	width: 100%;
	flex: 1 1 auto;
	min-height: 0;
	height: 100%;
	border: 0;
	background: #0e0b08;
}

.asmon-lightbox-root__embed-media {
	display: block;
	width: 100%;
	max-height: min(72vh, 42rem);
	margin: 0 auto;
}

.asmon-lightbox-root__embed-audio {
	display: block;
	width: min(28rem, 100%);
	margin: 2rem auto;
}

.asmon-lightbox-root__embed-text {
	width: 100%;
	margin: 0;
	padding: 1rem 1.1rem;
	color: var(--asmon-text-bright, #e8dec8);
	font-family: var(--asmon-font-body, "Crimson Pro", Georgia, serif);
	font-size: 0.9rem;
	line-height: 1.55;
	white-space: pre-wrap;
	word-break: break-word;
}

.asmon-lightbox-root__embed-message {
	margin: 0;
	padding: 2rem 1.25rem;
	color: var(--asmon-text, #9a8b72);
	font-size: 0.95rem;
	font-style: italic;
	line-height: 1.5;
	text-align: center;
}

.asmon-lightbox-root__download {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	margin: 0.45rem auto 0;
	padding: 0;
	border: 1px solid rgba(201, 168, 76, 0.42);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.35);
	color: var(--asmon-accent, #c9a84c);
	cursor: pointer;
	opacity: 0;
	transform: translateY(6px);
	transition:
		opacity 0.35s ease,
		transform 0.35s ease,
		border-color 0.25s ease,
		background 0.25s ease;
	flex-shrink: 0;
}

.asmon-lightbox-root--has-download .asmon-lightbox-root__figure {
	gap: 0.45rem;
}

.asmon-lightbox-root--has-download .asmon-lightbox-root__caption {
	margin-bottom: 0;
}

.asmon-lightbox-root__download:not([hidden]) {
	display: inline-flex;
}

.asmon-lightbox-root.is-active:not(.is-closing) .asmon-lightbox-root__download:not([hidden]) {
	opacity: 1;
	transform: translateY(0);
}

.asmon-lightbox-root__download:hover,
.asmon-lightbox-root__download:focus-visible {
	border-color: rgba(201, 168, 76, 0.72);
	background: rgba(201, 168, 76, 0.12);
	outline: none;
}
