/*!
 * H1 Gallery Zoom — styles front-end
 * Tous les réglages visuels sont pilotés par des variables CSS que les
 * contrôles Elementor viennent surcharger sur {{WRAPPER}} .h1gz
 */

.h1gz {
	/* Rythme général */
	--h1gz-gap: 12px;
	--h1gz-anim: 350ms;
	--h1gz-ratio: 1/1;

	/* Miniatures */
	--h1gz-thumbs-size: 96px;
	--h1gz-thumbs-gap: 10px;
	--h1gz-thumb-count: 5;
	--h1gz-thumb-ratio: 1/1;

	/* Zoom */
	--h1gz-lens-size: 180px;
	--h1gz-panel-w: 460px;
	--h1gz-panel-offset: 16px;

	/* Lightbox */
	--h1gz-lb-bg: rgba(8, 8, 10, 0.94);
	--h1gz-lb-ui: #fff;

	/* Gabarits de grille : sélectionnés par le contrôle « position des
	   miniatures » via var(--h1gz-tpl-{{VALUE}}) — donc responsive natif. */
	--h1gz-tpl-bottom: "stage" minmax(0, 1fr) "thumbs" auto / minmax(0, 1fr);
	--h1gz-tpl-top: "thumbs" auto "stage" minmax(0, 1fr) / minmax(0, 1fr);
	--h1gz-tpl-left: "thumbs stage" minmax(0, 1fr) / var(--h1gz-thumbs-size) minmax(0, 1fr);
	--h1gz-tpl-right: "stage thumbs" minmax(0, 1fr) / minmax(0, 1fr) var(--h1gz-thumbs-size);

	--h1gz-flow-bottom: column;
	--h1gz-flow-top: column;
	--h1gz-flow-left: row;
	--h1gz-flow-right: row;

	--h1gz-strip: calc(
		(100% - (var(--h1gz-thumb-count) - 1) * var(--h1gz-thumbs-gap)) / var(--h1gz-thumb-count)
	);
	--h1gz-ac-bottom: var(--h1gz-strip);
	--h1gz-ac-top: var(--h1gz-strip);
	--h1gz-ac-left: 100%;
	--h1gz-ac-right: 100%;

	--h1gz-ar-bottom: auto;
	--h1gz-ar-top: auto;
	--h1gz-ar-left: auto;
	--h1gz-ar-right: auto;

	--h1gz-snap-bottom: x proximity;
	--h1gz-snap-top: x proximity;
	--h1gz-snap-left: y proximity;
	--h1gz-snap-right: y proximity;

	position: relative;
	max-width: 100%;
}

.h1gz *,
.h1gz *::before,
.h1gz *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------- Layout */

.h1gz-inner {
	display: grid;
	gap: var(--h1gz-gap);
	grid-template: var(--h1gz-tpl-bottom);
	align-items: stretch;
}

.h1gz--no-thumbs .h1gz-inner {
	display: block;
}

.h1gz-stage {
	grid-area: stage;
	position: relative;
	min-width: 0;
	min-height: 0;
}

/* ----------------------------------------------------------------- Cadre */

.h1gz-frame {
	position: relative;
	overflow: hidden;
	aspect-ratio: var(--h1gz-ratio);
	border-radius: 16px;
	touch-action: pan-y;
	outline: none;
}

.h1gz-frame:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.h1gz-slides {
	position: relative;
	width: 100%;
	height: 100%;
}

.h1gz-slide {
	position: absolute;
	inset: 0;
	display: block;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--h1gz-anim) ease, transform var(--h1gz-anim) ease;
	text-decoration: none;
}

.h1gz-slide.is-active {
	position: relative;
	/* Indispensable : en position relative, `inset` ne s'applique plus. Sans
	   height:100%, la diapo prend la hauteur naturelle de l'image, object-fit
	   ne s'applique jamais et un cadre à ratio fixe laisse une zone vide.
	   En ratio « naturel », ce 100% se résout en auto et la chaîne suit
	   la hauteur réelle de l'image. */
	height: 100%;
	opacity: 1;
	pointer-events: auto;
	z-index: 1;
}

.h1gz-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	transition: transform var(--h1gz-anim) ease, filter 0.3s ease, opacity 0.3s ease;
	will-change: transform;
	user-select: none;
	-webkit-user-drag: none;
}

.h1gz--fit-cover .h1gz-img {
	object-fit: cover;
}

/* Animations d'entrée alternatives (classes posées par Elementor). */
.h1gz-anim-slide .h1gz-slide {
	transform: translate3d(6%, 0, 0);
}
.h1gz-anim-slide .h1gz-slide.is-active {
	transform: none;
}
.h1gz-anim-zoom .h1gz-slide {
	transform: scale(1.05);
}
.h1gz-anim-zoom .h1gz-slide.is-active {
	transform: none;
}
.h1gz-anim-none .h1gz-slide {
	transition: none;
}

