/* Better Homes: custom product option fields (Advanced Product Fields Pro) styled to match the site.
 *
 * - Text swatches: the same blocks as the variation buttons (assets/css/variation-buttons.css).
 * - Text swatches with image (e.g. Bed Base): the same blocks, then a clean preview image of the
 *   chosen option with its name underneath.
 * - Image swatches (e.g. Fabrics): image tiles with the name underneath.
 * Scoped to .wapf-field-group, so nothing else on the site is affected. */

/* ---------- Field labels ---------- */
.wapf-field-group .wapf-field-label label {
	font-weight: 600;
}

/* ---------- Text swatches (also the buttons of "text swatch with image") ---------- */
.wapf-field-group .wapf-swatch-wrapper:not(.wapf-image-swatch-wrapper) {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.wapf-field-group .wapf-swatch--text {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin: 0;
	padding: 8px 14px;
	border: 1px solid #e3e3e3;
	border-radius: var(--btn-brd-radius, 4px);
	background: #fff;
	color: #242424;
	font-family: "Poppins", Arial, Helvetica, sans-serif;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.2;
	text-align: center;
	text-transform: capitalize;
	transition: border-color .15s ease, box-shadow .15s ease;
}

@media (hover: hover) {
	.wapf-field-group .wapf-swatch--text:hover:not(.wapf-checked) {
		border-color: #9a9a9a;
	}
}

.wapf-field-group .wapf-swatch--text.wapf-checked {
	border-color: var(--wd-primary-color, #2d1042);
	box-shadow: inset 0 0 0 1px var(--wd-primary-color, #2d1042);
	background: #fff;
	color: #242424;
	font-weight: 600;
}

.wapf-field-group .wapf-swatch .wapf-pricing-hint {
	margin-inline-start: 4px;
	font-size: .85em;
	font-weight: 400;
	opacity: .7;
}

/* ---------- Text swatch with image: preview of the chosen option, name below ---------- */
.wapf-field-group .wapf-selected-swatch-preview {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	width: 240px;
	max-width: 100%;
	margin-top: 14px;
}

.wapf-field-group .wapf-selected-swatch-preview[hidden],
.wapf-field-group .wapf-selected-swatch-image[hidden] {
	display: none !important;
}

.wapf-field-group .wapf-selected-swatch-image {
	order: 1;
	box-sizing: border-box;
	width: 100%;
	padding: 6px;
	border: 1px solid #e3e3e3;
	border-radius: var(--btn-brd-radius, 4px);
	background: #fff;
}

.wapf-field-group .wapf-selected-swatch-image img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: 3px;
}

.wapf-field-group .wapf-selected-swatch-heading {
	order: 2;
	width: 100%;
	margin: 0;
	color: #555;
	font-size: 14px;
	line-height: 1.4;
	text-align: center;
}

.wapf-field-group .wapf-selected-swatch-value {
	color: #242424;
	font-weight: 600;
}

/* ---------- Image swatches: image tile, name below ---------- */
/* 5 per row, 3 on phones (overrides the per-field "items per row" setting). */
.wapf-field-group .wapf-image-swatch-wrapper {
	grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
	gap: 10px;
}

@media (max-width: 768px) {
	.wapf-field-group .wapf-image-swatch-wrapper {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
	}
}

.wapf-field-group .wapf-swatch--image {
	position: relative;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	padding: 4px;
	border: 1px solid #e3e3e3;
	border-radius: var(--btn-brd-radius, 4px);
	background: #fff;
	transition: border-color .15s ease, box-shadow .15s ease;
}

@media (hover: hover) {
	.wapf-field-group .wapf-swatch--image:hover:not(.wapf-checked) {
		border-color: #9a9a9a;
	}
}

.wapf-field-group .wapf-swatch--image.wapf-checked {
	border-color: var(--wd-primary-color, #2d1042);
	box-shadow: inset 0 0 0 1px var(--wd-primary-color, #2d1042);
}

.wapf-field-group .wapf-swatch--image img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: 3px;
}

.wapf-field-group .wapf-swatch--image .wapf-swatch-label {
	padding: 6px 2px 2px;
	color: #242424;
	font-family: "Poppins", Arial, Helvetica, sans-serif;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.3;
	text-align: center;
	text-transform: capitalize;
}

.wapf-field-group .wapf-swatch--image.wapf-checked .wapf-swatch-label {
	font-weight: 600;
}

/* Eye button (top right of each image swatch) -> opens the image large. */
.wapf-field-group .bh-swatch-zoom {
	position: absolute;
	top: 5px;
	right: 5px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	color: #f2f2f2;
	/* Soft shadow on the icon itself so it stays visible on light fabrics. */
	filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, .55));
	cursor: zoom-in;
	transition: color .15s ease, transform .15s ease;
}

.wapf-field-group .bh-swatch-zoom svg {
	width: 14px;
	height: 14px;
}

.wapf-field-group .bh-swatch-zoom:hover {
	background: transparent;
	color: #fff;
	transform: scale(1.12);
}

.wapf-field-group .bh-swatch-zoom:focus-visible {
	outline: 2px solid var(--wd-primary-color, #2d1042);
	outline-offset: 2px;
}

/* ---------- Option price labels: "£0" / "+ £50" ---------- */
.wapf-field-group .bh-opt-price {
	margin-inline-start: 6px;
	color: #6b6b6b;
	font-size: .85em;
	font-weight: 400;
	white-space: nowrap;
}

.wapf-field-group .wapf-swatch-label .bh-opt-price {
	display: block;
	margin: 2px 0 0;
}

/* ---------- Price under the options (replaces the plugin's "Total Price" line) ---------- */
.wapf-product-totals.bh-has-price-total .wapf--inner {
	display: none !important;
}

.wapf-product-totals.bh-has-price-total {
	display: block !important;
	text-align: start;
}

.wapf-product-totals .bh-price-total {
	display: flex;
	justify-content: flex-start;
	width: 100%;
	margin: 18px 0 6px;
	text-align: start;
}

/* ---------- Large image viewer ---------- */
html.bh-lightbox-open {
	overflow: hidden;
}

.bh-lightbox {
	position: fixed;
	inset: 0;
	z-index: 2147483000; /* above the sticky header and every theme layer */
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.bh-lightbox[hidden] {
	display: none;
}

.bh-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .78);
	cursor: zoom-out;
}

.bh-lightbox__figure {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: min(92vw, 720px);
	margin: 0;
}

.bh-lightbox__img {
	display: block;
	max-width: 100%;
	max-height: 76vh;
	width: auto;
	height: auto;
	border-radius: 4px;
	background: #fff;
	object-fit: contain;
}

.bh-lightbox__caption {
	margin-top: 12px;
	color: #fff;
	font-family: "Poppins", Arial, Helvetica, sans-serif;
	font-size: 17px;
	font-weight: 500;
	text-align: center;
	text-transform: capitalize;
}

.bh-lightbox__close {
	position: absolute;
	top: -14px;
	right: -14px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	min-height: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
	color: #222;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}

@media (max-width: 576px) {
	.bh-lightbox__close {
		top: -44px;
		right: 0;
	}
}

/* ---------- Phones ---------- */
@media (max-width: 576px) {
	.wapf-field-group .wapf-swatch-wrapper:not(.wapf-image-swatch-wrapper) {
		gap: 6px;
	}

	.wapf-field-group .wapf-swatch--text {
		flex: 1 1 calc(50% - 6px); /* two per row, like the variation blocks */
		padding: 8px 10px;
		font-size: 14px;
	}

	.wapf-field-group .wapf-swatch--image .wapf-swatch-label {
		font-size: 12px;
	}
}
