/**
 * Build-a-box / mix & match (Pro) — styling.
 *
 * A full-width grid of product cards with quantity steppers, a "N of M added"
 * meter and a progress bar that turns complete-green when the box is full.
 * Reads the configurator's --bb-* tokens so it brands with everything else.
 */

.bb-box {
	margin-top: 4px;
	/* Clearance so the last grid row can sit above the docked sticky summary
	   bar (~80px tall) instead of tucking behind it. The compact grid rows
	   otherwise have too little room below them, unlike the tall list items. */
	padding-bottom: 72px;
}

/* Keyboard / anchored scrolling parks a card above the pinned bar, matching
   .bundle-item's clearance. */
.bb-box-card {
	scroll-margin-bottom: 96px;
}

/* Head: the "Choose 6" instruction + the live "3 / 6" meter. */
.bb-box-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 8px;
}

.bb-box-instruction {
	font-weight: 600;
	color: var(--bb-ink);
}

.bb-box-meter {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	color: var(--bb-muted);
	white-space: nowrap;
}

.bb-box-ok .bb-box-meter {
	color: var(--bb-success);
}

.bb-box-over .bb-box-meter {
	color: #b91c1c;
}

/* Quantity-break note: "10% off" / "add 2 more for 15% off", under the head row. */
.bb-box-break-note {
	flex-basis: 100%;
	margin-top: 2px;
	font-size: 0.85em;
	font-weight: 600;
	color: var(--bb-success);
}

.bb-box-break-note:empty {
	display: none;
}

/* Progress bar. */
.bb-box-bar {
	height: 6px;
	background: var(--bb-surface-alt);
	border-radius: 3px;
	overflow: hidden;
	margin-bottom: 14px;
}

.bb-box-bar-fill {
	display: block;
	height: 100%;
	width: 0;
	background: var(--bb-accent);
	border-radius: 3px;
	transition: width 0.25s ease;
}

.bb-box-ok .bb-box-bar-fill {
	background: var(--bb-success-bright);
}

.bb-box-over .bb-box-bar-fill {
	background: #dc2626;
}

/* Card grid: auto-fills as many columns as fit, no sideways scroll. */
.bb-box-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 12px;
}

.bb-box-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 6px;
	padding: 12px 10px 10px;
	background: var(--bb-surface);
	border: 1px solid var(--bb-border);
	border-radius: 10px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bb-box-card-chosen {
	border-color: var(--bb-accent);
	box-shadow: inset 0 0 0 1px var(--bb-accent);
}

.bb-box-card-img {
	width: 72px;
	height: 72px;
	object-fit: cover;
	border-radius: 8px;
	background: var(--bb-surface-faint);
}

.bb-box-card-name {
	font-size: 13px;
	font-weight: 600;
	color: var(--bb-ink-soft);
	line-height: 1.3;
}

.bb-box-card-price {
	font-size: 13px;
	color: var(--bb-muted);
}

.bb-box-card-price del {
	color: var(--bb-muted-light);
	margin-right: 4px;
}

/* Variation chooser on a variable card: a compact select above the stepper. */
.bb-box-var {
	width: 100%;
	max-width: 152px;
	margin-top: 2px;
	padding: 5px 8px;
	font-size: 12.5px;
	border: 1px solid var(--bb-border-strong);
	border-radius: 8px;
	background: var(--bb-surface);
	color: var(--bb-ink);
}

/* A nudge shown only when a quantity is set but no option has been chosen. */
.bb-box-card-hint {
	display: none;
	font-size: 11.5px;
	font-weight: 600;
	color: #b91c1c;
}

.bb-box-card-pending .bb-box-card-hint {
	display: block;
}

/* A pending card flags the missing choice in red, overriding the chosen accent. */
.bb-box-card-pending,
.bb-box-card-pending.bb-box-card-chosen {
	border-color: #f0b4b4;
	box-shadow: inset 0 0 0 1px #f0b4b4;
}

/* Stepper: − [n] + */
.bb-box-stepper {
	display: inline-flex;
	align-items: center;
	margin-top: 2px;
	border: 1px solid var(--bb-border-strong);
	border-radius: 999px;
	overflow: hidden;
	background: var(--bb-surface);
}

