/**
 * Frequently Bought Together: the block on a product page. Free.
 *
 * A quiet card inside the product form: a strip of pictures (what is not
 * ticked is faded), then stacked rows, one per product, each a tick, a name,
 * and a price on the right. Never a carousel. It borrows the theme's font and
 * text colour, so it sits in any shop; the only fixed colours are greys and
 * the green tick for what is already in the basket.
 */

.bb-fbt {
	--bb-fbt-line: rgba(0, 0, 0, 0.1);
	--bb-fbt-soft: rgba(0, 0, 0, 0.04);
	--bb-fbt-muted: rgba(0, 0, 0, 0.58);
	box-sizing: border-box;
	flex: 0 0 100%;
	width: 100%;
	margin: 4px 0 18px;
	padding: 16px 18px 10px;
	border: 1px solid var(--bb-fbt-line);
	border-radius: 12px;
	font-size: 15px;
	line-height: 1.4;
}

/* The product form lays the quantity and button in one row; the block takes
   a row of its own above them, whatever the theme's flex settings. */
form.cart:has(> .bb-fbt),
.woocommerce-variation-add-to-cart:has(> .bb-fbt) {
	flex-wrap: wrap;
}

.bb-fbt-title {
	margin: 0 0 12px;
	font-size: 1.05em;
	font-weight: 700;
}
.bb-fbt-title:has(+ .bb-fbt-deal) { margin-bottom: 2px; }
/* Why the prices are struck: "15% off when bought together". */
.bb-fbt-deal { margin: 0 0 12px !important; font-size: .875em; font-weight: 600; }

/* The pictures: what goes in together, at a glance. */
.bb-fbt-strip {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 6px;
	overflow: hidden;
}

.bb-fbt-thumb {
	flex: 0 0 auto;
	box-sizing: border-box;
	display: grid;
	place-items: center;
	width: 60px;
	height: 60px;
	padding: 4px;
	overflow: hidden;
	border-radius: 10px;
	background: var(--bb-fbt-soft);
	opacity: 0.45;
	transition: opacity 0.15s ease;
}

.bb-fbt-thumb.is-on {
	opacity: 1;
}

/* Themes size product images their own way (Astra: height auto); the tile keeps the picture whole and inside. */
.bb-fbt-thumb img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	object-fit: contain !important;
	border-radius: 6px;
	box-shadow: none !important;
}

.bb-fbt-plus {
	flex: 0 0 auto;
	font-size: 18px;
	line-height: 1;
	color: var(--bb-fbt-muted);
}

@media (prefers-reduced-motion: reduce) {
	.bb-fbt-thumb {
		transition: none;
	}
}

/* The rows. */
.bb-fbt-rows {
	margin: 0;
	padding: 0;
	list-style: none;
}

.bb-fbt .bb-fbt-row {
	display: grid;
	grid-template-columns: 28px minmax(0, 1fr) auto;
	align-items: center;
	column-gap: 10px;
	min-height: 48px;
	margin: 0;
	padding: 8px 0;
	border-top: 1px solid var(--bb-fbt-line);
}

.bb-fbt .bb-fbt-row:first-child {
	border-top: 0;
}

.bb-fbt-lead {
	display: flex;
	align-items: center;
	justify-content: center;
}

.bb-fbt-check {
	width: 20px;
	height: 20px;
	margin: 0;
	accent-color: currentColor;
	cursor: pointer;
}

.bb-fbt-main {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.bb-fbt .bb-fbt-name {
	margin: 0;
	font-weight: 600;
	font-size: 0.95em;
	cursor: pointer;
	overflow-wrap: anywhere;
}

.bb-fbt-row.is-this .bb-fbt-name {
	font-weight: 400;
	cursor: default;
}

/* A name that opens the item's page: the theme's link colour would shout in a
   list of products, so it reads as the name, underlined on hover and focus. */
.bb-fbt .bb-fbt-goto {
	color: inherit;
	text-decoration: none;
}

.bb-fbt .bb-fbt-goto:hover,
.bb-fbt .bb-fbt-goto:focus-visible {
	text-decoration: underline;
	text-underline-offset: 2px;
}

.bb-fbt-row.is-this .bb-fbt-name b {
	font-weight: 600;
}

.bb-fbt-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.45;
}

