/**
 * JSD Deal Card
 *
 * Premium black-and-white card. The only colour in the component comes from
 * two controlled places: the semantic deal-type badge and the small retailer
 * identity dot. Everything else is white, black and neutral grey.
 *
 * The card is width-agnostic and fills its container, so grids and carousels
 * built later size it without needing to restyle it.
 */

.jsd-deal-card {
	--jsd-black: #000000;
	--jsd-near-black: #111111;
	--jsd-dark-gray: #333333;
	--jsd-mid-gray: #767676;
	--jsd-border: #e5e5e5;
	--jsd-hairline: #efefef;
	--jsd-light-bg: #f4f4f4;
	--jsd-off-white: #fafafa;
	--jsd-white: #ffffff;
	--jsd-faint: #a8a8a8;
	--jsd-fainter: #c4c4c4;

	/* One frame for every product image, whatever the source dimensions. */
	--jsd-media-ratio: 4 / 3;

	display: flex;
	flex-direction: column;
	height: 100%;
	box-sizing: border-box;
	background: var(--jsd-white);
	border: 1px solid var(--jsd-border);
	border-radius: 2px;
	transition: border-color 0.15s ease;
}

.jsd-deal-card *,
.jsd-deal-card *::before,
.jsd-deal-card *::after {
	box-sizing: border-box;
}

.jsd-deal-card:hover {
	border-color: var(--jsd-near-black);
}

/* Top row: badge + featured mark ---------------------------------------- */

.jsd-deal-card__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	min-height: 22px;
	padding: 12px 16px 0;
}

.jsd-deal-card .jsd-deal-card__badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 8px;
	border: 1px solid var(--jsd-badge-color, var(--jsd-near-black));
	border-radius: 2px;
	color: var(--jsd-badge-color, var(--jsd-near-black));
	font-size: 10px;
	font-weight: 700;
	line-height: 1.6;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	white-space: nowrap;
}

.jsd-deal-card .jsd-deal-card__badge-glyph {
	font-size: 11px;
	line-height: 1;
}

/*
 * Featured mark. Kept as a real, labelled indicator for _jsd_featured, but
 * deliberately quiet: the semantic Deal Type badge is the loudest thing in the
 * top row and this must not compete with it.
 */
.jsd-deal-card .jsd-deal-card__featured {
	margin-left: auto;
	color: var(--jsd-faint);
	font-size: 11px;
	line-height: 1;
}

/* Media ----------------------------------------------------------------- */

.jsd-deal-card__media {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: var(--jsd-media-ratio);
	margin: 10px 16px 0;
	padding: 12px 16px;
	background: var(--jsd-off-white);
	overflow: hidden;
}

.jsd-deal-card__media img,
.jsd-deal-card__image {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

/*
 * No-image fallback. The frame keeps the ratio, ground and inset it would have
 * for a real product image, so the day authorised photography arrives nothing
 * about this card changes — the fallback simply stops rendering. What fills it
 * is the shared JSD-owned component in media-fallback.css: no stock photo, no
 * illustration of the product, no retailer mark.
 */
.jsd-deal-card.has-no-image .jsd-deal-card__media {
	box-shadow: inset 0 0 0 1px var(--jsd-hairline);
}

/* Body ------------------------------------------------------------------ */

.jsd-deal-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	padding: 14px 16px 16px;
}

/*
 * Retailer line. Still identifiable at a glance, but stepped down a notch so
 * the title and price carry the card.
 */
.jsd-deal-card .jsd-deal-card__meta-line {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 3px 10px;
	margin: 0 0 5px;
	color: var(--jsd-faint);
	font-size: 10px;
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0.09em;
	text-transform: uppercase;
}

/*
 * The retailer name is the one piece of type on the card allowed a colour, and
 * it takes it from the custom property JSD_Core_Retailers prints on this
 * element — never from a per-retailer class. The category beside it keeps the
 * meta line's grey, so the accent identifies the store rather than tinting the
 * row. Falls back to the neutral grey when the retailer is unmapped.
 */
.jsd-deal-card .jsd-deal-card__retailer {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--jsd-retailer-label, var(--jsd-faint));
	font-weight: 700;
}

.jsd-deal-card .jsd-deal-card__retailer-dot {
	width: 6px;
	height: 6px;
}

.jsd-deal-card .jsd-deal-card__category::before {
	content: "";
	display: inline-block;
	width: 1px;
	height: 10px;
	margin-right: 10px;
	background: var(--jsd-border);
	vertical-align: -1px;
}

/*
 * Two-line cap with the space for both lines always reserved. A long title
 * truncates instead of stretching the card, and a one-line title does not pull
 * the price up out of alignment with its neighbours — so a grid row keeps a
 * single, consistent rhythm.
 */
