/*
 * Test Academy — v2 card price/hours strip.
 *
 * Scoped to the real markup rendered by the MasterStudy/STM course loop on
 * test.academy (ul.stm-courses > li.product > .product__inner > a.woocommerce-
 * loop-product__link > { title, .price, .course-duration }) — NOT vanilla
 * WooCommerce ul.products markup.
 *
 * unid-customizations/unid-ms/ms-elementor/category-product-template.php
 * already forces conflicting !important rules on .price / .price ins bdi /
 * .price del bdi / .course-duration — every rule here that touches those
 * properties needs an equal-or-stronger !important to actually win.
 *
 * Sizing note: the desktop card is genuinely narrow — measured ~280px
 * (stm-courses container ~1210px / 4 columns), not the ~430px the original
 * TA_expected.png mockup assumed. The base (>1024px) rules below are sized
 * for that real width; mobile (<600px) cards are ~377px, close enough to
 * the mockup that its original proportions already look right there.
 */

:root {
	--unid-cc-ta-accent: #18d78f;
	--unid-cc-ta-accent-dark: #0fbe7b;
	--unid-cc-ta-ink: #1c2c4e;
	--unid-cc-ta-muted: #6d7078;
	--unid-cc-ta-separator: #d9dde1;
	--unid-cc-ta-price-bg-top: #f7fcfa;
	--unid-cc-ta-price-bg-bottom: #eef9f4;
	--unid-cc-ta-price-border: #dcefe6;
}

/* Push the price panel to the bottom of the card regardless of title length. */
.stm-courses li.product .product__inner {
	display: flex;
	flex-direction: column;
}

.stm-courses li.product .product__inner .woocommerce-loop-product__link {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
}

/*
 * The shared file hardcodes `.product__inner img { width: 280px !important }`,
 * a fixed px value that only matches the card's actual rendered width by
 * coincidence at some viewport widths — at others (e.g. the 1-card-per-row
 * mobile layout, where product__inner stretches to the full column width)
 * it leaves a visible blank strip beside the image. Override to fill
 * whatever width the card actually has; height/object-fit stay as the
 * shared file set them.
 */
.stm-courses li.product .product__inner img {
	width: 100% !important;
}

/* The theme already draws its own divider under the title; our new price
 * panel adds a second, cleaner one right above itself — keeping both would
 * double up, so hide the title's. */
.stm-courses li.product .woocommerce-loop-product__title::after {
	display: none !important;
}

.stm-courses li.product .price {
	position: relative;
	display: grid !important;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-rows: auto auto;
	column-gap: 16px;
	row-gap: 6px;
	align-items: center;

	box-sizing: border-box;
	width: 100%;
	float: none !important;
	margin: auto 0 0 !important;
	padding: 14px 20px 16px !important;

	background: linear-gradient(
		180deg,
		var(--unid-cc-ta-price-bg-top) 0%,
		var(--unid-cc-ta-price-bg-bottom) 100%
	);
	border-top: 1px solid var(--unid-cc-ta-price-border);

	font-style: normal;
}

/* Separator: grey line with a centered brand-green segment, just above the panel. */
.stm-courses li.product .price::before {
	content: "";
	position: absolute;
	right: 20px;
	left: 20px;
	top: -14px;
	height: 1px;
	background: var(--unid-cc-ta-separator);
}

.stm-courses li.product .price::after {
	content: "";
	position: absolute;
	top: -15px;
	left: 50%;
	width: 57px;
	height: 2px;
	transform: translateX(-50%);
	background: var(--unid-cc-ta-accent);
	border-radius: 1px;
}

/* Original (crossed-out) price — top-left. */
.stm-courses li.product .price del {
	grid-column: 1;
	grid-row: 1;
	justify-self: start;
	align-self: end;
	margin: 0 !important;

	color: var(--unid-cc-ta-muted);
	font-size: 15px !important;
	font-weight: 500;
	line-height: 1.15;
	text-decoration-thickness: 1.5px;
}

.stm-courses li.product .price del .amount,
.stm-courses li.product .price del bdi {
	color: inherit !important;
	font-size: inherit !important;
	font-weight: inherit !important;
}

/* Discounted price — large, brand green, bottom-left. */
.stm-courses li.product .price ins {
	grid-column: 1;
	grid-row: 2;
	justify-self: start;
	align-self: start;
	margin: 0 !important;

	color: var(--unid-cc-ta-accent);
	font-size: clamp(22px, 2.5vw, 28px) !important;
	font-weight: 800;
	line-height: .95 !important;
	letter-spacing: -0.025em;
	text-decoration: none;
}