.bb-fbt-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 10px;
	font-size: 0.84em;
	color: var(--bb-fbt-muted);
}

.bb-fbt-rating {
	white-space: nowrap;
}

.bb-fbt .bb-fbt-price {
	font-size: 0.95em;
	font-weight: 600;
	text-align: right;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.bb-fbt-price del {
	margin-right: 4px;
	font-weight: 400;
	font-size: 0.9em;
	color: var(--bb-fbt-muted);
}

/* A row that is not ticked reads a little quieter than one that is. */
.bb-fbt-row[data-row]:not(.is-ticked) .bb-fbt-price {
	color: var(--bb-fbt-muted);
}

/* Colour or size, chosen in the row. */
.bb-fbt-opts {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.bb-fbt-opt {
	position: relative;
	margin: 0;
	cursor: pointer;
}

.bb-fbt-opt input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
}

.bb-fbt-opt span {
	display: inline-flex;
	align-items: center;
	min-height: 32px;
	padding: 0 12px;
	border: 1px solid var(--bb-fbt-line);
	border-radius: 999px;
	font-size: 0.95em;
	color: inherit;
	background: transparent;
}

.bb-fbt-opt input:checked + span {
	border-color: currentColor;
	box-shadow: inset 0 0 0 1px currentColor;
	font-weight: 600;
}

.bb-fbt-opt input:focus-visible + span {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.bb-fbt .bb-fbt-select {
	max-width: 100%;
	min-height: 34px;
	padding: 2px 8px;
	font-size: 0.95em;
}

/* Colour and size chosen apart, side by side; stacked when the row is narrow. */
.bb-fbt .bb-fbt-axes {
	flex: 1 1 100%;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	max-width: 100%;
}

.bb-fbt .bb-fbt-axes .bb-fbt-axis {
	width: auto;
	flex: 1 1 6.5em;
	min-width: 0;
	min-height: 34px;
	padding: 2px 8px;
	font-size: 0.95em;
}

@media (max-width: 600px) {
	.bb-fbt .bb-fbt-axis {
		min-height: 44px;
	}
}

.bb-fbt .bb-fbt-check:disabled {
	opacity: .45;
}

/* A product chosen on its own page: the whole row is the link. */
.bb-fbt .bb-fbt-row.is-link {
	display: block;
	padding: 0;
}

.bb-fbt .bb-fbt-link {
	display: grid;
	grid-template-columns: 28px minmax(0, 1fr) auto;
	align-items: center;
	column-gap: 10px;
	min-height: 48px;
	padding: 8px 0;
	color: inherit;
	text-decoration: none;
}

.bb-fbt-link:hover .bb-fbt-name,
.bb-fbt-link:focus-visible .bb-fbt-name {
	text-decoration: underline;
}

.bb-fbt-chev {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--bb-fbt-soft);
}

.bb-fbt-chev::before {
	content: "";
	width: 6px;
	height: 6px;
	margin-left: -2px;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
	transform: rotate(45deg);
}

.bb-fbt-cta {
	font-weight: 600;
	color: inherit;
}

.bb-fbt-price--from {
	font-weight: 400;
}

/* Already in the basket. */
.bb-fbt-in {
	display: inline-flex;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: #1a7f37;
}

.bb-fbt-in::before {
	content: "";
	width: 5px;
	height: 9px;
	margin: 3px 0 0 7px;
	border-right: 2px solid #fff;
	border-bottom: 2px solid #fff;
	transform: rotate(45deg);
}

.bb-fbt-row.is-in .bb-fbt-name {
	cursor: default;
}

/* What the block adds, said once. */
.bb-fbt-sum,
.bb-fbt-express,
.bb-fbt-note {
	margin: 8px 0 4px;
	font-size: 0.84em;
	color: var(--bb-fbt-muted);
}

.bb-fbt-sum {
	font-weight: 600;
	color: inherit;
}

/* The page's own button, counting what is ticked. */
.bb-fbt-more {
	font-variant-numeric: tabular-nums;
}

/* Express pay buys the product alone, so it stands down while anything is
   ticked (the block's note says so). */
body.bb-fbt-ticked #wcpay-payment-request-wrapper,
body.bb-fbt-ticked #wcpay-express-checkout-element,
body.bb-fbt-ticked .wcpay-express-checkout-wrapper,
body.bb-fbt-ticked #wcpay-payment-request-button-separator,
body.bb-fbt-ticked #wcpay-woopay-button,
body.bb-fbt-ticked #wc-stripe-payment-request-wrapper,
body.bb-fbt-ticked #wc-stripe-express-checkout-element,
body.bb-fbt-ticked #wc-stripe-payment-request-button-separator,
body.bb-fbt-ticked .ppc-button-wrapper,
body.bb-fbt-ticked #ppc-button-ppcp-gateway,
body.bb-fbt-ticked #ppc-button-applepay-container,
body.bb-fbt-ticked #ppc-button-googlepay-container,
body.bb-fbt-ticked #wc-square-digital-wallet {
	display: none !important;
}

