/*
 * The Pro upgrade modal.
 *
 * One BEM block, no framework. Portable to any plugin: copy the folder, and if
 * the colours need to change, override the custom properties below on
 * `.pro-modal` from your own stylesheet. Nothing in here needs editing.
 *
 * Geometry is taken from the supplied design rather than reinterpreted: card
 * 550x420 at radius 45, art 389x132 flush to the top edge, four 35x37 counter
 * boxes 12px apart with their units below them, a 192x48 pill, and a plain text
 * link under it.
 *
 * SPECIFICITY, which is the thing to get right when this lands in wp-admin.
 * WordPress ships `a:active, a:focus, a:hover { color: <scheme blue> }` at
 * (0,1,1), so a bare `.pro-modal__cta` at (0,1,0) would lose and a white button
 * label would silently turn blue on hover. Every rule below is scoped under the
 * block, which buys (0,2,0), and the two anchors additionally qualify the
 * element - `a.pro-modal__cta` at (0,2,1) - which beats (0,1,1) outright. No
 * `!important` anywhere.
 */

.pro-modal {
	/*
	 * The palette. Measured ratios are against the surface unless stated, and
	 * they are written here so nobody swaps a value without knowing what it has
	 * to clear. WCAG AA: 4.5:1 for text, 3:1 for a boundary.
	 */
	--pm-ink: #1f324f; /* 12.90:1 - heading */
	--pm-muted: #475569; /*  7.58:1 - urgency line, dismiss link */
	--pm-label: #64748b; /*  4.76:1 - countdown units */
	--pm-digit: #343a3f; /* 10.14:1 on --pm-box-fill */
	--pm-box-fill: #edf1f4;
	--pm-hairline: #7b8794; /*  3.66:1 - the dotted box outline */
	--pm-surface: #ffffff;
	--pm-cta-bg: #000000;
	--pm-cta-bg-active: var( --pm-ink );
	--pm-cta-fg: #ffffff; /* 21:1 on --pm-cta-bg */
	--pm-close-bg: #f3f4f6;
	--pm-close-bg-active: #e5e7eb;
	--pm-close-fg: #64748b;
	--pm-close-fg-active: #334155;
	--pm-focus: #085df2;
	--pm-scrim: rgba( 0, 0, 0, 0.6 );
	--pm-z: 999999;

	/*
	 * Type is deliberately inherited rather than declared. This card floats over
	 * whatever screen the reader was on, so it takes that host's own stack and is
	 * guaranteed to be the same face as the page title behind it, on every
	 * platform.
	 */
	position: fixed;
	inset: 0;
	z-index: var( --pm-z );
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: var( --pm-scrim );
	backdrop-filter: blur( 4px );
	animation: pro-modal-fade 160ms ease-out both;
}

/* Preflight is off in some hosts and on in others. State it and stop guessing. */
.pro-modal,
.pro-modal *,
.pro-modal *::before,
.pro-modal *::after {
	box-sizing: border-box;
}

.pro-modal__card {
	position: relative;
	width: 550px;
	max-width: 92vw;
	max-height: 90vh;
	overflow-y: auto;
	padding: 0 0 35px;
	border-radius: 45px;
	background: var( --pm-surface );
	text-align: center;
	-webkit-font-smoothing: antialiased;
	box-shadow:
		0 4px 6px -4px rgba( 15, 23, 42, 0.08 ),
		0 10px 20px -5px rgba( 15, 23, 42, 0.12 );
	animation: pro-modal-panel 220ms cubic-bezier( 0.2, 0.8, 0.25, 1 ) both;
}

/*
 * The design draws a 40px disc. This is 44, the minimum a pointer target should
 * be; four pixels of extra ground is not a visible change and a dead 40px target
 * is.
 */
