/* ==========================================================================
   Hamon - Galerie Produit
   ========================================================================== */

.hamon-gallery {
	display: flex;
	flex-direction: row;
	gap: 14px;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	--hamon-gallery-thumb-size: 76px;
}

.hamon-gallery--position-bottom {
	flex-direction: column;
}

.hamon-gallery * {
	box-sizing: border-box;
}

/* ---- Vignettes ---- */

.hamon-gallery__thumbs {
	display: flex;
	flex-shrink: 0;
	gap: 10px;
	overflow-y: auto;
	scrollbar-width: thin;
}

.hamon-gallery--position-left .hamon-gallery__thumbs {
	flex-direction: column;
	width: var(--hamon-gallery-thumb-size);
	max-height: 520px;
}

.hamon-gallery--position-bottom .hamon-gallery__thumbs {
	flex-direction: row;
	width: 100%;
	max-height: none;
	overflow-x: auto;
	order: 2;
	justify-content: center;
}

.hamon-gallery__thumb {
	flex-shrink: 0;
	width: var(--hamon-gallery-thumb-size);
	height: var(--hamon-gallery-thumb-size);
	padding: 0;
	border: 2px solid transparent;
	border-radius: 6px;
	overflow: hidden;
	cursor: pointer;
	background: #f4f4f2;
	opacity: 0.7;
	transition: opacity 0.15s ease, border-color 0.15s ease;
}

.hamon-gallery__thumb:hover {
	opacity: 1;
}

.hamon-gallery__thumb.is-active {
	opacity: 1;
	border-color: #006D77;
}

.hamon-gallery__thumb img {
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	object-fit: cover;
	display: block;
	border: none;
	box-shadow: none;
	border-radius: 0;
}

/* Vignette vidéo : pas d'image miniature disponible (le plugin de vidéo ne
   fournit pas de thumbnail séparé), donc une icône play centrée sur un fond
   sombre uni — cohérent avec la convention visuelle habituelle (YouTube,
   lecteurs vidéo natifs, galerie WooCommerce native). */
.hamon-gallery__thumb--video {
	background: #2b2b2b;
	display: flex;
	align-items: center;
	justify-content: center;
}

.hamon-gallery__thumb-play-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	opacity: 0.9;
}

/* ---- Zone principale (stage) ---- */

.hamon-gallery__stage {
	position: relative;
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
}

.hamon-gallery--position-bottom .hamon-gallery__stage {
	order: 1;
}

.hamon-gallery__viewport {
	position: relative;
	flex: 0 0 auto;
	width: 100%; /* valeur de repli ; remplacée par le JS selon la largeur réelle de la photo active */
	max-width: 100%;
	height: auto;
	min-height: 60px; /* valeur de repli minime, juste pour éviter un flash à hauteur nulle avant le calcul JS ; n'impose jamais une hauteur supérieure à la vraie valeur calculée (cf. applySlideDimensions) */
	margin: 0 auto; /* centre le cadre dans le stage quand il devient plus étroit (photo verticale) */
	overflow: hidden;
	border-radius: 8px;
	background: #f4f4f2;
	touch-action: pan-y;
	transition: width 0.3s ease, height 0.3s ease;
}

.hamon-gallery__track {
	display: flex;
	height: 100%;
	transition: transform 0.3s ease;
}

.hamon-gallery__slide {
	flex: 0 0 auto;
	width: 100%; /* remplacé par une largeur fixe en px, posée par le JS (= largeur du viewport) */
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.hamon-gallery__slide img.hamon-gallery__image {
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	-o-object-fit: contain;
	object-fit: contain;
	display: block;
	cursor: zoom-in;
	-webkit-user-select: none;
	user-select: none;
	-webkit-user-drag: none;
	border: none;
	box-shadow: none;
	border-radius: 0;
}

/* Vidéo "Really Simple Featured Video" : même logique de dimensionnement que
   les images (épouse exactement la hauteur de référence x de la galerie),
   mais sans curseur zoom-in ni restriction de sélection — la vidéo garde ses
   propres contrôles natifs de lecture. */
.hamon-gallery__slide video {
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	-o-object-fit: contain;
	object-fit: contain;
	display: block;
	border: none;
	box-shadow: none;
	border-radius: 0;
}

/* ---- Flèches de navigation ---- */

.hamon-gallery__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 5;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.85);
	color: #2b2b2b;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	transition: background 0.15s ease;
}

.hamon-gallery__nav:hover {
	background: #fff;
}

.hamon-gallery__nav--prev {
	left: 10px;
}

.hamon-gallery__nav--next {
	right: 10px;
}

/* Masque les flèches s'il n'y a qu'une seule image */
.hamon-gallery__stage:has(.hamon-gallery__slide:only-child) .hamon-gallery__nav,
.hamon-gallery__stage:has(.hamon-gallery__slide:only-child) .hamon-gallery__counter {
	display: none;
}

/* ---- Bouton plein écran ---- */

.hamon-gallery__fullscreen-trigger {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 5;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.85);
	color: #2b2b2b;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.hamon-gallery__fullscreen-trigger:hover {
	background: #fff;
}