/* On its own (a page sold through a grid) and as a box under the product's
   form: a button of its own. */
.bb-fbt--alone .bb-fbt-add,
.bb-fbt--box .bb-fbt-add {
	width: 100%;
	margin: 8px 0 6px;
}

/* Working: a turning ring beside the words until the add answers. Done: a
   tick before "In your cart", until something new is ticked. */
.bb-fbt--box .bb-fbt-add.is-busy {
	cursor: progress;
}

.bb-fbt--box .bb-fbt-add.is-busy::after {
	content: "";
	display: inline-block;
	width: 1em;
	height: 1em;
	margin-left: 8px;
	vertical-align: -0.15em;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
}

.bb-fbt--box .bb-fbt-add.is-done::before {
	content: "\2713";
	margin-right: 6px;
}

@media (prefers-reduced-motion: no-preference) {
	.bb-fbt--box .bb-fbt-add.is-busy::after {
		animation: bb-fbt-spin 0.8s linear infinite;
	}
}

/* The box sits under the product's own button: clear of it. */
.bb-fbt--box {
	margin-top: 16px;
}

/* A bundle's tray is narrow: smaller pictures, same rows. */
.bb-fbt--bundle {
	padding: 14px 14px 8px;
}

.bb-fbt--bundle .bb-fbt-thumb {
	width: 44px;
	height: 44px;
}

@media (max-width: 480px) {
	.bb-fbt {
		padding: 14px 14px 8px;
	}

	.bb-fbt-thumb {
		width: 48px;
		height: 48px;
	}
}

/* An extra with more choices than its row holds: Choose options, and after
   the window, what was chosen with Change. */
.bb-fbt-chosen {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 10px;
}

.bb-fbt .bb-fbt-choose {
	display: inline-flex;
	align-items: center;
	min-height: 32px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.9em;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
}

.bb-fbt .bb-fbt-choose.is-change {
	min-height: 0;
	padding: 0;
	border: 0;
	font-weight: 400;
	text-decoration: underline;
}

.bb-fbt .bb-fbt-choose:focus-visible,
.bb-fbt-dlg button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.bb-fbt-said {
	font-size: 0.9em;
}

/* Options it can go without: a quiet Add options under the row's own choices
   (never a second Choose options pill: nothing here must be answered), and
   once added, what was added with Change. */
.bb-fbt-more {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px 10px;
}

.bb-fbt-more .bb-fbt-said[hidden] {
	display: none;
}

