/**
 * Brand Woo - carousel and dropdown.
 *
 * The carousel keeps its neutral ecommerce palette by default; the dropdown is
 * a custom disclosure panel. With "Follow the active theme colors" enabled both
 * read the block-theme presets (`--wp--preset--color--*`), and classic themes
 * fall back to `currentColor`, so the plugin inherits the site palette.
 */

/* -------------------------------------------------- Base ------------------ */

.bw-carousel {
	--bw-gap: 24px;
	--bw-bg: #ffffff;
	--bw-logo-height: 48px;
	--bw-line: #e5e7eb;
	--bw-ink: #111827;
	--bw-muted: #6b7280;
	--bw-hover-line: #111827;
	--bw-radius: 8px;

	position: relative;
	box-sizing: border-box;
	margin: 0 auto 1.5em;
	padding: 0;
	width: 100%;
	max-width: 100%;
	color: var(--bw-ink);
	font-size: 14px;
	line-height: 1.4;
	-webkit-tap-highlight-color: transparent;
}

.bw-carousel *,
.bw-carousel *::before,
.bw-carousel *::after {
	box-sizing: border-box;
}

.bw-carousel__title {
	margin: 0 0 16px;
	padding: 0;
	font-size: 18px;
	font-weight: 600;
	letter-spacing: 0;
	color: var(--bw-ink);
	border-radius: var(--bw-radius);
}

/* ------------------------------------------------- Viewport and track ---- */

.bw-carousel__viewport {
	position: relative;
	overflow: hidden;
	margin: 0;
	padding: 0;
	touch-action: pan-y;
	cursor: grab;
}

.bw-carousel--single .bw-carousel__viewport {
	cursor: default;
}

.bw-carousel__viewport.is-dragging,
.bw-carousel.is-dragging .bw-carousel__viewport {
	cursor: grabbing;
}

.bw-carousel__track {
	display: flex;
	flex-wrap: nowrap;
	align-items: stretch;
	gap: var(--bw-gap);
	margin: 0;
	padding: 0;
	list-style: none;
	will-change: transform;
	transition-property: transform;
	transition-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
	transition-duration: 520ms;
}

.bw-carousel__item {
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
	list-style: none;
	min-width: 0;
}

.bw-carousel__link {
	display: block;
	height: 100%;
	text-decoration: none;
	color: inherit;
	outline: none;
}

.bw-carousel__link:focus-visible {
	outline: 2px solid var(--bw-ink);
	outline-offset: 2px;
}

/* --------------------------------------------------- Logo tile ----------- */

