/*
 * "Brands Slider / Grid" Elementor widget (inc/class-bwzagg-brands-widget.php).
 *
 * The slider is plain CSS scroll-snap (no slider library): the list scrolls horizontally, each
 * brand snaps to the start, and js/brands-widget.js only adds the arrows, dots, autoplay and
 * mouse-drag. Without JavaScript it is still a working, swipeable row.
 *
 * Settings that Elementor writes as CSS variables on .bwzagg-brands:
 *   --bwzagg-spv   brands per view (slider)      --bwzagg-cols  columns (grid)
 *   --bwzagg-gap   space between brands          --bwzagg-logo-h  logo area height
 * The defaults below apply until/unless those controls are set.
 */
.bwzagg-brands {
	--bwzagg-spv: 6;
	--bwzagg-cols: 6;
	--bwzagg-gap: 20px;
	--bwzagg-logo-h: 80px;
	position: relative;
	width: 100%;
}
.bwzagg-brands__list {
	list-style: none;
	margin: 0;
	padding: 0;
}
.bwzagg-brands__item {
	display: block;
	min-width: 0;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* ---- Slider ------------------------------------------------------------ */
.bwzagg-brands--slider .bwzagg-brands__viewport {
	position: relative;
}
.bwzagg-brands--slider .bwzagg-brands__list {
	display: flex;
	gap: var(--bwzagg-gap);
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
	/* Room for the card shadows (the scroll container would clip them), cancelled by the negative margin. */
	padding: 8px 4px 24px;
	margin: -8px -4px -24px;
}
.bwzagg-brands--slider .bwzagg-brands__list::-webkit-scrollbar {
	display: none;
}
.bwzagg-brands--slider .bwzagg-brands__item {
	flex: 0 0 calc((100% - (var(--bwzagg-spv) - 1) * var(--bwzagg-gap)) / var(--bwzagg-spv));
	scroll-snap-align: start;
}
.bwzagg-brands--slider .bwzagg-brands__list.is-dragging {
	scroll-snap-type: none;
	scroll-behavior: auto;
	cursor: grabbing;
	user-select: none;
}
.bwzagg-brands--slider .bwzagg-brands__list.is-dragging a {
	pointer-events: none;
}

/* ---- Grid -------------------------------------------------------------- */
.bwzagg-brands--grid .bwzagg-brands__list {
	display: grid;
	grid-template-columns: repeat(var(--bwzagg-cols), minmax(0, 1fr));
	gap: var(--bwzagg-gap);
}

/* ---- Brand card -------------------------------------------------------- */
.bwzagg-brands__card {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 100%;
	box-sizing: border-box;
	padding: 16px;
	background: #fff;
	border: 1px solid rgba(12, 10, 13, 0.06);
	border-radius: 12px;
	box-shadow: 0 4px 16px rgba(12, 10, 13, 0.06);
	color: inherit;
	text-decoration: none;
	text-align: center;
	transition: box-shadow 0.25s ease, transform 0.25s ease, background-color 0.25s ease, border-color 0.25s ease;
}
a.bwzagg-brands__card:hover,
a.bwzagg-brands__card:focus-visible {
	box-shadow: 0 12px 28px rgba(12, 10, 13, 0.14);
	transform: translateY(-3px);
}
a.bwzagg-brands__card:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}
.bwzagg-brands__logo {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: var(--bwzagg-logo-h);
}
.bwzagg-brands__img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	transition: filter 0.25s ease;
}
.bwzagg-brands__name {
	font-weight: 500;
	line-height: 1.3;
}
.bwzagg-brands__count {
	font-size: 0.85em;
	opacity: 0.75;
}

/* ---- Arrows & dots ----------------------------------------------------- */
.bwzagg-brands__nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	margin-top: 18px;
}
.bwzagg-brands__nav .bwzagg-brands__dots {
	margin-top: 0;
}
.bwzagg-brands__arrow {
	position: relative;
	z-index: 2;
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: #0c0a0d;
	box-shadow: 0 4px 14px rgba(12, 10, 13, 0.18);
	cursor: pointer;
	transition: opacity 0.2s ease, background-color 0.2s ease;
}
.bwzagg-brands__arrow:hover:not(:disabled) {
	background: #f75207;
	color: #fff;
}
.bwzagg-brands__arrow:focus-visible {
	outline: 2px solid #f75207;
	outline-offset: 2px;
}
.bwzagg-brands__arrow:disabled {
	opacity: 0.35;
	cursor: default;
}
.bwzagg-brands__arrow--prev svg {
	transform: scaleX(-1);
}
/* Optional layout: arrows on the left / right edges, centred on the slider. */
.bwzagg-brands--arrows-sides .bwzagg-brands__arrow {
	position: absolute;
	top: calc(50% - 20px);
}
.bwzagg-brands--arrows-sides .bwzagg-brands__arrow--prev {
	left: -14px;
}
.bwzagg-brands--arrows-sides .bwzagg-brands__arrow--next {
	right: -14px;
}
.bwzagg-brands.is-static .bwzagg-brands__nav,
.bwzagg-brands.is-static .bwzagg-brands__arrow,
.bwzagg-brands.is-static .bwzagg-brands__dots {
	display: none;
}
.bwzagg-brands__dots {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 18px;
}
.bwzagg-brands__dot {
	width: 8px;
	height: 8px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(12, 10, 13, 0.25);
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.2s ease;
}
.bwzagg-brands__dot.is-active {
	background: #f75207;
	transform: scale(1.25);
}

/* Elementor editor: shown when the widget has nothing to display. */
.bwzagg-brands-empty {
	padding: 24px;
	border: 2px dashed #c4c4c4;
	border-radius: 8px;
	color: #555;
	text-align: center;
}

/* On phones the arrows sit inside the edges so they are not clipped by the page margin. */
@media (max-width: 767px) {
	.bwzagg-brands--arrows-sides .bwzagg-brands__arrow--prev {
		left: 4px;
	}
	.bwzagg-brands--arrows-sides .bwzagg-brands__arrow--next {
		right: 4px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bwzagg-brands--slider .bwzagg-brands__list {
		scroll-behavior: auto;
	}
	.bwzagg-brands__card,
	.bwzagg-brands__img {
		transition: none;
	}
	a.bwzagg-brands__card:hover,
	a.bwzagg-brands__card:focus-visible {
		transform: none;
	}
}