.pro-modal .pro-modal__close {
	position: absolute;
	top: 14px;
	right: 15px;
	z-index: 1;
	display: flex;
	width: 44px;
	height: 44px;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var( --pm-close-bg );
	color: var( --pm-close-fg );
	cursor: pointer;
	transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.pro-modal .pro-modal__close:hover,
.pro-modal .pro-modal__close:focus-visible {
	background: var( --pm-close-bg-active );
	color: var( --pm-close-fg-active );
}

.pro-modal .pro-modal__close:focus-visible {
	outline: 3px solid var( --pm-focus );
	outline-offset: 2px;
}

.pro-modal .pro-modal__close:active {
	transform: scale( 0.95 );
}

.pro-modal .pro-modal__art {
	display: block;
	width: 389px;
	max-width: 100%;
	height: auto;
	margin: 0 auto;
}

/* 26/700/-0.025em at 1.15, matching a WordPress admin page title. */
.pro-modal .pro-modal__title {
	margin: 36px 0 0;
	padding: 0;
	font-size: 26px;
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: -0.025em;
	color: var( --pm-ink );
}

/*
 * One line, one weight, one colour, and that colour is a step under the heading
 * rather than the same ink. Three levels: heading 12.90:1, this 7.58:1, the
 * countdown labels below 4.76:1. In the heading's own ink it read as a second
 * headline and flattened the card.
 */
.pro-modal .pro-modal__urgency {
	margin: 18px 0 0;
	padding: 0;
	font-size: 12.5px;
	font-weight: 600;
	line-height: 1.2;
	color: var( --pm-muted );
}

.pro-modal__countdown {
	display: flex;
	justify-content: center;
	gap: 12px;
	margin-top: 8px;
}

.pro-modal__unit {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.pro-modal__unit-box {
	display: flex;
	width: 35px;
	height: 37px;
	align-items: center;
	justify-content: center;
	border: 1px dotted var( --pm-hairline );
	border-radius: 8.5px;
	background: var( --pm-box-fill );
}

.pro-modal__digit {
	font-size: 17.5px;
	font-weight: 600;
	line-height: 1;
	font-variant-numeric: tabular-nums;
	color: var( --pm-digit );
}

.pro-modal__unit-label {
	margin-top: 6px;
	font-size: 8px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var( --pm-label );
}

/*
 * 28px above the button, where the design drew 21.
 *
 * The card reads 36 / 18 / 8 / _ / 10 / 36, so at 21 the gap above the primary
 * action was three pixels wider than the gap inside the text group above it, and
 * the button sat inside the countdown cluster instead of below it. 28 makes it
 * its own block, which is what the one control that has to look like a decision
 * should be.
 */
.pro-modal a.pro-modal__cta,
.pro-modal a.pro-modal__cta:link,
.pro-modal a.pro-modal__cta:visited {
	display: inline-flex;
	width: 192px;
	height: 48px;
	align-items: center;
	justify-content: center;
	margin-top: 28px;
	border-radius: 12px;
	background: var( --pm-cta-bg );
	color: var( --pm-cta-fg );
	font-size: 15.5px;
	font-weight: 700;
	letter-spacing: -0.01em;
	text-decoration: none;
	transition: background-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.pro-modal a.pro-modal__cta:hover,
.pro-modal a.pro-modal__cta:focus,
.pro-modal a.pro-modal__cta:focus-visible {
	background: var( --pm-cta-bg-active );
	color: var( --pm-cta-fg );
	text-decoration: none;
}

.pro-modal a.pro-modal__cta:hover {
	transform: translateY( -2px );
	box-shadow:
		0 2px 4px -2px rgba( 15, 23, 42, 0.06 ),
		0 4px 8px -2px rgba( 15, 23, 42, 0.08 );
}

.pro-modal a.pro-modal__cta:focus-visible {
	outline: 3px solid var( --pm-focus );
	outline-offset: 2px;
}

.pro-modal a.pro-modal__cta:active {
	background: var( --pm-cta-bg-active );
	color: var( --pm-cta-fg );
	transform: none;
	box-shadow: none;
}

.pro-modal__secondary-wrap {
	margin-top: 9px;
}

.pro-modal a.pro-modal__secondary,
.pro-modal a.pro-modal__secondary:link,
.pro-modal a.pro-modal__secondary:visited {
	font-size: 12px;
	font-weight: 400;
	line-height: 1.2;
	color: var( --pm-muted );
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
	transition: color 150ms ease;
}

/*
 * A real hover, not a repetition of the resting state.
 *
 * Every state used to be pinned to the same colour, which meant the one control
 * on this card that looks like a link gave no sign it could be pressed. It
 * darkens to the heading's ink instead - 12.90:1, the strongest step available,
 * and unmistakable against the 7.58:1 it sits at when idle.
 */
.pro-modal a.pro-modal__secondary:hover,
.pro-modal a.pro-modal__secondary:focus,
.pro-modal a.pro-modal__secondary:focus-visible,
.pro-modal a.pro-modal__secondary:active {
	color: var( --pm-ink );
	text-decoration: underline;
	text-underline-offset: 3px;
}

.pro-modal a.pro-modal__secondary:focus-visible {
	outline: 2px solid var( --pm-focus );
	outline-offset: 4px;
}

.pro-modal__sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/*
 * A backdrop fades and the panel arrives from slightly below: two motions
 * reading as one object being placed, not a box appearing.
 */
@keyframes pro-modal-fade {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@keyframes pro-modal-panel {
	from {
		opacity: 0;
		transform: translateY( 10px ) scale( 0.985 );
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.pro-modal,
	.pro-modal__card {
		animation: none;
	}

	.pro-modal .pro-modal__close,
	.pro-modal a.pro-modal__cta,
	.pro-modal a.pro-modal__secondary {
		transition: none;
	}

	.pro-modal .pro-modal__close:active,
	.pro-modal a.pro-modal__cta:hover {
		transform: none;
	}
}
