/*
 * Passcode Welcome: passcode screen and form.
 * The form rules (.pcw-form …) are also what the Elementor Passcode Form widget
 * starts from; its Style controls override the custom properties below.
 */

html,
body.pcw-gate-page {
	margin: 0;
	min-height: 100%;
}

body.pcw-gate-page {
	min-height: 100vh;
	min-height: 100dvh;
	background-color: var(--pcw-bg);
	color: var(--pcw-ink);
	font-family: var(--pcw-font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
	font-weight: var(--pcw-font-body-weight, 400);
	-webkit-font-smoothing: antialiased;
}

/* Built-in screen: centred, optional background image under a scheme-tinted wash. */
body.pcw-gate-page--builtin {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px 16px;
	box-sizing: border-box;
	background-image: var(--pcw-bg-image, none);
	background-position: center;
	background-size: cover;
	background-attachment: fixed;
}

body.pcw-gate-page--builtin::before {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
}

body.pcw-gate-page--builtin.pcw-scheme-dark::before {
	background:
		radial-gradient(ellipse 80% 60% at 50% 40%, rgba(30, 38, 43, 0.35), rgba(6, 8, 9, 0.88) 75%),
		linear-gradient(rgba(6, 8, 9, 0.35), rgba(6, 8, 9, 0.35));
}

body.pcw-gate-page--builtin.pcw-scheme-light::before {
	background:
		radial-gradient(ellipse 80% 60% at 50% 40%, rgba(255, 255, 255, 0.55), rgba(243, 246, 249, 0.92) 75%);
}

.pcw-gate--builtin {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 40px;
	width: 100%;
	max-width: 560px;
	text-align: center;
	transition: opacity 0.4s ease, transform 0.4s ease;
}

.pcw-gate--elementor {
	display: block;
	min-height: 100vh;
	min-height: 100dvh;
}

body.pcw-leaving .pcw-gate {
	opacity: 0;
	transform: scale(0.985);
}

.pcw-logo img {
	display: block;
	width: auto;
	max-width: 220px;
	height: auto;
	max-height: 90px;
}

.pcw-preview-note {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 5;
	padding: 8px 16px;
	background: #fff6d6;
	color: #5a4400;
	font-size: 13px;
	text-align: center;
}

.pcw-preview-note a {
	margin-left: 8px;
	color: inherit;
	font-weight: 600;
}

/* ---------------------------------------------------------------------------
 * Form. One real input is laid over the visual boxes, so typing at any speed,
 * pasting, and SMS code autofill all work.
 * ------------------------------------------------------------------------- */

.pcw-form {
	--pcw-box-gap: clamp(8px, 2.6vw, 18px);
	--pcw-box-radius: 8px;
	--pcw-box-border: var(--pcw-line);
	--pcw-box-focus: var(--pcw-accent, #1aa3c2);
	--pcw-digit-color: var(--pcw-ink);

	display: flex;
	flex-direction: column;
	align-items: var(--pcw-align, center);
	gap: 24px;
	width: 100%;
	margin: 0;
	text-align: var(--pcw-text-align, center);
}

.pcw-boxes {
	position: relative;
	display: grid;
	/* Boxes shrink to fit narrow screens and longer codes unless a size is set. */
	--pcw-auto-size: min(84px, calc((100vw - 48px - (var(--pcw-len, 4) - 1) * var(--pcw-box-gap)) / var(--pcw-len, 4)));
	grid-template-columns: repeat(var(--pcw-len, 4), var(--pcw-box-size, var(--pcw-auto-size)));
	gap: var(--pcw-box-gap);
	max-width: 100%;
}

.pcw-box {
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	height: calc(var(--pcw-box-size, var(--pcw-auto-size)) * 1.08);
	border: 1px solid var(--pcw-box-border);
	border-radius: var(--pcw-box-radius);
	background: var(--pcw-box-bg);
	color: var(--pcw-digit-color);
	font-family: var(--pcw-font-display, inherit);
	font-weight: var(--pcw-font-display-weight, 500);
	font-size: calc(var(--pcw-box-size, var(--pcw-auto-size)) * 0.5);
	line-height: 1;
	transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.pcw-box.is-filled {
	background: var(--pcw-box-bg-filled);
	transform: translateY(-2px);
}

.pcw-box.is-active {
	border-color: var(--pcw-box-focus);
	box-shadow: 0 0 0 1px var(--pcw-box-focus);
}

.pcw-box.is-active:empty::after {
	content: "";
	width: 2px;
	height: 40%;
	background: var(--pcw-box-focus);
	animation: pcw-blink 1s steps(1) infinite;
}

.pcw-form .pcw-code {
	position: absolute;
	inset: 0;
	z-index: 1;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: transparent;
	caret-color: transparent;
	font-size: 16px; /* Stops iOS zooming in on focus. */
	opacity: 0;
	cursor: text;
}

.pcw-form[data-static] .pcw-code {
	pointer-events: none;
}

.pcw-heading {
	margin: 0;
	color: var(--pcw-heading-color, var(--pcw-ink));
	font-family: var(--pcw-font-display, inherit);
	font-weight: var(--pcw-font-display-weight, 500);
	font-size: clamp(20px, 4vw, 28px);
	line-height: 1.2;
	letter-spacing: 0.02em;
	text-transform: var(--pcw-display-case, none);
}

.pcw-msg {
	min-height: 1.5em;
	margin: -10px 0 0;
	color: var(--pcw-error);
	font-size: 15px;
	line-height: 1.5;
}

.pcw-msg:empty {
	visibility: hidden;
}

.pcw-help {
	display: flex;
	flex-direction: column;
	align-items: var(--pcw-align, center);
	margin-top: -8px;
}

.pcw-help__text {
	max-width: 420px;
	margin-top: 10px;
	color: var(--pcw-help-text-color, var(--pcw-muted));
	font-size: 15px;
	line-height: 1.55;
}

.pcw-help__text p {
	margin: 0 0 0.6em;
}

.pcw-help__text a {
	color: inherit;
}

/* States */
.pcw-form.is-error .pcw-box {
	border-color: var(--pcw-error);
}

.pcw-form.is-shake .pcw-boxes {
	animation: pcw-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.pcw-form.is-busy .pcw-box {
	opacity: 0.6;
}

.pcw-form.is-success .pcw-box {
	border-color: var(--pcw-box-focus);
	box-shadow: 0 0 0 1px var(--pcw-box-focus);
}

.pcw-form.is-locked .pcw-boxes {
	opacity: 0.4;
}

@keyframes pcw-blink {
	50% {
		opacity: 0;
	}
}

@keyframes pcw-shake {
	10%, 90% { transform: translateX(-2px); }
	20%, 80% { transform: translateX(4px); }
	30%, 50%, 70% { transform: translateX(-7px); }
	40%, 60% { transform: translateX(7px); }
}

@media (prefers-reduced-motion: reduce) {
	.pcw-form.is-shake .pcw-boxes,
	.pcw-box.is-active:empty::after {
		animation: none;
	}

	.pcw-box,
	.pcw-gate--builtin {
		transition: none;
	}
}

/* ---------------------------------------------------------------------------
 * Help link.
 * Typography sits at 0-2-0: above theme/kit button fonts (0-1-1) but below
 * Elementor widget controls ({{WRAPPER}} …, 0-4-0), so the Passcode Form
 * widget's Typography control can restyle it. Colours and every state are set
 * at 0-4-0 via custom properties, so kit button :hover/:focus can't leak in.
 * ------------------------------------------------------------------------- */

.pcw-form .pcw-help__toggle {
	font-family: inherit;
	font-size: 14px;
	font-weight: inherit;
	line-height: 1.4;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.pcw-form .pcw-help__toggle.pcw-help__toggle,
.pcw-form .pcw-help__toggle.pcw-help__toggle:is(:focus, :active) {
	width: auto;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 4px 2px;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: var(--pcw-help-color, var(--pcw-accent, #1aa3c2));
	text-decoration: none;
	text-shadow: none;
	white-space: nowrap;
	transition: color 0.2s ease;
	cursor: pointer;
}

.pcw-form .pcw-help__toggle.pcw-help__toggle:is(:hover, :focus-visible) {
	background: none;
	color: var(--pcw-help-hover-color, var(--pcw-help-color, var(--pcw-accent, #1aa3c2)));
	text-decoration: underline;
	text-underline-offset: 4px;
	text-decoration-thickness: 1px;
}

.pcw-form .pcw-help__toggle.pcw-help__toggle:focus-visible {
	outline: 2px solid var(--pcw-accent, #1aa3c2);
	outline-offset: 3px;
	border-radius: 2px;
}

/* Editor-only hint under a widget. */
.pcw-editor-note {
	margin: 8px 0 0;
	color: #69727d;
	font: 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	text-align: center;
}
