/**
 * Promotions grid.
 *
 * Colours come from the active theme's palette variables with neutral
 * fallbacks, so the plugin reskins with the theme rather than fighting it.
 */

.cp-grid {
	display: grid;
	grid-template-columns: repeat(var(--cp-cols, 3), 1fr);
	gap: var(--wp--preset--spacing--30, 20px);
}

.cp-card {
	display: flex;
	flex-direction: column;
	background: var(--wp--preset--color--surface, #fff);
	border: 1px solid var(--wp--preset--color--hairline, #e0e0e0);
	border-radius: 8px;
	overflow: hidden;
}

.cp-card:hover { border-color: var(--wp--preset--color--accent, #037e21); }

.cp-card__media { display: block; }

.cp-card__media img {
	width: 100%;
	/* 414 x 243 — the source banner ratio. */
	aspect-ratio: 414 / 243;
	object-fit: cover;
	display: block;
}

.cp-card__placeholder {
	display: block;
	aspect-ratio: 414 / 243;
	background: repeating-linear-gradient(
		45deg,
		var(--wp--preset--color--hairline, #e0e0e0),
		var(--wp--preset--color--hairline, #e0e0e0) 10px,
		transparent 10px,
		transparent 20px
	);
}

.cp-card__body {
	padding: 16px;
	display: flex;
	flex-direction: column;
	flex: 1;
}

.cp-card__title {
	margin: 0 0 4px;
	font-size: 16px;
	line-height: 1.3;
}

.cp-card__title a { text-decoration: none; }

.cp-card__value {
	margin: 0 0 8px;
	font-weight: 700;
	font-size: 20px;
	color: var(--wp--preset--color--accent, #037e21);
}

.cp-card__terms {
	margin: 0 0 12px;
	font-size: 12px;
	line-height: 1.5;
	color: var(--wp--preset--color--muted, #666);
}

.cp-card__actions {
	margin-top: auto;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.cp-btn {
	display: inline-block;
	padding: 10px 22px;
	border-radius: 8px;
	background: var(--wp--preset--color--action, #efbf01);
	color: #000;
	font-weight: 700;
	font-size: 14px;
	text-decoration: none;
}

.cp-btn:hover { filter: brightness(1.05); }

.cp-link { font-size: 13px; }

.cp-card__expiry {
	margin: 10px 0 0;
	font-size: 11px;
	color: var(--wp--preset--color--muted, #666);
}

.cp-expired {
	display: block;
	padding: 14px 16px;
	margin-bottom: 24px;
	border-radius: 8px;
	border: 1px solid #f0c0c0;
	background: #fdf0f0;
	color: #8a2020;
	font-size: 14px;
}

.cp-empty {
	padding: 24px;
	border: 1px dashed var(--wp--preset--color--hairline, #ccc);
	border-radius: 8px;
	color: var(--wp--preset--color--muted, #666);
}

@media (max-width: 900px) {
	.cp-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
	.cp-grid { grid-template-columns: 1fr; }
}

/* --- Wide banner header on a single promotion page ------------------------
   A 3.5:1 banner with the offer text overlaid as HTML, so the values stay
   editable and translatable. Falls back cleanly when only a card exists. --- */

.cp-banner {
	position: relative;
	width: 100%;
	overflow: hidden;
	margin-bottom: 28px;
	border-radius: 8px;
	background: #062E10;
}

.cp-banner img {
	width: 100%;
	height: auto;
	display: block;
	/* Cap the height so a very wide banner does not push the offer terms
	   below the fold on a large screen. */
	max-height: 420px;
	object-fit: cover;
	object-position: center;
}

.cp-banner__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	/* Scrim only on the left, so the artwork on the right stays visible. */
	background: linear-gradient(
		90deg,
		rgba(2, 24, 8, 0.88) 0%,
		rgba(2, 24, 8, 0.62) 34%,
		rgba(2, 24, 8, 0.08) 56%,
		rgba(2, 24, 8, 0) 70%
	);
}

/* Flex parent shrinks its child to content width; force full width so the
   copy pins left rather than centring. */
.cp-banner__overlay > * { width: 100%; }

.cp-banner__inner {
	padding: 24px clamp(20px, 5vw, 56px);
	max-width: 46%;
	margin-right: auto;
	color: #fff;
	text-align: left;
}

.cp-banner__kicker {
	margin: 0 0 6px;
	font-size: clamp(14px, 1.6vw, 18px);
	font-weight: 600;
	color: rgba(255, 255, 255, 0.9);
	line-height: 1.3;
}

.cp-banner__value {
	margin: 0 0 18px;
	font-size: clamp(24px, 3.6vw, 44px);
	font-weight: 800;
	line-height: 1.1;
	color: #fff;
	text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.cp-banner__cta {
	display: inline-block;
	background: var(--wp--preset--color--action, #efbf01);
	color: #000;
	font-weight: 800;
	font-size: clamp(15px, 1.8vw, 19px);
	padding: clamp(12px, 1.6vw, 18px) clamp(28px, 4vw, 52px);
	border-radius: 8px;
	text-decoration: none;
	box-shadow: 0 4px 0 rgba(150, 110, 0, 0.5), 0 10px 26px rgba(0, 0, 0, 0.32);
	transition: transform 0.15s ease, filter 0.15s ease;
}

.cp-banner__cta:hover {
	filter: brightness(1.06);
	transform: translateY(-1px);
}

@media (max-width: 780px) {
	.cp-banner img { max-height: 260px; }
	.cp-banner__overlay {
		background: linear-gradient(
			180deg,
			rgba(2, 24, 8, 0.25) 0%,
			rgba(2, 24, 8, 0.82) 60%
		);
		align-items: flex-end;
	}
	.cp-banner__inner { max-width: 100%; padding: 18px 20px 22px; }
}

/* --- FAQ ------------------------------------------------------------------- */

.cp-faq { margin-block: 40px; }

.cp-faq__heading {
	font-size: clamp(20px, 3vw, 28px);
	font-weight: 700;
	margin: 0 0 18px;
}

.cp-faq__item {
	background: var(--wp--preset--color--surface, #fff);
	border: 1px solid var(--wp--preset--color--hairline, #e0e0e0);
	border-radius: 8px;
	margin-bottom: 8px;
	overflow: hidden;
}

.cp-faq__q {
	cursor: pointer;
	list-style: none;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	padding: 16px 20px;
	font-weight: 700;
	font-size: 15px;
	line-height: 1.4;
}

.cp-faq__q::-webkit-details-marker { display: none; }

.cp-faq__q::after {
	content: "+";
	flex: none;
	font-size: 22px;
	line-height: 1;
	font-weight: 400;
	color: var(--wp--preset--color--accent, #037e21);
	transition: transform 0.2s ease;
}

.cp-faq__item[open] .cp-faq__q::after { transform: rotate(45deg); }

.cp-faq__item[open] .cp-faq__q {
	border-bottom: 1px solid var(--wp--preset--color--hairline, #e0e0e0);
}

.cp-faq__a {
	padding: 16px 20px;
	font-size: 14px;
	line-height: 1.7;
	color: var(--wp--preset--color--muted, #555);
}

.cp-faq__a p:last-child { margin-bottom: 0; }

.cp-faq__q:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent, #037e21);
	outline-offset: -2px;
}

@media (max-width: 600px) {
	.cp-faq__q { padding: 14px 16px; font-size: 14px; }
	.cp-faq__a { padding: 14px 16px; }
}

/* --- Banner wall ----------------------------------------------------------
   Image-only tiles that link straight out. No card body: the banner carries
   its own message. ------------------------------------------------------- */

.cp-wall {
	display: grid;
	grid-template-columns: repeat(var(--cp-cols, 3), 1fr);
	gap: var(--wp--preset--spacing--30, 20px);
}

.cp-wall__item {
	display: block;
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid var(--wp--preset--color--hairline, #e0e0e0);
	background: var(--wp--preset--color--surface, #fff);
	transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.cp-wall__item:hover {
	transform: translateY(-3px);
	border-color: var(--wp--preset--color--accent, #037e21);
	box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
}

.cp-wall__item img {
	width: 100%;
	height: auto;
	display: block;
	aspect-ratio: 414 / 243;
	object-fit: cover;
}

.cp-wall__item:focus-visible {
	outline: 3px solid var(--wp--preset--color--accent, #037e21);
	outline-offset: 2px;
}

/* Link text for screen readers and crawlers: the offer is inside the image,
   which neither can read. */
.cp-wall .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 900px) {
	.cp-wall { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
	.cp-wall { grid-template-columns: 1fr; }
}

/* --- Brand comparison table -----------------------------------------------
   Rows rather than a real <table>: a comparison needs to become stacked cards
   on mobile, and a table element fights that. Each row is a grid whose columns
   collapse cleanly. ------------------------------------------------------- */

.cb-table { display: flex; flex-direction: column; gap: 10px; }

.cb-row {
	display: grid;
	grid-template-columns: 44px minmax(180px, 1.4fr) 1.3fr 1fr 130px 170px;
	gap: 16px;
	align-items: center;
	padding: 16px 18px;
	background: var(--wp--preset--color--surface, #fff);
	border: 1px solid var(--wp--preset--color--hairline, #e0e0e0);
	border-radius: 8px;
}

.cb-row:hover { border-color: var(--wp--preset--color--accent, #037e21); }

.cb-row.is-featured {
	border-color: var(--wp--preset--color--action, #efbf01);
	border-width: 2px;
}

.cb-rank {
	font-size: 20px;
	font-weight: 800;
	text-align: center;
	color: var(--wp--preset--color--muted, #888);
}

.cb-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.cb-logo {
	flex: none;
	width: 62px;
	height: 62px;
	overflow: hidden;
	border-radius: 6px;
	border: 1px solid var(--wp--preset--color--hairline, #e0e0e0);
}

.cb-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cb-name { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cb-name strong { font-size: 16px; line-height: 1.25; }
.cb-name small { font-size: 11px; color: var(--wp--preset--color--muted, #888); }

.cb-badge {
	align-self: flex-start;
	font-size: 10px;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding: 3px 8px;
	border-radius: 3px;
	background: var(--wp--preset--color--action, #efbf01);
	color: #1a1200;
}

.cb-bonus { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cb-bonus strong { font-size: 15px; color: var(--wp--preset--color--accent, #037e21); line-height: 1.3; }
.cb-bonus small { font-size: 11px; color: var(--wp--preset--color--muted, #888); line-height: 1.4; }

.cb-facts { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--wp--preset--color--muted, #888); }
.cb-facts b { color: var(--wp--preset--color--contrast, #333); font-weight: 700; }

.cb-rating { display: flex; align-items: center; gap: 6px; }

.cb-stars {
	display: inline-block;
	width: 5.2em;
	height: 1em;
	position: relative;
	background: rgba(127, 127, 127, 0.28);
	vertical-align: -0.1em;
	-webkit-mask: repeat-x left center / 1.04em 1em var(--star);
	mask: repeat-x left center / 1.04em 1em var(--star);
	--star: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><polygon points="10,1 12.6,7.2 19,7.6 14,11.9 15.6,18.4 10,14.9 4.4,18.4 6,11.9 1,7.6 7.4,7.2"/></svg>');
}

.cb-stars i {
	position: absolute;
	inset: 0 auto 0 0;
	width: var(--pct, 0%);
	background: var(--wp--preset--color--action, #efbf01);
	-webkit-mask: inherit;
	mask: inherit;
}

.cb-score { font-weight: 800; font-size: 15px; color: var(--wp--preset--color--action, #efbf01); }

.cb-cta { display: flex; flex-direction: column; align-items: stretch; gap: 5px; }

.cb-btn {
	display: block;
	text-align: center;
	padding: 13px 18px;
	border-radius: 8px;
	background: var(--wp--preset--color--action, #efbf01);
	color: #000;
	font-weight: 800;
	font-size: 14px;
	text-decoration: none;
	white-space: nowrap;
}

.cb-btn:hover { filter: brightness(1.06); text-decoration: none; }

.cb-verified { font-size: 10px; text-align: center; color: var(--wp--preset--color--muted, #888); }

@media (max-width: 980px) {
	.cb-row { grid-template-columns: 36px 1.4fr 1.2fr 150px; row-gap: 12px; }
	.cb-facts { grid-column: 2 / -1; flex-direction: row; gap: 16px; }
	.cb-rating { grid-column: 2; }
	.cb-cta { grid-column: 3 / -1; }
}

@media (max-width: 640px) {
	.cb-row { grid-template-columns: 34px 1fr; padding: 14px; }
	.cb-brand { grid-column: 2; }
	.cb-bonus, .cb-facts, .cb-rating, .cb-cta { grid-column: 1 / -1; }
	.cb-facts { flex-direction: row; flex-wrap: wrap; }
	.cb-logo { width: 50px; height: 50px; }
}

/* Noir: square, hairline, gold. */
.is-style-noir .cb-row,
.is-style-noir .cb-btn,
.is-style-noir .cb-logo,
.is-style-noir .cb-badge { border-radius: 0; }

.is-style-noir .cb-row:hover { border-color: var(--wp--preset--color--accent); }
.is-style-noir .cb-bonus strong { color: var(--wp--preset--color--action); }

/* A brand with no affiliate URL renders a disabled button rather than a link to
   nowhere useful, and editors see why. */
.cb-btn.is-disabled {
	background: rgba(127, 127, 127, 0.25);
	color: rgba(127, 127, 127, 0.9);
	cursor: not-allowed;
}

.cb-warn {
	display: block;
	text-align: center;
	font-size: 10px;
	color: #c5221f;
	margin-top: 3px;
}

.cb-cta .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