.bb-fbt .bb-fbt-addopts {
	display: inline-flex;
	align-items: center;
	min-height: 24px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.9em;
	line-height: 1.3;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

.bb-fbt .bb-fbt-addopts:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Its colour and size were chosen in the window with its options: the row's
   own controls step aside, and Change opens them all again. */
.bb-fbt-row.is-opted .bb-fbt-opts,
.bb-fbt-row.is-opted .bb-fbt-axes,
.bb-fbt-row.is-opted .bb-fbt-select {
	display: none;
}

/* The window: the browser's own modal dialog, the page dimmed behind it. */
html.bb-fbt-locked {
	overflow: hidden;
}

/* Opened with showModal(), so in the browser's top layer, above everything on
   the page whatever its z-index. Where a browser lacks it (Safari before
   15.4), the window is fixed above chat launchers (Tidio: 999999999). */
.bb-fbt-dlg[open] {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
}

.bb-fbt-dlg {
	--bb-fbt-line: rgba(0, 0, 0, 0.12);
	--bb-fbt-muted: rgba(0, 0, 0, 0.6);
	box-sizing: border-box;
	width: min(520px, calc(100vw - 32px));
	max-height: min(640px, calc(100vh - 32px));
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 14px;
	background: #fff;
	color: #1d1c1a;
	font-size: 15px;
	line-height: 1.4;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
	overflow: hidden;
}

.bb-fbt-dlg::backdrop {
	background: rgba(0, 0, 0, 0.45);
}

.bb-fbt-dlg-in {
	display: flex;
	flex-direction: column;
	max-height: inherit;
}

.bb-fbt-dlg-head {
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr) 44px;
	gap: 12px;
	align-items: center;
	padding: 14px 16px;
	border-bottom: 1px solid var(--bb-fbt-line);
}

.bb-fbt-dlg-img {
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.04);
}

.bb-fbt-dlg-name {
	margin: 0;
	font-weight: 700;
	/* The one place a gift's long name is shown whole (its card keeps two
	   lines): three lines at most, so a name never pushes the choices down. */
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
}

.bb-fbt-dlg-with {
	margin: 2px 0 0;
	font-size: 0.85em;
	color: var(--bb-fbt-muted);
}

.bb-fbt-dlg .bb-fbt-dlg-x {
	width: 44px; /* a thumb's tap, phone or not */
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}

.bb-fbt-dlg-body {
	position: relative;
	padding: 16px;
	overflow: auto;
	overscroll-behavior: contain;
}

.bb-fbt-dlg-qs {
	display: grid;
	gap: 16px;
}

/* An extra that asks its own questions: the window holds its own page. */
.bb-fbt-dlg.is-frame {
	width: min(640px, calc(100vw - 32px));
	height: min(760px, calc(100vh - 32px));
}

.bb-fbt-dlg.is-frame .bb-fbt-dlg-in {
	height: 100%;
}

.bb-fbt-dlg.is-frame .bb-fbt-dlg-body {
	flex: 1 1 auto;
	min-height: 0;
	padding: 0;
	overflow: hidden;
}

.bb-fbt-dlg.is-frame .bb-fbt-dlg-qs,
.bb-fbt-dlg:not(.is-frame) .bb-fbt-dlg-frame,
.bb-fbt-dlg-frame[hidden] {
	display: none;
}

.bb-fbt-dlg-frame {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Once its page says how tall it is, the window fits it (two selects left
   most of a 760px window empty); a taller page scrolls inside, up to the most. */
.bb-fbt-dlg.is-frame.is-sized {
	height: fit-content; /* a modal dialog stretches to its most at auto */
	max-height: min(760px, calc(100vh - 32px));
}

.bb-fbt-dlg.is-frame.is-sized .bb-fbt-dlg-body {
	overflow: auto;
}

.bb-fbt-dlg.is-frame.is-sized .bb-fbt-dlg-frame {
	height: var(--bb-fbt-frame-h, 100%);
}

.bb-fbt-dlg.is-loading .bb-fbt-dlg-frame {
	visibility: hidden;
}

.bb-fbt-dlg.is-loading .bb-fbt-dlg-body::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 28px;
	height: 28px;
	margin: -14px 0 0 -14px;
	border: 3px solid var(--bb-fbt-line);
	border-top-color: #1d1c1a;
	border-radius: 50%;
}

