/* --bs-csm-color is the badge color setting, printed in wp_head */

/* The mini cart's "does this cart qualify" marker (data only, read by scripts.js) */
.bs-csm-answer {
	display: none !important;
}

/* Cross-sale cart / mini cart item */
.bs-csm-item {
	position: relative;
	border: 2px solid var(--bs-csm-color, #469ab7);
}

/* Checkout order review: rows are separated by a bottom divider, not boxed, so the
   cross-sale row keeps that divider and is marked by its badge instead. */
.woocommerce-checkout-review-order-table .bs-csm-item {
	border-width: 0 0 1px;
	border-color: #dfdfdf;
}

/* Mini cart items are borderless rounded cards; a border inside the 20px radius
   crowds the content, so the cross-sale item is marked by its badge alone. */
.woocommerce-mini-cart li.bs-csm-item {
	border: 0;
}

/* Matches the BOGO badge and the theme's .bs-bundle-tag pill */
.bs-csm-badge {
	display: inline-block;
	margin-top: 4px;
	padding: 4px 10px;
	border-radius: 999px;
	background-color: var(--bs-csm-color, #469ab7);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
}

/* Quantity is locked to 1 for the cross-sale item */
.bs-csm-item input[type="button"]:disabled,
.bs-csm-item button:disabled {
	background-color: #ddd;
	color: #999;
	cursor: auto;
}

.bs-csm-item .quantity > .qty {
	background-color: #ddd;
}

/* Waiting on the server: the mini cart Checkout button and the modal's buttons get the
   theme's own add-to-cart loading classes (bs-loading rbb-spinner bs-spinner, see
   ajaxCart.js): the label turns invisible and the theme's loading animation shows in
   the middle, drawn by .rbb-spinner::before. This only gives it a box to center in.
   scripts.js hides the label inline, as the theme's !important text colors on the
   mini cart button beat .bs-spinner's. */
.bs-csm-loading {
	position: relative;
	pointer-events: none;
}

/* ----- Modal (scripts.js) ----- */

html.bs-csm-open {
	overflow: hidden;
}

.bs-csm-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(23, 44, 48, .55);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	opacity: 0;
	transition: opacity .25s ease;
}

.bs-csm-overlay.is-shown {
	opacity: 1;
}

.bs-csm-modal {
	position: relative;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	width: 100%;
	max-width: 880px;
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	margin: 0;
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
	overflow: hidden;
	transform: translateY(16px) scale(.97);
	transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
}

.bs-csm-overlay.is-shown .bs-csm-modal {
	transform: none;
}

/* Same icon and look as the mini cart drawer's close button (.mini-cart-close) */
.bs-csm-modal__close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 9999px;
	background: transparent;
	color: var(--rbb-general-primary-color);
	line-height: 1;
	cursor: pointer;
	transition: background-color .2s ease, color .2s ease;
}

.bs-csm-modal__close:hover {
	background: #f0f0f0;
}

.bs-csm-modal__header {
	flex: 0 0 auto;
	padding: 28px 56px 8px;
	text-align: center;
}

/* Same treatment as the BOGO "unlocked" banner icon, in the badge color */
/* Alarm clock emoji for the "Wait!" title; it rings (wiggles) as the modal opens.
   The emoji font stack keeps it in full color everywhere. */
.bs-csm-modal__icon {
	display: inline-block;
	margin-bottom: 6px;
	font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
	font-size: 44px;
	line-height: 1;
	transform-origin: 50% 60%;
}

.bs-csm-overlay.is-shown .bs-csm-modal__icon {
	animation: bs-csm-ring 1s ease .3s 2;
}

.bs-csm-modal__title {
	margin: 0;
	font-size: 26px;
	font-weight: 700;
	line-height: 1.2;
}

.bs-csm-modal__description {
	margin: 8px auto 0;
	max-width: 520px;
	color: #555;
	font-size: 14px;
	line-height: 1.45;
}

/* Scrolls on its own, so the header and buttons stay put */
.bs-csm-modal__products {
	display: grid;
	flex: 1 1 auto;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 14px;
	min-height: 0;
	margin: 0;
	padding: 18px 28px 8px;
	border: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.bs-csm-product {
	position: relative;
	display: block;
	margin: 0;
	cursor: pointer;
}

/* The radio stays focusable but out of sight; the card shows its state */
.bs-csm-product__input {
	position: absolute;
	top: 0;
	left: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	opacity: 0;
}

.bs-csm-product__card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	box-sizing: border-box;
	height: 100%;
	padding: 12px 10px 14px;
	border: 2px solid #e6e6e6;
	border-radius: 14px;
	background: #fff;
	text-align: center;
	transition: border-color .2s, box-shadow .2s, background-color .2s;
}

.bs-csm-overlay.is-shown .bs-csm-product__card {
	animation: bs-csm-rise .4s ease-out backwards;
}