.stm-courses li.product .price ins .amount,
.stm-courses li.product .price ins bdi {
	color: inherit !important;
	font-size: inherit !important;
	font-weight: inherit !important;
}

/* Discount badge — top-right. */
.stm-courses li.product .price .unid-cc-ta-discount-badge {
	grid-column: 2;
	grid-row: 1;
	justify-self: end;
	align-self: center;

	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 30px;
	padding: 6px 11px;

	background: rgba(255, 255, 255, .72);
	border: 1.5px solid var(--unid-cc-ta-accent);
	border-radius: 7px;

	color: var(--unid-cc-ta-accent-dark);
	font-size: 12px;
	font-weight: 750;
	line-height: 1;
	white-space: nowrap;
}

.stm-courses li.product:hover .unid-cc-ta-discount-badge {
	background: #fff;
	border-color: var(--unid-cc-ta-accent-dark);
	color: var(--unid-cc-ta-accent-dark);
}

/* Course hours — bottom-right, replaces the theme's own .course-duration node. */
.stm-courses li.product .price .unid-cc-ta-course-hours {
	grid-column: 2;
	grid-row: 2;
	justify-self: end;
	align-self: center;

	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding-right: 4px;

	color: var(--unid-cc-ta-ink);
	font-size: 16px;
	font-weight: normal;
	line-height: 1;
	white-space: nowrap;
}

.stm-courses li.product .price .unid-cc-ta-course-hours__text {
	font-size: 16px !important;
	font-weight: normal !important;
}

.stm-courses li.product .price .unid-cc-ta-course-hours__clock {
	position: relative;
	display: inline-block;
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
	border: 1.5px solid var(--unid-cc-ta-ink);
	border-radius: 50%;
}

.stm-courses li.product .price .unid-cc-ta-course-hours__clock::before,
.stm-courses li.product .price .unid-cc-ta-course-hours__clock::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 1.5px;
	background: var(--unid-cc-ta-ink);
	border-radius: 1px;
	transform-origin: 50% 100%;
}

.stm-courses li.product .price .unid-cc-ta-course-hours__clock::before {
	height: 4px;
	transform: translate(-50%, -100%);
}

.stm-courses li.product .price .unid-cc-ta-course-hours__clock::after {
	height: 3.5px;
	transform: translate(-50%, -100%) rotate(125deg);
}

/* The theme's own duration node is superseded by .unid-cc-ta-course-hours above. */
.stm-courses li.product .course-duration {
	display: none !important;
}

/* Course grid — Bootstrap's .col-xs-6 (50% width, no media guard) puts two
 * cards per row below 768px; the card's own min-width makes them overlap.
 * Force one card per row until .col-sm-4 takes over at 768px. */
@media (max-width: 767px) {
	.course-col.col-xs-6 {
		width: 100% !important;
	}
}

/* Tablet — card is still narrow here (same column-count territory as
 * desktop), so this only trims spacing a bit further; font sizes stay at
 * the base (already sized for the real ~280px card, not the wider mockup). */
@media (max-width: 1024px) {
	.stm-courses li.product .price {
		column-gap: 14px;
		padding-right: 16px !important;
		padding-left: 16px !important;
	}

	.stm-courses li.product .price::before {
		right: 16px;
		left: 16px;
	}

	.stm-courses li.product .price .unid-cc-ta-discount-badge {
		padding-right: 9px;
		padding-left: 9px;
	}
}

/* Mobile. */
@media (max-width: 600px) {
	.stm-courses li.product .price {
		grid-template-columns: minmax(0, 1fr) auto;
		column-gap: 12px;
		row-gap: 8px;
		padding: 20px 18px 21px !important;
	}

	.stm-courses li.product .price::before {
		right: 18px;
		left: 18px;
		top: -19px;
	}

	.stm-courses li.product .price::after {
		top: -20px;
		width: 70px;
	}

	.stm-courses li.product .price ins,
	.stm-courses li.product .price ins .amount,
	.stm-courses li.product .price ins bdi {
		font-size: clamp(30px, 9vw, 38px) !important;
	}

	.stm-courses li.product .price del {
		font-size: 15px !important;
	}

	.stm-courses li.product .price .unid-cc-ta-course-hours {
		gap: 7px;
		font-size: 14px;
	}

	.stm-courses li.product .price .unid-cc-ta-course-hours__clock {
		width: 19px;
		height: 19px;
	}

	.stm-courses li.product .price .unid-cc-ta-discount-badge {
		min-height: 39px;
		padding: 8px 11px;
		border-radius: 8px;
		font-size: 13px;
	}
}
