/* Best Before theme · shared product-card hover/focus interactions (site-wide).
   Loaded everywhere the one card (template-parts/product/card.php) renders:
   category/shop/search grids, home rails, related products, quick-view
   suggestions, the Promotions [products] shortcode grid.

   .bb-card itself already gets a box-shadow + border-color hover transition
   from assets/css/main.css - this file only ADDS to that (lift, image zoom,
   title underline, button darken, Sale badge wiggle), never redefines it.

   Touch devices: :hover rules that would otherwise "stick" after a tap are
   gated behind @media (hover: hover). Keyboard focus gets the same state at
   every width via :focus-within, which is not hover-gated. */

.bb-card {
	position: relative; /* containing block for the wishlist heart below */
}
.bb-card__img {
	overflow: hidden; /* keeps the hover zoom inside the image's own box */
}

/* ---------- Gary: "Save to wishlist" heart on every card ----------
   Same [woosw] button/states/toast as the product page and quick view
   (assets/css/wishlist.css, assets/js/wishlist.js - not edited here, this only
   positions/sizes it for the card). One DOM position (next to the add-to-
   basket button, template-parts/product/card.php); CSS alone floats it into
   the image's top-right corner for grid/compact cards and leaves it inline
   for the list-row card. */
.bb-card:not(.bb-card--row) .bb-card__wish {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
}
.bb-card__wish .woosw-btn {
	width: 40px !important;
	height: 40px !important;
	min-width: 40px !important;
}
/* Reserve room on the right of the sale/saving + best-before badges so the
   heart never overlaps them when a product happens to carry both. */
.bb-card:has(.bb-card__wish) .bb-card__badges {
	right: 56px;
}
.bb-card--row .bb-card__action {
	display: flex;
	align-items: center;
	gap: 8px;
}
.bb-card--row .bb-card__action .bb-btn {
	flex: 1;
}
.bb-card--row .bb-card__wish {
	flex: none;
}
.bb-card__img img {
	transition: transform .25s var(--bb-ease), opacity .25s var(--bb-ease);
}
.bb-card__name a {
	transition: text-decoration-color .15s var(--bb-ease);
}
.bb-card__action .bb-btn--primary {
	transition: background-color .2s var(--bb-ease), color .2s var(--bb-ease), transform .15s var(--bb-ease);
}
.bb-badge--sale {
	transition: background-color .25s var(--bb-ease), color .25s var(--bb-ease);
	transform-origin: center;
}
/* WDR promo labels are free text from the rule ("ANY 4 FOR R99", or a long
   "buy 1 ... and get a free ..." sentence): one line, clipped with an
   ellipsis inside the badge row instead of overflowing a narrow card. */
.bb-card__badges .bb-badge--sale,
.bb-scout-item__badges .bb-badge--sale,
.bb-product__salebadge {
	display: inline-block;
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 22px;
}
/* Two-up phone grid: a touch tighter so typical labels ("ANY 4 FOR R99")
   fit beside the wishlist heart without clipping. */
@media (max-width: 479px) {
	.bb-card__badges .bb-badge--sale {
		padding: 0 5px;
		font-size: .6875rem;
	}
}

@media (hover: hover) {
	.bb-card:hover {
		transform: translateY(-2px);
	}
	.bb-card:hover .bb-card__img img {
		transform: scale(1.04);
		opacity: .85;
	}
	.bb-card:hover .bb-card__name a {
		text-decoration: underline;
		text-decoration-thickness: 2px;
	}
	.bb-card:hover .bb-card__action .bb-btn--primary {
		background: var(--bb-ink);
		color: var(--bb-yellow);
	}
	.bb-card:hover .bb-badge--sale {
		background: var(--bb-yellow);
		color: var(--bb-ink);
		animation: bb-card-badge-wiggle .4s var(--bb-ease);
	}
}

/* Keyboard focus (any device, any hover capability) gets the same state. */
.bb-card:focus-within {
	transform: translateY(-2px);
}
.bb-card:focus-within .bb-card__img img {
	transform: scale(1.04);
	opacity: .85;
}
.bb-card:focus-within .bb-card__name a {
	text-decoration: underline;
	text-decoration-thickness: 2px;
}
.bb-card:focus-within .bb-card__action .bb-btn--primary {
	background: var(--bb-ink);
	color: var(--bb-yellow);
}
.bb-card:focus-within .bb-badge--sale {
	background: var(--bb-yellow);
	color: var(--bb-ink);
}

/* ================= Reusable accessible CSS tooltip ================= */
/* Gary: `data-bbt-tip="Label text"` on any icon-only (or icon+text) control -
   grid/list view buttons, the wishlist heart wrapper, the sort button, the
   mobile Filters button. Shown on hover (desktop only - @media (hover: hover),
   never "stuck" on touch) and on keyboard focus (:focus-within covers the
   wishlist wrapper, which isn't itself focusable; :focus-visible covers plain
   buttons). This is a decoration only - every element still carries its own
   real aria-label/accessible name, never relies on the tooltip for that. */
