/*
 * Ammani Variant Cards: layout only.
 * The card look (border, radio dot, checked state) comes from codaraby's form.css (.promotion-card).
 */

/* Cards show only once the JS is running. Without JS the normal WooCommerce selects stay usable. */
.ammani-vc-wrap {
	display: none;
	margin: 12px 0;
}

.ammani-vc-on .ammani-vc-wrap {
	display: block;
}

/*
 * The selects and their labels stay in the form (WooCommerce and the order form still read them). The cards replace them.
 * Extra selector weight: WooCommerce's own ".woocommerce table.variations { display: block }" would otherwise win.
 */
form.variations_form.ammani-vc-on .variations {
	display: none;
}

.ammani-vc {
	margin-bottom: 14px;
}

.ammani-vc-label {
	margin: 0 0 8px;
	font-weight: 600;
	text-align: start;
}

/* Cards need about 240px so the title can sit beside the 56px image. Two columns on wide screens, one on phones. Cards in a row are equal height. */
.ammani-vc-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 10px;
	align-items: stretch;
}

.ammani-vc .promotion-container {
	position: relative;
	margin-bottom: 0;
}

.ammani-vc-card {
	cursor: pointer;
	height: 100%;
	box-sizing: border-box;
	margin: 0;
}

/*
 * Image runs edge to edge: no padding on the image side (the card's outer side, after the radio), so the
 * image touches the top, bottom and outer edge. Text keeps its padding (.promotion-details below).
 * overflow clips the image to the rounded corners. The .ammani-vc prefix beats codaraby's .promotion-card padding.
 */
.ammani-vc .ammani-vc-card {
	padding: 0;
	padding-inline-start: 14px;
	overflow: hidden;
	align-items: stretch;
}

/* Keep the radio dot at its full 18px. Without this, the flex row squeezes it to a thin line. */
.ammani-vc-card::before {
	flex: 0 0 18px;
	align-self: center;
}

/* Text can wrap inside the card instead of pushing into the image. */
.ammani-vc-card .card-content,
.ammani-vc-card .promotion-details {
	min-width: 0;
}

/* The image column stretches to the full card height. The text stays centred with its own vertical padding. */
.ammani-vc-card .card-content {
	align-items: stretch;
}

.ammani-vc-card .promotion-details {
	align-self: center;
	padding: 12px 0;
}

.ammani-vc-card .promotion-title {
	overflow-wrap: anywhere;
}

/* Image column: 96px wide, full card height. The card's rounded corners clip it, so it needs no radius of its own. */
.ammani-vc-card .product-image {
	flex: 0 0 96px;
	width: 96px;
	height: auto;
	align-self: stretch;
	border-radius: 0;
	overflow: hidden;
	background: #f5f5f5;
}

.ammani-vc-card .product-image img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

/*
 * Keep the radio focusable and checkable but out of sight. codaraby's form.css sets
 * display:none on promotion radios, which would make them unreachable by keyboard.
 */
.ammani-vc .promotion-container input.ammani-vc-input[type="radio"] {
	display: inline-block;
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
}

.ammani-vc-input:focus-visible + .ammani-vc-card {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Out-of-stock or unavailable variants: visible but not selectable. */
.ammani-vc-card.is-disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.ammani-vc-oos {
	color: #b42318;
}

.ammani-vc-error {
	margin: 8px 0 0;
	color: #b42318;
	font-size: 14px;
}

.ammani-vc-error[hidden] {
	display: none;
}