/* ------------------------------------------------------------ Miniatures */

.h1gz-thumbs {
	grid-area: thumbs;
	display: grid;
	gap: var(--h1gz-thumbs-gap);
	grid-auto-flow: column;
	grid-auto-columns: var(--h1gz-ac-bottom);
	grid-auto-rows: auto;
	/* Sans cela, la grille étire les pistes automatiques pour remplir la
	   hauteur disponible et les miniatures perdent leur format. */
	align-content: start;
	justify-content: start;
	overflow: auto;
	min-width: 0;
	min-height: 0;
	max-height: 100%;
	scroll-snap-type: x proximity;
	scroll-behavior: smooth;
	overscroll-behavior: contain;
	padding: 2px;
}

.h1gz-hide-scrollbar-yes .h1gz-thumbs {
	scrollbar-width: none;
	-ms-overflow-style: none;
}
.h1gz-hide-scrollbar-yes .h1gz-thumbs::-webkit-scrollbar {
	width: 0;
	height: 0;
}

.h1gz-thumb {
	position: relative;
	display: block;
	width: 100%;
	padding: 0;
	margin: 0;
	border: 2px solid transparent;
	border-radius: 10px;
	background: none;
	overflow: hidden;
	cursor: pointer;
	opacity: 0.65;
	aspect-ratio: var(--h1gz-thumb-ratio);
	scroll-snap-align: center;
	transition: opacity 0.25s ease, border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
	-webkit-appearance: none;
	appearance: none;
}

.h1gz-thumb:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.h1gz-thumb.is-active {
	opacity: 1;
	border-color: #111;
}

.h1gz-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: inherit;
}

/* --------------------------------------------------------------- Flèches */

.h1gz-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: rgba(255, 255, 255, 0.86);
	color: #111;
	cursor: pointer;
	z-index: 12;
	opacity: 0;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
	transition: opacity 0.25s ease, background-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
	--h1gz-icon-size: 20px;
}

.h1gz-arrow--prev {
	left: 12px;
}
.h1gz-arrow--next {
	right: 12px;
}

.h1gz:hover .h1gz-arrow,
.h1gz-frame:focus-within .h1gz-arrow,
.h1gz-arrows-always .h1gz-arrow {
	opacity: 1;
}

.h1gz-arrow[disabled] {
	opacity: 0.25 !important;
	cursor: default;
	pointer-events: none;
}

/* Par défaut la navigation reste accessible pendant le zoom ; l'option
   « Masquer l'interface pendant le zoom » ajoute la classe h1gz-hideui-yes. */
.h1gz-hideui-yes .h1gz-frame.is-zooming .h1gz-arrow {
	opacity: 0 !important;
	pointer-events: none;
}

/* ----------------------------------------------------- Boutons d'actions */

.h1gz-actions {
	--h1gz-actions-offset: 12px;
	position: absolute;
	top: var(--h1gz-actions-offset);
	right: var(--h1gz-actions-offset);
	display: flex;
	flex-direction: column;
	gap: 8px;
	z-index: 13;
}

.h1gz-actions-top-left .h1gz-actions {
	left: var(--h1gz-actions-offset);
	right: auto;
}
.h1gz-actions-bottom-right .h1gz-actions {
	top: auto;
	bottom: var(--h1gz-actions-offset);
}
.h1gz-actions-bottom-left .h1gz-actions {
	top: auto;
	bottom: var(--h1gz-actions-offset);
	left: var(--h1gz-actions-offset);
	right: auto;
}

.h1gz-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 0;
	border-radius: 0;
	background-color: transparent;
	color: #fff;
	cursor: pointer;
	/* Nu par défaut : ni pastille, ni contour. Une ombre portée légère garde
	   l'icône et le texte lisibles au-dessus d'une image claire. */
	filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
	transition: background-color 0.25s ease, color 0.25s ease, opacity 0.2s ease;
	--h1gz-icon-size: 17px;
}

.h1gz-btn:hover {
	opacity: 0.72;
}

/* Bouton zoom avec libellé : icône + texte, sans habillage. */
.h1gz-btn.has-label {
	width: auto;
	min-width: 0;
	gap: 8px;
	padding: 0;
}

.h1gz-btn__label {
	font-size: 13px;
	font-weight: 500;
	line-height: 1;
	white-space: nowrap;
}

.h1gz-hideui-yes .h1gz-frame.is-zooming .h1gz-btn--expand {
	opacity: 0;
	pointer-events: none;
}

