/* ==========================================================================
   KNA Distribution — Vidéo dans la galerie produit
   Portée : fiche produit uniquement, chargée avec le module product-video.php.
   Aucune règle ne s'applique hors de `body.single-product`.
   ========================================================================== */

/* --- 1) Composant non encore placé ---------------------------------------
   Le bloc est rendu dans la galerie native, après les vignettes. Tant que le
   script ne l'a pas déplacé (ou si JavaScript est absent), il reste masqué :
   la galerie est alors strictement identique à l'existant. */

body.single-product .kna-video[hidden],
body.single-product .kna-video__player[hidden],
body.single-product .kna-video__notice[hidden],
body.single-product .kna-video__back[hidden] {
	display: none !important;
}

/* --- 2) Miniature vidéo --------------------------------------------------
   Mêmes dimensions, espacement, rayon et bordure que les miniatures photo
   (single-product.css : 84 px, 2 px #e5e7eb, rayon 10 px, actif #0e5b32). */

body.single-product div.images .kna-video-thumb-item {
	width: 84px;
	float: none;
	margin: 0;
}

body.single-product div.images .kna-video-thumb {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 2px solid #e5e7eb;
	border-radius: 10px;
	background: #f3f4f6;
	cursor: pointer;
	transition: border-color 0.15s ease;
}

body.single-product div.images .kna-video-thumb:hover,
body.single-product div.images .kna-video-thumb:focus {
	border-color: var(--kna-color-brand);
}

body.single-product div.images .kna-video-thumb[aria-pressed="true"] {
	border-color: var(--kna-color-brand);
}

body.single-product div.images .kna-video-thumb:focus-visible {
	outline: 2px solid var(--kna-color-brand);
	outline-offset: 2px;
}

body.single-product div.images .kna-video-thumb__poster {
	position: absolute;
	inset: 0;
	display: block;
	overflow: hidden;
	border-radius: 8px;
}

body.single-product div.images .kna-video-thumb__poster--empty {
	background: #eceef0;
}

/* Le thème applique déjà une bordure de 2 px aux images de la rangée
   (`div.images .flex-control-thumbs img`) : sans cette règle plus spécifique,
   l'affiche se retrouve avec deux bordures — donc deux contours verts. */
body.single-product div.product div.images .flex-control-thumbs li.kna-video-thumb-item img.kna-video-thumb__img,
body.single-product div.product div.images .kna-video-thumbs li.kna-video-thumb-item img.kna-video-thumb__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 8px;
	background: none;
	box-shadow: none;
	object-fit: cover;
}

body.single-product div.images .kna-video-thumb__play {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

body.single-product div.images .kna-video-thumb__play svg {
	width: 26px;
	height: 26px;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Tant que la vidéo est sélectionnée, seule sa miniature porte l'état actif :
   la bordure verte de la photo en cours est neutralisée. `.kna-video-active`
   est posé sur la galerie elle-même (div.images) : le sélecteur doit viser ce
   même élément, et battre la règle du thème qui inclut `#kna-main`. */
body.single-product #kna-main div.product div.images.kna-video-active .flex-control-thumbs li:not(.kna-video-thumb-item) img.flex-active,
body.single-product #kna-main div.product div.images.kna-video-active .flex-control-thumbs li:not(.kna-video-thumb-item) img:hover {
	border-color: #e5e7eb;
}

/* --- 3) Rangée de secours ------------------------------------------------
   Un produit à photo unique n'a aucune rangée de miniatures (FlexSlider est
   désactivé). La vidéo crée alors sa propre rangée, au même style. */

body.single-product div.images .kna-video-thumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 12px 0 0;
	padding: 0;
	list-style: none;
}

body.single-product div.images .kna-video-thumbs li {
	width: 84px;
	float: none;
	margin: 0;
}

/* --- 4) Zone principale --------------------------------------------------
   Le cadre de lecture prend la place de la zone photo (masquée pendant la
   lecture) et adopte le rapport largeur/hauteur réel du média : la vidéo
   remplit le cadre, sans bandes noires. */

body.single-product #kna-main div.product div.images.kna-video-active .flex-viewport,
body.single-product #kna-main div.product div.images.kna-video-active .woocommerce-product-gallery__wrapper {
	display: none;
}

body.single-product .kna-video__player {
	display: block;
	width: 100%;
}

body.single-product .kna-video__frame {
	position: relative;
	width: 100%;
	aspect-ratio: var(--kna-video-ratio, 16 / 9);
	overflow: hidden;
	border-radius: 16px 16px 0 0;
	background: #000;
}

body.single-product .kna-video__media {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	/* Aucun rayon propre : c'est le cadre qui arrondit le haut. Le bas reste
	   droit pour venir se souder à la barre de commandes. */
	border-radius: 0;
	background: none;
	object-fit: contain;
}

/* --- 4 bis) Barre de commandes KNA --------------------------------------- */

body.single-product .kna-video__controls {
	position: relative;
	overflow: hidden;
	margin: 0;
	padding: 0;
	border-radius: 0 0 16px 16px;
	background: #070908;
	color: #ffffff;
}

/* Reflet : la vidéo en cours est recopiée dans un canvas minuscule (aucun
   second lecteur, aucun second téléchargement), miroir vertical, flou léger. */
