/*
 * Sitewide sale. Scoped to body.cp-sale / .cp-sale-* so the file does nothing until
 * the sale class is on the body. Enqueued only while cp_sale_is_on().
 * Sale palette (coral, sun, deep teal) is not in theme.json; everything else uses --cp-*.
 * Markup uses .screen-reader-text from base.css. .cp-sr is the same clip, kept for the spec.
 */
@layer components {
	:root {
		--cp-sale-accent: #FF7B5C;
		--cp-sale-sun: #FFC94D;
		--cp-sale-ink: var(--cp-charcoal, #1E2329);
		--cp-sale-deep: #173F37;
	}
	.cp-sr {
		position: absolute !important;
		width: 1px;
		height: 1px;
		padding: 0;
		margin: -1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border: 0;
	}

	.cp-sale-count { display: inline-flex; gap: 8px; margin: 0; padding: 0; list-style: none; }
	.cp-sale-count li {
		min-width: 64px;
		text-align: center;
		background: rgba(255, 255, 255, .1);
		border: 1px solid rgba(255, 255, 255, .25);
		border-radius: 12px;
		padding: 8px 6px;
	}
	.cp-sale-count b { display: block; font: 700 28px/1.05 var(--cp-font-head); color: var(--cp-white, #fff); }
	.cp-sale-count span {
		display: block;
		font: 500 12px/1.2 var(--cp-font-body);
		letter-spacing: .08em;
		text-transform: uppercase;
		color: #CFEDE5;
	}

	body.cp-sale .cp-sale-hero {
		position: relative;
		overflow: hidden;
		background: var(--cp-sale-deep);
		color: var(--cp-white, #fff);
		padding: 64px 0 72px;
	}
	.cp-sale-hero__grid {
		position: relative;
		z-index: 1;
		max-width: 1200px;
		margin: 0 auto;
		padding: 0 24px;
		display: grid;
		grid-template-columns: 1.25fr .75fr;
		gap: 32px;
		align-items: center;
	}
	.cp-sale-hero h1.cp-sale-hero__seo {
		font: 600 14px/1.3 var(--cp-font-head);
		letter-spacing: .12em;
		text-transform: uppercase;
		color: #9FE3D1;
		margin: 0 0 12px;
	}
	.cp-sale-hero__title {
		margin: 0;
		font: 700 clamp(44px, 6.2vw, 84px)/.98 var(--cp-font-head);
		letter-spacing: -.02em;
		color: var(--cp-white, #fff);
	}
	.cp-sale-hero__title .cp-sale-hero__pct {
		display: inline-block;
		background: var(--cp-sale-accent);
		color: var(--cp-sale-ink);
		padding: 0 .18em;
		border-radius: .16em;
		transform: rotate(-2deg);
	}
	.cp-sale-hero__lede {
		margin: 20px 0 0;
		max-width: 34em;
		font: 400 clamp(17px, 1.6vw, 20px)/1.5 var(--cp-font-body);
		color: #E6F4F0;
	}
	.cp-sale-hero__lede strong { color: var(--cp-white, #fff); }
	.cp-sale-hero__row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 28px; }
	.cp-sale-btn {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-height: 52px;
		padding: 0 28px;
		border-radius: 999px;
		background: var(--cp-sale-sun);
		color: var(--cp-sale-ink);
		font: 700 17px/1 var(--cp-font-head);
		text-decoration: none;
		box-shadow: 0 4px 0 #C99A22;
	}
	.cp-sale-btn:focus-visible { outline: 3px solid var(--cp-white, #fff); outline-offset: 3px; }
	.cp-sale-link {
		color: var(--cp-white, #fff);
		font: 600 16px/1 var(--cp-font-head);
		text-underline-offset: 4px;
		min-height: 44px;
		display: inline-flex;
		align-items: center;
	}
	.cp-sale-hero__count { margin-top: 28px; }
	.cp-sale-hero__countlabel { margin: 0 0 8px; font: 600 14px/1.3 var(--cp-font-body); color: #CFEDE5; }
	.cp-sale-hero__fine { margin: 20px 0 0; font: 400 13px/1.5 var(--cp-font-body); color: #B9D9D0; max-width: 44em; }
	.cp-sale-hero__art { position: relative; justify-self: center; }
	.cp-sale-hero__art img { display: block; width: min(320px, 100%); height: auto; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .35)); }
	.cp-sale-burst {
		position: absolute;
		z-index: 2;
		top: -6px;
		left: -28px;
		width: 150px;
		height: 150px;
		display: grid;
		place-items: center;
		text-align: center;
		background: var(--cp-sale-sun);
		color: var(--cp-sale-ink);
		font: 700 34px/.9 var(--cp-font-head);
		clip-path: polygon(50% 0, 61% 12%, 76% 6%, 80% 22%, 96% 24%, 90% 39%, 100% 50%, 90% 61%, 96% 76%, 80% 78%, 76% 94%, 61% 88%, 50% 100%, 39% 88%, 24% 94%, 20% 78%, 4% 76%, 10% 61%, 0 50%, 10% 39%, 4% 24%, 20% 22%, 24% 6%, 39% 12%);
		transform: rotate(-10deg);
	}
	.cp-sale-burst small { display: block; font: 700 14px/1 var(--cp-font-head); letter-spacing: .06em; }
	.cp-sale-confetti { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
	.cp-sale-confetti i { position: absolute; display: block; border-radius: 3px; opacity: .9; }
	.cp-sale-confetti i:nth-child(6n+1) { background: var(--cp-teal, #5AC1A7); }
	.cp-sale-confetti i:nth-child(6n+2) { background: var(--cp-sale-sun); }
	.cp-sale-confetti i:nth-child(6n+3) { background: var(--cp-sale-accent); }
	.cp-sale-confetti i:nth-child(6n+4) { background: var(--cp-white, #fff); opacity: .5; }
	.cp-sale-confetti i:nth-child(6n+5) { background: var(--cp-sale-sun); border-radius: 50%; }
	.cp-sale-confetti i:nth-child(6n) { background: var(--cp-teal, #5AC1A7); border-radius: 50%; }
	@media (prefers-reduced-motion: no-preference) {
		.cp-sale-confetti i { animation: cp-sale-drift 9s ease-in-out infinite alternate; }
	}
	@keyframes cp-sale-drift { to { transform: translateY(14px) rotate(40deg); } }
	@media (max-width: 820px) {
		body.cp-sale .cp-sale-hero { padding: 40px 0 48px; }
		.cp-sale-hero__grid { grid-template-columns: 1fr; gap: 8px; }
		.cp-sale-hero__art { order: -1; justify-self: end; margin: -8px 4px -24px 0; }
		.cp-sale-hero__art img { width: 120px; }
		.cp-sale-burst { width: 96px; height: 96px; font-size: 22px; left: -84px; top: 8px; }
		.cp-sale-burst small { font-size: 11px; }
		.cp-sale-btn { width: 100%; }
		.cp-sale-count li { min-width: 58px; }
		.cp-sale-count b { font-size: 24px; }
		.cp-sale-confetti i:nth-child(n+9) { display: none; }
	}

	.cp-sale-badge {
		display: inline-flex;
		align-items: center;
		gap: 6px;
		min-height: 28px;
		padding: 4px 12px;
		border-radius: 999px;
		background: var(--cp-sale-accent);
		color: var(--cp-sale-ink);
		font: 700 13px/1.1 var(--cp-font-head);
		letter-spacing: .04em;
		text-transform: uppercase;
	}
	body.cp-sale .cp-product-card { position: relative; border-color: var(--cp-teal, #5AC1A7); }
	body.cp-sale .cp-product-card > .cp-sale-badge { position: absolute; top: -14px; right: 16px; transform: rotate(3deg); }
	body.cp-sale .cp-products { padding-top: 18px; }

	.cp-price__regular {
		color: var(--cp-grey-2, #5B636B);
		font-weight: 500;
		text-decoration: line-through;
		text-decoration-color: var(--cp-sale-accent);
		text-decoration-thickness: 2px;
		margin-right: 6px;
	}
	body.cp-sale .cp-price.is-sale .cp-price__amount { color: var(--cp-teal-ink, #1F6E5B); }
	.cp-price__then {
		display: block;
		flex-basis: 100%;
		font: 500 13px/1.35 var(--cp-font-body);
		color: var(--cp-grey-2, #5B636B);
		margin-top: 2px;
	}
	.cp-plan__excluded {
		display: block;
		margin-top: 6px;
		font: 500 13px/1.35 var(--cp-font-body);
		color: var(--cp-grey-2, #5B636B);
	}

	.cp-sale-strip {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 10px 14px;
		margin: 0 0 16px;
		padding: 12px 16px;
		border-radius: 14px;
		background: #FFF4EE;
		border: 2px solid var(--cp-sale-accent);
		color: var(--cp-sale-ink);
	}
	.cp-sale-strip p { margin: 0; font: 500 15px/1.4 var(--cp-font-body); }
	.cp-sale-strip strong { font-family: var(--cp-font-head); }

	.cp-sale-steps {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		gap: 16px;
		margin: 24px 0 8px;
		padding: 0;
		list-style: none;
		counter-reset: cps;
	}
	.cp-sale-steps li {
		position: relative;
		padding: 18px 18px 18px 64px;
		border-radius: 16px;
		background: var(--cp-white, #fff);
		border: 1px solid var(--cp-line, #E3E6E8);
		font: 400 15px/1.45 var(--cp-font-body);
		color: var(--cp-sale-ink);
	}
	.cp-sale-steps li::before {
		counter-increment: cps;
		content: counter(cps);
		position: absolute;
		left: 16px;
		top: 16px;
		width: 34px;
		height: 34px;
		border-radius: 50%;
		display: grid;
		place-items: center;
		background: var(--cp-sale-sun);
		font: 700 17px/1 var(--cp-font-head);
	}
	.cp-sale-steps strong { display: block; font: 700 16px/1.3 var(--cp-font-head); margin-bottom: 2px; }
	.cp-sale-code {
		font: 700 14px/1 ui-monospace, Menlo, monospace;
		letter-spacing: .06em;
		background: var(--cp-white, #fff);
		border: 2px dashed var(--cp-sale-accent);
		border-radius: 6px;
		padding: 3px 7px;
		white-space: nowrap;
	}
	@media (max-width: 820px) { .cp-sale-steps { grid-template-columns: 1fr; } }

	body.cp-sale .cp-plan { position: relative; }
	body.cp-sale .cp-plan > .cp-sale-badge { position: absolute; top: -14px; left: 20px; transform: rotate(-2deg); }
	body.cp-sale .cp-plans__terms { padding-top: 18px; }
	body.cp-sale .cp-aap-savings { display: none; }
}

/* Unlayered on purpose: beats core's .wp-site-blocks block gap and later layered
   component rules for the strikethrough and the regular-price comparison lines. */
body.cp-sale .wp-site-blocks > main.cp-main:has(> .cp-sale-hero:first-child) { margin-block-start: 0; }
body.cp-sale .cp-price__regular {
	text-decoration: line-through;
	text-decoration-color: var(--cp-sale-accent, #FF7B5C);
	text-decoration-thickness: 2px;
}
body.cp-sale .cp-aap-savings,
body.cp-sale .cp-product-hero__savings,
body.cp-sale .cp-pricing__aap-price > .cp-muted,
body.cp-sale .cp-pricing-page__savings { display: none; }
