/**
 * WCAR Pro email capture popup.
 *
 * Scoped entirely under .wcar-popup / .wcar-popup-inline so nothing here can
 * leak into the storefront theme. No global resets, no element selectors.
 *
 * Icons ride as data-URI backgrounds rather than inline SVG. A block-authored
 * design runs the form through `allowed_design_html()`, and while that now
 * permits the shape elements an icon needs, a background carries no attributes
 * for a filter to disagree with and renders the same in both places.
 *
 * Colours are stated rather than derived from `opacity`, so dimmed text keeps
 * a real contrast ratio no matter what the theme paints behind the panel.
 */

.wcar-popup {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	box-sizing: border-box;
}

.wcar-popup[hidden] {
	display: none;
}

.wcar-popup__overlay {
	position: absolute;
	inset: 0;
	background: rgba( 16, 24, 40, 0.6 );
	cursor: pointer;
}

.wcar-popup__panel {
	position: relative;
	width: 100%;
	max-width: 440px;
	max-height: calc( 100vh - 32px );
	overflow-y: auto;
	box-sizing: border-box;
	padding: 36px 32px 28px;
	border-radius: 16px;
	background: #fff;
	color: #101828;
	box-shadow: 0 1px 3px rgba( 16, 24, 40, 0.08 ), 0 28px 56px -16px rgba( 16, 24, 40, 0.32 );
	opacity: 0;
	transform: translateY( 10px ) scale( 0.98 );
	transition: opacity 0.22s ease, transform 0.22s ease;
}

.wcar-popup.is-open .wcar-popup__panel {
	opacity: 1;
	transform: none;
}

.wcar-popup__close {
	position: absolute;
	top: 12px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: #667085;
	cursor: pointer;
	opacity: 1;
}

.wcar-popup__close svg {
	display: block;
	pointer-events: none;
}

/* No hover affordance beyond the cursor -- and that has to be stated rather
   than merely left out, because themes style `button:hover` and `button:focus`
   through selectors that outrank a lone class. Astra fills both with its accent
   colour, so deleting our own hover rule handed the close button a solid blue
   background instead of no effect at all. */
.wcar-popup .wcar-popup__close:hover,
.wcar-popup .wcar-popup__close:focus {
	border: 0;
	background: transparent;
	color: #667085;
	opacity: 1;
}

/* The one exception, and it is not a hover effect: without a focus indicator
   the close button is invisible to anyone tabbing through the popup. Listed
   after the rule above, at the same specificity, so it wins for keyboard
   focus while a click or a hover still changes nothing. */
.wcar-popup .wcar-popup__close:focus-visible {
	background: #f2f4f7;
	color: #101828;
}

.wcar-popup__intro {
	text-align: center;
}

/* The visual anchor, and the reason the panel no longer reads as a browser
   dialog. Built-in copy only: an inline placement sits inside a design the
   merchant has already composed, so it brings its own. */
.wcar-popup__icon {
	width: 56px;
	height: 56px;
	margin: 0 auto 20px;
	border-radius: 14px;
	background-color: #f2f4f7;
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23344054' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='5' width='19' height='14' rx='2.5'/%3E%3Cpath d='M3.2 7.6l7.5 5.3a2.3 2.3 0 0 0 2.6 0l7.5-5.3'/%3E%3C/svg%3E" );
	background-repeat: no-repeat;
	background-position: center;
	background-size: 24px 24px;
}

/* Weight and size are stated, not inherited. A theme that renders `h2` at 400
   and body copy at 300 -- Astra's default pairing does -- otherwise leaves the
   panel with no hierarchy at all. */
.wcar-popup__heading {
	margin: 0 0 8px;
	color: #101828;
	font-size: 24px;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -0.01em;
	text-wrap: pretty;
}

.wcar-popup__subheading {
	margin: 0 0 24px;
	color: #475467;
	font-size: 15px;
	line-height: 1.55;
	text-wrap: pretty;
}

/* Stacked, not side by side. Sharing one row left the field on a 190px basis,
   which is too narrow to read a typed address back in and too narrow to give
   the button a resting size that survives a longer label. */
