/* Photo swatches (includes/swatches.php + assets/swatches.js).
   Colours come from brand.css. Loaded after shop.css, so these win over its text-button rules. */

/* ---------------------------------------------------------------- product page
   Shop Kit's colour buttons, each filled with its colour's photo. The class hj-sw-photo is added
   by swatches.js only when every colour has a photo. Shop Kit paints its buttons with !important
   backgrounds, so these selectors are deliberately long. */
.woocommerce div.product.hj-pdp form.cart .qav-swatches.hj-sw-ready { gap: 10px; }
.woocommerce div.product.hj-pdp form.cart .qav-swatches .qav-swatch.hj-sw-photo {
	position: relative;
	display: block;
	width: 84px;
	height: 105px;         /* 4:5, the same shape as the product photos */
	min-width: 0;
	padding: 0;
	overflow: hidden;
	background: var(--hj-mist) !important;
	border: 1px solid var(--hj-line-2);
	border-radius: 0;
	box-shadow: none;
	font-size: 0 !important;
	line-height: 0;
}
.woocommerce div.product.hj-pdp form.cart .qav-swatches .qav-swatch.hj-sw-photo img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
	pointer-events: none;  /* the click lands on the button, not the picture */
}
.woocommerce div.product.hj-pdp form.cart .qav-swatches .qav-swatch.hj-sw-photo:hover:not(.is-disabled):not(.is-active) {
	border-color: var(--hj-accent-deep);
}
/* Chosen: a gold frame twice as thick as the others (border + ring) */
.woocommerce div.product.hj-pdp form.cart .qav-swatches .qav-swatch.hj-sw-photo.is-active {
	background: var(--hj-mist) !important;
	border-color: var(--hj-accent-deep);
	box-shadow: 0 0 0 1px var(--hj-accent-deep);
}
.woocommerce div.product.hj-pdp form.cart .qav-swatches .qav-swatch.hj-sw-photo:focus-visible {
	outline: 2px solid var(--hj-accent-deep);
	outline-offset: 3px;
}
/* Sold out: faded, with a thin diagonal line across the photo */
.woocommerce div.product.hj-pdp form.cart .qav-swatches .qav-swatch.hj-sw-photo.is-disabled {
	opacity: .45;
	text-decoration: none;
}
.woocommerce div.product.hj-pdp form.cart .qav-swatches .qav-swatch.hj-sw-photo.is-disabled::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(to top right, transparent calc(50% - .5px), var(--hj-ink-2) calc(50% - .5px), var(--hj-ink-2) calc(50% + .5px), transparent calc(50% + .5px));
}
/* The colour name stays in the page for screen readers */
.hj-sw-photo .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
/* The label ("Colour") sits left of the photos, level with the first line of photos, and gets room so it never touches them. */
.woocommerce div.product.hj-pdp form.cart .variations tr:has(.hj-sw-ready) th { padding-right: 18px; vertical-align: top; padding-top: 6px; }
@media (max-width: 767px) {
	/* Phone: every label goes above its value, so the photos can use the full width, four per line
	   (4 x 76 + 3 x 8 = 328 of 343px). The table, its body and its rows turn into plain blocks;
	   otherwise a table row shrinks to its narrowest photo and the photos stack in one column. */
	.woocommerce div.product.hj-pdp form.cart table.variations:has(.hj-sw-ready),
	.woocommerce div.product.hj-pdp form.cart table.variations:has(.hj-sw-ready) tbody,
	.woocommerce div.product.hj-pdp form.cart table.variations:has(.hj-sw-ready) tr {
		display: block;
		width: 100%;
	}
	.woocommerce div.product.hj-pdp form.cart table.variations:has(.hj-sw-ready) th,
	.woocommerce div.product.hj-pdp form.cart table.variations:has(.hj-sw-ready) td {
		display: block;
		width: 100%;
		padding: 0;
	}
	.woocommerce div.product.hj-pdp form.cart table.variations:has(.hj-sw-ready) th { padding-bottom: 8px; }
	.woocommerce div.product.hj-pdp form.cart table.variations:has(.hj-sw-ready) tr + tr { margin-top: 14px; }
	.woocommerce div.product.hj-pdp form.cart .qav-swatches.hj-sw-ready { gap: 8px; }
	.woocommerce div.product.hj-pdp form.cart .qav-swatches .qav-swatch.hj-sw-photo { width: 76px; height: 95px; }
}