/* ---- Compteur (mobile surtout) ---- */

.hamon-gallery__counter {
	position: absolute;
	bottom: 12px;
	right: 12px;
	z-index: 5;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 12px;
	padding: 3px 9px;
	border-radius: 12px;
	display: none;
}

/* ---- Loupe (desktop uniquement) ---- */

.hamon-gallery__loupe-lens {
	position: absolute;
	width: 110px;
	height: 110px;
	border: 2px solid rgba(255, 255, 255, 0.9);
	background-color: rgba(255, 255, 255, 0.15);
	border-radius: 4px;
	pointer-events: none;
	display: none;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
	z-index: 6;
}

/* Panneau de résultat zoomé : positionné en JS pour rester visuellement
   collé au coin haut-droit de la photo affichée (cf. updateLoupeResultPosition
   dans hamon-galerie.js). Taille fixe (260px, 320px sur grand écran), gardée
   constante quelle que soit la largeur de la photo — le panneau est un enfant
   du STAGE (pas du viewport, qui a overflow:hidden), donc il peut déborder
   librement du cadre étroit d'une photo verticale sans jamais être tronqué. */
.hamon-gallery__loupe-result {
	position: absolute;
	background-repeat: no-repeat;
	background-color: #f4f4f2;
	border-radius: 8px;
	border: 2px solid rgba(255, 255, 255, 0.9);
	display: none;
	z-index: 7;
	pointer-events: none;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.hamon-gallery.is-loupe-active .hamon-gallery__loupe-lens,
.hamon-gallery.is-loupe-active .hamon-gallery__loupe-result {
	display: block;
}

/* La loupe ne s'active jamais sur petit écran / tactile */
@media (max-width: 900px), (hover: none) {
	.hamon-gallery__loupe-lens,
	.hamon-gallery__loupe-result {
		display: none !important;
	}
}

/* ==========================================================================
   Responsive : mobile = vignettes en dessous, swipe, compteur visible
   ========================================================================== */

@media (max-width: 700px) {
	.hamon-gallery {
		flex-direction: column;
	}

	.hamon-gallery__thumbs,
	.hamon-gallery--position-left .hamon-gallery__thumbs {
		width: 100%;
		flex-direction: row;
		overflow-x: auto;
		max-height: none;
		order: 2;
		padding-bottom: 4px;
		justify-content: center;
	}

	.hamon-gallery__stage {
		order: 1;
	}

	.hamon-gallery__counter {
		display: block;
	}

	.hamon-gallery__nav {
		width: 34px;
		height: 34px;
	}

	.hamon-lightbox__nav {
		width: 38px;
		height: 38px;
	}
}

/* ==========================================================================
   Lightbox plein écran
   ========================================================================== */

.hamon-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(10, 10, 10, 0.96);
	display: none;
	align-items: center;
	justify-content: center;
}

.hamon-lightbox.is-open {
	display: flex;
}

.hamon-lightbox__viewport {
	position: relative;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	touch-action: none;
	z-index: 1;
}

/* Centrage par position absolute + transform plutôt que par flexbox sur
   .hamon-lightbox__viewport : un enfant flex sans largeur/hauteur déclarée
   dépend du calcul de taille intrinsèque de l'image par le moteur de rendu,
   qui s'est avéré peu fiable sur certains appareils Android bas/milieu de
   gamme (taille quasi nulle au premier rendu). Donner une taille de boîte
   fixe (92vw/88vh) lève toute ambiguïté, quel que soit l'appareil. Le JS
   (applyTransform(), dans hamon-galerie.js) compose ce centrage de base
   avec le pan/zoom : translate(-50%,-50%) translate(posX,posY) scale(scale). */
.hamon-lightbox__image {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 92vw;
	height: 88vh;
	transform: translate(-50%, -50%);
	-o-object-fit: contain;
	object-fit: contain;
	will-change: transform;
	transform-origin: center center;
	cursor: zoom-in;
	-webkit-user-select: none;
	user-select: none;
	-webkit-user-drag: none;
	user-drag: none;
	border: none;
	box-shadow: none;
	border-radius: 0;
}

.hamon-lightbox__image.is-zoomed {
	cursor: grab;
}

.hamon-lightbox__video {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 92vw;
	height: 88vh;
	transform: translate(-50%, -50%);
	-o-object-fit: contain;
	object-fit: contain;
	border: none;
	box-shadow: none;
	border-radius: 0;
}

.hamon-lightbox__close {
	position: absolute;
	top: 64px;
	right: 18px;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 2;
}

.hamon-lightbox__close:hover {
	background: rgba(255, 255, 255, 0.22);
}

.hamon-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 46px;
	height: 46px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 2;
}

.hamon-lightbox__nav:hover {
	background: rgba(255, 255, 255, 0.22);
}

.hamon-lightbox__nav--prev {
	left: 16px;
}

.hamon-lightbox__nav--next {
	right: 16px;
}

.hamon-lightbox__hint {
	position: absolute;
	bottom: 18px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.65);
	font-size: 13px;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.hamon-lightbox__hint.is-hidden {
	opacity: 0;
}