.bb-fbt-dlg .bb-fbt-dlg-add[aria-busy="true"] {
	cursor: progress;
}

.bb-fbt-dlg-qt {
	margin: 0 0 8px;
	font-size: 0.78em;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--bb-fbt-muted);
}

.bb-fbt-dlg-qt b {
	margin-left: 6px;
	font-size: 1.15em;
	letter-spacing: 0;
	text-transform: none;
	color: #1d1c1a;
}

.bb-fbt-dlg-vs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.bb-fbt-dlg .bb-fbt-dlg-v {
	min-height: 44px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid var(--bb-fbt-line);
	border-radius: 999px;
	background: #fff;
	color: #1d1c1a;
	font: inherit;
	font-size: 0.95em;
	cursor: pointer;
}

.bb-fbt-dlg .bb-fbt-dlg-v.is-on {
	border: 2px solid #1d1c1a;
	padding: 0 13px;
	font-weight: 700;
}

/* A choice that does not go with what is picked: still pressable (it lets
   go of the clash), but quiet. */
.bb-fbt-dlg .bb-fbt-dlg-v.is-off {
	color: rgba(0, 0, 0, 0.4);
	border-style: dashed;
}

.bb-fbt-dlg-foot {
	display: grid;
	gap: 8px;
	padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--bb-fbt-line);
}

.bb-fbt-dlg-price {
	margin: 0;
	text-align: right;
}

.bb-fbt-dlg-price:empty {
	display: none;
}

.bb-fbt-dlg-price del {
	color: var(--bb-fbt-muted);
}

.bb-fbt-dlg .bb-fbt-dlg-add {
	width: 100%;
	margin: 0;
	min-height: 44px; /* a theme that styles no .button (a block theme) left it a bare 20px browser button */
	cursor: pointer;
}

.bb-fbt-dlg .bb-fbt-dlg-add:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.bb-fbt-dlg-need {
	margin: 0;
	min-height: 1em;
	font-size: 0.85em;
	text-align: center;
	color: var(--bb-fbt-muted);
}

/* A pick that let go of another says which: "Navy isn't available in Adult". */
.bb-fbt-dlg-need.is-clash {
	color: #b42318;
	font-weight: 600;
}

/* Opened from a tap the window holds the focus itself, with no ring; an
   option focused without a keyboard wears no theme ring either, so nothing
   reads as chosen that was not. */
.bb-fbt-dlg:focus {
	outline: none;
}

.bb-fbt-dlg .bb-fbt-dlg-v:focus:not(:focus-visible) {
	outline: none;
	box-shadow: none;
}

/* A phone: a sheet from the bottom, the page's top still showing. */
@media (max-width: 600px) {
	.bb-fbt-dlg {
		width: 100vw;
		max-width: 100vw;
		max-height: calc(100vh - 48px);
		margin: auto 0 0;
		border-radius: 16px 16px 0 0;
	}

	.bb-fbt-dlg.is-frame {
		width: 100vw;
		height: calc(100vh - 48px);
	}

	.bb-fbt-dlg.is-frame.is-sized {
		height: fit-content;
		max-height: calc(100vh - 48px);
	}
}

@media (prefers-reduced-motion: no-preference) {
	.bb-fbt-dlg[open] {
		animation: bb-fbt-dlg-in 0.18s ease-out;
	}

	.bb-fbt-dlg.is-loading .bb-fbt-dlg-body::after {
		animation: bb-fbt-spin 0.8s linear infinite;
	}

	@keyframes bb-fbt-spin {
		to {
			transform: rotate(360deg);
		}
	}

	@keyframes bb-fbt-dlg-in {
		from {
			opacity: 0;
			transform: translateY(12px);
		}
	}
}
