/* ── Editor preview — flat flex grid (no Splide structure) ─────────────── */
.block-brands--preview {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	row-gap: 30px;
	align-items: center;
	justify-content: center;
	align-content: center;
}

/* Allow cards to overflow only when Splide has destroyed itself into a flex
   grid. Must NOT apply while the carousel is active — it would expose the
   cloned loop slides on either side of the visible slide. */
.block-brands.splide.is-initialized:not(.is-active) .splide__track,
.block-brands.splide:not(.is-initialized) .splide__track {
	overflow: visible;
}

/* Base list resets — safe to apply in all states */
.block-brands .splide__list {
	list-style: none;
	padding: 0;
	margin: 0;
}

/* Centre items only in flex-grid mode (Splide destroyed or not yet initialised).
   MUST NOT apply while the carousel is active: Splide positions slides via
   transform: translateX() assuming the list starts at the left edge. Adding
   align-items/justify-content: center shifts the list inward by an amount
   Splide can't measure, misaligning every slide and causing clone bleed-through. */
.block-brands.splide.is-initialized:not(.is-active) .splide__list,
.block-brands.splide:not(.is-initialized) .splide__list {
	align-items: center;
	justify-content: center;
	gap: 10px;
}

/* Flex grid when Splide is destroyed (any breakpoint) or never initialized */
.block-brands.splide.is-initialized:not(.is-active) .splide__list,
.block-brands.splide:not(.is-initialized) .splide__list {
	display: flex;
	flex-wrap: wrap;
	row-gap: 30px;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.brands-item {
	height: var(--brands-item-height, 120px);
	background: #fffcf8;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	position: relative;
	padding: 12px 20px;
	box-sizing: border-box;
}

/* Width applied in grid mode only — slider width is controlled by Splide */
.block-brands.splide.is-initialized:not(.is-active) .brands-item,
.block-brands.splide:not(.is-initialized) .brands-item,
.block-brands--preview .brands-item {
	width: var(--brands-item-width, 219px);
}

.brands-item:before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 0;
	background: var(--wp--preset--color--primary);
	transition: height 0.2s ease;
}

.brands-item:hover:before,
.brands-item.is-visible:before,
.brands-item.is-active:before {
	height: 2px;
}

/* ── Image wrapper ─────────────────────────────────────────────────────────── */
.brands-item__image {
	display: flex;
	align-items: center;
	justify-content: center;
	/* max-width is overridden per-item via inline style from the ACF field */
	max-width: 136px;
	max-height: 82px;
	width: 100%;
}

/*
 * Cover all raster types the PHP generates (webp, png, jpeg, gif…).
 * The original rule used --img which is never produced by the MIME-type
 * class logic in block-brands.php, so logos had no size constraints at all.
 */
.brands-item__image img {
	max-width: 100%;
	max-height: 82px;
	width: auto;
	height: auto;
	object-fit: contain;
	display: block;
}

/* SVG rendered inline (fill inherits from parent) */
.brands-item__image--svg svg {
	max-width: 100%;
	max-height: 82px;
	width: 100%;
	height: auto;
}

/* ── Text label ────────────────────────────────────────────────────────────── */
.brands-item__text {
	font-family: 'LibreFranklin-Bold', sans-serif;
	font-size: 20px;
	font-weight: 700;
	text-transform: uppercase;
	text-align: center;
	color: #000;
	padding: 0 16px;
}

/* ── Scroll-in animation ─────────────────────────────────────────────────── */
@keyframes brands-fade-in-down {
	from {
		opacity: 0;
		transform: translateY(-18px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Grid mode — each item hidden until it animates in */
.brands-item.will-animate {
	opacity: 0;
}

.brands-item.is-in-view {
	animation: brands-fade-in-down 0.55s ease forwards;
	animation-delay: var(--anim-delay, 0ms);
}

/* Slider mode — whole container hidden until it animates in */
.block-brands.will-animate {
	opacity: 0;
}

.block-brands.is-in-view {
	animation: brands-fade-in-down 0.55s ease forwards;
}

@media (prefers-reduced-motion: reduce) {
	.brands-item.will-animate,
	.block-brands.will-animate {
		opacity: 1;
	}

	.brands-item.is-in-view,
	.block-brands.is-in-view {
		animation: none;
	}
}

/* ── Editor placeholder ────────────────────────────────────────────────────── */
.block-brands--placeholder {
	min-height: 120px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px dashed #c6a85e;
	color: #888;
	font-style: italic;
}

/* ── Responsive row-gap (grid mode only) ───────────────────────────────────── */
@media (min-width: 1024px) {
	.block-brands--preview,
	.block-brands.splide.is-initialized:not(.is-active) .splide__list,
	.block-brands.splide:not(.is-initialized) .splide__list {
		row-gap: 45px;
	}
}
