/* Tree-only enhancement. Keep original cards intact until JS validates the data. */
.jm-tree-variations[hidden] {
	display: none !important;
}

ul.products li.jm-tree-card-ready > .price,
ul.products li.jm-tree-card-ready > .ct-woo-card-actions {
	display: none !important;
}

ul.products li.product.jm-tree-card-ready {
	--jm-tree-ink: #174d38;
	--jm-tree-border: #dce4de;
	--jm-tree-inset: 14px;
	display: flex;
	flex-direction: column;
	align-self: start;
	gap: 8px;
	min-width: 0;
	box-sizing: border-box;
	padding: 0;
	border: 1px solid var(--jm-tree-border);
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 3px 16px rgb(23 77 56 / 4%);
	text-align: start;
}

ul.products li.product.jm-tree-card-ready > figure {
	margin: 0 !important; /* Blocksy otherwise adds a 25px gap below the image. */
	min-width: 0;
	border-radius: 13px 13px 0 0;
	overflow: hidden;
}

ul.products li.product.jm-tree-card-ready > figure .ct-media-container {
	aspect-ratio: 1 / 1;
	background: #f5f7f3;
}

/* Neutralise the live fixed-height crop for enhanced tree images only. */
ul.products li.product.jm-tree-card-ready > figure .ct-media-container img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover !important;
	object-position: center;
}

ul.products li.product.jm-tree-card-ready > .woocommerce-loop-product__title {
	margin: 0;
	padding: 0 var(--jm-tree-inset);
	font-size: 16px;
	line-height: 1.3;
	font-weight: 600;
	overflow-wrap: anywhere;
}

ul.products li.product.jm-tree-card-ready > .entry-meta {
	margin: 0;
	padding: 0 var(--jm-tree-inset) var(--jm-tree-inset);
	font-size: 11px;
	line-height: 1.4;
}

ul.products li.product .jm-tree-variations {
	display: flex;
	flex-direction: column;
	gap: 6px;
	width: 100%;
	min-width: 0;
	margin: 0;
	margin-block-start: 0;
	padding: 0 var(--jm-tree-inset, 14px);
	box-sizing: border-box;
}

.jm-tree-size-label {
	font-size: 12px;
	font-weight: 600;
	line-height: 1.4;
	color: #52665a;
}

.jm-tree-sizes {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
	min-width: 0;
}

ul.products li.product .jm-tree-size {
	position: relative;
	isolation: isolate;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 28px;
	max-width: 100%;
	margin: 0;
	padding: 3px 8px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--jm-tree-ink, #174d38);
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	line-height: 1.2;
	white-space: normal;
	overflow-wrap: anywhere;
	cursor: pointer;
	box-shadow: none;
}