.bs-csm-product:nth-child(3) .bs-csm-product__card { animation-delay: .05s; }
.bs-csm-product:nth-child(4) .bs-csm-product__card { animation-delay: .1s; }
.bs-csm-product:nth-child(5) .bs-csm-product__card { animation-delay: .15s; }
.bs-csm-product:nth-child(n+6) .bs-csm-product__card { animation-delay: .2s; }

.bs-csm-product:hover .bs-csm-product__card {
	border-color: #c8c8c8;
}

.bs-csm-product__input:checked + .bs-csm-product__card {
	border-color: var(--bs-csm-color, #469ab7);
	background-color: color-mix(in srgb, var(--bs-csm-color, #469ab7) 6%, #fff);
	box-shadow: 0 6px 18px color-mix(in srgb, var(--bs-csm-color, #469ab7) 30%, transparent);
}

.bs-csm-product__input:focus-visible + .bs-csm-product__card {
	outline: 2px solid var(--bs-csm-color, #469ab7);
	outline-offset: 3px;
}

.bs-csm-product__input:disabled + .bs-csm-product__card {
	cursor: default;
}

.bs-csm-product__check {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--bs-csm-color, #469ab7);
	color: #fff;
	opacity: 0;
	transform: scale(.4);
	transition: opacity .2s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.bs-csm-product__input:checked + .bs-csm-product__card .bs-csm-product__check {
	opacity: 1;
	transform: none;
}

.bs-csm-product__image {
	display: block;
	width: 100%;
	margin-bottom: 6px;
	border-radius: 10px;
	overflow: hidden;
	aspect-ratio: 1;
	background: #f5f5f5;
}

.bs-csm-product__image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.bs-csm-product__name {
	display: -webkit-box;
	overflow: hidden;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
}

.bs-csm-product__variation {
	color: #777;
	font-size: 12px;
	line-height: 1.3;
}

.bs-csm-product__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: center;
	gap: 0 6px;
	margin-top: auto;
	padding-top: 4px;
}

.bs-csm-product__price-now {
	color: color-mix(in srgb, var(--bs-csm-color, #469ab7) 80%, #000);
	font-size: 16px;
	font-weight: 700;
}

.bs-csm-product__price-was {
	color: #999;
	font-size: 13px;
}

.bs-csm-product__card .bs-csm-badge {
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bs-csm-modal__footer {
	display: flex;
	flex: 0 0 auto;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 14px 28px 22px;
	border-top: 1px solid #eee;
	background: #fff;
}

.bs-csm-modal__footer .bs-csm-modal__add {
	border: 0;
	cursor: pointer;
}

.bs-csm-modal__decline {
	padding: 6px 10px;
	border: 0;
	background: none;
	color: #666;
	font-size: 13px;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

/* The decline link is text on white: the theme's dark version of the same animation
   (.bs-spinner uses the white one, made for its colored buttons) */
.bs-csm-modal__decline.bs-spinner::before {
	background: var(--rbb-button-loading) center center / cover no-repeat;
}

.bs-csm-modal__decline:hover {
	color: #172c30;
}

.bs-csm-modal button:disabled {
	cursor: default;
}

@media (max-width: 767px) {
	.bs-csm-overlay {
		align-items: flex-end;
		padding: 0;
	}

	/* A bottom sheet on phones */
	.bs-csm-modal {
		max-height: calc(100vh - 24px);
		max-height: calc(100dvh - 24px);
		border-radius: 20px 20px 0 0;
		transform: translateY(40px);
		transition-timing-function: cubic-bezier(.2, .8, .3, 1);
	}

	.bs-csm-modal__header {
		padding: 22px 48px 4px;
	}

	.bs-csm-modal__icon {
		margin-bottom: 4px;
		font-size: 36px;
	}

	.bs-csm-modal__title {
		font-size: 20px;
	}

	.bs-csm-modal__description {
		font-size: 13px;
	}

	.bs-csm-modal__products {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 10px;
		padding: 14px 16px 8px;
	}

	.bs-csm-product__card {
		padding: 10px 8px 12px;
	}

	.bs-csm-product__name {
		font-size: 13px;
	}

	.bs-csm-modal__footer {
		padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
	}

	.bs-csm-modal__add {
		width: 100%;
	}
}

/* A quick alarm-clock buzz that settles */
@keyframes bs-csm-ring {
	0%, 60%, 100% { transform: rotate(0); }
	6%, 18%, 30%, 42% { transform: rotate(-14deg) scale(1.08); }
	12%, 24%, 36%, 48% { transform: rotate(14deg) scale(1.08); }
}

@keyframes bs-csm-rise {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.bs-csm-overlay,
	.bs-csm-modal,
	.bs-csm-product__check {
		transform: none;
		transition: opacity .2s;
	}

	.bs-csm-overlay.is-shown .bs-csm-modal__icon,
	.bs-csm-overlay.is-shown .bs-csm-product__card {
		animation: none;
	}
}
