/*
 * Promo Deals front end.
 * Fonts, headings, links and prices come from your theme. Colours can be set in
 * the element/block/shortcode, or in your theme with these variables on .promo-deals:
 *   --pd-accent        buttons (defaults to the theme's primary colour)
 *   --pd-badge-bg      badge background      --pd-badge-color  badge text
 *   --pd-card-bg       card background       --pd-text         card text
 *   --pd-radius        card corners          --pd-image-height deal image height
 *   --pd-shadow        card shadow           --pd-max-width    panel width
 */
.promo-deals {
	--pd-accent: var(--fs-color-primary, var(--wp--preset--color--primary, #1e8bc3));
	--pd-badge-bg: #d0021b;
	--pd-badge-color: #fff;
	--pd-card-bg: #fff;
	--pd-text: inherit;
	--pd-muted: rgba(0, 0, 0, 0.55);
	--pd-line: rgba(0, 0, 0, 0.08);
	--pd-radius: 22px;
	--pd-shadow: 0 3px 14px rgba(0, 0, 0, 0.14);
	--pd-columns: 3;
	--pd-gap: clamp(14px, 2vw, 28px);
	--pd-image-height: 200px;
	--pd-min-card: 240px;
	box-sizing: border-box;
	width: 100%;
	max-width: var(--pd-max-width, none);
	margin-inline: auto;
	color: var(--pd-text);
}
.promo-deals *, .promo-deals *::before, .promo-deals *::after { box-sizing: border-box; }
.promo-deals__heading { margin: 0 0 0.75em; }

/* Grid: never more than --pd-columns, never narrower than --pd-min-card, so it scales with the column it sits in. */
.promo-deals__items {
	display: grid;
	gap: var(--pd-gap);
	grid-template-columns: repeat(auto-fill, minmax(max(var(--pd-min-card), calc((100% - (var(--pd-columns) - 1) * var(--pd-gap)) / var(--pd-columns))), 1fr));
	align-items: stretch;
}
.promo-deals--list .promo-deals__items { grid-template-columns: 1fr; }
.promo-deals--compact .promo-deals__items { --pd-min-card: 220px; }

/* Card */
.promo-deal {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	background: var(--pd-card-bg);
	border-radius: var(--pd-radius);
	box-shadow: var(--pd-shadow);
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.promo-deal:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); }
.promo-deal--upcoming { opacity: 0.85; }

.promo-deal__media {
	position: relative;
	height: var(--pd-image-height);
	padding: 0;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
}
.promo-deals .promo-deal__media img.promo-deal__image {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: contain;
	margin: 0;
}

/* Badge (also used in shop listings and on product pages) */
.promo-deal__badge {
	display: inline-block;
	background: var(--pd-badge-bg, #d0021b);
	color: var(--pd-badge-color, #fff);
	font-weight: 700;
	font-size: 13px;
	line-height: 1.2;
	letter-spacing: 0.01em;
	text-transform: none;
	white-space: nowrap;
	padding: 5px 10px;
	border-radius: 999px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.promo-deal__media .promo-deal__badge { position: absolute; top: 12px; left: 12px; z-index: 1; font-size: 14px; padding: 6px 12px; }
.promo-deal__badge--inline { margin: 16px 18px 0; align-self: flex-start; }

/* Body */
.promo-deal__body { display: flex; flex-direction: column; gap: 6px; padding: 14px 18px 18px; flex: 1; min-width: 0; }
.promo-deals .promo-deal__title { margin: 0; font-size: 1.1em; line-height: 1.3; }
.promo-deal__description { font-size: 0.92em; }
.promo-deal__description p { margin: 0 0 0.4em; }
.promo-deal__description p:last-child { margin-bottom: 0; }
.promo-deal__dates { margin: 0; font-size: 0.8em; color: var(--pd-muted); }
.promo-deal__pricing { margin: 2px 0 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.promo-deal__pricing del { opacity: 0.55; font-size: 0.9em; }
.promo-deal__price { text-decoration: none; font-weight: 700; font-size: 1.35em; }
.promo-deal__saving { color: var(--pd-badge-bg); font-weight: 700; font-size: 0.9em; }

/* Products inside a card */
.promo-deals .promo-deal__products { list-style: none; margin: 6px 0 0; padding: 0; }
.promo-deals .promo-deal__product {
	display: grid;
	grid-template-columns: 44px minmax(0, 1fr) auto;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 8px 0;
	border-top: 1px solid var(--pd-line);
	list-style: none;
}
.promo-deal__product-thumb { display: block; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: #fff; }
.promo-deals .promo-deal__product-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; margin: 0; }
.promo-deal__product-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.promo-deals .promo-deal__product-name {
	font-size: 0.88em;
	color: inherit;
	text-decoration: none;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.promo-deals .promo-deal__product-name:hover { text-decoration: underline; }
.promo-deals .promo-deal__product-price { display: block; margin: 2px 0 0; font-size: 1em; font-weight: 700; line-height: 1.2; }
.promo-deals .promo-deal__product-price del { font-size: 0.8em; font-weight: 400; }

/* Buttons use plugin classes (not the theme's .button) so theme button sizes can't distort them. */
.promo-deals .promo-deal__add,
.promo-deals .promo-deal__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin: 0;
	border: 2px solid var(--pd-accent);
	border-radius: 999px;
	font-family: inherit;
	font-weight: 700;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: normal;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, filter 0.15s ease;
}
.promo-deals .promo-deal__add {
	min-height: 32px;
	padding: 4px 14px;
	font-size: 0.8em;
	background: transparent;
	color: var(--pd-accent);
}
.promo-deals .promo-deal__add:hover,
.promo-deals .promo-deal__add:focus-visible { background: var(--pd-accent); color: #fff; }
.promo-deals .promo-deal__add.loading { opacity: 0.6; }
.promo-deals .promo-deal__add.added::after { content: "\2713"; }
/* WooCommerce inserts a "View cart" link after an AJAX add; hide it so rows don't jump (the mini-cart still updates). */
.promo-deals .promo-deal__product .added_to_cart { display: none !important; }

.promo-deal__actions { margin: auto 0 0; padding-top: 10px; }
.promo-deals .promo-deal__button {
	width: 100%;
	min-height: 44px;
	padding: 10px 18px;
	font-size: 0.95em;
	background: var(--pd-accent);
	color: #fff;
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}
.promo-deals .promo-deal__button:hover,
.promo-deals .promo-deal__button:focus-visible { filter: brightness(0.92); color: #fff; }

/* [- n +] basket quantity stepper */
.promo-deals .promo-deal__qty {
	display: inline-flex;
	align-items: center;
	height: 36px;
	border: 2px solid var(--pd-accent);
	border-radius: 999px;
	background: #fff;
	color: var(--pd-accent);
	overflow: hidden;
	transition: background-color 0.15s ease, color 0.15s ease;
}
.promo-deals .promo-deal__qty.has-qty { background: var(--pd-accent); color: #fff; }
.promo-deals .promo-deal__qty-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 100%;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: inherit;
	font: 700 18px/1 system-ui, sans-serif;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
}
.promo-deals .promo-deal__qty-btn:hover:not(:disabled):not(.is-disabled) { background: rgba(0, 0, 0, 0.08); }
.promo-deals .promo-deal__qty-btn:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
.promo-deals .promo-deal__qty-btn:disabled,
.promo-deals .promo-deal__qty-btn.is-disabled { opacity: 0.35; cursor: default; }
.promo-deals .promo-deal__qty-value { min-width: 22px; text-align: center; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.promo-deals .promo-deal__qty.is-busy { opacity: 0.6; pointer-events: none; }
html:not(.promo-deals-js) .promo-deals .promo-deal__qty-btn--minus,
html:not(.promo-deals-js) .promo-deals .promo-deal__qty-value { display: none; }
html:not(.promo-deals-js) .promo-deals .promo-deal__qty-btn--plus { width: 40px; }
.promo-deals .promo-deal__qty-msg { grid-column: 2 / -1; justify-self: end; font-size: 0.78em; color: #b00020; }

/* Live deal progress line (space reserved so cards don't jump) */
.promo-deals .promo-deal__progress { min-height: 1.4em; margin: 6px 0 0; font-size: 0.85em; font-weight: 700; line-height: 1.4; color: var(--pd-badge-bg); }
.promo-deals .promo-deal__progress.is-done { color: #1a8a3e; }
.promo-deals .promo-deal__progress.is-done::before { content: "\2713  "; }

/* Carousel layout */
.promo-deals__carousel { position: relative; }
.promo-deals--carousel .promo-deals__items {
	display: grid;
	grid-auto-flow: column;
	grid-template-columns: none;
	grid-auto-columns: calc((100% - (var(--pd-columns) - 1) * var(--pd-gap)) / var(--pd-columns));
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-padding-inline: 4px;
	padding: 6px 4px 20px;
	margin: -6px -4px -20px;
	scrollbar-width: none;
}
.promo-deals--carousel .promo-deals__items::-webkit-scrollbar { display: none; }
.promo-deals--carousel .promo-deals__items:focus-visible { outline: 2px solid var(--pd-accent); outline-offset: 4px; }
.promo-deals--carousel .promo-deal { scroll-snap-align: start; }
.promo-deals .promo-deals__nav {
	position: absolute;
	top: 50%;
	z-index: 3;
	display: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: -22px 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: var(--pd-accent);
	box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
	font: 400 30px/1 system-ui, sans-serif;
	cursor: pointer;
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.promo-deals__carousel.is-scrollable .promo-deals__nav { display: inline-flex; }
.promo-deals .promo-deals__nav span { margin-top: -4px; }
.promo-deals .promo-deals__nav:hover:not(:disabled) { transform: scale(1.06); }
.promo-deals .promo-deals__nav:disabled { opacity: 0; pointer-events: none; }
.promo-deals__nav--prev { left: -14px; }
.promo-deals__nav--next { right: -14px; }
@media (max-width: 900px) {
	.promo-deals--carousel .promo-deals__items { grid-auto-columns: calc((100% - var(--pd-gap)) / 2); }
}
@media (max-width: 640px) {
	.promo-deals--carousel .promo-deals__items { grid-auto-columns: 82%; }
	.promo-deals__nav--prev { left: 2px; }
	.promo-deals__nav--next { right: 2px; }
}

/* List layout: image beside the content on wide screens */
.promo-deals--list .promo-deal { flex-direction: row; }
.promo-deals--list .promo-deal__media { flex: 0 0 clamp(160px, 28%, 280px); height: auto; min-height: var(--pd-image-height); }
.promo-deals--list .promo-deal__products { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); column-gap: 18px; }
.promo-deals--list .promo-deal__actions { max-width: 320px; }

/* Narrow screens */
@media (max-width: 640px) {
	.promo-deals { --pd-min-card: 100%; }
	.promo-deal__media { height: min(var(--pd-image-height), 170px); }
	.promo-deals--list .promo-deal { flex-direction: column; }
	.promo-deals--list .promo-deal__media { height: var(--pd-image-height); flex-basis: auto; }
	.promo-deals--list .promo-deal__actions { max-width: none; }
}

/* Product page badges */
.promo-deals-badges { margin: 0 0 12px; }
.promo-deals-badges .promo-deal__badge { margin: 0 6px 6px 0; }
.promo-deals-badges__text { font-size: 0.9em; }

/* Shop listing badge: hidden until loop-badges.js overlays it on the image (no change to card height). */
.promo-deals-loop-badge { display: none; }
.promo-deals-loop-badge.is-placed { display: block; position: absolute; top: 10px; right: 10px; z-index: 5; pointer-events: none; line-height: 1; margin: 0; }
.promo-deals-loop-badge.is-inline { display: inline-block; margin: 4px 0 0; line-height: 1; }
.promo-deals-loop-badge .promo-deal__badge { font-size: 12px; padding: 5px 10px; }
@media (max-width: 549px) { .promo-deals-loop-badge .promo-deal__badge { font-size: 11px; padding: 4px 8px; } }
.no-js .promo-deals-loop-badge { display: inline-block; }

/* Basket */
.promo-deals-savings td { color: #d0021b; font-weight: 600; }
