/* Shop / category / brand listing: banner, filter sidebar, toolbar, grid + list view. */

/* ---------- Layout ---------- */
.bb-shop {
	display: block;
	padding-block: clamp(24px, 4vw, 56px);
}

@media (min-width: 1100px) {
	.bb-shop {
		display: grid;
		grid-template-columns: 290px minmax(0, 1fr);
		gap: 40px;
		align-items: start;
	}
}

.bb-shop__main {
	min-width: 0;
	transition: opacity 0.15s;
}

.bb-shop.is-loading .bb-shop__main {
	opacity: 0.45;
	pointer-events: none;
}

/* ---------- Filters ---------- */
.bb-filters {
	/* mobile: slide-in drawer */
	position: fixed;
	inset: 0 auto 0 0;
	z-index: 110;
	width: min(88vw, 360px);
	padding: 0 20px 24px;
	overflow-y: auto;
	background: var(--bb-light);
	transform: translateX(-100%);
	visibility: hidden;
	transition: transform 0.25s, visibility 0.25s;
}

.bb-filters.is-open {
	transform: none;
	visibility: visible;
}

.bb-filters__head {
	position: sticky;
	top: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-inline: -20px;
	padding: 8px 8px 8px 20px;
	background: var(--bb-dark);
	color: #fff;
}

.bb-filters__title {
	font-family: var(--bb-font-head);
	font-size: 20px;
	font-weight: 700;
	text-transform: uppercase;
}

/* "In stock only" switch */
.bb-switch {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 4px 0 18px;
	border-bottom: 1px solid #e2e2e2;
	cursor: pointer;
}

.bb-switch input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.bb-switch__track {
	position: relative;
	flex: none;
	width: 48px;
	height: 26px;
	border-radius: 13px;
	background: #c9c9c9;
	transition: background-color 0.2s;
}

.bb-switch__track::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
	transition: transform 0.2s;
}

.bb-switch input:checked + .bb-switch__track {
	background: #1a9c2f;
}

.bb-switch input:checked + .bb-switch__track::after {
	transform: translateX(22px);
}

.bb-switch input:focus-visible + .bb-switch__track {
	outline: 3px solid var(--bb-orange);
	outline-offset: 2px;
}

.bb-switch__label {
	font-family: var(--bb-font-head);
	font-size: 19px;
	font-weight: 700;
	text-transform: uppercase;
}

.bb-fgroup {
	padding-block: 20px 4px;
	border-bottom: 1px solid #e2e2e2;
}

.bb-fgroup summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
	font-family: var(--bb-font-head);
	font-size: 20px;
	font-weight: 700;
	text-transform: uppercase;
	cursor: pointer;
	list-style: none;
}

.bb-fgroup summary::-webkit-details-marker {
	display: none;
}

.bb-fgroup summary::after {
	content: "";
	width: 8px;
	height: 8px;
	border: solid currentcolor;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
	transition: transform 0.15s;
}

.bb-fgroup[open] summary::after {
	transform: rotate(-135deg);
}

.bb-check {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 7px 0;
	font-family: var(--bb-font-head);
	font-size: 17px;
	font-weight: 500;
	line-height: 1.2;
	cursor: pointer;
}

.bb-check input {
	flex: none;
	width: 17px;
	height: 17px;
	margin: 0;
	accent-color: var(--bb-orange);
}

.bb-check:hover .bb-check__name {
	color: var(--bb-orange);
}

.bb-check__count {
	color: var(--bb-muted);
	font-weight: 400;
}

.bb-flist li + li,
.bb-ftree > li + li {
	border-top: 1px solid #e8e8e8;
}

.bb-flist--scroll {
	max-height: 340px;
	overflow-y: auto;
	padding-right: 8px;
}

/* Category tree */
.bb-ftree__item {
	position: relative;
}

.bb-ftree__toggle {
	position: absolute;
	top: 4px;
	right: 0;
	width: 30px;
	height: 30px;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
}

.bb-ftree__toggle::before {
	content: "+";
	color: #5aa31b;
	font-size: 22px;
	font-weight: 700;
	line-height: 30px;
}

.bb-ftree__item.is-open > .bb-ftree__toggle::before {
	content: "–";
}

.bb-ftree__sub {
	display: none;
	padding-left: 24px;
}