.bb-box-dec,
.bb-box-inc {
	border: 0;
	background: var(--bb-surface-faint);
	color: var(--bb-ink);
	width: 30px;
	height: 30px;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.bb-box-dec:hover,
.bb-box-inc:hover {
	background: var(--bb-accent-bg);
	color: var(--bb-accent-deep);
}

.bb-box-full .bb-box-inc {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Variety cap: dim the cards you have not chosen once the cap of different
   products is reached, so it is clear why their plus is disabled. */
.bb-box-card-locked {
	opacity: 0.55;
}

.bb-box-card-locked .bb-box-inc,
.bb-box-inc:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.bb-box-variety {
	font-size: 12px;
	color: var(--bb-ink-soft, #6b6b6b);
}

.bb-box-qty {
	width: 38px;
	height: 30px;
	border: 0;
	border-left: 1px solid var(--bb-border);
	border-right: 1px solid var(--bb-border);
	text-align: center;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	-moz-appearance: textfield;
	appearance: textfield;
	background: var(--bb-surface);
	color: var(--bb-ink);
}

.bb-box-qty::-webkit-outer-spin-button,
.bb-box-qty::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* Sold-out card: muted, no stepper. */
.bb-box-card-oos {
	opacity: 0.55;
}

.bb-box-oos {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--bb-muted-light);
}

@media (max-width: 480px) {
	.bb-box-grid {
		grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
		gap: 10px;
	}

	.bb-box-card-img {
		width: 60px;
		height: 60px;
	}
}

/* -----------------------------------------------------------------
 * Size-driven box: the customer first picks a size / pack (say
 * "3kg bucket", "Medium hamper", "500g bag") — a flat price and an exact
 * fill count — then fills it. The sizes read as a distinct pricing-tier
 * chooser (not another product card), with a best-value badge, so the
 * value ladder is obvious. Reusable for any "pick a pack, fill it" shop.
 * ----------------------------------------------------------------- */

.bb-box-sizes {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
	gap: 12px;
	margin: 10px 0 4px;
}

.bb-box-size {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	padding: 16px 14px 14px;
	margin-top: 9px; /* room for the best-value badge to sit above */
	background: var(--bb-surface);
	border: 1.5px solid var(--bb-border);
	border-radius: 14px;
	cursor: pointer;
	text-align: center;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease, background 0.15s ease;
}

.bb-box-size:hover {
	border-color: var(--bb-accent);
	transform: translateY(-1px);
}

.bb-box-size:focus-visible {
	outline: 2px solid var(--bb-accent);
	outline-offset: 2px;
}

/* Best-value tile: a quiet highlight even before it's chosen. */
.bb-box-size-featured {
	border-color: var(--bb-success-bright, var(--bb-accent));
}

/* Chosen size: a filled accent tile with a check — clearly a selection, and
   nothing like the border a chosen sweet gets. Explicit colours so the text
   stays legible on the fill whatever the theme's tokens are. */
.bb-box-size-on {
	border-color: var(--bb-accent);
	background: var(--bb-accent);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.bb-box-size-on .bb-box-size-name,
.bb-box-size-on .bb-box-size-price {
	color: #fff;
}

.bb-box-size-on .bb-box-size-meta {
	color: rgba(255, 255, 255, 0.85);
}

.bb-box-size-on .bb-box-size-check {
	background: #fff;
	color: var(--bb-accent);
}

.bb-box-size-name {
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--bb-ink-soft, var(--bb-ink));
	line-height: 1.25;
}

.bb-box-size-price {
	font-size: 20px;
	font-weight: 700;
	color: var(--bb-ink);
	line-height: 1.15;
}

.bb-box-size-meta {
	font-size: 12px;
	color: var(--bb-muted);
}

/* Selected check, top-right, revealed when the size is on. */
.bb-box-size-check {
	position: absolute;
	top: 9px;
	right: 9px;
	width: 19px;
	height: 19px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--bb-accent);
	color: #fff;
	opacity: 0;
	transform: scale(0.5);
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.bb-box-size-on .bb-box-size-check {
	opacity: 1;
	transform: scale(1);
}

.bb-box-size-badge {
	position: absolute;
	top: -9px;
	left: 50%;
	transform: translateX(-50%);
	padding: 3px 10px;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	white-space: nowrap;
	color: #fff;
	background: var(--bb-success-bright, var(--bb-accent));
	border-radius: 999px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

/* "Now fill it" divider between the size chooser and the item grid. */
.bb-box-fill-label {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 18px 0 12px;
}

.bb-box-fill-label::before,
.bb-box-fill-label::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--bb-border);
}

.bb-box-fill-label span {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--bb-muted);
}

/* Until a size is chosen, the item grid is dormant — the size is the first
   decision, and picking items before it would be meaningless. */
.bb-box-needs-size .bb-box-grid {
	opacity: 0.4;
	pointer-events: none;
	filter: grayscale(0.5);
}

.bb-box-needs-size .bb-box-fill-label {
	opacity: 0.4;
}

@media (max-width: 480px) {
	.bb-box-sizes {
		grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
		gap: 10px;
	}

	.bb-box-size-price {
		font-size: 18px;
	}
}

/* -----------------------------------------------------------------
 * Box search: filter the item grid by name. Shown only for large pools
 * (dozens of choices), where a flat grid is unusable without it.
 * ----------------------------------------------------------------- */

.bb-box-search {
	position: relative;
	margin: 6px 0 12px;
}

.bb-box-search-icon {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--bb-muted);
	pointer-events: none;
}

.bb-box-search-input {
	width: 100%;
	box-sizing: border-box;
	/* !important so a theme restyling search inputs can't slide the text back
	   under the magnifier icon. */
	padding: 10px 14px 10px 40px !important;
	font-size: 14px;
	color: var(--bb-ink);
	background: var(--bb-surface);
	border: 1px solid var(--bb-border);
	border-radius: 10px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bb-box-search-input:focus {
	outline: none;
	border-color: var(--bb-accent);
	box-shadow: 0 0 0 3px var(--bb-surface-alt);
}

.bb-box-card-hidden {
	display: none !important;
}

.bb-box-noresults {
	margin: 4px 0 0;
	padding: 16px 0;
	text-align: center;
	font-size: 13px;
	color: var(--bb-muted);
}

/* Category filter chips for a large box grid: browse by category alongside
   the search box. */
.bb-box-cats {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	margin: 0 0 14px;
}

.bb-box-cat {
	padding: 5px 13px;
	font-size: 12.5px;
	font-weight: 500;
	color: var(--bb-ink-soft, var(--bb-ink));
	background: var(--bb-surface);
	border: 1px solid var(--bb-border);
	border-radius: 999px;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.bb-box-cat:hover {
	border-color: var(--bb-accent);
}

.bb-box-cat-on {
	color: #fff;
	background: var(--bb-accent);
	border-color: var(--bb-accent);
}