/* ---------------------------------------------------------------- product cards
   A row of small round pictures between the photo and the product name. */
.woocommerce ul.products li.product .hj-sw-card,
ul.products li.product .hj-sw-card {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 6px;
	/* The card is a flex column (16px gap) and the photo link has a 12px bottom margin, so a plain
	   margin would leave about 28px above and below the row. Pull it to about 12px under the photo
	   and 10px above the name. */
	margin: -16px 0 -6px;
}
/* The name's own top margin would add to that, so the row owns the space above it */
.woocommerce ul.products li.product .hj-sw-card + a.woocommerce-LoopProduct-link .woocommerce-loop-product__title {
	margin-top: 0 !important;
}
.woocommerce ul.products li.product .hj-sw-card .hj-sw-opt,
ul.products li.product .hj-sw-card .hj-sw-opt {
	position: relative;
	box-sizing: border-box;
	width: 34px;
	height: 34px;
	min-width: 0;
	margin: 0;
	padding: 2px;
	background: transparent;
	border: 1.5px solid transparent;
	border-radius: 50%;
	box-shadow: none;
	color: var(--hj-ink);
	font-size: 0;
	line-height: 0;
	cursor: pointer;
	transition: border-color .12s ease-out;
}
.woocommerce ul.products li.product .hj-sw-card .hj-sw-opt img,
ul.products li.product .hj-sw-card .hj-sw-opt img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	border-radius: 50%;
	object-fit: cover;
	pointer-events: none;
}
.woocommerce ul.products li.product .hj-sw-card .hj-sw-opt:hover,
.woocommerce ul.products li.product .hj-sw-card .hj-sw-opt:focus {
	background: transparent;
	border-color: var(--hj-accent-soft);
	box-shadow: none;
}
.woocommerce ul.products li.product .hj-sw-card .hj-sw-opt[aria-pressed="true"] {
	background: transparent;
	border-color: var(--hj-accent-deep);
}
.woocommerce ul.products li.product .hj-sw-card .hj-sw-opt:focus-visible {
	outline: 2px solid var(--hj-accent-deep);
	outline-offset: 2px;
}
/* Sold out: faded with a diagonal line */
.woocommerce ul.products li.product .hj-sw-card .hj-sw-opt.is-out img { opacity: .4; }
.woocommerce ul.products li.product .hj-sw-card .hj-sw-opt.is-out::after {
	content: "";
	position: absolute;
	inset: 4px;
	border-radius: 50%;
	background: linear-gradient(to top right, transparent calc(50% - .5px), var(--hj-ink-2) calc(50% - .5px), var(--hj-ink-2) calc(50% + .5px), transparent calc(50% + .5px));
}
.woocommerce ul.products li.product .hj-sw-card .hj-sw-more,
ul.products li.product .hj-sw-card .hj-sw-more {
	display: inline-flex;
	align-items: center;
	min-height: 34px;
	padding: 0 4px;
	color: var(--hj-muted);
	font-size: 12.5px;
	font-variant-numeric: tabular-nums;
	text-decoration: none;
}
.woocommerce ul.products li.product .hj-sw-card .hj-sw-more:hover { color: var(--hj-accent-deep); }
/* Four pictures and the "+N" must stay on one line in a two-column phone grid (about 166px wide) */
@media (max-width: 480px) {
	.woocommerce ul.products li.product .hj-sw-card { gap: 3px; }
	.woocommerce ul.products li.product .hj-sw-card .hj-sw-opt { width: 30px; height: 30px; }
	.woocommerce ul.products li.product .hj-sw-card .hj-sw-more { min-height: 30px; padding: 0 3px; }
}
