/**
 * JSD Compact Deal Card
 *
 * The high-density tile. Same black-and-white system as the full card, with the
 * proportions rebalanced for four-up scanning: full-bleed media, the badge
 * overlaid rather than given its own row, the discount reduced to a single
 * number, and no CTA button — the whole tile is the link.
 *
 * Width-agnostic, so the grid decides how many fit.
 */

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

	--jsd-compact-ratio: 1 / 1;
	--jsd-compact-title-lines: 2;

	position: relative;
	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-compact *,
.jsd-deal-card-compact *::before,
.jsd-deal-card-compact *::after {
	box-sizing: border-box;
}

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

/*
 * The whole tile is one target, so the focus ring belongs on the tile rather
 * than on the title text inside it.
 */
.jsd-deal-card-compact:focus-within {
	border-color: var(--jsd-black);
	outline: 2px solid var(--jsd-black);
	outline-offset: 2px;
}

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

/*
 * Full-bleed, unlike the full card's inset frame. At tile width the inset was
 * spending horizontal space the product image needs.
 */
.jsd-deal-card-compact__media {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: var(--jsd-compact-ratio);
	padding: 14px;
	background: var(--jsd-off-white);
	border-bottom: 1px solid var(--jsd-hairline);
	overflow: hidden;
}

.jsd-deal-card-compact__media img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

/*
 * The frame is left exactly as it would be for a real product image — same
 * ratio, same ground — so authorised photography drops in later with no
 * redesign. The shared JSD-owned component in media-fallback.css fills it.
 */
.jsd-deal-card-compact.has-no-image .jsd-deal-card-compact__media {
	box-shadow: inset 0 0 0 1px var(--jsd-hairline);
}

/* Badge, overlaid ---------------------------------------------------------- */

.jsd-deal-card-compact .jsd-deal-card-compact__badge {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	gap: 3px;
	max-width: calc(100% - 16px);
	padding: 3px 7px;
	background: var(--jsd-white);
	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: 9.5px;
	font-weight: 700;
	line-height: 1.5;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.jsd-deal-card-compact .jsd-deal-card-compact__badge-glyph {
	font-size: 10px;
	line-height: 1;
}

/*
 * Discount mark. One number instead of "Save $30 (38%)" — at four-up the
 * sentence wrapped, and the percentage is the part a scanning eye uses.
 */
.jsd-deal-card-compact .jsd-deal-card-compact__discount {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 1;
	padding: 3px 7px;
	background: var(--jsd-near-black);
	border-radius: 2px;
	color: var(--jsd-white);
	font-size: 11px;
	font-weight: 800;
	line-height: 1.45;
	letter-spacing: 0.01em;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

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

.jsd-deal-card-compact__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	padding: 11px 12px 13px;
}

/*
 * The retailer name carries its store's accent, taken from the custom property
 * JSD_Core_Retailers prints on this element — never from a per-retailer class.
 * Weight goes up a step because the darker accents need it at 9.5px, and the
 * name is allowed to wrap rather than truncate so a two-word store never
 * becomes "Best…". Falls back to grey for an unmapped retailer.
 */
.jsd-deal-card-compact .jsd-deal-card-compact__retailer {
	display: flex;
	align-items: center;
	gap: 5px;
	margin: 0 0 5px;
	color: var(--jsd-retailer-label, var(--jsd-faint));
	font-size: 9.5px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: 0.09em;
	text-transform: uppercase;
}

.jsd-deal-card-compact .jsd-deal-card-compact__retailer-dot {
	width: 5px;
	height: 5px;
}

/*
 * Clamped with the space reserved, so a one-line title never pulls its price
 * out of line with the tile beside it.
 */
.jsd-deal-card-compact .jsd-deal-card-compact__title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--jsd-compact-title-lines);
	line-clamp: var(--jsd-compact-title-lines);
	overflow: hidden;
	min-height: calc(var(--jsd-compact-title-lines) * 1.35em);
	margin: 0 0 8px;
	color: var(--jsd-near-black);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.35;
	letter-spacing: -0.005em;
	overflow-wrap: anywhere;
}

.jsd-deal-card-compact .jsd-deal-card-compact__link {
	color: inherit;
	text-decoration: none;
}

/* The stretched target: the tile is the link, the title carries its name. */
.jsd-deal-card-compact .jsd-deal-card-compact__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
}

