/* ==========================================
   1. CONTENEUR ET CONFIGURATION GLOBALE
   ========================================== */
.wrapper-diapo {
	display: block;
	clear: both;
	width: 100%;
	text-align: center;
	margin: 20px 0;
}

#diapo-unique {
	position: relative;
	width: 100%;
	max-width: 1200px;
	aspect-ratio: 900 / 300;
	overflow: hidden;
	perspective: 1000px;
	margin: 20px auto;
	background-color: #ffffff;
	display: block;
}

#diapo-unique .image-group {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
}

#diapo-unique .slice {
	flex: 1;
	height: 100%;
	background-repeat: no-repeat;
	background-size: 500% 100%; /* FORCE LE FOND À FAIRE 5 FOIS LA LARGEUR DE LA TRANCHE */
	background-position: calc(var(--i) * 100% / 4) center; /* REPARTIT LE FOND SUR LE RATIO DES 5 TRANCHES */
	transform-origin: center center;
	will-change: transform, opacity;
	transform: translateZ(0); 
	
	/* FIX COMPATIBILITÉ PHP : Masqué par défaut pour éviter le mélange de tranches */
	opacity: 0;
	visibility: hidden;
}


/* ==========================================
   2. LÉGENDES (CAPTIONS)
   ========================================== */
#diapo-unique .slider-caption {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	width: 90%; 
	max-width: 90%;
	background: rgba(0, 0, 0, 0.10);
	color: #ffffff;
	padding: 15px;
	font-family: sans-serif;
	border-radius: 5px;
	z-index: 10;
	box-sizing: border-box;
}

#diapo-unique .slider-caption.texte-sombre {
	color: #111111;
	background: rgba(255, 255, 255, 0.15);
}

#diapo-unique .slider-caption p {
	margin: 0;
	font-size: 18px;
	text-align: center;
	line-height: 1.4;
}

/* Masque le fond si la légende est vide (géré par votre fonction PHP) */
#diapo-unique .slider-caption:has(p:empty),
#diapo-unique .slider-caption p:empty {
	display: none;
}

/* ==========================================
   3. LOGIQUE SUR ÉCRANS LARGE (ANIMATIONS)
   ========================================== */
@media screen and (min-width: 769px) {
	/* L'animation gère l'apparition/disparition progressive sur PC si NON FIXE */
	#diapo-unique:not(.none) .slice {
		animation: animeSlices var(--cycle-duration) infinite;
		animation-delay: calc((var(--img-index) * 7s));
	}

	#diapo-unique:not(.none) .slider-caption {
		opacity: 0;
		visibility: hidden;
		animation: animeCaption var(--cycle-duration) infinite;
		animation-delay: calc((var(--img-index) * 7s));
	}
}

@keyframes animeSlices {
	0% { opacity: 0; visibility: hidden; transform: rotateY(90deg); }
	2% { opacity: 1; visibility: visible; transform: rotateY(0deg); }
	25% { opacity: 1; visibility: visible; transform: rotateY(0deg); }
	27% { opacity: 0; visibility: hidden; transform: rotateY(-90deg); }
	100% { opacity: 0; visibility: hidden; transform: rotateY(-90deg); }
}

@keyframes animeCaption {
	0% { opacity: 0; visibility: hidden; }
	2% { opacity: 1; visibility: visible; }
	25% { opacity: 1; visibility: visible; }
	27% { opacity: 0; visibility: hidden; }
	100% { opacity: 0; visibility: hidden; }
}


/* ==========================================
   4. LOGIQUE MODE FIXE ET MOBILE
   ========================================== */

/* --- RÈGLES POUR LE MODE FIXE (.none) --- */

/* 1. Arrêt des animations en mode fixe */
#diapo-unique.none * {
	animation: none !important;
	transition: none !important;
}

/* 2. Affichage exclusif de la première image et de ses morceaux */
#diapo-unique.none .image-group.ig-1,
#diapo-unique.none .image-group.ig-1 .slice {
	opacity: 1 !important;
	visibility: visible !important;
	transform: rotateY(0deg) scale(1) !important;
}

/* 3. Masquage strict des autres images */
#diapo-unique.none .image-group:not(.ig-1),
#diapo-unique.none .image-group:not(.ig-1) .slice {
	display: none !important;
	opacity: 0 !important;
	visibility: hidden !important;
}


/* --- RÈGLES POUR LE MODE MOBILE (< 768px) --- */
@media screen and (max-width: 768px) {
	#diapo-unique { 
		pointer-events: none; 
	}
	
	/* Masque proprement la légende sur mobile */
	#diapo-unique .slider-caption { 
		display: none !important; 
	}
	
	/* Arrêt des animations */
	#diapo-unique * {
		animation: none !important;
		transition: none !important;
	}
	
	/* Affichage de la première image */
	#diapo-unique .image-group.ig-1,
	#diapo-unique .image-group.ig-1 .slice {
		opacity: 1 !important;
		visibility: visible !important;
		transform: rotateY(0deg) scale(1) !important;
	}
	
	/* Masquage des autres images */
	#diapo-unique .image-group:not(.ig-1),
	#diapo-unique .image-group:not(.ig-1) .slice {
		display: none !important;
		opacity: 0 !important;
		visibility: hidden !important;
	}
}
