/**
 * Styles frontend — Image Carousel Block
 *
 * Mobile-first. Variables CSS pour personnalisation par le thème.
 * Utilise Slick Carousel pour le carrousel.
 *
 * @package ImageCarouselBlock
 */

/* ---------------------------------------------------------------------------
   Variables
   --------------------------------------------------------------------------- */

.image-carousel-wrapper {
	--icb-slide-radius:     0.5rem;
	--icb-nav-btn-size:     3rem;
	--icb-nav-btn-bg:       rgba(0 0 0 / 0.65);
	--icb-nav-btn-hover:    rgba(0 0 0 / 0.9);
	--icb-dot-color:        rgba(0 0 0 / 0.25);
	--icb-dot-active:       #007cba;
	--icb-transition:       0.4s ease;
	--icb-focus-ring:       0 0 0 3px rgba(0 123 186 / 0.55);
}

/* ---------------------------------------------------------------------------
   Wrapper principal
   --------------------------------------------------------------------------- */

.image-carousel-wrapper {
	position: relative;
	width: 100%;
	overflow: hidden;
	padding-bottom: 3.5rem; /* Espace pour les dots */
	box-sizing: border-box;
}

/* ---------------------------------------------------------------------------
   Carrousel Slick
   --------------------------------------------------------------------------- */

/* Masque le carrousel pendant l'initialisation de Slick (évite le flash). */
.image-carousel:not(.slick-initialized) {
	opacity: 0;
	overflow: hidden;
}

.image-carousel.slick-initialized {
	opacity: 1;
	transition: opacity 0.3s ease;
}

.image-carousel {
	max-width: 100%;
	position: relative;
	padding: 0 3rem; /* Espace pour les flèches superposées */
}

.image-carousel .slick-track {
	display: flex;
	align-items: center;
}

.image-carousel .slick-slide {
	height: auto;
}

/* ---------------------------------------------------------------------------
   Slides
   --------------------------------------------------------------------------- */

.carousel-slide {
	padding: 0 0.5rem;
	box-sizing: border-box;
	outline: none;
	transition: all var(--icb-transition);
}

.carousel-image {
	display: block;
	width: 100%;
	height: auto;
	max-height: 600px;
	object-fit: cover;
	border-radius: var(--icb-slide-radius);
	cursor: pointer;
	transition: all var(--icb-transition);

	/* État par défaut : légèrement atténué */
	filter: brightness(0.7) saturate(0.8);
	transform: scale(0.95);
	box-shadow: 0 2px 8px rgba(0 0 0 / 0.1);
}

/* Slide central mis en avant */
.carousel-slide.slick-center .carousel-image,
.carousel-slide.slick-current .carousel-image,
.carousel-slide.is-center .carousel-image {
	filter: brightness(1) saturate(1);
	transform: scale(1);
	box-shadow: 0 8px 25px rgba(0 0 0 / 0.25);
}

/* Slides latéraux */
.carousel-slide.is-side .carousel-image {
	filter: brightness(0.6) saturate(0.7);
	transform: scale(0.9);
}

/* Hover sur n'importe quelle image */
.carousel-image:hover {
	filter: brightness(1) saturate(1);
	transform: scale(1.02);
	box-shadow: 0 4px 16px rgba(0 0 0 / 0.2);
}

/* Les clones Slick restent atténués */
.carousel-slide.slick-cloned .carousel-image {
	filter: brightness(0.6) saturate(0.7);
	transform: scale(0.9);
}

/* ---------------------------------------------------------------------------
   Flèches Slick (superposées sur l'image)
   --------------------------------------------------------------------------- */

.image-carousel-wrapper .slick-prev,
.image-carousel-wrapper .slick-next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 10;
	width: var(--icb-nav-btn-size);
	height: var(--icb-nav-btn-size);
	background: var(--icb-nav-btn-bg);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background var(--icb-transition), transform var(--icb-transition);
	font-size: 1.5rem;
	color: #fff;
	line-height: 1;
}

.image-carousel-wrapper .slick-prev { left: 0.5rem; }
.image-carousel-wrapper .slick-next { right: 0.5rem; }

.image-carousel-wrapper .slick-prev:hover,
.image-carousel-wrapper .slick-next:hover {
	background: var(--icb-nav-btn-hover);
	transform: translateY(-50%) scale(1.1);
}

.image-carousel-wrapper .slick-prev:focus-visible,
.image-carousel-wrapper .slick-next:focus-visible {
	outline: none;
	box-shadow: var(--icb-focus-ring);
}

/* Masque le ::before natif de Slick-theme (caractères ← →) pour éviter
   la double flèche avec notre HTML personnalisé prevArrow / nextArrow. */
.image-carousel-wrapper .slick-prev::before,
.image-carousel-wrapper .slick-next::before {
	display: none;
}

/* ---------------------------------------------------------------------------
   Dots Slick
   --------------------------------------------------------------------------- */

