/**
 * TIF Carousel — primitives CSS réutilisables
 * ------------------------------------------------
 * Classes génériques pour tout carrousel horizontal (drag / flèches / fondu).
 * Les avis ([tif_reviews]) les consomment via des classes doubles :
 *   .tif-carousel.tif-reviews-carousel
 *   .tif-carousel__viewport.tif-reviews-viewport
 *   etc.
 *
 * Réutilisation ailleurs :
 *   1. Enqueuer ce fichier (handle WP : tif-carousel)
 *   2. Markup :
 *      <div class="tif-carousel tif-carousel--fade-x">
 *        <button class="tif-carousel__arrow tif-carousel__arrow--prev">…</button>
 *        <div class="tif-carousel__viewport">
 *          <div class="tif-carousel__track">
 *            <div class="tif-carousel__slide">…</div>
 *          </div>
 *        </div>
 *        <button class="tif-carousel__arrow tif-carousel__arrow--next">…</button>
 *      </div>
 *   3. JS : tif-reviews.js peut servir de base (initCarousel) — à factoriser
 *      plus tard en tif-carousel.js si besoin.
 *
 * Variables (surchargeables sur un parent) :
 *   --tif-carousel-gap
 *   --tif-carousel-arrow-w / -h
 *   --tif-carousel-pad-x   (place flèches + ombres)
 *   --tif-carousel-fade-x  (largeur du fondu latéral)
 */

:root {
	--tif-carousel-gap: 16px;
	--tif-carousel-arrow-w: 42px;
	--tif-carousel-arrow-h: 56px;
	--tif-carousel-pad-x: 52px;
	--tif-carousel-fade-x: 52px;
	--tif-carousel-arrow-bg: rgba(46, 58, 75, 0.88);
	--tif-carousel-arrow-bg-hover: #2e3a4b;
	--tif-carousel-transition: transform 0.4s ease;
}

/* --- Shell --- */
.tif-carousel {
	position: relative;
	width: 100%;
	max-width: 100%;
	overflow: visible; /* flèches + ombres hors clip */
	box-sizing: border-box;
	padding: 12px 0 20px;
}

/* --- Viewport (clip + zone flèches) --- */
.tif-carousel__viewport {
	overflow: hidden;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	padding: 10px var(--tif-carousel-pad-x);
	margin: 0 -4px;
	cursor: default;
	touch-action: pan-y;
	user-select: none;
}

.tif-carousel__viewport.is-dragging {
	cursor: grabbing;
}

.tif-carousel__viewport.is-dragging a,
.tif-carousel__viewport.is-dragging button {
	pointer-events: none;
}

/* Fondu latéral (masque) — opt-in via modificateur */
.tif-carousel--fade-x .tif-carousel__viewport,
.tif-carousel__viewport--fade-x {
	-webkit-mask-image: linear-gradient(
		to right,
		transparent 0,
		#000 var(--tif-carousel-fade-x),
		#000 calc(100% - var(--tif-carousel-fade-x)),
		transparent 100%
	);
	mask-image: linear-gradient(
		to right,
		transparent 0,
		#000 var(--tif-carousel-fade-x),
		#000 calc(100% - var(--tif-carousel-fade-x)),
		transparent 100%
	);
}

/* --- Track / slides --- */
.tif-carousel__track {
	display: flex;
	flex-direction: row;
	align-items: stretch;
	gap: var(--tif-carousel-gap);
	width: max-content;
	transform: translate3d(0, 0, 0);
	transition: var(--tif-carousel-transition);
	will-change: transform;
}

.tif-carousel__slide {
	flex: 0 0 auto;
	min-width: 0;
	box-sizing: border-box;
}

/* Mode figé (≤ N slides, pas de nav) */
.tif-carousel.is-static .tif-carousel__track {
	width: 100%;
}

.tif-carousel.is-static .tif-carousel__slide {
	flex: 1 1 0;
	width: auto;
	max-width: none;
}

/* --- Flèches --- */
.tif-carousel__arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 5;
	width: var(--tif-carousel-arrow-w);
	height: var(--tif-carousel-arrow-h);
	padding: 0;
	border: 0;
	background: var(--tif-carousel-arrow-bg);
	color: #ffffff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: background 0.2s ease, opacity 0.2s ease;
	box-shadow: 0 4px 14px rgba(20, 35, 58, 0.22);
}

.tif-carousel__arrow:hover {
	background: var(--tif-carousel-arrow-bg-hover);
}

.tif-carousel__arrow span {
	font-size: 32px;
	line-height: 1;
	font-weight: 200;
	margin-top: -4px;
}

.tif-carousel__arrow--prev {
	left: 0;
}

.tif-carousel__arrow--next {
	right: 0;
}

.tif-carousel__arrow.is-hidden {
	opacity: 0;
	pointer-events: none;
}

@media (max-width: 699px) {
	.tif-carousel__viewport {
		padding-left: 44px;
		padding-right: 44px;
	}
}