.h1gz-arrow svg,
.h1gz-btn svg {
	width: var(--h1gz-icon-size);
	height: var(--h1gz-icon-size);
	display: block;
}

.h1gz-arrow i,
.h1gz-btn i {
	font-size: var(--h1gz-icon-size);
	line-height: 1;
}

/* ------------------------------------------------- Points de pagination */

.h1gz-dots {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--h1gz-dot-gap, 8px);
	z-index: 12;
}

.h1gz--dots-over .h1gz-dots {
	position: absolute;
	left: 50%;
	bottom: var(--h1gz-dots-offset, 16px);
	transform: translateX(-50%);
	transition: opacity 0.25s ease;
}

.h1gz--dots-below .h1gz-dots {
	margin-top: var(--h1gz-dots-offset, 16px);
}

.h1gz-hideui-yes .h1gz--dots-over .h1gz-frame.is-zooming ~ .h1gz-dots {
	opacity: 0;
	pointer-events: none;
}

.h1gz-dot {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4px;
	margin: 0;
	border: 0;
	background: none;
	cursor: pointer;
	line-height: 0;
	-webkit-appearance: none;
	appearance: none;
}

.h1gz-dot span {
	display: block;
	width: var(--h1gz-dot-size, 9px);
	height: var(--h1gz-dot-size, 9px);
	border-radius: 50%;
	background-color: rgba(255, 255, 255, 0.55);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
	transition: background-color 0.25s ease, width 0.3s ease, border-color 0.25s ease;
}

.h1gz-dot.is-active span {
	background-color: #fff;
	width: var(--h1gz-dot-active-w, var(--h1gz-dot-size, 9px));
}

.h1gz-dot:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 1px;
	border-radius: 4px;
}

/* -------------------------------------------------------------- Compteur */

.h1gz-counter {
	position: absolute;
	bottom: 12px;
	right: 12px;
	z-index: 11;
	display: inline-flex;
	gap: 2px;
	padding: 4px 10px;
	border-radius: 999px;
	background-color: rgba(17, 17, 17, 0.72);
	color: #fff;
	font-size: 12px;
	line-height: 1.4;
	letter-spacing: 0.02em;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	pointer-events: none;
	transition: opacity 0.25s ease;
}

.h1gz-counter-bottom-left .h1gz-counter {
	left: 12px;
	right: auto;
}
.h1gz-counter-top-right .h1gz-counter {
	top: 12px;
	bottom: auto;
}
.h1gz-counter-top-left .h1gz-counter {
	top: 12px;
	bottom: auto;
	left: 12px;
	right: auto;
}

.h1gz-hideui-yes .h1gz-frame.is-zooming .h1gz-counter {
	opacity: 0;
}

/* --------------------------------------------------------------- Légende */

.h1gz-caption {
	font-size: 14px;
	line-height: 1.5;
	text-align: center;
}

.h1gz--cap-over .h1gz-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 10;
	padding: 28px 16px 12px;
	color: #fff;
	background-image: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
	pointer-events: none;
	transition: opacity 0.25s ease;
}

.h1gz--cap-below .h1gz-caption {
	margin-top: 10px;
	color: inherit;
	opacity: 0.85;
}

.h1gz-hideui-yes .h1gz--cap-over .h1gz-frame.is-zooming .h1gz-caption {
	opacity: 0;
}

/* ------------------------------------------------------------- Indice UI */