body.single-product .kna-video__reflection {
	position: absolute;
	inset: 0;
	z-index: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0.8;
	transform: scaleY(-1);
	filter: blur(1.5px) saturate(0.9);
	pointer-events: none;
}

body.single-product .kna-video__controls::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	/* Voile plus clair en haut (le reflet reste lisible près de la vidéo) et
	   un peu plus dense en bas pour garantir le contraste des commandes. */
	background: linear-gradient(to bottom, rgba(7, 9, 8, 0.26), rgba(7, 9, 8, 0.56));
	pointer-events: none;
}

body.single-product .kna-video__controls-inner {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 5px 8px;
}

body.single-product .kna-video__controls[hidden] {
	display: none !important;
}

body.single-product .kna-video__ctrl {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: #ffffff;
	cursor: pointer;
}

body.single-product .kna-video__ctrl:hover,
body.single-product .kna-video__ctrl:focus {
	background: rgba(255, 255, 255, 0.14);
}

body.single-product .kna-video__ctrl:focus-visible {
	outline: 2px solid var(--kna-color-accent);
	outline-offset: 2px;
}

body.single-product .kna-video__ctrl-icon {
	display: block;
	width: 22px;
	height: 22px;
}

body.single-product .kna-video__ctrl-icon[hidden] {
	display: none !important;
}

body.single-product .kna-video__timeline {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	min-width: 64px;
}

body.single-product .kna-video__time {
	flex: 0 0 auto;
	margin: 0;
	color: #ffffff;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	line-height: 1;
	white-space: nowrap;
}

body.single-product .kna-video__seek {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 24px;
	margin: 0;
	padding: 0;
	background: transparent;
	cursor: pointer;
}

body.single-product .kna-video__seek:disabled {
	opacity: 0.55;
	cursor: default;
}

body.single-product .kna-video__seek::-webkit-slider-runnable-track {
	height: 4px;
	border-radius: 2px;
	background: linear-gradient(
		to right,
		var(--kna-color-brand) 0%,
		var(--kna-color-brand) var(--kna-progress, 0%),
		rgba(255, 255, 255, 0.3) var(--kna-progress, 0%),
		rgba(255, 255, 255, 0.3) 100%
	);
}

body.single-product .kna-video__seek::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 12px;
	height: 12px;
	margin-top: -4px;
	border: 2px solid #ffffff;
	border-radius: 50%;
	background: var(--kna-color-brand);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

body.single-product .kna-video__seek::-moz-range-track {
	height: 4px;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.3);
}

body.single-product .kna-video__seek::-moz-range-progress {
	height: 4px;
	border-radius: 2px;
	background: var(--kna-color-brand);
}

body.single-product .kna-video__seek::-moz-range-thumb {
	width: 12px;
	height: 12px;
	border: 2px solid #ffffff;
	border-radius: 50%;
	background: var(--kna-color-brand);
}

body.single-product .kna-video__seek:focus-visible {
	outline: 2px solid var(--kna-color-accent);
	outline-offset: 4px;
	border-radius: 4px;
}

body.single-product .kna-video__seek:disabled::-webkit-slider-thumb {
	background: #9ca3af;
	border-color: rgba(255, 255, 255, 0.65);
}

body.single-product .kna-video__seek:disabled::-moz-range-thumb {
	background: #9ca3af;
	border-color: rgba(255, 255, 255, 0.65);
}

/* Le message d'échec se place au-dessus du bas du cadre, sans gêner la barre
   de commandes qui vit désormais sous le lecteur. */
body.single-product .kna-video__notice {
	position: absolute;
	left: 12px;
	right: 12px;
	bottom: 12px;
	margin: 0;
	padding: 8px 12px;
	border-radius: 8px;
	background: rgba(7, 9, 8, 0.82);
	color: #ffffff;
	font-size: 12px;
	line-height: 1.4;
	text-align: center;
}

body.single-product .kna-video__back {
	position: absolute;
	top: 10px;
	right: 10px;
	min-height: 32px;
	padding: 0 12px;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 8px;
	background: rgba(7, 9, 8, 0.72);
	color: #ffffff;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
}

body.single-product .kna-video__back:hover,
body.single-product .kna-video__back:focus {
	border-color: #ffffff;
	background: rgba(7, 9, 8, 0.9);
}

body.single-product .kna-video__back:focus-visible {
	outline: 2px solid var(--kna-color-accent);
	outline-offset: 2px;
}

/* Le déclencheur de lightbox concerne les photos seulement : il est masqué
   pendant la lecture, puis rétabli au retour sur une photo. */
body.single-product .kna-video-active .woocommerce-product-gallery__trigger {
	display: none;
}

/* --- 5) Préférences de mouvement ---------------------------------------- */
@media (max-width: 640px) {
	body.single-product .kna-video__controls-inner {
		gap: 6px;
		padding: 4px 6px;
	}

	body.single-product .kna-video__ctrl {
		width: 38px;
		height: 38px;
	}

	body.single-product .kna-video__time {
		font-size: 11px;
	}
}

@media (prefers-reduced-motion: reduce) {
	body.single-product div.images .kna-video-thumb {
		transition: none;
	}
}
