/**
 * AI Community Page Builder — Community Carousel
 *
 * Styles for the [cpb_community_carousel] shortcode. One clean, neutral,
 * understated style: a featured image with the community name beneath it.
 *
 * Layout uses CSS scroll-snap on a flexbox track (native touch-swipe on
 * mobile for free). Cards-per-view is driven by a single custom property
 * (--cpb-carousel-per-view) flipped at each breakpoint: 4 desktop / 2 tablet
 * / 1 mobile. Arrow / accent colors use the GeneratePress global color
 * variables (--accent, --accent-2) with sensible fallbacks.
 *
 * @package AI_Community_Page_Builder
 * @since   1.6.0
 */

.cpb-carousel {
	--cpb-carousel-per-view: 4;
	--cpb-carousel-gap: 20px;
	position: relative;
	margin: 2rem 0;
	width: 100%;
	box-sizing: border-box;
}

/* ---------------------------------------------------------------------------
   Track — flexbox scroller with scroll-snap.
   --------------------------------------------------------------------------- */

.cpb-carousel__track {
	display: flex;
	gap: var(--cpb-carousel-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	padding: 8px 4px;
	margin: 0;
	list-style: none;
	scrollbar-width: none; /* Firefox — hide scrollbar, snap does the work. */
	-ms-overflow-style: none; /* IE / old Edge. */
}

.cpb-carousel__track::-webkit-scrollbar {
	display: none; /* WebKit. */
}

/* ---------------------------------------------------------------------------
   Card — entire card is a single link: image on top, name below.
   --------------------------------------------------------------------------- */

.cpb-carousel__card {
	flex: 0 0 calc(
		(100% - (var(--cpb-carousel-per-view) - 1) * var(--cpb-carousel-gap))
		/ var(--cpb-carousel-per-view)
	);
	scroll-snap-align: start;
	display: flex;
	flex-direction: column;
	text-decoration: none;
	color: inherit;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.cpb-carousel__card:hover,
.cpb-carousel__card:focus-visible {
	transform: translateY(-4px);
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}

.cpb-carousel__card:focus-visible {
	outline: 2px solid var(--accent, #2c3e50);
	outline-offset: 2px;
}

.cpb-carousel__image-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 3;
	background: #eef0f2;
	overflow: hidden;
}

.cpb-carousel__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease;
}

.cpb-carousel__card:hover .cpb-carousel__image {
	transform: scale(1.04);
}

.cpb-carousel__name {
	display: block;
	padding: 16px 18px;
	font-size: 18px;
	line-height: 1.3;
	font-weight: 600;
	color: #1f2933;
	text-align: center;
}

/* ---------------------------------------------------------------------------
   Arrows — simple, positioned at the track edges. Rendered only for 5+ cards.
   --------------------------------------------------------------------------- */

.cpb-carousel__arrow {
	position: absolute;
	top: calc(50% - 20px);
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--accent, #2c3e50);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
	transition: background 0.2s ease, transform 0.2s ease;
}

.cpb-carousel__arrow:hover,
.cpb-carousel__arrow:focus-visible {
	background: var(--accent-2, #1a252f);
	transform: scale(1.06);
}

.cpb-carousel__arrow:focus-visible {
	outline: 2px solid var(--accent-2, #1a252f);
	outline-offset: 2px;
}

.cpb-carousel__arrow svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.cpb-carousel__arrow--prev {
	left: -10px;
}

.cpb-carousel__arrow--next {
	right: -10px;
}

/* ---------------------------------------------------------------------------
   Responsive — 4 (desktop) / 2 (tablet) / 1 (mobile).
   --------------------------------------------------------------------------- */

@media (max-width: 1024px) {
	.cpb-carousel {
		--cpb-carousel-per-view: 2;
	}
}

@media (max-width: 600px) {
	.cpb-carousel {
		--cpb-carousel-per-view: 1;
	}

	.cpb-carousel__arrow--prev {
		left: 2px;
	}

	.cpb-carousel__arrow--next {
		right: 2px;
	}
}
