/**
 * Attribute icons overlaid on the shop-grid product image.
 *
 * Flatsome prints `flatsome_product_box_tools_bottom` inside
 * `.image-tools.is-small.hide-for-small.bottom.left.show-on-hover`, which is
 * hover-only and hidden on small screens. We want the attribute icons always
 * visible, on every screen, so we override that specific container — scoped
 * with :has() so only the tools box that actually holds our icons is affected.
 */
.product-small.box .box-image{
	overflow: visible;
}
.box-image .image-tools.bottom.left:has(.bb-attr-icons) {
	/*
	 * Pin to the bottom-left corner explicitly. Flatsome ships `.left{left:0}`
	 * and `.top{top:0}` but NO bare `.bottom{bottom:0}`, so this container would
	 * otherwise sit at its static (top) position.
	 */
	position: absolute !important;
	top: auto !important;
	right: auto !important;
	bottom: -15px !important;
	left: 0 !important;
	z-index: 5;
	opacity: 1 !important;
	filter: none !important;
	transform: none !important;
	pointer-events: auto !important;
	padding: 0 0 0 12px !important;
}

@media (max-width: 549px) {
	/* Defeat Flatsome's .hide-for-small (display:none!important). */
	.box-image .image-tools.bottom.left:has(.bb-attr-icons) {
		display: block !important;
		padding: 0 0 8px 8px !important;
	}
}

.bb-attr-icons {
	display: flex;
	gap: 8px;
	align-items: center;
}

/*
 * Each icon is a rounded tile. Two modes:
 *  - No background colour set  → the uploaded image fills the tile (use this
 *    when the icon art already includes its own coloured background).
 *  - Background colour set (.has-bg + --bb-icon-bg) → the tile is that colour
 *    and a transparent glyph sits inset on top, matching the shop mockup.
 */
.bb-attr-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	/* Anchor for the tooltip pseudo-elements below. */
	position: relative;
	width: 46px;
	height: 46px;
	border-radius: 12px;
	border: 2px solid #ffffff;
}

/*
 * Neutralise Flatsome's `.box-image img` / `.image-cover img` /
 * `.has-equal-box-heights .box-image img` rule, which forces EVERY image in the
 * box (ours included) to position:absolute; inset:0; width/height:100%;
 * object-fit:cover — stretching our icons to cover the whole product image.
 * Flatsome sets those without !important, so !important here always wins.
 */
.box-image .bb-attr-icon img {
	display: block;
	position: static !important;
	top: auto !important;
	right: auto !important;
	bottom: auto !important;
	left: auto !important;
	margin: 0 !important;
	max-width: 100% !important;
	object-fit: contain !important;
	object-position: center center !important;
}

.box-image .bb-attr-icon:not(.has-bg) img {
	width: 100% !important;
	height: 100% !important;
	/* The tile can't clip (it needs overflow for the tooltip), so the image that
	   fills it carries the rounding itself: 12px tile radius minus the 2px border. */
	border-radius: 10px;
}

.bb-attr-icon.has-bg {
	background-color: var(--bb-icon-bg, transparent);
}

.box-image .bb-attr-icon.has-bg img {
	width: 60% !important;
	height: 60% !important;
}

@media (max-width: 549px) {
	.bb-attr-icon {
		width: 46px;
		height: 46px;
	}
}

/*
 * Tooltip with the attribute term name.
 *
 * Pure CSS, label read from `data-bb-tip` on the tile. Hover-capable pointers
 * only: on touch there is no hover state and a tap on the product image belongs
 * to the product link, so showing (and having to dismiss) a tooltip there would
 * only get in the way. Screen readers already announce the term name from the
 * icon image's alt text, so nothing is lost when the tooltip is not shown.
 *
 * The bubble is left-aligned to its tile rather than centred: the first icon
 * sits 12px from the column edge, so a centred bubble would hang off the left
 * of the product column.
 */
@media (hover: hover) {
	.bb-attr-icon[data-bb-tip]::before,
	.bb-attr-icon[data-bb-tip]::after {
		position: absolute;
		z-index: 10;
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.15s ease, visibility 0.15s ease;
		pointer-events: none;
	}

	/* Bubble. */
	.bb-attr-icon[data-bb-tip]::after {
		content: attr(data-bb-tip);
		bottom: calc(100% + 10px);
		left: -2px;
		width: max-content;
		max-width: 160px;
		padding: 6px 10px;
		border-radius: 8px;
		background-color: rgba(0, 0, 0, 0.85);
		color: #ffffff;
		font-size: 12px;
		font-weight: 500;
		line-height: 1.3;
		text-align: left;
		text-transform: none;
		white-space: normal;
	}

	/* Arrow — a rotated square, tucked under the bubble and centred on the tile. */
	.bb-attr-icon[data-bb-tip]::before {
		content: "";
		bottom: calc(100% + 6px);
		left: 21px;
		width: 8px;
		height: 8px;
		background-color: rgba(0, 0, 0, 0.85);
		transform: rotate(45deg);
	}

	.bb-attr-icon[data-bb-tip]:hover::before,
	.bb-attr-icon[data-bb-tip]:hover::after,
	.bb-attr-icon[data-bb-tip]:focus-visible::before,
	.bb-attr-icon[data-bb-tip]:focus-visible::after {
		opacity: 1;
		visibility: visible;
	}
}

/*
 * Filter-widget variant of the tile.
 *
 * Rendered by BB_Attribute_Icons::layered_nav_term_html() in front of the term
 * name in the "Filter products by attribute" widget. Smaller than the product
 * card tile, no white border (it doesn't sit on a photo), and no tooltip — the
 * term name is right next to it. Row layout (checkbox, spacing, chosen state)
 * belongs to the theme: flatsome-child/assets/css/bb-shop-filters.css.
 */
.bb-attr-icon--filter {
	width: 28px;
	height: 28px;
	flex: 0 0 auto;
	border: 0;
	border-radius: 8px;
	vertical-align: middle;
}

.bb-attr-icon--filter img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: contain;
	border-radius: 7px;
}

.bb-attr-icon--filter.has-bg img {
	width: 62%;
	height: 62%;
	border-radius: 0;
}