.jsd-deal-card .jsd-deal-card__title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
	min-height: 2.7em;
	margin: 0 0 7px;
	color: var(--jsd-near-black);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
	letter-spacing: -0.005em;
	overflow-wrap: anywhere;
}

/* Pricing --------------------------------------------------------------- */

.jsd-deal-card__pricing {
	margin: 0 0 9px;
}

.jsd-deal-card .jsd-deal-card__price {
	margin: 0;
	color: var(--jsd-black);
	font-size: 22px;
	font-weight: 800;
	line-height: 1.15;
	letter-spacing: -0.02em;
}

.jsd-deal-card .jsd-deal-card__price-meta {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 0 6px;
	margin: 4px 0 0;
	color: var(--jsd-mid-gray);
	font-size: 12.5px;
	line-height: 1.45;
}

.jsd-deal-card .jsd-deal-card__was s {
	text-decoration-thickness: 1px;
}

.jsd-deal-card .jsd-deal-card__savings {
	color: var(--jsd-dark-gray);
	font-weight: 600;
}

.jsd-deal-card .jsd-deal-card__sep {
	color: #c9c9c9;
}

/* Note and timing -------------------------------------------------------- */

.jsd-deal-card .jsd-deal-card__note {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
	margin: 0 0 9px;
	padding-left: 9px;
	border-left: 2px solid var(--jsd-hairline);
	color: var(--jsd-dark-gray);
	font-size: 12.5px;
	line-height: 1.45;
}

/* Timing is the most tertiary line on the card — present, never competing. */
.jsd-deal-card .jsd-deal-card__expiry {
	margin: 0 0 10px;
	color: var(--jsd-fainter);
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}

/* CTA -------------------------------------------------------------------- */

.jsd-deal-card__actions {
	margin-top: auto;
	padding-top: 2px;
}

.jsd-deal-card .jsd-deal-card__cta {
	display: block;
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var(--jsd-black);
	border-radius: 2px;
	background: var(--jsd-black);
	color: var(--jsd-white);
	font-size: 11.5px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: 0.09em;
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	transition: background-color 0.15s ease, color 0.15s ease;
}

a.jsd-deal-card__cta:hover,
a.jsd-deal-card__cta:focus {
	background: var(--jsd-dark-gray);
	border-color: var(--jsd-dark-gray);
	color: var(--jsd-white);
}

a.jsd-deal-card__cta:focus-visible {
	outline: 2px solid var(--jsd-black);
	outline-offset: 2px;
}

.jsd-deal-card .jsd-deal-card__cta--disabled {
	background: var(--jsd-light-bg);
	border-color: var(--jsd-border);
	color: var(--jsd-mid-gray);
	cursor: default;
}

/* Non-active states ------------------------------------------------------ */

.jsd-deal-card.is-expired,
.jsd-deal-card.is-scheduled {
	background: var(--jsd-off-white);
}

.jsd-deal-card.is-expired .jsd-deal-card__media,
.jsd-deal-card.is-scheduled .jsd-deal-card__media {
	opacity: 0.55;
	filter: grayscale(0.5);
}

.jsd-deal-card.is-expired .jsd-deal-card__title,
.jsd-deal-card.is-scheduled .jsd-deal-card__title {
	color: var(--jsd-mid-gray);
}

.jsd-deal-card.is-expired .jsd-deal-card__price,
.jsd-deal-card.is-scheduled .jsd-deal-card__price {
	color: var(--jsd-mid-gray);
}

.jsd-deal-card.is-expired .jsd-deal-card__price {
	text-decoration: line-through;
	text-decoration-thickness: 1px;
}

/* Editor placeholder notice --------------------------------------------- */

.jsd-deal-card-notice {
	margin: 0;
	padding: 16px;
	border: 1px dashed var(--jsd-border, #e5e5e5);
	border-radius: 2px;
	background: #fafafa;
	color: #767676;
	font-size: 13px;
	text-align: center;
}

/* Responsive ------------------------------------------------------------- */

@media (max-width: 782px) {
	.jsd-deal-card__media {
		margin: 8px 12px 0;
		padding: 10px 12px;
	}

	.jsd-deal-card__top {
		padding: 11px 12px 0;
	}

	.jsd-deal-card__body {
		padding: 12px 12px 14px;
	}

	.jsd-deal-card .jsd-deal-card__title {
		font-size: 14.5px;
	}

	.jsd-deal-card .jsd-deal-card__price {
		font-size: 20px;
	}

	.jsd-deal-card .jsd-deal-card__cta {
		padding: 10px 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jsd-deal-card,
	.jsd-deal-card__cta {
		transition: none;
	}
}
