/* ==========================================================================
   [stbhh_sticky_buy]: the bar fixed at the bottom of the screen on mobile.

   The bar is hidden by default (moved off-screen and visibility:hidden), so it
   cannot flash before the script runs. sticky-buy.js decides, from the
   shortcode's breakpoint, when it shows: the `stbhh-sb-hide` class is removed
   only on small screens, so no media query is needed here.
   ========================================================================== */

:where(.stbhh-sticky-buy) {
	--stbhh-sb-font: var(--stbhh-set-font-head, 'Space Grotesk', sans-serif);
	--stbhh-sb-body: var(--stbhh-set-font-body, 'DM Sans', sans-serif);
	--stbhh-sb-ink: var(--stbhh-set-ink, #40415E);
	--stbhh-sb-faint: var(--stbhh-set-ink45, #9A9BAD);
	--stbhh-sb-rose: var(--stbhh-set-bb-sale, var(--stbhh-set-save, #2FA97E));
	--stbhh-sb-line: rgba(64, 65, 94, .10);
}

.stbhh-sticky-buy {
	display: flex;
	align-items: center;
	gap: 12px;
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 60;
	padding: 12px 10px;
	background: var(--stbhh-set-bb-sb-bg, rgb(255 255 255 / 95%));
	border-top: 1px solid var(--stbhh-set-bb-sb-border, #ECECEF);
	/* Soft upward shadow (ink-tinted) so the bar floats above the page. */
	box-shadow: var(--stbhh-set-bb-sb-shadow, 0 -10px 30px -6px rgba(64, 65, 94, .18), 0 -2px 6px rgba(64, 65, 94, .1));
	transform: translateY(0);
	visibility: visible;
	transition: transform .25s ease, visibility 0s;
}

.stbhh-sticky-buy.stbhh-sb-hide {
	transform: translateY(130%);
	visibility: hidden;
	box-shadow: none;
	/* Stay visible while sliding out, then switch off. */
	transition: transform .25s ease, visibility 0s .25s;
}

/* Product thumbnail, left of the name and price. */
.stbhh-sticky-buy .stbhh-sb-thumb {
	flex-shrink: 0;
	width: var(--stbhh-set-bb-sb-thumb, 44px);
	height: var(--stbhh-set-bb-sb-thumb, 44px);
	border-radius: var(--stbhh-set-bb-sb-thumb-r, 10px);
	overflow: hidden;
}

.stbhh-sticky-buy .stbhh-sb-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	margin: 0;
	border-radius: 0;
}

.stbhh-sticky-buy .stbhh-sb-info {
	flex: 1;
	min-width: 0;
}

.stbhh-sticky-buy .stbhh-sb-name {
	margin-bottom: 4px;
	font-family: var(--stbhh-set-bb-sb-name-font, var(--stbhh-sb-font));
	font-weight: var(--stbhh-set-bb-sb-name-weight, 400);
	font-size: var(--stbhh-set-bb-sb-name-size, 14px);
	line-height: 1.3;
	color: var(--stbhh-set-bb-sb-name-color, var(--stbhh-sb-ink));
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.stbhh-sticky-buy .stbhh-sb-price {
	display: flex;
	align-items: baseline;
	gap: 8px;
	font-size: var(--stbhh-set-bb-sb-old, 13px);
	line-height: 1.3;
}

.stbhh-sticky-buy .stbhh-sb-now {
	font-family: var(--stbhh-set-bb-price-font, var(--stbhh-sb-font));
	font-weight: var(--stbhh-set-bb-price-weight, 700);
	font-size: var(--stbhh-set-bb-sb-price, 15px);
	color: var(--stbhh-set-bb-price-color, var(--stbhh-sb-ink));
}

/* On sale: the current price is highlighted; regular prices stay ink. */
.stbhh-sticky-buy .stbhh-sb-now.stbhh-sb-sale {
	color: var(--stbhh-sb-rose);
}

/* The old price is WooCommerce's plain markup (no raised decimals), so the line-through reads cleanly. */
.stbhh-sticky-buy .stbhh-sb-was {
	font-family: var(--stbhh-set-bb-old-font, var(--stbhh-sb-body));
	font-weight: var(--stbhh-set-bb-old-weight, 400);
	color: var(--stbhh-set-bb-old-color, var(--stbhh-sb-faint));
	text-decoration: line-through;
}

.stbhh-sticky-buy .stbhh-sb-was[hidden] {
	display: none;
}

/* The Add button keeps the Elementor kit's button style (like the main Add to basket); only its size is set here. */
/* The Add button is the Global button style (gradient, radius, font, weight, text colour), like the main Add to basket button. It starts
   with `body` and repeats each state, so the site kit's button rules never win. Only its size is its own. */
body .stbhh-sticky-buy .stbhh-sb-add,
body .stbhh-sticky-buy .stbhh-sb-add:is(:hover, :focus, :active) {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-sizing: border-box;
	min-height: 0;
	margin: 0;
	padding: 12px 16px;
	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-sb-font));
	font-size: var(--stbhh-set-bb-sb-btn, 14px);
	font-weight: var(--stbhh-set-btn-weight, 600);
	line-height: 1.2;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	color: var(--stbhh-set-btn-text, var(--stbhh-set-on-cta, #fff));
	white-space: nowrap;
	cursor: pointer;
	transition: filter .14s;
}

body .stbhh-sticky-buy .stbhh-sb-add:hover:not(:disabled) {
	filter: brightness(1.05);
}

body .stbhh-sticky-buy .stbhh-sb-add:focus-visible {
	outline: 2px solid var(--stbhh-sb-ink);
	outline-offset: 2px;
}

/* The bag before the label (a mask: it takes the text colour and survives a label change). */
.stbhh-sticky-buy .stbhh-sb-add::before {
	content: "";
	display: block;
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	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-sticky-buy .stbhh-sb-add:disabled {
	opacity: var(--stbhh-set-btn-disabled, 60%);
	cursor: not-allowed;
}

/* Mirrors the main button while it adds (the script copies its class): the same loading look, a spinner in the text colour. */
.stbhh-sticky-buy .stbhh-sb-add.stbhh-is-loading {
	opacity: .5;
	pointer-events: none;
	cursor: default;
}

.stbhh-sticky-buy .stbhh-sb-add.stbhh-is-loading::before {
	box-sizing: border-box;
	width: 14px;
	height: 14px;
	margin: 1px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	background: none;
	-webkit-mask: none;
	mask: none;
	opacity: .9;
	animation: stbhhSbSpin .7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.stbhh-sticky-buy .stbhh-sb-add.stbhh-is-loading::before {
		animation-duration: 1.6s;
	}

	.stbhh-sticky-buy,
	.stbhh-sticky-buy.stbhh-sb-hide {
		transition: none;
	}
}