/* Compact frames; desktop rows are tighter than the mobile touch layout. */
ul.products li.product .jm-tree-size::before {
	content: "";
	position: absolute;
	inset: 3px 6px;
	z-index: -1;
	border: 1px solid var(--jm-tree-border, #dce4de);
	border-radius: 5px;
	background: #fff;
	pointer-events: none;
}

@media (hover: hover) {
	ul.products li.product .jm-tree-size:not(:disabled):not([aria-pressed="true"]):hover::before {
		border-color: var(--jm-tree-ink, #174d38);
		background: #f1f6f2;
	}
}

ul.products li.product .jm-tree-size[aria-pressed="true"] {
	color: #fff;
}

ul.products li.product .jm-tree-size[aria-pressed="true"]::before {
	border-color: var(--jm-tree-ink, #174d38);
	background: var(--jm-tree-ink, #174d38);
	box-shadow: inset 0 0 0 1px var(--jm-tree-ink, #174d38);
}

ul.products li.product .jm-tree-size:disabled {
	color: #7d847f;
	text-decoration: line-through;
	cursor: not-allowed;
}

ul.products li.product .jm-tree-size:disabled::before {
	background: #f4f5f4;
}

ul.products li.product .jm-tree-size:focus-visible,
ul.products li.product .jm-tree-size-select:focus-visible,
ul.products li.product .jm-tree-add-to-cart:focus-visible {
	outline: 2px solid var(--jm-tree-ink, #174d38);
	outline-offset: 3px;
}

ul.products li.product .jm-tree-size-select {
	width: 100%;
	min-width: 0;
	min-height: 44px;
	margin: 0;
	padding: 8px 30px 8px 10px;
	border: 1px solid var(--jm-tree-border, #dce4de);
	border-radius: 8px;
	color: var(--jm-tree-ink, #174d38);
	font-family: inherit;
	font-size: 16px; /* Avoid automatic field zoom on iOS. */
	line-height: 1.4;
}

.jm-tree-price {
	min-height: 24px;
	font-variant-numeric: tabular-nums;
	line-height: 1.4;
	overflow-wrap: anywhere;
}

/* Override the existing live price snippet only inside this feature. */
ul.products li.product.jm-tree-card-ready .jm-tree-price.is-placeholder {
	font-size: 13px !important;
	font-weight: 400 !important;
	color: #52665a !important;
}

ul.products li.product.jm-tree-card-ready .jm-tree-price del,
ul.products li.product.jm-tree-card-ready .jm-tree-price del * {
	font-size: 13px !important;
	font-weight: 400 !important;
	color: #68756c !important;
}

ul.products li.product.jm-tree-card-ready .jm-tree-price ins {
	text-decoration: none;
	background: none;
}

ul.products li.product.jm-tree-card-ready .jm-tree-price > .price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 8px;
}

ul.products li.product .jm-tree-add-to-cart {
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 10px 12px;
	border-radius: 8px;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.35;
	white-space: normal;
	overflow-wrap: anywhere;
}

ul.products li.product .jm-tree-add-to-cart:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

/* Desktop only: equal title slots and aligned price/actions within each grid row. */
@media (min-width: 690px) {
	/* Equal rows only in all-enhanced tree grids; mixed product grids stay intact. */
	ul.products:has(> li.product.jm-tree-card-ready):not(:has(> li.product:not(.jm-tree-card-ready))) {
		grid-auto-rows: 1fr;
	}

	ul.products li.product.jm-tree-card-ready {
		align-self: stretch;
	}

	ul.products li.product.jm-tree-card-ready > figure {
		flex-shrink: 0;
	}

	ul.products li.product.jm-tree-card-ready > .woocommerce-loop-product__title {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		line-clamp: 3;
		min-block-size: 3.9em;
		max-block-size: 3.9em;
		flex-shrink: 0;
		overflow: hidden;
	}

	ul.products li.product.jm-tree-card-ready > .jm-tree-variations {
		flex: 1;
	}

	ul.products li.product.jm-tree-card-ready .jm-tree-price {
		min-height: 28px;
		margin-block-start: auto;
		flex-shrink: 0;
	}
}

/* Blocksy's mobile breakpoint: one horizontal card per row, trees only. */
@media (max-width: 689.98px) {
	ul.products li.product.jm-tree-card-ready {
		--jm-tree-inset: 10px;
		grid-column: 1 / -1;
		display: grid !important; /* Existing Customizer makes all product cards flex. */
		grid-template-columns: minmax(0, 35fr) minmax(0, 65fr);
		grid-template-rows: auto 1fr auto;
		grid-template-areas: "image title" "image controls" "image meta";
		gap: 4px 0;
	}

	ul.products li.product.jm-tree-card-ready > figure {
		grid-area: image;
		align-self: stretch;
		width: 100%;
		height: 100%;
		margin: 0;
		border-radius: 13px 0 0 13px;
		background: #f5f7f3;
	}

	ul.products li.product.jm-tree-card-ready > figure .ct-media-container {
		width: 100%;
		height: 100%;
		aspect-ratio: auto !important;
		padding: 0;
	}

	/* The live Customizer sets a 260px image height with !important. */
	ul.products li.product.jm-tree-card-ready > figure .ct-media-container img {
		width: 100% !important;
		height: 100% !important;
		object-fit: cover !important; /* Fill the portrait frame; crop the wide background. */
		object-position: center;
		border-radius: 0;
	}

	ul.products li.product.jm-tree-card-ready > .woocommerce-loop-product__title {
		grid-area: title;
		padding: var(--jm-tree-inset) var(--jm-tree-inset) 0;
		line-height: 1.25;
	}

	ul.products li.product.jm-tree-card-ready > .jm-tree-variations {
		grid-area: controls;
		align-self: start;
		min-width: 0;
		margin: 0;
		gap: 4px;
	}

	ul.products li.product.jm-tree-card-ready .jm-tree-sizes {
		gap: 0;
	}

	ul.products li.product.jm-tree-card-ready .jm-tree-size {
		min-height: 36px;
		padding-block: 7px;
	}

	ul.products li.product.jm-tree-card-ready .jm-tree-size::before {
		inset-block: 7px;
	}

	ul.products li.product.jm-tree-card-ready .jm-tree-add-to-cart {
		min-height: 32px;
		padding: 6px 10px;
	}

	ul.products li.product.jm-tree-card-ready > .entry-meta {
		grid-area: meta;
	}

	ul.products li.product.jm-tree-card-ready .jm-tree-price {
		min-height: 0;
		font-size: 16px;
		line-height: 1.3;
	}

}

@media (max-width: 359.98px) {
	ul.products li.product.jm-tree-card-ready {
		--jm-tree-inset: 10px;
	}
}