.bb-ftree__item.is-open > .bb-ftree__sub {
	display: block;
}

.bb-ftree__item:not(.is-open) > .bb-ftree__sub {
	display: none;
}

/* Price range */
.bb-range {
	padding-bottom: 16px;
}

.bb-range__track {
	position: relative;
	height: 22px;
	margin: 6px 8px 14px;
}

.bb-range__track::before,
.bb-range__fill {
	content: "";
	position: absolute;
	top: 9px;
	height: 4px;
	border-radius: 2px;
}

.bb-range__track::before {
	left: 0;
	right: 0;
	background: #d5d5d5;
}

.bb-range__fill {
	background: var(--bb-orange);
}

.bb-range input[type="range"] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 22px;
	margin: 0;
	background: none;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
}

.bb-range input[type="range"]::-webkit-slider-thumb {
	width: 20px;
	height: 20px;
	border: 0;
	border-radius: 50%;
	background: var(--bb-orange);
	cursor: pointer;
	pointer-events: auto;
	-webkit-appearance: none;
	appearance: none;
}

.bb-range input[type="range"]::-moz-range-thumb {
	width: 20px;
	height: 20px;
	border: 0;
	border-radius: 50%;
	background: var(--bb-orange);
	cursor: pointer;
	pointer-events: auto;
}

.bb-range input[type="range"]::-webkit-slider-runnable-track {
	background: none;
}

.bb-range input[type="range"]::-moz-range-track {
	background: none;
}

.bb-range__fields {
	display: flex;
	align-items: center;
	gap: 8px;
}

.bb-range__fields input {
	width: 100%;
	min-width: 0;
	padding: 9px 10px;
	border: 1px solid #d5d5d5;
	background: #fff;
	font-family: var(--bb-font-head);
	font-size: 16px;
}

.bb-range__label {
	margin-top: 12px;
	color: var(--bb-muted);
	font-size: 14px;
}

.bb-filters__apply {
	width: 100%;
	margin-top: 24px;
}

@media (min-width: 1100px) {
	.bb-filters {
		position: static;
		z-index: auto;
		width: auto;
		padding: 0;
		overflow: visible;
		background: none;
		transform: none;
		visibility: visible;
	}

	.bb-filters__head {
		display: none;
	}

	.bb-fgroup:first-of-type {
		padding-top: 0;
	}

	/* With JS, results update instantly, so the apply button is only for no-JS use. */
	.js .bb-filters__apply {
		display: none;
	}
}

/* ---------- Toolbar ---------- */
.bb-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 20px;
	margin-bottom: 8px;
}

.bb-toolbar__filters {
	order: -1;
}

@media (min-width: 1100px) {
	.bb-toolbar__filters {
		display: none;
	}
}

.bb-views {
	display: flex;
}

.bb-views__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	background: #fff;
	color: #555;
	cursor: pointer;
}

.bb-views__btn[aria-pressed="true"] {
	background: var(--bb-orange);
	color: #fff;
}

.bb-toolbar__field {
	display: flex;
	align-items: center;
	gap: 10px;
	font-family: var(--bb-font-head);
	font-size: 18px;
}

.bb-toolbar__field select {
	height: 44px;
	padding: 0 36px 0 14px;
	border: 0;
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23555' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center;
	color: #555;
	font-family: var(--bb-font-head);
	font-size: 17px;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
}

.bb-toolbar__pages {
	margin-left: auto;
}

/* Compact pager (toolbar) */
.bb-pager {
	display: flex;
	align-items: center;
	gap: 6px;
}

.bb-pager__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	background: #fff;
	color: #333;
	font-size: 24px;
	line-height: 1;
}

a.bb-pager__btn:hover {
	background: var(--bb-orange);
	color: #fff;
}

.bb-pager__btn.is-disabled {
	color: #c4c4c4;
}

.bb-pager__pos {
	min-width: 76px;
	padding-inline: 10px;
	font-family: var(--bb-font-head);
	font-size: 18px;
	text-align: center;
}

.bb-pager__pos strong {
	color: var(--bb-orange);
}

/* Load more + progress */
.bb-loadmore {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	margin-top: 40px;
}

.bb-loadmore__text {
	color: #555;
	font-family: var(--bb-font-head);
	font-size: 17px;
}

.bb-loadmore__bar {
	width: min(280px, 80%);
	height: 4px;
	background: #d9d9d9;
}

