.tdpp-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba( 0, 0, 0, 0.75 );
	opacity: 0;
	transition: opacity 200ms ease;
}

.tdpp-overlay[hidden] {
	display: none;
}

.tdpp-overlay.tdpp-open {
	opacity: 1;
}

.tdpp-modal {
	--tdpp-bg: #ffffff;
	--tdpp-title: #111111;
	--tdpp-accent: #e3212b;
	--tdpp-accent-tint: rgba( 227, 33, 43, 0.12 );
	--tdpp-text: #4a4a4a;
	--tdpp-button: #e3212b;
	--tdpp-button-text: #ffffff;
	--tdpp-countdown-value: #111111;

	width: min( 680px, calc( 100vw - 40px ) );
	max-height: 90dvh;
	max-height: 90vh;
	overflow-y: auto;
	background: var( --tdpp-bg );
	color: var( --tdpp-text );
	border-radius: 16px;
	box-shadow: 0 10px 40px rgba( 0, 0, 0, 0.25 );
	font-family: inherit;
	opacity: 0;
	transform: scale( 0.98 );
	transition: opacity 200ms ease, transform 200ms ease;
}

.tdpp-overlay.tdpp-open .tdpp-modal {
	opacity: 1;
	transform: scale( 1 );
}

/*
 * Host themes frequently style bare `button`/`a` elements (WooCommerce and
 * theme "button" resets in particular), and those rules can carry equal or
 * higher specificity than ours depending on load order. Since this popup is
 * injected independently of the page's own markup, we reset every
 * interactive element inside it to a known baseline before applying our own
 * intended look, both with `!important`, so host CSS can never leak in.
 */
.tdpp-modal *,
.tdpp-modal *::before,
.tdpp-modal *::after {
	box-sizing: border-box !important;
}

/*
 * :where() keeps this reset's specificity at zero, so the targeted rules
 * further down (.tdpp-button, .tdpp-close, .tdpp-dismiss) reliably win
 * even though both sides use !important — a plain ".tdpp-modal button"
 * selector here would itself outrank those single-class rules and silently
 * cancel their re-styling.
 */
:where( .tdpp-modal ) :where( button, a ) {
	all: unset !important;
	box-sizing: border-box !important;
	cursor: pointer !important;
	font-family: inherit !important;
}

/* `all: unset` above also clears the default focus outline, so restore a
   visible one explicitly rather than leaving keyboard focus invisible. */
.tdpp-modal button:focus-visible,
.tdpp-modal a:focus-visible {
	outline: 2px solid var( --tdpp-accent ) !important;
	outline-offset: 2px !important;
}

.tdpp-media {
	position: relative;
	border-radius: 16px 16px 0 0;
	overflow: hidden;
	background: var( --tdpp-accent-tint );
}

/* Fades the bottom of the image into the popup background colour so the
   image doesn't end on a hard edge above the body content. */
.tdpp-media::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 40%;
	background: linear-gradient( to bottom, rgba( 0, 0, 0, 0 ), var( --tdpp-bg ) );
	pointer-events: none;
}

.tdpp-image {
	display: block;
	width: 100%;
	aspect-ratio: 9 / 5;
	object-fit: cover;
}

.tdpp-pill {
	position: absolute;
	top: 16px;
	left: 16px;
	padding: 6px 16px;
	border-radius: 999px;
	background: var( --tdpp-accent );
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	z-index: 1;
}

.tdpp-close {
	position: absolute !important;
	top: 16px !important;
	right: 16px !important;
	z-index: 1 !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 34px !important;
	height: 34px !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: rgba( 0, 0, 0, 0.55 ) !important;
	color: #fff !important;
	font-size: 20px !important;
	line-height: 1 !important;
	text-decoration: none !important;
	box-shadow: none !important;
}

.tdpp-close:hover,
.tdpp-close:focus {
	background: rgba( 0, 0, 0, 0.75 ) !important;
	color: #fff !important;
}

.tdpp-body {
	padding: clamp( 20px, 4vw, 32px );
	text-align: center;
}

.tdpp-title {
	margin: 0 0 6px !important;
	padding: 0 !important;
	color: var( --tdpp-title ) !important;
	font-size: clamp( 22px, 4vw, 30px ) !important;
	font-weight: 800 !important;
	line-height: 1.2 !important;
	letter-spacing: 0.02em !important;
	text-transform: uppercase !important;
}

.tdpp-secondary {
	margin: 0 0 20px;
	color: var( --tdpp-accent );
	font-size: clamp( 14px, 2.5vw, 17px );
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.tdpp-countdown {
	margin: 0 0 20px;
	padding: 16px;
	border: 1px solid var( --tdpp-accent );
	border-radius: 12px;
	background: var( --tdpp-accent-tint );
}

.tdpp-countdown-label {
	display: block;
	margin-bottom: 6px;
	color: var( --tdpp-accent );
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.tdpp-countdown-value {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	gap: clamp( 10px, 3vw, 22px );
}

.tdpp-countdown-segment {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	min-width: 2.4em;
}

.tdpp-countdown-number {
	color: var( --tdpp-countdown-value );
	font-size: clamp( 22px, 5vw, 32px );
	font-weight: 900;
	font-variant-numeric: tabular-nums;
	line-height: 1;
}

.tdpp-countdown-unit {
	color: var( --tdpp-text );
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	opacity: 0.7;
}

.tdpp-description {
	margin: 0 0 20px;
	font-size: clamp( 14px, 2.5vw, 16px );
	line-height: 1.5;
}

.tdpp-button {
	display: block !important;
	width: 100% !important;
	margin: 0 !important;
	padding: 16px !important;
	border: 0 !important;
	border-radius: 10px !important;
	background: var( --tdpp-button ) !important;
	color: var( --tdpp-button-text ) !important;
	font-size: clamp( 15px, 2.5vw, 17px ) !important;
	font-weight: 700 !important;
	letter-spacing: 0.03em !important;
	line-height: normal !important;
	text-align: center !important;
	text-decoration: none !important;
	text-transform: uppercase !important;
	box-shadow: none !important;
}

.tdpp-button:hover,
.tdpp-button:focus {
	color: var( --tdpp-button-text ) !important;
	filter: brightness( 0.92 );
}

.tdpp-dismiss {
	display: block !important;
	width: 100% !important;
	margin: 14px 0 0 !important;
	padding: 4px !important;
	border: 0 !important;
	background: none !important;
	color: var( --tdpp-text ) !important;
	font-size: 14px !important;
	font-weight: normal !important;
	line-height: normal !important;
	text-decoration: underline !important;
	text-transform: none !important;
	box-shadow: none !important;
}

.tdpp-dismiss:hover,
.tdpp-dismiss:focus {
	color: var( --tdpp-text ) !important;
}

body.tdpp-no-scroll {
	overflow: hidden;
}

@media ( max-width: 480px ) {
	.tdpp-modal {
		width: calc( 100vw - 24px );
		border-radius: 14px;
	}

	.tdpp-media {
		border-radius: 14px 14px 0 0;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.tdpp-overlay,
	.tdpp-modal {
		transition-duration: 1ms;
	}
}
