/**
 * SA Brèves Carousel - Styles pour la modale et les tuiles Uncode
 *
 * @package SABrevesCarousel
 */

/* ==========================================================================
   1. Tuiles Uncode et Badges Taxonomiques
   ========================================================================== */

/* Curseur pointer sur toute la tuile pour expliciter l'interactivité */
.sa-breves .tmb,
.sa-breve-tile {
	cursor: pointer;
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Badges SVG pour les articles selon les catégories (pdf, images) */
.sa-breve-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: middle;
	margin-right: 6px;
	transition: color 0.2s ease, transform 0.2s ease;
}

.sa-breve-badge svg {
	display: inline-block;
	vertical-align: middle;
}

/* Badge PDF (Rouge vif) */
.sa-breve-badge--pdf {
	color: #e53e3e;
}

/* Badge Image (Teinte gris-bleu ardoise élégante) */
.sa-breve-badge--image {
	color: #5a738e;
}

.sa-breve-tile:hover .sa-breve-badge--pdf {
	color: #c53030;
}

.sa-breve-tile:hover .sa-breve-badge--image {
	color: #3b5066;
}

/* Traitement visuel de la catégorie 'images' vs 'no-images' */
.sa-breve-tile.sa-no-images .t-entry-visual {
	background-color: rgba(0, 0, 0, 0.04);
}

.sa-breve-tile.sa-has-images .t-entry-visual img,
.sa-breve-tile.has-image .t-entry-visual img {
	transition: transform 0.35s ease;
}

.sa-breve-tile.sa-has-images:hover .t-entry-visual img,
.sa-breve-tile.has-image:hover .t-entry-visual img {
	transform: scale(1.03);
}

/* ==========================================================================
   2. Modale Accessible
   ========================================================================== */

/* Verrouillage strict du scroll d'arrière-plan (HTML + BODY pour contrer la règle Uncode) */
html.sa-modal-locked,
body.sa-modal-locked,
html.uncode-unmodal-body-disable-scroll {
	overflow: hidden !important;
	overflow-y: hidden !important;
	touch-action: none;
}