.image-carousel-wrapper .slick-dots {
	position: absolute;
	bottom: 0.75rem;
	left: 0;
	right: 0;
	display: flex;
	justify-content: center;
	gap: 0.375rem;
	list-style: none;
	padding: 0;
	margin: 0;
}

.image-carousel-wrapper .slick-dots li { margin: 0; }

.image-carousel-wrapper .slick-dots li button {
	width: 0.5rem;
	height: 0.5rem;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--icb-dot-color);
	cursor: pointer;
	font-size: 0;
	transition: background var(--icb-transition), transform var(--icb-transition);
}

.image-carousel-wrapper .slick-dots li.slick-active button {
	background: var(--icb-dot-active);
	transform: scale(1.4);
}

.image-carousel-wrapper .slick-dots li button:focus-visible {
	outline: none;
	box-shadow: var(--icb-focus-ring);
}

/* ---------------------------------------------------------------------------
   Alignements WordPress
   --------------------------------------------------------------------------- */

.image-carousel-wrapper.alignwide {
	width: var(--wp--style--global--wide-size, 1200px);
	max-width: 100%;
	margin-left: auto;
	margin-right: auto;
}

.image-carousel-wrapper.alignfull {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
}

/* ---------------------------------------------------------------------------
   Placeholder (aucune image configurée)
   --------------------------------------------------------------------------- */

.image-carousel-placeholder {
	padding: 2.5rem;
	border: 2px dashed rgba(0 0 0 / 0.15);
	border-radius: var(--icb-slide-radius);
	color: rgba(0 0 0 / 0.45);
	text-align: center;
	font-size: 0.9375rem;
}

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

.icb-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	animation: icb-fade-in 200ms ease;
}

.icb-lightbox[hidden] {
	display: none;
}

.icb-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0 0 0 / 0.93);
	cursor: pointer;
}

body.icb-lightbox-open {
	overflow: hidden;
}

.icb-lightbox__content {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 1rem;
	max-width: min(90vw, 1200px);
	max-height: 90vh;
}

.icb-lightbox__figure {
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
}

.icb-lightbox__img {
	display: block;
	max-width: min(80vw, 1000px);
	max-height: 80vh;
	width: auto;
	height: auto;
	border-radius: 4px;
	object-fit: contain;
	transition: opacity 150ms ease;
	box-shadow: 0 20px 60px rgba(0 0 0 / 0.5);
}

.icb-lightbox__caption {
	color: rgba(255 255 255 / 0.7);
	font-size: 0.875rem;
	text-align: center;
	min-height: 1.2em;
}

.icb-lightbox__close {
	position: absolute;
	top: -0.75rem;
	right: -0.75rem;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	border: 2px solid rgba(255 255 255 / 0.3);
	border-radius: 50%;
	background: rgba(0 0 0 / 0.6);
	color: #fff;
	cursor: pointer;
	transition: background var(--icb-transition);
}

.icb-lightbox__close:hover { background: rgba(220 53 69 / 0.85); border-color: rgba(220 53 69 / 0.85); }
.icb-lightbox__close:focus-visible { outline: none; box-shadow: var(--icb-focus-ring); }

.icb-lightbox__nav {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	border: 2px solid rgba(255 255 255 / 0.25);
	border-radius: 50%;
	background: rgba(255 255 255 / 0.12);
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	transition: background var(--icb-transition);
}

.icb-lightbox__nav:hover        { background: rgba(255 255 255 / 0.25); }
.icb-lightbox__nav:focus-visible { outline: none; box-shadow: var(--icb-focus-ring); }

.icb-lightbox__counter {
	position: absolute;
	bottom: -2rem;
	left: 50%;
	translate: -50% 0;
	color: rgba(255 255 255 / 0.6);
	font-size: 0.8125rem;
	white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 767px) {
	.image-carousel { padding: 0; }

	.image-carousel-wrapper .slick-prev { left: 0.375rem; }
	.image-carousel-wrapper .slick-next { right: 0.375rem; }

	.carousel-image { max-height: 400px; }

	.icb-lightbox__nav  { width: 2.5rem; height: 2.5rem; }
	.icb-lightbox__img  { max-width: 90vw; max-height: 75vh; }
	.icb-lightbox__content { gap: 0.5rem; padding: 0.5rem; }

	.icb-lightbox__close { top: 0.5rem; right: 0.5rem; }
	.icb-lightbox__nav--prev { position: absolute; left: 0.5rem; top: 50%; translate: 0 -50%; }
	.icb-lightbox__nav--next { position: absolute; right: 0.5rem; top: 50%; translate: 0 -50%; }
}

/* ---------------------------------------------------------------------------
   Accessibilité : prefers-reduced-motion
   --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.carousel-image,
	.carousel-slide,
	.icb-lightbox__img,
	.image-carousel-wrapper .slick-prev,
	.image-carousel-wrapper .slick-next {
		transition: none;
	}
	.icb-lightbox { animation: none; }
}

/* ---------------------------------------------------------------------------
   Animation
   --------------------------------------------------------------------------- */

@keyframes icb-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}