[data-bbt-tip] {
	position: relative;
}
[data-bbt-tip]::after {
	content: attr(data-bbt-tip);
	position: absolute;
	bottom: calc(100% + 9px);
	left: 50%;
	z-index: 40;
	transform: translateX(-50%) translateY(4px);
	padding: 5px 10px;
	border-radius: var(--bb-r-small);
	background: var(--bb-ink);
	color: #fff;
	font-size: .75rem;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity .12s var(--bb-ease), transform .12s var(--bb-ease), visibility .12s;
}
@media (hover: hover) {
	[data-bbt-tip]:hover::after,
	[data-bbt-tip]:focus-visible::after,
	[data-bbt-tip]:focus-within::after {
		opacity: 1;
		visibility: visible;
		transform: translateX(-50%) translateY(0);
		transition-delay: .3s;
	}
}
/* Keyboard users on any device still get it (not hover-gated). */
[data-bbt-tip]:focus-visible::after,
[data-bbt-tip]:focus-within::after {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0);
	transition-delay: .3s;
}
@media (prefers-reduced-motion: reduce) {
	[data-bbt-tip]::after { transition: none; }
}

@keyframes bb-card-badge-wiggle {
	0% { transform: scale(1) rotate(0); }
	35% { transform: scale(1.08) rotate(-4deg); }
	65% { transform: scale(1.05) rotate(3deg); }
	100% { transform: scale(1.04) rotate(0); }
}

@media (prefers-reduced-motion: reduce) {
	.bb-card,
	.bb-card__img img,
	.bb-card__action .bb-btn--primary,
	.bb-badge--sale {
		transition: none;
	}
	.bb-card:hover,
	.bb-card:focus-within {
		transform: none;
	}
	.bb-card:hover .bb-card__img img,
	.bb-card:focus-within .bb-card__img img {
		transform: none;
		opacity: .85;
	}
	.bb-card:hover .bb-badge--sale,
	.bb-card:focus-within .bb-badge--sale {
		animation: none;
		transform: none;
	}
}

/* WDR promo tag on the product page gallery and quick view (same badge as
   the card, pinned top-left of the image like the -x% badge). */
.bb-product__salebadge {
	position: absolute;
	top: 18px;
	left: 18px;
	z-index: 2;
	max-width: calc(100% - 36px);
	height: 30px;
	padding: 0 10px;
	line-height: 30px;
	font-size: .875rem;
	pointer-events: none;
}
.bb-quickview__main .bb-product__salebadge {
	top: 12px;
	left: 12px;
	max-width: calc(100% - 24px);
}
@media (max-width: 767px) {
	.bb-product__salebadge { top: 14px; left: 14px; max-width: calc(100% - 28px); }
}

/* ================= Info tip ("i" button with a wrapping tooltip) =================
   QA 23 Nov 2026: postal code help on basket + checkout. Reuses [data-bbt-tip];
   the text is longer than a control label, so it wraps in a fixed-width bubble,
   right-anchored so it never overflows a 320px screen. Tap (:focus) shows it on
   touch devices too. The button's aria-label carries the same text. */
.bb-infotip {
	display: inline-grid;
	place-items: center;
	width: 32px;
	height: 32px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--bb-muted);
	cursor: help;
	vertical-align: middle;
}
.bb-infotip:hover, .bb-infotip:focus { color: var(--bb-ink); }
.bb-infotip svg { display: block; }
.bb-infotip[data-bbt-tip]::after {
	left: auto;
	right: -6px;
	width: min(260px, calc(100vw - 48px));
	white-space: normal;
	font-weight: 500;
	text-align: left;
	transform: translateY(4px);
}
.bb-infotip[data-bbt-tip]:focus::after,
.bb-infotip[data-bbt-tip]:focus-visible::after {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	transition-delay: 0s;
}
@media (hover: hover) {
	.bb-infotip[data-bbt-tip]:hover::after { transform: translateY(0); transition-delay: .15s; }
}
.bb-label-row { display: flex; align-items: center; gap: 2px; }
.bb-label-row .bb-label { margin-bottom: 0; }
/* Inside a floating-label checkout row: sits at the right end of the input. */
.form-row.bb-has-infotip { position: relative; }
.form-row.bb-has-infotip .woocommerce-input-wrapper { position: relative; display: block; }
.bb-infotip--field { position: absolute; top: 10px; right: 8px; }
.form-row.bb-has-infotip input.input-text { padding-right: 44px; }
.bb-field-error { display: block; margin-top: 6px; font-size: .8125rem; color: var(--bb-error); }
.bb-field-error[hidden] { display: none; }