.bb-loadmore__bar span {
	display: block;
	height: 100%;
	background: var(--bb-orange);
}

.bb-loadmore__btn {
	min-width: 220px;
	min-height: 52px;
	margin-top: 6px;
	font-size: 18px;
}

.bb-loadmore__btn {
	position: relative;
}

/* Loading: label fades out, a spinner shows in the middle, the button can't be clicked twice. */
.bb-loadmore__btn.is-loading {
	color: transparent;
	pointer-events: none;
}

.bb-loadmore__btn.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 24px;
	height: 24px;
	margin: -12px 0 0 -12px;
	border: 3px solid rgba(243, 58, 10, 0.25);
	border-top-color: var(--bb-orange);
	border-radius: 50%;
	animation: bb-spin 0.7s linear infinite;
}

@keyframes bb-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.bb-loadmore__btn.is-loading::after {
		animation: none;
		border-top-color: rgba(243, 58, 10, 0.25);
		border-right-color: var(--bb-orange);
	}
}

/* Result count + active filter chips */
.bb-resultbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 20px;
	margin-block: 12px 24px;
}

.bb-resultbar__count {
	color: var(--bb-muted);
	font-size: 15px;
}

.bb-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.bb-chip {
	display: inline-block;
	padding: 5px 12px;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 999px;
	font-family: var(--bb-font-head);
	font-size: 15px;
}

.bb-chip:hover {
	border-color: var(--bb-orange);
	color: var(--bb-orange);
}

.bb-chip--clear {
	border-color: transparent;
	background: none;
	color: var(--bb-orange);
	text-decoration: underline;
}

.bb-empty {
	padding: 64px 0;
	text-align: center;
}

.bb-empty p {
	margin: 8px 0 20px;
	color: var(--bb-muted);
}

/* ---------- Product grid (with sidebar) ---------- */
.bb-grid--shop {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 700px) {
	.bb-grid--shop {
		gap: 20px;
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 1500px) {
	.bb-grid--shop {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* ---------- List view ---------- */
[data-view="list"] .bb-grid--shop {
	grid-template-columns: minmax(0, 1fr);
	gap: 12px;
}

[data-view="list"] .bb-card {
	display: grid;
	grid-template-columns: clamp(120px, 20vw, 220px) minmax(0, 1fr);
	align-items: center;
}

[data-view="list"] .bb-card__media {
	aspect-ratio: 1;
	padding: 16px;
}

[data-view="list"] .bb-card__body {
	padding: 16px 24px;
	text-align: left;
}

[data-view="list"] .bb-card__title {
	min-height: 0;
	font-size: 19px;
}

[data-view="list"] .bb-card__stock {
	position: static;
	width: auto;
	height: auto;
	margin-top: 6px;
	overflow: visible;
	clip-path: none;
	font-size: 14px;
}

/* Phones: a tidy toolbar in three rows instead of five controls wrapping at random.
   Row 1: Filters + view switch. Row 2: Sort by (full width). Row 3: Show + page arrows. */
@media (max-width: 699px) {
	.bb-toolbar {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: stretch;
		gap: 12px;
		margin-bottom: 4px;
	}

	.bb-toolbar__filters {
		grid-column: 1;
		grid-row: 1;
		order: 0;
		min-height: 50px;
		font-size: 19px;
	}

	.bb-views {
		grid-column: 2;
		grid-row: 1;
	}

	.bb-views__btn {
		height: 50px;
	}

	/* first label = Sort by */
	.bb-toolbar__field:nth-of-type(1) {
		grid-column: 1 / -1;
		grid-row: 2;
	}

	.bb-toolbar__field:nth-of-type(1) > span {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
	}

	.bb-toolbar__field:nth-of-type(1) select {
		width: 100%;
	}

	/* second label = Show */
	.bb-toolbar__field:nth-of-type(2) {
		grid-column: 1;
		grid-row: 3;
		gap: 12px;
	}

	.bb-toolbar__field select {
		height: 50px;
	}

	.bb-toolbar__pages {
		grid-column: 2;
		grid-row: 3;
		margin-left: 0;
	}

	.bb-pager__btn {
		width: 50px;
		height: 50px;
	}

	.bb-resultbar {
		margin-block: 8px 20px;
	}
}
