/* ==========================================================================
   Buy Box: [stbhh_variations], [stbhh_price] and [stbhh_add_to_cart]

   Buttons are real <button>s, so the site's Elementor kit styles them in every
   state (background, border, colours...). Their rules therefore start with
   `body` and re-declare each state, which outranks the kit's
   `.elementor-kit-N button:hover` rules by specificity, never by forcing priority.
   ========================================================================== */

:where(.stbhh-variations, .stbhh-pricebox, .stbhh-add-to-cart) {
	--stbhh-bb-font: var(--stbhh-set-font-head, 'Space Grotesk', sans-serif);
	--stbhh-bb-body: var(--stbhh-set-font-body, 'DM Sans', sans-serif);
	--stbhh-bb-ink: var(--stbhh-set-ink, #40415E);
	--stbhh-bb-muted: var(--stbhh-set-ink70, #6A6B84);
	--stbhh-bb-faint: var(--stbhh-set-ink45, #9A9BAD);
	--stbhh-bb-line: rgba(64, 65, 94, .10);
	--stbhh-bb-accent: #6C8AE4;
	--stbhh-bb-accent-deep: #506FCB;
	--stbhh-bb-rose: var(--stbhh-set-bb-tag-accent, #D65C8A);
	--stbhh-bb-coral: #FF8B79;
	--stbhh-bb-coral-deep: #F0705C;
	--stbhh-bb-mint-deep: var(--stbhh-set-save, #2FA97E);
}

/* ---------- Variation picker ---------- */

.stbhh-variations .stbhh-opt-label {
	font-family: var(--stbhh-set-bb-label-font, var(--stbhh-bb-body));
	font-size: var(--stbhh-set-bb-label-size, 12px);
	font-weight: var(--stbhh-set-bb-label-weight, 700);
	line-height: 1.3;
	letter-spacing: .03em;
	text-transform: uppercase;
	color: var(--stbhh-set-bb-label-color, var(--stbhh-bb-muted));
}

/* One row, always. The layout is decided in the browser by variations.js, from the
   cards' real content width (not the number of variations):
   - fit mode: every card fits at its natural width, so the cards share the row
     equally (2 give halves, 3 give thirds...);
   - slider mode (.stbhh-opts-scroll): they don't fit, so the row scrolls sideways
     with half of the next card peeking in and the selected card slid into view.
   The card width comes from --stbhh-opt-w, set by the script; thirds until it runs.
   overflow-x also clips vertically, so padding-top makes room for the badge
   (top: -10px) and the margin drops by the same amount; the 2px side padding
   (cancelled by the negative side margin) keeps the first and last card's border
   from being clipped by the scroll edge. */
.stbhh-opts {
	display: flex;
	gap: 10px;
	margin: 2px -2px 0;
	padding: 12px 2px 2px;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.stbhh-opts::-webkit-scrollbar {
	display: none;
}

.stbhh-opts > .stbhh-opt {
	flex: 0 0 var(--stbhh-opt-w, calc((100% - 20px) / 3));
	min-width: 0;
}

/* Measuring pass only (a few ms inside the script): the cards' natural width. */
.stbhh-opts.stbhh-opts-measure > .stbhh-opt {
	flex: 0 0 auto;
	width: max-content;
}

body .stbhh-opts .stbhh-opt {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	box-sizing: border-box;
	margin: 0;
	padding: 16px 15px 13px;
	border-style: solid;
	border-width: 1.5px;
	border-color: var(--stbhh-set-bb-card-border, #ECECEF);
	border-radius: var(--stbhh-set-bb-card-radius, 14px);
	background: var(--stbhh-set-bb-card-bg, #fff);
	font: inherit;
	text-align: center;
	cursor: pointer;
	transition: .14s;
}

body .stbhh-opts .stbhh-opt:hover {
	border-style: solid;
	border-color: var(--stbhh-set-bb-card-active, var(--stbhh-bb-accent));
	background: var(--stbhh-set-bb-card-bg, #fff);
}

body .stbhh-opts .stbhh-opt.stbhh-active,
body .stbhh-opts .stbhh-opt.stbhh-active:hover {
	border-style: solid;
	border-color: var(--stbhh-set-bb-card-active, var(--stbhh-bb-accent));
	background: var(--stbhh-set-bb-card-bg, #fff);
	box-shadow: inset 0 0 0 1px var(--stbhh-set-bb-card-active, var(--stbhh-bb-accent));
}

body .stbhh-opts .stbhh-opt:disabled {
	opacity: .4;
	cursor: not-allowed;
}

.stbhh-opts .stbhh-op-pages {
	font-family: var(--stbhh-set-bb-card-main-font, var(--stbhh-bb-font));
	font-weight: var(--stbhh-set-bb-card-main-weight, 700);
	font-size: var(--stbhh-set-bb-card-main-size, 16px);
	line-height: 1.3;
	color: var(--stbhh-set-bb-card-main-color, var(--stbhh-bb-ink));
}

.stbhh-opts .stbhh-op-dur {
	font-family: var(--stbhh-set-bb-card-dur-font, var(--stbhh-bb-body));
	font-weight: var(--stbhh-set-bb-card-dur-weight, 400);
	font-size: var(--stbhh-set-bb-card-dur-size, 12px);
	line-height: 1.3;
	color: var(--stbhh-set-bb-card-dur-color, var(--stbhh-bb-faint));
}

.stbhh-opts .stbhh-active .stbhh-op-dur {
	font-weight: 600;
	color: var(--stbhh-set-bb-card-dur-on, var(--stbhh-bb-accent-deep));
}

.stbhh-opts .stbhh-op-priceline {
	display: flex;
	align-items: baseline;
	gap: 7px;
	margin-top: 3px;
}

.stbhh-opts .stbhh-op-now {
	font-family: var(--stbhh-set-bb-price-font, var(--stbhh-bb-font));
	font-weight: var(--stbhh-set-bb-price-weight, 700);
	font-size: var(--stbhh-set-bb-card-price, 17px);
	line-height: 1;
	color: var(--stbhh-set-bb-price-color, var(--stbhh-bb-ink));
}

.stbhh-opts .stbhh-op-was {
	font-family: var(--stbhh-set-bb-old-font, var(--stbhh-bb-body));
	font-weight: var(--stbhh-set-bb-old-weight, 400);
	font-size: var(--stbhh-set-bb-card-old, 12px);
	line-height: 1;
	color: var(--stbhh-set-bb-old-color, var(--stbhh-bb-faint));
	text-decoration: line-through;
}

.stbhh-opts .stbhh-op-tag {
	position: absolute;
	top: -10px;
	left: 50%;
	padding: 3px 9px;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--stbhh-set-bb-tag-a, #E57AA1), var(--stbhh-set-bb-tag-mid, #D65C8A) 55%, var(--stbhh-set-bb-tag-b, #C24877));
	font-family: var(--stbhh-set-bb-tag-font, var(--stbhh-bb-font));
	font-weight: var(--stbhh-set-bb-tag-weight, 700);
	font-size: var(--stbhh-set-bb-tag-size, 12px);
	line-height: 1;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--stbhh-set-bb-tag-color, #fff);
	white-space: nowrap;
	transform: translateX(-50%);
}

/* The badged option uses the badge's rose, instead of the accent, for its hover and
   selected border, so the badge and the card read as one. */
body .stbhh-opts .stbhh-opt.stbhh-has-tag:hover {
	border-color: var(--stbhh-bb-rose);
}

body .stbhh-opts .stbhh-opt.stbhh-has-tag.stbhh-active,
body .stbhh-opts .stbhh-opt.stbhh-has-tag.stbhh-active:hover {
	border-color: var(--stbhh-bb-rose);
	background: var(--stbhh-set-bb-card-bg, #fff);
	box-shadow: inset 0 0 0 1px var(--stbhh-bb-rose);
}

.stbhh-opts .stbhh-has-tag.stbhh-active .stbhh-op-dur {
	color: var(--stbhh-bb-rose);
}

/* ---------- Picker, second level (two varying attributes) ----------
   The cards above are the first attribute (they control the price); under them,
   plain options for the second attribute, only the row of the chosen card showing. */

.stbhh-variations .stbhh-opts + .stbhh-opt-label {
	margin-top: 18px;
}

.stbhh-opts2 {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 8px 0 0;
}

.stbhh-opts2[hidden] {
	display: none;
}

body .stbhh-opts2 .stbhh-opt2,
body .stbhh-opts2 .stbhh-opt2:is(:hover, :focus, :active) {
	box-sizing: border-box;
	margin: 0;
	padding: 9px 18px;
	border-style: solid;
	border-width: 1.5px;
	border-color: var(--stbhh-set-bb-pill-border, #ECECEF);
	border-radius: 999px;
	background: var(--stbhh-set-bb-pill-bg, #fff);
	box-shadow: none;
	font-family: var(--stbhh-set-bb-pill-font, var(--stbhh-bb-font));
	font-weight: var(--stbhh-set-bb-pill-weight, 600);
	font-size: var(--stbhh-set-bb-pill-size, 14px);
	line-height: 1.2;
	letter-spacing: normal;
	text-transform: none;
	color: var(--stbhh-set-bb-pill-color, var(--stbhh-bb-ink));
	cursor: pointer;
	transition: .14s;
}

body .stbhh-opts2 .stbhh-opt2:hover {
	border-color: var(--stbhh-set-bb-pill-active, var(--stbhh-bb-accent));
}

body .stbhh-opts2 .stbhh-opt2.stbhh-active,
body .stbhh-opts2 .stbhh-opt2.stbhh-active:is(:hover, :focus, :active) {
	border-color: var(--stbhh-set-bb-pill-active, var(--stbhh-bb-accent));
	box-shadow: inset 0 0 0 1px var(--stbhh-set-bb-pill-active, var(--stbhh-bb-accent));
	color: var(--stbhh-set-bb-pill-active-text, var(--stbhh-bb-accent-deep));
}

body .stbhh-opts2 .stbhh-opt2:focus-visible {
	outline: 2px solid var(--stbhh-bb-accent);
	outline-offset: 2px;
}

/* The price difference of an option against its card ("+£2.00" or "−£3.00", only when it
   differs): plain text next to the option's name, in the normal weight, a little smaller. */
.stbhh-opts2 .stbhh-op2-diff {
	margin-left: 6px;
	font-family: var(--stbhh-set-bb-pill-diff-font, inherit);
	font-size: var(--stbhh-set-bb-pill-diff-size, 13px);
	font-weight: var(--stbhh-set-bb-pill-diff-weight, 400);
	color: var(--stbhh-set-bb-pill-diff-color, inherit);
}

body .stbhh-opts2 .stbhh-opt2:disabled {
	opacity: .4;
	cursor: not-allowed;
}

/* ---------- Price ---------- */

.stbhh-pricebox .stbhh-offer {
	position: relative;
	padding: 16px 18px 15px;
	border: 1px solid var(--stbhh-set-bb-offer-line, #FFDCD7);
	border-radius: var(--stbhh-set-bb-offer-radius, 18px);
	background: linear-gradient(135deg, var(--stbhh-set-bb-offer-a, #FFF1EC), var(--stbhh-set-bb-offer-mid, #FFF7F2) 55%, var(--stbhh-set-bb-offer-b, #FFFDFB));
}

.stbhh-pricebox .stbhh-offer-tag {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-family: var(--stbhh-set-bb-offer-tag-font, var(--stbhh-bb-font));
	font-weight: var(--stbhh-set-bb-offer-tag-weight, 700);
	font-size: var(--stbhh-set-bb-offer-tag-size, 12px);
	line-height: 1;
	letter-spacing: .09em;
	text-transform: uppercase;
	color: var(--stbhh-set-bb-offer-tag-color, var(--stbhh-bb-coral-deep));
}

.stbhh-pricebox .stbhh-pricing {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px 12px;
	margin: 5px 0;
}

.stbhh-pricebox .stbhh-price-now {
	font-family: var(--stbhh-set-bb-price-font, var(--stbhh-bb-font));
	font-weight: var(--stbhh-set-bb-price-weight, 700);
	font-size: var(--stbhh-set-bb-pb-price, 37px);
	line-height: 1;
	color: var(--stbhh-set-bb-price-color, var(--stbhh-bb-ink));
}

.stbhh-pricebox .stbhh-price-was {
	font-family: var(--stbhh-set-bb-old-font, var(--stbhh-bb-body));
	font-size: var(--stbhh-set-bb-pb-old, 16px);
	font-weight: var(--stbhh-set-bb-old-weight, 400);
	line-height: 1;
	color: var(--stbhh-set-bb-old-color, var(--stbhh-bb-faint));
	text-decoration: line-through;
}

.stbhh-pricebox .stbhh-save-badge {
	padding: 5px 11px;
	border-radius: 999px;
	background: var(--stbhh-set-bb-badge-bg, var(--stbhh-bb-coral));
	font: 700 var(--stbhh-set-bb-badge-size, 12px)/1 var(--stbhh-bb-font);
	letter-spacing: .02em;
	color: #fff;
}

.stbhh-pricebox .stbhh-save-line {
	display: flex;
	align-items: center;
	gap: 7px;
	margin: 0;
	font-family: var(--stbhh-set-bb-save-font, var(--stbhh-bb-body));
	font-size: var(--stbhh-set-bb-save-size, 13px);
	font-weight: var(--stbhh-set-bb-save-weight, 600);
	line-height: 1.4;
	color: var(--stbhh-set-bb-save-color, var(--stbhh-bb-mint-deep));
}

/* The bare price: no card. */
.stbhh-pricebox .stbhh-price-plain {
	padding-top: 18px;
	border-top: 1px solid var(--stbhh-bb-line);
	font-family: var(--stbhh-set-bb-price-font, var(--stbhh-bb-font));
	font-weight: var(--stbhh-set-bb-price-weight, 700);
	font-size: var(--stbhh-set-bb-pb-price, 37px);
	line-height: 1;
	color: var(--stbhh-set-bb-price-color, var(--stbhh-bb-ink));
}

/* ---------- Quantity + Add to basket ---------- */

.stbhh-add-to-cart .stbhh-buy-row {
	display: flex;
	gap: 15px;
}

.stbhh-add-to-cart .stbhh-qty {
	display: flex;
	align-items: center;
	border: 1.5px solid var(--stbhh-set-bb-qty-border, #ECECEF);
	border-radius: 999px;
	background: var(--stbhh-set-bb-qty-bg, #fff);
	overflow: hidden;
}

/* Author display rules would otherwise defeat the [hidden] attribute. */
.stbhh-add-to-cart .stbhh-qty[hidden],
.stbhh-add-to-cart .stbhh-cart-message[hidden] {
	display: none;
}

body .stbhh-add-to-cart .stbhh-qty-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: var(--stbhh-set-bb-qty-btn-bg, transparent);
	font-family: inherit;
	font-size: 18px;
	line-height: 1;
	color: var(--stbhh-set-bb-qty-btn, var(--stbhh-bb-ink));
	cursor: pointer;
	transition: background-color .14s, color .14s;
}

/* Each end button takes the container's pill radius on its outer corner only, so
   the two buttons and the number read as one seamless pill. */
body .stbhh-add-to-cart .stbhh-qty-btn:first-child {
	border-radius: 999px 0 0 999px;
}

body .stbhh-add-to-cart .stbhh-qty-btn:last-child {
	border-radius: 0 999px 999px 0;
}

/* Every state is explicit: the kit's Buttons style has its own (gradient) background
   for :hover, :focus and :active, which a real <button> would otherwise inherit. */
body .stbhh-add-to-cart .stbhh-qty-btn:focus:not(:disabled) {
	background: var(--stbhh-set-bb-qty-btn-bg, transparent);
}

body .stbhh-add-to-cart .stbhh-qty-btn:hover:not(:disabled),
body .stbhh-add-to-cart .stbhh-qty-btn:active:not(:disabled) {
	background: var(--stbhh-set-bb-qty-hover-bg, rgba(108, 138, 228, .10));
	color: var(--stbhh-set-bb-qty-hover, var(--stbhh-set-accent-deep, #506FCB));
}

/* A real disabled state: the script sets it at the minimum / maximum quantity. */
body .stbhh-add-to-cart .stbhh-qty-btn:disabled {
	background: var(--stbhh-set-bb-qty-btn-bg, transparent);
	color: var(--stbhh-set-bb-qty-btn, var(--stbhh-bb-ink));
	opacity: .35;
	cursor: not-allowed;
}

.stbhh-add-to-cart .stbhh-qty-val {
	min-width: 25px;
	font-family: var(--stbhh-set-bb-qty-num-font, var(--stbhh-bb-font));
	font-weight: var(--stbhh-set-bb-qty-num-weight, 700);
	font-size: var(--stbhh-set-bb-qty-num-size, 16px);
	text-align: center;
	color: var(--stbhh-set-bb-qty-num-color, var(--stbhh-bb-ink));
}

/* "Add to basket" has no background, colour, font or radius of its own: it takes the
   Elementor kit's Buttons style (via the wp-element-button class), like any other
   default button on the site. Only the layout need (fill the row) is set here. */
/* The button is the Global button style (the same gradient, radius, font and weight as the cart's), not the site kit's.
   Like the other buttons it starts with `body` and repeats each state, so the kit's button rules never win. */
body .stbhh-add-to-cart .stbhh-add-btn,
body .stbhh-add-to-cart .stbhh-add-btn:is(:hover, :focus, :active) {
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-sizing: border-box;
	min-height: 0;
	margin: 0;
	padding: 16px 24px;
	border: 0;
	border-radius: var(--stbhh-set-btn-radius, 999px);
	background: linear-gradient(135deg, var(--stbhh-set-cta-start, #6C8AE4) 0%, var(--stbhh-set-cta-mid, #7b83e8) 55%, var(--stbhh-set-cta-end, #9370e0) 100%);
	box-shadow: none;
	font-family: var(--stbhh-set-btn-font-bb, var(--stbhh-bb-font));
	font-size: var(--stbhh-set-btn-size-buy, 18px);
	font-weight: var(--stbhh-set-btn-weight, 600);
	line-height: 22px;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	color: var(--stbhh-set-btn-text, var(--stbhh-set-on-cta, #fff));
	cursor: pointer;
	transition: filter .14s;
}

body .stbhh-add-to-cart .stbhh-add-btn:hover:not(:disabled) {
	filter: brightness(1.05);
}

body .stbhh-add-to-cart .stbhh-add-btn:focus-visible {
	outline: 2px solid var(--stbhh-bb-ink);
	outline-offset: 2px;
}

body .stbhh-add-to-cart .stbhh-add-btn:disabled {
	opacity: var(--stbhh-set-btn-disabled, 60%);
	cursor: not-allowed;
}

/* While it adds (the script sets the class and keeps the label): the same look as the cart's, the mini cart's and the checkout's buttons.
   The button fades and takes no click, and a small spinner in the text colour takes the bag's place. */
body .stbhh-add-to-cart .stbhh-add-btn.stbhh-is-loading {
	opacity: .5;
	pointer-events: none;
	cursor: default;
}

body .stbhh-add-to-cart .stbhh-add-btn.stbhh-is-loading::before {
	display: block;
	box-sizing: border-box;
	width: 16px;
	height: 16px;
	margin: 1px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	background: none;
	-webkit-mask: none;
	mask: none;
	opacity: .9;
	animation: stbhhBbSpin .7s linear infinite;
}

@keyframes stbhhBbSpin {
	to {
		transform: rotate(360deg);
	}
}

/* The bag before the label: a mask, so it takes the text colour and survives the script changing the label while it adds. */
.stbhh-add-to-cart .stbhh-add-btn::before {
	content: "";
	display: block;
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8h14l-1 12H6L5 8Z'/%3E%3Cpath d='M9 8V6a3 3 0 0 1 6 0v2'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8h14l-1 12H6L5 8Z'/%3E%3Cpath d='M9 8V6a3 3 0 0 1 6 0v2'/%3E%3C/svg%3E") center / contain no-repeat;
}

.stbhh-add-to-cart .stbhh-cart-message {
	margin: 10px 0 0;
	font-size: var(--stbhh-set-err-text-size, 13px);
	line-height: 1.4;
	color: var(--stbhh-set-err-text-color, var(--stbhh-set-notice-err, #D23C4F));
}

/* ---------- Responsive ---------- */

@media (prefers-reduced-motion: reduce) {
	.stbhh-opts {
		scroll-behavior: auto;
	}

	body .stbhh-add-to-cart .stbhh-add-btn.stbhh-is-loading::before {
		animation-duration: 1.6s;
	}
}

@media (max-width: 600px) {
	.stbhh-pricebox .stbhh-price-now,
	.stbhh-pricebox .stbhh-price-plain {
		font-size: var(--stbhh-set-bb-pb-price-m, 26px);
	}

	/* An Elementor container that wraps its widgets in a row shrinks the price widget to its content, so the divider above a plain
	   price came out short and the button squeezed in beside it. The price gets its own full-width line, as it has on desktop. */
	.elementor-widget:has(> .elementor-shortcode > .stbhh-pricebox),
	.elementor-widget:has(> .elementor-widget-container > .elementor-shortcode > .stbhh-pricebox) {
		flex: 0 0 100%;
		width: 100%;
	}
}

@media (max-width: 400px) {
	body .stbhh-opts .stbhh-opt {
		padding: 13px 15px;
	}

	.stbhh-opts .stbhh-op-pages,
	.stbhh-opts .stbhh-op-now {
		font-size: var(--stbhh-set-bb-card-text-m, 14px);
	}
}