.bw-carousel__frame {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	min-height: 104px;
	padding: 20px 16px;
	background: var(--bw-bg);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
	border: 1px solid var(--bw-line);
	border-radius: var(--bw-radius);
	transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.bw-carousel--no-border .bw-carousel__frame {
	border-color: transparent;
}

.bw-carousel__img {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: var(--bw-logo-height);
	object-fit: contain;
	object-position: center;
}

.bw-carousel__fallback {
	display: block;
	font-size: 15px;
	font-weight: 600;
	text-align: center;
	color: var(--bw-muted);
}

.bw-carousel--grayscale .bw-carousel__img {
	filter: grayscale(100%);
	opacity: 0.72;
	transition: filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

@media (hover: hover) {
	.bw-carousel--grayscale .bw-carousel__item:hover .bw-carousel__img {
		filter: grayscale(0%);
		opacity: 1;
		transform: scale(1.04);
	}

	.bw-carousel__item:hover .bw-carousel__frame {
		border-color: var(--bw-hover-line);
		transform: translateY(-2px);
	}

	.bw-carousel--shadow .bw-carousel__item:hover .bw-carousel__frame {
		box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 12px 28px rgba(17, 24, 39, 0.1);
	}
}

/* --------------------------------------------------- Controls ------------ */

.bw-carousel__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	margin: 18px 0 0;
	padding: 0;
}

.bw-carousel__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	min-width: 40px;
	padding: 0;
	background: #ffffff;
	border: 1px solid var(--bw-line);
	border-radius: 50%;
	color: var(--bw-ink);
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.bw-carousel__arrow:hover {
	background: var(--bw-ink);
	border-color: var(--bw-ink);
	color: #ffffff;
	transform: translateY(-1px);
}

.bw-carousel__arrow:focus-visible {
	outline: 2px solid var(--bw-ink);
	outline-offset: 2px;
}

.bw-carousel__arrow:disabled {
	opacity: 0.35;
	cursor: default;
}

.bw-carousel__arrow:disabled:hover {
	background: #ffffff;
	border-color: var(--bw-line);
	color: var(--bw-ink);
	transform: none;
}

.bw-carousel__counter {
	min-width: 56px;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0;
	text-align: center;
	color: var(--bw-muted);
}

.bw-carousel__icon {
	display: block;
	width: 20px;
	height: 20px;
}

/* -------------------------------------------------- Utilities ------------ */

.bw-carousel__empty {
	padding: 24px;
	background: #f9fafb;
	border: 1px dashed var(--bw-line);
	border-radius: var(--bw-radius);
	color: var(--bw-muted);
	text-align: center;
}

.bw-carousel__empty a {
	color: var(--bw-ink);
	font-weight: 600;
}

.bw-carousel .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.bw-carousel.alignwide {
	width: 100%;
	max-width: 1440px;
}

.bw-carousel.alignfull {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
}

/* -------------------------------------------------- Responsive ---------- */

@media (max-width: 1023px) {
	.bw-carousel__frame {
		min-height: 92px;
		padding: 18px 14px;
	}
}

@media (max-width: 767px) {
	.bw-carousel {
		--bw-logo-height: 40px;
	}

	.bw-carousel__frame {
		min-height: 80px;
		padding: 14px 10px;
	}

	.bw-carousel__controls {
		gap: 10px;
		margin-top: 14px;
	}

	.bw-carousel__arrow {
		width: 36px;
		height: 36px;
		min-width: 36px;
	}
}

/* -------------------------------------------------- Motion ------------- */

@media (prefers-reduced-motion: reduce) {
	.bw-carousel__track,
	.bw-carousel__img,
	.bw-carousel__frame {
		transition: none !important;
	}
}

/* Widget context keeps a tidy, compact frame. */
.widget .bw-carousel__frame,
.bw-carousel--compact .bw-carousel__frame {
	min-height: 84px;
	padding: 12px;
}

/* ------------------------------------------------ Theme palette ---------- */

/*
 * "Follow the active theme colors" maps the plugin onto the block-theme
 * presets (`--wp--preset--color--*`). Classic themes have no presets, so the
 * `currentColor` fallback keeps the plugin inheriting the theme's own text
 * color instead of forcing the neutral defaults.
 */

.bw-carousel.bw-theme-colors {
	--bw-ink: var(--wp--preset--color--contrast, currentColor);
	--bw-hover-line: var(--wp--preset--color--primary, currentColor);
	--bw-bg: var(--wp--preset--color--base, #ffffff);
	--bw-muted: color-mix(in srgb, currentColor 64%, transparent);
	--bw-line: color-mix(in srgb, currentColor 14%, transparent);
}

.bw-dropdown.bw-theme-colors {
	--bw-accent: var(--wp--preset--color--primary, currentColor);
	--bw-bg: var(--wp--preset--color--base, #ffffff);
	--bw-border: color-mix(in srgb, currentColor 16%, transparent);
}

/* -------------------------------------------------- Brand dropdown ------- */

/*
 * A custom disclosure panel: theme-driven colors, a pill count, and hover
 * highlights. Built on native <details>, so it works
 * without JavaScript and stays keyboard and screen-reader accessible.
 */

.bw-dropdown {
	--bw-accent: #111827;
	--bw-bg: #ffffff;
	--bw-border: #e5e7eb;
	--bw-panel-gap: 10px;
	--bw-radius: 10px;

	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 0 0 1.5em;
	color: inherit;
	font-size: 15px;
	line-height: 1.4;
	-webkit-tap-highlight-color: transparent;
}

/*
 * Progressive enhancement: without `color-mix()` support the translucent
 * highlights fall back to the solid accent color instead of disappearing.
 */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
	.bw-dropdown,
	.bw-dropdown.bw-theme-colors {
		--bw-border: rgba(17, 24, 39, 0.16);
	}

	.bw-dropdown__count,
	.bw-dropdown__mark {
		background: var(--bw-accent);
		color: var(--bw-bg);
	}

	.bw-dropdown__link:hover,
	.bw-dropdown__link:focus-visible {
		background: var(--bw-accent);
		color: var(--bw-bg);
	}
}

.bw-dropdown *,
.bw-dropdown *::before,
.bw-dropdown *::after {
	box-sizing: border-box;
}

.bw-dropdown__title {
	margin: 0 0 12px;
	font-size: 18px;
	font-weight: 600;
	letter-spacing: 0;
}

.bw-dropdown__details {
	position: relative;
}

/*
 * While open, lift the dropdown above following siblings. Many themes and
 * builders place an image/banner widget after the dropdown and give it its own
 * stacking context; raising this block on open keeps the panel visible.
 */
.bw-dropdown.bw-dropdown--open,
.bw-dropdown:focus-within,
.bw-dropdown:has(.bw-dropdown__details[open]) {
	z-index: 2147483000;
}

.bw-dropdown__trigger {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 12px 14px;
	background: var(--bw-bg);
	border: 1px solid var(--bw-border);
	border-radius: var(--bw-radius);
	color: inherit;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	list-style: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.bw-dropdown__trigger::-webkit-details-marker {
	display: none;
}

.bw-dropdown__trigger:hover {
	border-color: var(--bw-accent);
}

.bw-dropdown__trigger:focus-visible {
	outline: 2px solid var(--bw-accent);
	outline-offset: 2px;
}

.bw-dropdown__trigger-label {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-align: left;
}

.bw-dropdown__trigger .bw-dropdown__count {
	flex-shrink: 0;
}


.bw-dropdown__count {
	flex: 0 0 auto;
	min-width: 26px;
	padding: 2px 8px;
	border-radius: 999px;
	background: color-mix(in srgb, var(--bw-accent) 12%, transparent);
	color: var(--bw-accent);
	font-size: 12px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	text-align: center;
}

.bw-dropdown__details[open] > .bw-dropdown__trigger {
	border-color: var(--bw-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--bw-accent) 14%, transparent);
}

.bw-dropdown__panel {
	position: absolute;
	z-index: 2147483000;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	max-height: 340px;
	overflow-y: auto;
	margin: 0;
	padding: 6px;
	background: var(--bw-bg);
	border: 1px solid var(--bw-border);
	border-radius: var(--bw-radius);
	box-shadow: 0 16px 40px rgba(17, 24, 39, 0.14);
	animation: bw-dropdown-in 0.18s ease;
}

/*
 * When the dropdown lives in a sidebar or any ancestor that clips overflow or
 * owns a stacking context, the script moves the open panel to <body> and pins
 * it under the trigger with inline fixed coordinates. This keeps it above the
 * rest of the page and free of the sidebar's clipping.
 */
.bw-dropdown__panel--portal {
	position: fixed;
	z-index: 2147483000;
}

.bw-dropdown__panel--portal,
.bw-dropdown__panel--portal * {
	box-sizing: border-box;
}

@keyframes bw-dropdown-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.bw-dropdown__list {
	display: flex;
	flex-direction: column;
	gap: var(--bw-panel-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.bw-dropdown__item {
	margin: 0;
	padding: 0;
}

.bw-dropdown__link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 10px;
	border-radius: 6px;
	color: inherit;
	text-decoration: none;
	transition: background-color 0.16s ease, color 0.16s ease;
}

.bw-dropdown__link:hover,
.bw-dropdown__link:focus-visible {
	background: color-mix(in srgb, var(--bw-accent) 10%, transparent);
	color: var(--bw-accent);
	outline: none;
}

.bw-dropdown__link--static {
	cursor: default;
}

.bw-dropdown__link--static:hover {
	background: transparent;
	color: inherit;
}

.bw-dropdown__mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	border-radius: 6px;
	overflow: hidden;
	background: color-mix(in srgb, var(--bw-accent) 8%, transparent);
}

.bw-dropdown__logo {
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.bw-dropdown__name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bw-dropdown__item-icon {
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
	opacity: 0.45;
	transition: opacity 0.16s ease, transform 0.16s ease;
}

.bw-dropdown__link:hover .bw-dropdown__item-icon {
	opacity: 1;
	transform: translateX(2px);
}

.bw-dropdown--no-border .bw-dropdown__trigger,
.bw-dropdown--no-border .bw-dropdown__panel {
	border-color: transparent;
}

.bw-dropdown.alignwide {
	width: 100%;
	max-width: 1440px;
}

.bw-dropdown.alignfull {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
}

@media (prefers-reduced-motion: reduce) {
	.bw-dropdown__panel,
	.bw-dropdown__link,
	.bw-dropdown__item-icon {
		animation: none !important;
		transition: none !important;
	}
}