/* Conteneur principal fixe (z-index: 12500 pour être au-dessus du menu Uncode 11000, mais SOUS la Lightbox 13040/13050) */
.sa-modal {
	position: fixed;
	inset: 0;
	z-index: 12500;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
	opacity: 0;
	visibility: hidden;
	pointer-events: none !important;
	overscroll-behavior: contain;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sa-modal.is-active {
	display: flex !important;
	opacity: 1 !important;
	visibility: visible !important;
	pointer-events: auto !important;
}

/* Verrouillage strict : quand la modale n'est pas active, aucun enfant ne peut capturer de clic */
.sa-modal:not(.is-active),
.sa-modal:not(.is-active) * {
	pointer-events: none !important;
}

/* Voile d'arrière-plan avec flou moderne */
.sa-modal__backdrop {
	position: absolute;
	inset: 0;
	background-color: rgba(15, 23, 42, 0.75);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}

/* Fenêtre de dialogue */
.sa-modal__dialog {
	position: relative;
	width: 100%;
	max-width: 760px;
	max-height: 88vh;
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	overscroll-behavior: contain;
	outline: none;
	transform: translateY(20px) scale(0.98);
	transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
	z-index: 1;
}

.sa-modal.is-active .sa-modal__dialog {
	transform: translateY(0) scale(1);
}

/* Bouton de fermeture */
.sa-modal__close-btn {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 38px;
	height: 38px;
	border: none;
	background: rgba(0, 0, 0, 0.05);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #4a5568;
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
	z-index: 10;
}

.sa-modal__close-btn:hover {
	background-color: #e2e8f0;
	color: #1a202c;
	transform: rotate(90deg);
}

.sa-modal__close-btn:focus-visible {
	outline: 2px solid #3182ce;
	outline-offset: 2px;
}

/* Zone de contenu défilable */
.sa-modal__scrollable {
	padding: 36px 32px 32px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	outline: none;
}

/* Spinner & Loader */
.sa-modal__loader {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 240px;
}

.sa-modal__spinner {
	width: 44px;
	height: 44px;
	border: 3px solid rgba(0, 0, 0, 0.1);
	border-top-color: #3182ce;
	border-radius: 50%;
	animation: sa-spin 0.8s linear infinite;
}

@keyframes sa-spin {
	to {
		transform: rotate(360deg);
	}
}

.sa-modal__loading-text {
	margin-top: 16px;
	color: #718096;
	font-size: 0.95rem;
}

/* En-tête et métadonnées */
.sa-modal__header {
	margin-bottom: 24px;
	padding-bottom: 16px;
	border-bottom: 1px solid #edf2f7;
}

.sa-modal__meta {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 10px;
}

.sa-modal__date {
	font-size: 0.85rem;
	color: #718096;
	font-weight: 500;
}

.sa-modal__badges {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.sa-category-tag {
	display: inline-block;
	padding: 2px 8px;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	background: #edf2f7;
	color: #4a5568;
	border-radius: 4px;
}

.sa-category-tag--pdf {
	background: #fed7d7;
	color: #9b2c2c;
}

.sa-category-tag--images,
.sa-category-tag--image {
	background: #e2e8f0;
	color: #3b5066;
}

.sa-modal__title {
	margin: 0;
	font-size: 1.75rem;
	line-height: 1.3;
	color: #1a202c;
	font-weight: 700;
}

/* Image à la une dans la modale */
.sa-modal__featured-wrap {
	margin-bottom: 24px;
	border-radius: 8px;
	overflow: hidden;
}

.sa-modal__featured-wrap img {
	width: 100%;
	height: auto;
	display: block;
	object-fit: cover;
	max-height: 380px;
}

/* Contenu riche (Kadence, Gutenberg, médias) */
.sa-modal__content {
	color: #2d3748;
	font-size: 1.05rem;
	line-height: 1.7;
}

.sa-modal__content p {
	margin-bottom: 1.25em;
}

.sa-modal__content img {
	max-width: 100%;
	height: auto;
	border-radius: 6px;
}

.sa-modal__content iframe {
	max-width: 100%;
}

/* Message d'erreur */
.sa-modal__error-msg {
	color: #e53e3e;
	padding: 16px;
	background: #fff5f5;
	border-radius: 8px;
	border-left: 4px solid #e53e3e;
}

/* Responsive mobile */
@media (max-width: 640px) {
	.sa-modal {
		padding: 10px;
	}

	.sa-modal__scrollable {
		padding: 24px 18px 20px;
	}

	.sa-modal__title {
		font-size: 1.35rem;
	}
}

/* ==========================================================================
   3. Support & Initialisation des blocs Kadence (Advanced Gallery & Splide)
   ========================================================================== */

/* Conteneur global Kadence Advanced Gallery */
.sa-modal__content .wp-block-kadence-advancedgallery,
.sa-modal__content .kb-gallery-wrap,
.sa-modal__content .kb-gallery-ul {
	width: 100% !important;
	position: relative !important;
	margin-top: 1.5em;
	margin-bottom: 1.5em;
	display: block !important;
}

/* Mode Grille / Masonry Kadence */
.sa-modal__content .kb-gallery-type-grid,
.sa-modal__content .kb-gallery-type-masonry {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 12px;
}

/* Conteneur Carrousel et Slider Splide */
.sa-modal__content .kt-blocks-carousel,
.sa-modal__content .kb-gallery-type-slider,
.sa-modal__content .kb-gallery-type-carousel,
.sa-modal__content .kb-gallery-type-fluidcarousel,
.sa-modal__content .kb-gallery-type-thumbslider {
	display: block !important;
	width: 100% !important;
	position: relative !important;
	box-sizing: border-box !important;
}

/* Track Splide (zone visible) */
.sa-modal__content .splide__track {
	overflow: hidden !important;
	position: relative !important;
	width: 100% !important;
	border-radius: 8px;
}

/* Liste des diapositives (toujours en flex pour alignement horizontal) */
.sa-modal__content .splide__list,
.sa-modal__content .kt-blocks-carousel-init,
.sa-modal__content .kb-blocks-slider {
	display: flex !important;
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	box-sizing: border-box !important;
	width: 100% !important;
}

/* Mode Slider (1 diapositive à la fois / Type Slider / Fade) : largeur pleine garantie */
.sa-modal__content .kb-gallery-type-slider .splide__slide,
.sa-modal__content .kt-blocks-carousel[data-slider-type="slider"] .splide__slide,
.sa-modal__content .splide--fade .splide__slide {
	width: 100% !important;
	flex: 0 0 100% !important;
	max-width: 100% !important;
	box-sizing: border-box !important;
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
}

/* Mode Carrousel multiple (plusieurs colonnes) */
.sa-modal__content .kb-gallery-type-carousel .splide__slide,
.sa-modal__content .kb-gallery-type-fluidcarousel .splide__slide {
	flex-shrink: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0 6px;
	list-style: none;
}

/* Structure interne des items de galerie Kadence */
.sa-modal__content .kadence-blocks-gallery-item,
.sa-modal__content .kadence-blocks-gallery-item-inner,
.sa-modal__content figure.kb-gallery-figure,
.sa-modal__content .kb-gal-image-radius {
	position: relative !important;
	width: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
	display: block !important;
	box-sizing: border-box !important;
	border-radius: 6px;
	overflow: hidden;
}

/* Gestion du ratio intrinsèque Kadence (empêche l'écrasement ou la réduction de taille) */
.sa-modal__content .kadence-blocks-gallery-intrinsic {
	position: relative !important;
	width: 100% !important;
	height: 0 !important;
	display: block !important;
	overflow: hidden !important;
}

/* Ratios spécifiques Kadence (ex. land32 = 3:2, soit 66.67% de padding-bottom) */
.sa-modal__content .kadence-blocks-gallery-intrinsic.kb-gallery-image-ratio-land32,
.sa-modal__content .kadence-blocks-gallery-intrinsic.kb-has-image-ratio-land32 {
	padding-bottom: 66.67% !important;
}

.sa-modal__content .kadence-blocks-gallery-intrinsic.kb-gallery-image-ratio-land169,
.sa-modal__content .kadence-blocks-gallery-intrinsic.kb-has-image-ratio-land169 {
	padding-bottom: 56.25% !important;
}

.sa-modal__content .kadence-blocks-gallery-intrinsic.kb-gallery-image-ratio-land43,
.sa-modal__content .kadence-blocks-gallery-intrinsic.kb-has-image-ratio-land43 {
	padding-bottom: 75% !important;
}

.sa-modal__content .kadence-blocks-gallery-intrinsic.kb-gallery-image-ratio-square,
.sa-modal__content .kadence-blocks-gallery-intrinsic.kb-has-image-ratio-square {
	padding-bottom: 100% !important;
}

/* Positionnement strict de l'image absolue dans son conteneur intrinsèque */
.sa-modal__content .kadence-blocks-gallery-intrinsic img {
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	width: 100% !important;
	height: 100% !important;
	object-fit: cover !important;
	display: block !important;
	transition: transform 0.3s ease;
}

.sa-modal__content .kb-gallery-item-link:hover img {
	transform: scale(1.03);
}

/* Transition de fondu Splide (Fade) Kadence */
.sa-modal__content .splide--fade > .splide__track > .splide__list > .splide__slide,
.sa-modal__content .kb-splide.splide--fade > .splide__track > .splide__list > .splide__slide {
	opacity: 0;
	transition: opacity 0.4s ease-in-out;
	z-index: 0;
	pointer-events: none;
}

.sa-modal__content .splide--fade > .splide__track > .splide__list > .splide__slide.is-active,
.sa-modal__content .kb-splide.splide--fade > .splide__track > .splide__list > .splide__slide.is-active {
	opacity: 1;
	z-index: 1;
	pointer-events: auto;
}

/* Flèches de navigation Splide / Kadence */
.sa-modal__content .splide__arrows {
	display: flex;
	justify-content: space-between;
	pointer-events: none;
}

.sa-modal__content .splide__arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: #c2ed87 !important;
	color: #1b2311 !important;
	border: none;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	pointer-events: auto;
	z-index: 5;
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.sa-modal__content .splide__arrow:hover {
	background: #a9dd64 !important;
	transform: translateY(-50%) scale(1.08);
}

.sa-modal__content .splide__arrow--prev {
	left: 12px;
}

.sa-modal__content .splide__arrow--next {
	right: 12px;
}

/* Pagination (dots) Splide / Kadence */
.sa-modal__content .splide__pagination {
	display: flex;
	justify-content: center;
	gap: 6px;
	margin-top: 14px;
	padding: 0;
	list-style: none;
}

.sa-modal__content .splide__pagination__page {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.2);
	border: none;
	padding: 0;
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.sa-modal__content .splide__pagination__page.is-active {
	background: #8baf5a;
	transform: scale(1.3);
}

/* Bouton Pause / Lecture Kadence */
.sa-modal__content .kb-gallery-pause-button {
	position: absolute;
	bottom: 12px;
	right: 12px;
	background: #c2ed87 !important;
	color: #1b2311 !important;
	border: none;
	border-radius: 4px;
	padding: 6px 10px;
	cursor: pointer;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0.85;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.sa-modal__content .kb-gallery-pause-button:hover {
	opacity: 1;
	transform: scale(1.05);
}

.sa-modal__content .kb-gallery-pause-button svg {
	width: 18px;
	height: 18px;
	display: block;
}

/* Fallback de carrousel avec défilement horizontal fluide */
.sa-modal__content .is-fallback-carousel .splide__track {
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
}

.sa-modal__content .is-fallback-carousel .splide__slide {
	scroll-snap-align: start;
	min-width: 260px;
}

/* ==========================================================================
   4. Priorité d'affichage de la Lightbox (Uncode Lightgallery / Kadence)
   ========================================================================== */

/* Garantir que les conteneurs et voiles de la Lightbox passent toujours devant la modale */
.lg-backdrop {
	z-index: 13040 !important;
}

.lg-outer {
	z-index: 13050 !important;
}

.sl-overlay,
.mfp-bg {
	z-index: 13040 !important;
}

.sl-wrapper,
.mfp-wrap {
	z-index: 13050 !important;
}