.wcar-popup .wcar-popup__form .wcar-popup__row,
.wcar-popup-inline .wcar-popup__form .wcar-popup__row {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* Themes reach the field through selectors a lone class cannot outrank:
   `input[type="email"]` for Astra's height and padding, and
   `.woocommerce input[type="email"]` -- three components -- for its border
   radius. That left the field 40px and square against a 43px rounded button,
   top-aligned, because a fixed height is the one thing `align-items: stretch`
   cannot level out. Scoping to the widget root and the form gives these three
   components of their own, enough to hold both controls to one shared box on
   a WooCommerce page. Both roots are listed because the same form is also
   dropped inline into a Spectra popup or a block design. */
.wcar-popup .wcar-popup__form .wcar-popup__email,
.wcar-popup .wcar-popup__form .wcar-popup__submit,
.wcar-popup-inline .wcar-popup__form .wcar-popup__email,
.wcar-popup-inline .wcar-popup__form .wcar-popup__submit {
	box-sizing: border-box;
	width: 100%;
	height: auto;
	min-height: 48px;
	margin: 0;
	border-radius: 10px;
	font-size: 15px;
	line-height: 1.4;
}

.wcar-popup .wcar-popup__form .wcar-popup__email,
.wcar-popup-inline .wcar-popup__form .wcar-popup__email {
	min-width: 0;
	padding: 12px 14px;
	border: 1px solid #d0d5dd;
	background: #fff;
	color: #101828;
}

/* A ring rather than an outline: an outline cannot follow the 10px corner on
   every browser, and the theme's own focus style is already suppressed here. */
.wcar-popup .wcar-popup__form .wcar-popup__email:focus,
.wcar-popup-inline .wcar-popup__form .wcar-popup__email:focus {
	outline: none;
	border-color: #101828;
	box-shadow: 0 0 0 4px rgba( 16, 24, 40, 0.08 );
}

/* Centred rather than padded to the middle, so the label stays put whatever
   line-height the theme hands the button. */
.wcar-popup .wcar-popup__form .wcar-popup__submit,
.wcar-popup-inline .wcar-popup__form .wcar-popup__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 12px 20px;
	border: 0;
	background: #101828;
	color: #fff;
	font-weight: 600;
	cursor: pointer;
}

.wcar-popup .wcar-popup__form .wcar-popup__submit:hover:not( :disabled ),
.wcar-popup-inline .wcar-popup__form .wcar-popup__submit:hover:not( :disabled ) {
	background: #1d2939;
}

.wcar-popup .wcar-popup__form .wcar-popup__submit:disabled,
.wcar-popup-inline .wcar-popup__form .wcar-popup__submit:disabled {
	opacity: 0.6;
	cursor: default;
}

/* Honeypot: off-screen rather than display:none, so bots that skip hidden
   fields still fill it while no human ever sees or tabs into it. */
.wcar-popup__hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}

.wcar-popup__consent {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	margin-top: 18px;
	color: #475467;
	font-size: 13.5px;
	line-height: 1.5;
	cursor: pointer;
}

/* The box is drawn here rather than left to the browser. It is the one control
   the visitor must operate before the form will submit, and a 13px default
   checkbox was the least visible thing in the panel. Same scoping argument as
   the field above: `input[type="checkbox"]` is a theme's selector of choice. */
.wcar-popup .wcar-popup__form .wcar-popup__consent input,
.wcar-popup-inline .wcar-popup__form .wcar-popup__consent input {
	appearance: none;
	-webkit-appearance: none;
	box-sizing: border-box;
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	margin: 1px 0 0;
	padding: 0;
	border: 1px solid #d0d5dd;
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
}

.wcar-popup .wcar-popup__form .wcar-popup__consent input:checked,
.wcar-popup-inline .wcar-popup__form .wcar-popup__consent input:checked {
	border-color: #101828;
	background-color: #101828;
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.4 6.3l2.3 2.3 4.9-5'/%3E%3C/svg%3E" );
	background-repeat: no-repeat;
	background-position: center;
	background-size: 12px 12px;
}

.wcar-popup .wcar-popup__form .wcar-popup__consent input:focus-visible,
.wcar-popup-inline .wcar-popup__form .wcar-popup__consent input:focus-visible {
	outline: 2px solid #101828;
	outline-offset: 2px;
}

.wcar-popup__message {
	margin: 16px 0 0;
	font-size: 13.5px;
	line-height: 1.45;
	min-height: 1em;
}

/* Nothing to say yet, so take up no room -- the reserved line and its margin
   read as dead space under the consent row for the whole time the form sits
   untouched. Collapsed rather than `display: none`, because a live region has
   to already be in the accessibility tree when its text changes for the change
   to be announced. */
.wcar-popup .wcar-popup__form .wcar-popup__message:empty,
.wcar-popup-inline .wcar-popup__form .wcar-popup__message:empty {
	margin: 0;
	min-height: 0;
}

/* An error is the one message the visitor has to act on, so it gets a container
   and an icon instead of a coloured sentence that reads as body copy. */