.h1gz-hint {
	position: absolute;
	left: 50%;
	bottom: 14px;
	transform: translate(-50%, 6px);
	z-index: 11;
	padding: 6px 12px;
	border-radius: 999px;
	background-color: rgba(17, 17, 17, 0.75);
	color: #fff;
	font-size: 12px;
	line-height: 1.4;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.h1gz-frame:hover .h1gz-hint {
	opacity: 1;
	transform: translate(-50%, 0);
}

.h1gz-frame.is-zooming .h1gz-hint {
	opacity: 0;
}

/* ------------------------------------------------------------------ Zoom */

.h1gz-frame.is-zoomable {
	cursor: crosshair;
}

.h1gz-zoom-layer {
	position: absolute;
	z-index: 8;
	background-repeat: no-repeat;
	background-color: #fff;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.18s ease;
	border-radius: inherit;
}

.h1gz-frame.is-zooming .h1gz-zoom-layer {
	opacity: 1;
}

/* Le zoom interne remplit le cadre ; la lentille et la loupe non. */
.h1gz--zoom-lens .h1gz-zoom-layer,
.h1gz--zoom-magnifier .h1gz-zoom-layer {
	display: none;
}

.h1gz-lens {
	position: absolute;
	z-index: 9;
	width: var(--h1gz-lens-size);
	height: var(--h1gz-lens-size);
	border: 2px solid #fff;
	border-radius: 8px;
	background-color: rgba(255, 255, 255, 0.28);
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.18s ease;
	background-repeat: no-repeat;
}

.h1gz--zoom-inner .h1gz-lens {
	display: none;
}

.h1gz-frame.is-zooming .h1gz-lens {
	opacity: 1;
}

/* Loupe flottante : la lentille porte elle-même l'image agrandie. */
.h1gz--zoom-magnifier .h1gz-lens {
	background-color: #fff;
	border-radius: 50%;
	overflow: hidden;
}

.h1gz-zoom-panel {
	position: absolute;
	top: 0;
	left: calc(100% + var(--h1gz-panel-offset));
	width: var(--h1gz-panel-w);
	height: 100%;
	z-index: 30;
	border-radius: 16px;
	background-color: #fff;
	background-repeat: no-repeat;
	box-shadow: 0 18px 45px -10px rgba(0, 0, 0, 0.25);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.18s ease, visibility 0.18s ease;
}

.h1gz-panel-left .h1gz-zoom-panel {
	left: auto;
	right: calc(100% + var(--h1gz-panel-offset));
}

.h1gz-zoom-panel.is-active {
	opacity: 1;
	visibility: visible;
}

/* Pas la place d'un panneau latéral : il se superpose au cadre. La taille de
   la lentille étant dérivée du panneau en JS, la correspondance reste exacte. */
@media (max-width: 1024px) {
	.h1gz .h1gz-zoom-panel {
		top: 0;
		left: 0;
		right: auto;
		width: 100%;
		height: 100%;
	}
}

/* -------------------------------------------------------------- Lightbox */

.h1gz-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	background-color: var(--h1gz-lb-bg, rgba(8, 8, 10, 0.94));
	color: var(--h1gz-lb-ui, #fff);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.25s ease, visibility 0.25s ease;
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.h1gz-lb.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.h1gz-lb__stage {
	position: relative;
	flex: 1 1 auto;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: none;
}

.h1gz-lb__img {
	max-width: 92%;
	max-height: 92%;
	object-fit: contain;
	transform-origin: 0 0;
	cursor: zoom-in;
	transition: transform 0.2s ease;
	user-select: none;
	-webkit-user-drag: none;
}

.h1gz-lb__img.is-zoomed {
	cursor: grab;
	transition: none;
	max-width: none;
	max-height: none;
}

.h1gz-lb__img.is-dragging {
	cursor: grabbing;
}

.h1gz-lb__btn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border: 0;
	border-radius: 50%;
	background-color: rgba(255, 255, 255, 0.12);
	color: inherit;
	cursor: pointer;
	transition: background-color 0.2s ease;
	--h1gz-icon-size: 22px;
}

.h1gz-lb__btn:hover {
	background-color: rgba(255, 255, 255, 0.24);
}

.h1gz-lb__btn svg {
	width: var(--h1gz-icon-size);
	height: var(--h1gz-icon-size);
}

.h1gz-lb__prev {
	left: 20px;
}
.h1gz-lb__next {
	right: 20px;
}

.h1gz-lb__close {
	top: 20px;
	right: 20px;
	transform: none;
	width: 42px;
	height: 42px;
	--h1gz-icon-size: 20px;
}

.h1gz-lb__counter {
	position: absolute;
	top: 26px;
	left: 24px;
	font-size: 13px;
	letter-spacing: 0.04em;
	opacity: 0.8;
}

.h1gz-lb__thumbs {
	flex: 0 0 auto;
	display: flex;
	gap: 8px;
	padding: 14px 18px 20px;
	overflow-x: auto;
	justify-content: center;
	scrollbar-width: none;
}

.h1gz-lb__thumbs::-webkit-scrollbar {
	height: 0;
}

.h1gz-lb__thumb {
	flex: 0 0 auto;
	width: 62px;
	height: 62px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 8px;
	background: none;
	overflow: hidden;
	cursor: pointer;
	opacity: 0.55;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

.h1gz-lb__thumb.is-active {
	opacity: 1;
	border-color: currentColor;
}

.h1gz-lb__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

body.h1gz-lb-open {
	overflow: hidden;
}

/* ------------------------------------------------------------ Divers/A11Y */

.h1gz-empty {
	padding: 24px;
	border: 1px dashed currentColor;
	border-radius: 12px;
	opacity: 0.7;
	font-size: 14px;
	text-align: center;
}

@media (prefers-reduced-motion: reduce) {
	.h1gz *,
	.h1gz-lb * {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}
}

/* Sur écran tactile, la lentille/loupe reste utilisable mais discrète. */
@media (hover: none) {
	.h1gz-arrow {
		opacity: 1;
	}
}
