/*
 * Blur Gate for WooCommerce - front end.
 *
 * Colours, fonts, radius and blur strength arrive as --wgbg-* custom properties printed
 * inline on <body>. The first-paint blur rules are printed inline too, because they
 * depend on the selectors chosen in settings.
 *
 * Accessibility floors built in here on purpose (do not lower them):
 *   - inputs and buttons are at least 44px tall (WCAG 2.5.8)
 *   - sizes are in em, never rem: many themes set the root font to 10px (62.5%), which
 *     shrank every rem-based size by a third
 *   - input text is at least 16px (stops iOS zooming the page)
 *   - focus ring is 3px in --wgbg-focus, which PHP guarantees is 3:1 against the panel
 *   - the panel background is always a solid colour, so text is never read against blur
 */

/* ---------- Blur ---------- */

.wgbg-blurred {
	filter: blur(var(--wgbg-blur, 8px));
	pointer-events: none;
	-webkit-user-select: none;
	user-select: none;
}

/* A blurred pop-up, drawer or sticky bar must never sit on top of the login panel. */
.wgbg-blurred.wgbg-under {
	z-index: 0 !important;
}

/* ---------- Full-page gate ---------- */

body.wgbg-gate-page {
	position: relative;
}

.wgbg-gate--page {
	position: absolute;
	inset: 0;
	z-index: 99990;
	box-sizing: border-box;
	padding: 0 1em 1em;
	background: var(--wgbg-tint, rgba(255, 255, 255, 0.25));
	pointer-events: none;
}

.wgbg-gate--page .wgbg-panel {
	position: -webkit-sticky;
	position: sticky;
	top: max(1em, 8vh);
	margin: 0 auto;
	pointer-events: auto;
}

/* Sticky ignores the first offset until the page scrolls, so add it as padding. */
.wgbg-gate--page {
	padding-top: max(1em, 8vh);
}

.wgbg-gate--center {
	padding-top: max(1em, calc(50vh - var(--wgbg-panel-h, 60vh) / 2));
}

.wgbg-gate--center .wgbg-panel {
	top: max(1em, calc(50vh - var(--wgbg-panel-h, 60vh) / 2));
}

/* Panel taller than the screen: let it scroll with the page so every field is reachable. */
.wgbg-gate--static {
	padding-top: 1em;
}

.wgbg-gate--static .wgbg-panel {
	position: relative;
	top: auto;
}

/* ---------- Product-section gate ---------- */

.wgbg-section-ui {
	position: absolute !important;
	inset: 0 !important;
	z-index: 20;
	display: flex !important;
	align-items: flex-start;
	justify-content: center;
	box-sizing: border-box;
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 1em !important;
	float: none !important;
	list-style: none !important;
	background: var(--wgbg-tint, rgba(255, 255, 255, 0.25));
}

.wgbg-section-ui::before,
.wgbg-section-ui::after {
	content: none !important;
}

.wgbg-section-ui .wgbg-panel {
	position: -webkit-sticky;
	position: sticky;
	top: 1em;
}

.wgbg-section-ui--prompt {
	align-items: center;
}