.wcar-popup__message.is-error {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 10px 12px;
	border: 1px solid #fecdca;
	border-radius: 8px;
	background: #fef3f2;
	color: #b42318;
}

.wcar-popup__message.is-error::before {
	content: "";
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	margin-top: 1px;
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23b42318' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6.2'/%3E%3Cpath d='M8 5.1v3.3'/%3E%3Cpath d='M8 10.9h.01'/%3E%3C/svg%3E" );
	background-repeat: no-repeat;
	background-position: center;
	background-size: 16px 16px;
}

.wcar-popup__message.is-success {
	color: #101828;
}

.wcar-popup__form.is-done .wcar-popup__intro,
.wcar-popup__form.is-done .wcar-popup__row,
.wcar-popup__form.is-done .wcar-popup__consent,
.wcar-popup__form.is-done .wcar-popup__privacy {
	display: none;
}

/* The confirmation replaces the form, so it carries the panel on its own. Kept
   to one mark and one line because `wcar-popup.js` closes the popup 1800ms
   after success -- anything longer would not be read. */
.wcar-popup__form.is-done .wcar-popup__message.is-success {
	margin: 8px 0 4px;
	text-align: center;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.45;
	text-wrap: pretty;
}

.wcar-popup__form.is-done .wcar-popup__message.is-success::before {
	content: "";
	display: block;
	width: 56px;
	height: 56px;
	margin: 0 auto 18px;
	border-radius: 50%;
	background-color: #d1fadf;
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='%23027a48' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6.5L9.4 17.1 4 11.7'/%3E%3C/svg%3E" );
	background-repeat: no-repeat;
	background-position: center;
	background-size: 26px 26px;
}

/* The store's own privacy page, not a promise this plugin invents. Rendered
   only when the site has one set, so there is never a dead link here. */
.wcar-popup__privacy {
	margin: 18px 0 0;
	text-align: center;
	font-size: 12.5px;
	line-height: 1.5;
}

.wcar-popup .wcar-popup__form .wcar-popup__privacy a,
.wcar-popup-inline .wcar-popup__form .wcar-popup__privacy a {
	color: #667085;
	text-decoration: underline;
}

.wcar-popup .wcar-popup__form .wcar-popup__privacy a:hover,
.wcar-popup .wcar-popup__form .wcar-popup__privacy a:focus,
.wcar-popup-inline .wcar-popup__form .wcar-popup__privacy a:hover,
.wcar-popup-inline .wcar-popup__form .wcar-popup__privacy a:focus {
	color: #101828;
}

/* Inline placement (shortcode / Spectra / block design) has no panel of its
   own, so it inherits the surrounding design and only lays out the form. */
.wcar-popup-inline .wcar-popup__consent {
	color: inherit;
}

.wcar-popup-inline .wcar-popup__privacy {
	text-align: left;
}

/* Phone: a bottom sheet. A centred card on a short viewport sits under the
   thumb's reach and reads as though it has covered the whole screen; anchored
   to the bottom edge it covers only what it needs and the storefront stays
   visible above it. 52px controls and 16px field text, because iOS zooms the
   viewport on focusing anything smaller. */
@media (max-width: 480px) {
	.wcar-popup {
		align-items: flex-end;
		padding: 0;
	}

	.wcar-popup__panel {
		max-width: none;
		max-height: calc( 100vh - 24px );
		padding: 32px 20px 26px;
		border-radius: 20px 20px 0 0;
		box-shadow: 0 -8px 40px rgba( 16, 24, 40, 0.28 );
		transform: translateY( 24px );
	}

	.wcar-popup__close {
		top: 10px;
		right: 10px;
		width: 44px;
		height: 44px;
		border-radius: 12px;
	}

	.wcar-popup__icon {
		width: 52px;
		height: 52px;
		margin-bottom: 18px;
	}

	.wcar-popup__heading {
		font-size: 21px;
		line-height: 1.28;
	}

	.wcar-popup__subheading {
		margin-bottom: 22px;
		font-size: 14.5px;
	}

	.wcar-popup .wcar-popup__form .wcar-popup__email,
	.wcar-popup .wcar-popup__form .wcar-popup__submit {
		min-height: 52px;
		font-size: 16px;
	}

	.wcar-popup .wcar-popup__form .wcar-popup__email {
		padding: 14px;
	}

	.wcar-popup .wcar-popup__form .wcar-popup__consent input {
		width: 22px;
		height: 22px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wcar-popup__panel {
		transition: none;
		transform: none;
	}
}