.jsd-deal-card-compact .jsd-deal-card-compact__link:hover,
.jsd-deal-card-compact .jsd-deal-card-compact__link:focus-visible {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

/* The ring is drawn on the tile by :focus-within, so suppress the inner one. */
.jsd-deal-card-compact .jsd-deal-card-compact__link:focus {
	outline: none;
}

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

.jsd-deal-card-compact .jsd-deal-card-compact__pricing {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 0 7px;
	margin: auto 0 0;
}

.jsd-deal-card-compact .jsd-deal-card-compact__price {
	color: var(--jsd-black);
	font-size: 18px;
	font-weight: 800;
	line-height: 1.15;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
}

.jsd-deal-card-compact .jsd-deal-card-compact__was {
	color: var(--jsd-mid-gray);
	font-size: 12px;
	line-height: 1.4;
	font-variant-numeric: tabular-nums;
}

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

.jsd-deal-card-compact .jsd-deal-card-compact__unavailable {
	margin: 8px 0 0;
	color: var(--jsd-mid-gray);
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* Editorial variant -------------------------------------------------------- */

/*
 * Same component, three settings changed: a wider frame, a third title line and
 * more room around everything. Used where a row of three is making a
 * recommendation rather than listing inventory.
 */
.jsd-deal-card-compact--editorial {
	--jsd-compact-ratio: 4 / 3;
	--jsd-compact-title-lines: 3;
}

.jsd-deal-card-compact--editorial .jsd-deal-card-compact__media {
	padding: 20px;
}

.jsd-deal-card-compact--editorial .jsd-deal-card-compact__body {
	padding: 16px 18px 18px;
}

/*
 * The editorial title clamps at three lines but does not reserve them. The
 * price row is bottom-anchored and grid rows stretch to equal height, so the
 * price still lines up across the row without the reserve — and with it, a row
 * of short product names left two blank lines of dead space above every price.
 */
.jsd-deal-card-compact--editorial .jsd-deal-card-compact__title {
	min-height: 0;
	font-size: 15px;
	margin-bottom: 10px;
}

.jsd-deal-card-compact--editorial .jsd-deal-card-compact__price {
	font-size: 21px;
}

.jsd-deal-card-compact--editorial .jsd-deal-card-compact__was {
	font-size: 12.5px;
}

.jsd-deal-card-compact--editorial .jsd-deal-card-compact__cta {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 12px 0 0;
	padding-top: 11px;
	border-top: 1px solid var(--jsd-hairline);
	color: var(--jsd-near-black);
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
}

.jsd-deal-card-compact--editorial .jsd-deal-card-compact__cta-arrow {
	transition: transform 0.15s ease;
}

.jsd-deal-card-compact--editorial:hover .jsd-deal-card-compact__cta-arrow,
.jsd-deal-card-compact--editorial:focus-within .jsd-deal-card-compact__cta-arrow {
	transform: translateX(3px);
}

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

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

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

.jsd-deal-card-compact.is-expired .jsd-deal-card-compact__price {
	color: var(--jsd-mid-gray);
	text-decoration: line-through;
	text-decoration-thickness: 1px;
}

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

@media (max-width: 1024px) {
	.jsd-deal-card-compact--editorial {
		--jsd-compact-title-lines: 2;
	}

	.jsd-deal-card-compact--editorial .jsd-deal-card-compact__media {
		padding: 16px;
	}
}

/*
 * Two columns still hold on a phone, but only with the type stepped down: at
 * 360px a tile is about 154px wide and an 18px price with a struck original
 * beside it would wrap.
 */
@media (max-width: 599px) {
	.jsd-deal-card-compact__media {
		padding: 10px;
	}

	.jsd-deal-card-compact__body {
		padding: 9px 10px 11px;
	}

	.jsd-deal-card-compact .jsd-deal-card-compact__title {
		font-size: 12.5px;
		margin-bottom: 6px;
	}

	.jsd-deal-card-compact .jsd-deal-card-compact__price {
		font-size: 16px;
	}

	.jsd-deal-card-compact .jsd-deal-card-compact__was {
		font-size: 11px;
	}

	.jsd-deal-card-compact .jsd-deal-card-compact__badge {
		top: 6px;
		left: 6px;
		font-size: 9px;
		padding: 2px 5px;
	}

	.jsd-deal-card-compact .jsd-deal-card-compact__discount {
		top: 6px;
		right: 6px;
		font-size: 10px;
		padding: 2px 5px;
	}

	.jsd-deal-card-compact--editorial .jsd-deal-card-compact__title {
		font-size: 13px;
	}

	.jsd-deal-card-compact--editorial .jsd-deal-card-compact__price {
		font-size: 18px;
	}

	.jsd-deal-card-compact--editorial .jsd-deal-card-compact__cta {
		margin-top: 10px;
		padding-top: 9px;
		font-size: 10px;
	}
}

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