.wgbg-prompt,
.wgbg-prompt:visited {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: max(44px, 2.75em);
	padding: 0.625em 1.25em;
	border-radius: calc(var(--wgbg-radius, 12px) / 1.5);
	background: var(--wgbg-accent, #1f5f8b);
	color: var(--wgbg-btn-text, #fff);
	font-family: var(--wgbg-font-body, inherit);
	font-size: var(--wgbg-font-size, 16px);
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
	text-decoration: none;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.wgbg-prompt:hover,
.wgbg-prompt:focus {
	color: var(--wgbg-btn-text, #fff);
	text-decoration: underline;
}

.wgbg-prompt:focus-visible {
	outline: 3px solid var(--wgbg-focus, #1f5f8b);
	outline-offset: 3px;
	box-shadow: 0 0 0 3px var(--wgbg-bg, #fff);
}

.wgbg-noscript {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 99990;
	margin: 0;
	padding: 0.75em 1em;
	border-top: 1px solid var(--wgbg-border, #8c8f94);
	background: var(--wgbg-bg, #fff);
	color: var(--wgbg-text, #1d2327);
	text-align: center;
}

.wgbg-noscript a {
	color: inherit;
	font-weight: 600;
	text-decoration: underline;
}

/* ---------- Panel ---------- */

.wgbg-panel {
	container-type: inline-size;
	container-name: wgbg;
	box-sizing: border-box;
	width: 100%;
	max-width: var(--wgbg-max-w, 440px);
	border: 1px solid var(--wgbg-border, #8c8f94);
	border-radius: var(--wgbg-radius, 12px);
	background: var(--wgbg-bg, #fff);
	color: var(--wgbg-text, #1d2327);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	font-family: var(--wgbg-font-body, inherit);
	font-size: var(--wgbg-font-size, 16px);
	font-weight: 400;
	line-height: 1.5;
	letter-spacing: normal;
	text-align: left;
	text-transform: none;
}

[dir="rtl"] .wgbg-panel {
	text-align: right;
}

.wgbg-panel--row {
	max-width: min(100%, 1100px);
}

.wgbg-panel *,
.wgbg-panel *::before,
.wgbg-panel *::after {
	box-sizing: border-box;
}

.wgbg-panel:focus {
	outline: none;
}

.wgbg-panel:focus-visible {
	outline: 3px solid var(--wgbg-focus, #1f5f8b);
	outline-offset: 3px;
}

.wgbg-panel .wgbg-panel__inner {
	padding: 1.5em;
}

.wgbg-panel .wgbg-panel__logo {
	display: block;
	width: auto;
	max-width: 180px;
	height: auto;
	max-height: 72px;
	margin: 0 0 1em;
}

.wgbg-panel .wgbg-panel__title {
	margin: 0 0 0.5em;
	padding: 0;
	color: inherit;
	font-family: var(--wgbg-font-heading, inherit);
	font-size: 1.375em;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: normal;
	text-transform: none;
}

.wgbg-panel .wgbg-panel__message {
	margin: 0 0 1.25em;
	color: inherit;
	font-size: 1em;
}

/* ---------- Notices ---------- */

.wgbg-panel .wgbg-notice {
	display: flex;
	gap: 0.625em;
	align-items: flex-start;
	margin: 0 0 1em;
	padding: 0.625em 0.75em;
	border: 1px solid currentColor;
	border-left-width: 5px;
	border-radius: 4px;
	color: inherit;
	font-size: 0.9375em;
}

[dir="rtl"] .wgbg-panel .wgbg-notice {
	border-right-width: 5px;
	border-left-width: 1px;
}

/* State is carried by the icon and the text, never by colour alone. */
.wgbg-panel .wgbg-notice__icon {
	display: inline-flex;
	flex: 0 0 1.375em;
	align-items: center;
	justify-content: center;
	width: 1.375em;
	height: 1.375em;
	border-radius: 50%;
	background: var(--wgbg-text, #1d2327);
	color: var(--wgbg-bg, #fff);
	font-size: 0.875em;
	font-weight: 700;
	line-height: 1;
}

.wgbg-panel .wgbg-notice__text a {
	color: inherit;
	text-decoration: underline;
}

/* ---------- Log in / Create account switch ---------- */

.wgbg-panel .wgbg-switch {
	display: none;
	grid-template-columns: 1fr 1fr;
	margin: 0 0 1.25em;
	border: 1px solid var(--wgbg-border, #8c8f94);
	border-radius: calc(var(--wgbg-radius, 12px) / 1.5);
	overflow: hidden;
}

.wgbg-js .wgbg-panel .wgbg-switch {
	display: grid;
}

.wgbg-panel .wgbg-switch__btn {
	min-height: max(44px, 2.75em);
	margin: 0;
	padding: 0.5em 0.75em;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--wgbg-text, #1d2327);
	box-shadow: none;
	font: inherit;
	font-weight: 600;
	line-height: 1.3;
	text-transform: none;
	cursor: pointer;
}

.wgbg-panel .wgbg-switch__btn[aria-pressed="true"] {
	background: var(--wgbg-accent, #1f5f8b);
	color: var(--wgbg-btn-text, #fff);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.wgbg-panel .wgbg-switch__btn:focus-visible {
	outline: 3px solid var(--wgbg-focus, #1f5f8b);
	outline-offset: -5px;
	box-shadow: inset 0 0 0 2px var(--wgbg-bg, #fff);
}

/* ---------- Forms ---------- */

/* The forms also carry WooCommerce's form classes (security plugins look for them), so
   reset what themes add to those. */
.wgbg-panel form.wgbg-form {
	float: none;
	width: auto;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
}

.wgbg-panel .wgbg-form + .wgbg-form {
	margin-top: 1.5em;
	padding-top: 1.5em;
	border-top: 1px solid var(--wgbg-border, #8c8f94);
}

.wgbg-panel .wgbg-form__title {
	margin: 0 0 0.75em;
	color: inherit;
	font-family: var(--wgbg-font-heading, inherit);
	font-size: 1.125em;
	font-weight: 700;
	line-height: 1.3;
}

/* With JavaScript the switch names the form, and only one form shows at a time. */
.wgbg-js .wgbg-panel .wgbg-switch ~ .wgbg-form .wgbg-form__title {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.wgbg-js .wgbg-panel[data-wgbg-active="login"] .wgbg-form--register,
.wgbg-js .wgbg-panel[data-wgbg-active="register"] .wgbg-form--login {
	display: none;
}

.wgbg-js .wgbg-panel .wgbg-form + .wgbg-form {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

.wgbg-panel .wgbg-field {
	margin: 0 0 1em;
	padding: 0;
}

.wgbg-panel .wgbg-field label {
	display: block;
	margin: 0 0 0.375em;
	color: inherit;
	font-size: 0.9375em;
	font-weight: 600;
	line-height: 1.4;
}

.wgbg-panel .wgbg-input {
	display: block;
	width: 100%;
	min-height: max(44px, 2.75em);
	margin: 0;
	padding: 0.5em 0.75em;
	border: 1px solid var(--wgbg-border, #8c8f94);
	border-radius: calc(var(--wgbg-radius, 12px) / 2);
	background: var(--wgbg-bg, #fff);
	color: var(--wgbg-text, #1d2327);
	box-shadow: none;
	font: inherit;
	font-size: max(16px, 1em);
	line-height: 1.4;
}

.wgbg-panel .wgbg-input:focus,
.wgbg-panel .wgbg-button:focus-visible,
.wgbg-panel .wgbg-password__toggle:focus-visible,
.wgbg-panel .wgbg-link:focus-visible,
.wgbg-panel .wgbg-check input:focus-visible {
	outline: 3px solid var(--wgbg-focus, #1f5f8b);
	outline-offset: 2px;
}

.wgbg-panel .wgbg-input[aria-invalid="true"] {
	border-width: 2px;
}

.wgbg-panel .wgbg-password {
	position: relative;
	display: block;
}

.wgbg-js .wgbg-panel .wgbg-password .wgbg-input {
	padding-right: 4.75em;
}

[dir="rtl"] .wgbg-js .wgbg-panel .wgbg-password .wgbg-input {
	padding-right: 0.75em;
	padding-left: 4.75em;
}

.wgbg-panel .wgbg-password__toggle {
	position: absolute;
	top: 0;
	right: 0;
	min-width: 4.25em;
	height: 100%;
	min-height: max(44px, 2.75em);
	margin: 0;
	padding: 0 0.75em;
	border: 0;
	background: transparent;
	color: var(--wgbg-text, #1d2327);
	box-shadow: none;
	font: inherit;
	font-size: 0.875em;
	font-weight: 600;
	text-decoration: underline;
	text-transform: none;
	cursor: pointer;
}

[dir="rtl"] .wgbg-panel .wgbg-password__toggle {
	right: auto;
	left: 0;
}

.wgbg-panel .wgbg-password__toggle[hidden] {
	display: none;
}

/* WooCommerce's script adds its own eye icon to password fields. The panel has a labelled
 * Show / Hide button already, and the two overlapped. */
.wgbg-panel .show-password-input {
	display: none !important;
}

.wgbg-panel .wgbg-form__extra:empty {
	display: none;
}

.wgbg-panel .wgbg-form__hint,
.wgbg-panel .wgbg-captcha-note,
.wgbg-panel .woocommerce-privacy-policy-text {
	margin: 0 0 1em;
	color: inherit;
	font-size: 0.875em;
}

.wgbg-panel .wgbg-form__extra a {
	color: inherit;
	text-decoration: underline;
}

.wgbg-panel .wgbg-captcha {
	min-height: 65px;
	margin: 0 0 1em;
}

.wgbg-panel .wgbg-captcha[data-wgbg-captcha="recaptcha_v3"] {
	min-height: 0;
	margin: 0;
}

.wgbg-panel .wgbg-actions {
	margin: 0 0 1em;
	padding: 0;
}

.wgbg-panel .wgbg-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: max(44px, 2.75em);
	margin: 0;
	padding: 0.625em 1.25em;
	border: 1px solid transparent;
	border-radius: calc(var(--wgbg-radius, 12px) / 1.5);
	background: var(--wgbg-accent, #1f5f8b);
	color: var(--wgbg-btn-text, #fff);
	box-shadow: none;
	font: inherit;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: normal;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
}

.wgbg-panel .wgbg-button:hover {
	background: var(--wgbg-accent, #1f5f8b);
	color: var(--wgbg-btn-text, #fff);
	filter: brightness(0.9);
}

.wgbg-panel .wgbg-button[aria-busy="true"] {
	opacity: 0.75;
	cursor: progress;
}

.wgbg-panel .wgbg-form__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em 1em;
	align-items: center;
	justify-content: space-between;
	margin: 0;
	padding: 0;
	font-size: 0.9375em;
}

.wgbg-panel .wgbg-check {
	display: inline-flex;
	gap: 0.5em;
	align-items: center;
	min-height: max(24px, 1.75em);
	margin: 0;
	color: inherit;
	font-weight: 400;
	cursor: pointer;
}

.wgbg-panel .wgbg-check input {
	width: 1.125em;
	height: 1.125em;
	margin: 0;
}

.wgbg-panel .wgbg-link,
.wgbg-panel .wgbg-link:visited {
	display: inline-flex;
	align-items: center;
	min-height: max(24px, 1.75em);
	color: inherit;
	text-decoration: underline;
}

.wgbg-panel .wgbg-panel__back {
	margin: 1.25em 0 0;
	padding: 1em 0 0;
	border-top: 1px solid var(--wgbg-border, #8c8f94);
	font-size: 0.9375em;
}

/* Honeypot: off screen for everyone, including assistive technology. */
.wgbg-panel .wgbg-hp {
	position: absolute !important;
	top: auto !important;
	left: -10000px !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}

/* ---------- Row layout ----------
 * One horizontal bar. It is a container query, not a media query, so the bar falls back
 * to the stacked Block layout whenever the panel itself is narrow (phones, zoom, or a
 * narrow product section), which keeps it usable at 320px and 200% zoom.
 */
@container wgbg (min-width: 720px) {
	.wgbg-panel--row .wgbg-panel__inner {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr);
		gap: 1em 2em;
		align-items: start;
	}

	.wgbg-panel--row .wgbg-panel__message {
		margin-bottom: 0;
	}

	.wgbg-js .wgbg-panel--row .wgbg-form {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		column-gap: 0.75em;
		align-items: end;
	}

	.wgbg-js .wgbg-panel--row .wgbg-form > * {
		grid-column: 1 / -1;
	}

	.wgbg-js .wgbg-panel--row .wgbg-form > .wgbg-form__fields {
		display: flex;
		grid-row: 1;
		grid-column: 1;
		gap: 0.75em;
		align-items: flex-end;
	}

	.wgbg-js .wgbg-panel--row .wgbg-form__fields .wgbg-field {
		flex: 1 1 0;
		min-width: 0;
		margin: 0;
	}

	.wgbg-js .wgbg-panel--row .wgbg-form > .wgbg-actions {
		grid-row: 1;
		grid-column: 2;
		margin: 0;
	}

	.wgbg-js .wgbg-panel--row .wgbg-button {
		width: auto;
		white-space: nowrap;
	}

	.wgbg-js .wgbg-panel--row .wgbg-form__extra,
	.wgbg-js .wgbg-panel--row .wgbg-form__meta {
		margin-top: 0.75em;
	}

	.wgbg-js .wgbg-panel--row .wgbg-form__extra > :last-child {
		margin-bottom: 0;
	}

	.wgbg-js .wgbg-panel--row .wgbg-switch {
		max-width: 22em;
		margin-bottom: 1em;
	}

	.wgbg-js .wgbg-panel--row[data-wgbg-active="login"] .wgbg-form--register,
	.wgbg-js .wgbg-panel--row[data-wgbg-active="register"] .wgbg-form--login {
		display: none;
	}
}

/* ---------- Preferences ---------- */

@media (prefers-reduced-motion: reduce) {
	.wgbg-panel *,
	.wgbg-prompt {
		transition: none !important;
		animation: none !important;
	}
}

@media (forced-colors: active) {
	.wgbg-panel,
	.wgbg-panel .wgbg-button,
	.wgbg-prompt {
		border: 2px solid ButtonText;
	}

	.wgbg-panel .wgbg-switch__btn[aria-pressed="true"] {
		outline: 2px solid Highlight;
		outline-offset: -4px;
	}
}
