/*
 * W4 sign-in pages. Two layers:
 *   1. .w4wf-login       our own screens (/sign-in/).
 *   2. .w4wf-login-core  the screens wp-login.php still draws (wp-admin pop-up, the host's two-step step,
 *                         the fallback link), restyled from the standard markup.
 * Phone first: one column, full-width card, 16px+ inputs (no iOS zoom), 48px buttons, safe-area padding.
 * Needs brand-tokens.css.
 */

/* ---------------------------------------------------------------- 1. Our screens */

.w4wf-login-html {
	background: var(--w4-bg);
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

.w4wf-login {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	background: var(--w4-bg);
	color: var(--w4-text);
	font-family: var(--w4-font);
	font-size: 16px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	position: relative;
	overflow-x: hidden;
}

.w4wf-login *,
.w4wf-login *::before,
.w4wf-login *::after {
	box-sizing: border-box;
}

.w4wf-spectrum {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: var(--w4-spectrum);
	z-index: 3;
}

/* Background photo: large screens only, dimmed so the card stays readable. */
.w4wf-login__photo {
	display: none;
}

@media (min-width: 900px) {
	.w4wf-login--photo .w4wf-login__photo {
		display: block;
		position: fixed;
		inset: 0;
		background-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.88)), var(--w4-login-photo, none);
		background-size: cover;
		background-position: center;
		z-index: 0;
	}
}

/* A soft glow of the brand color behind the card on every screen size. */
.w4wf-login::before {
	content: "";
	position: fixed;
	inset: -20vh -20vw auto;
	height: 70vh;
	background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--w4-purple) 22%, transparent), transparent 70%);
	pointer-events: none;
	z-index: 0;
}

.w4wf-login__main {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 440px;
	margin: 0 auto;
	padding:
		calc(28px + env(safe-area-inset-top, 0px))
		max(16px, env(safe-area-inset-right, 0px))
		calc(24px + env(safe-area-inset-bottom, 0px))
		max(16px, env(safe-area-inset-left, 0px));
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
}

.w4wf-login__brand {
	text-align: center;
	margin: 8px 0 20px;
}

.w4wf-login__logo {
	display: block;
	margin: 0 auto;
	max-width: 200px;
	max-height: 72px;
	width: auto;
	height: auto;
}

.w4wf-login__logo--icon {
	width: 64px;
	height: 64px;
	border-radius: 16px;
}

.w4wf-login__company {
	margin: 10px 0 0;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: var(--w4-text-2);
}

.w4wf-card {
	background: var(--w4-panel);
	border: 1px solid var(--w4-border);
	border-radius: var(--w4-radius);
	padding: 28px 22px 24px;
	box-shadow: var(--w4-shadow);
	animation: w4wf-rise 220ms ease-out both;
}

@keyframes w4wf-rise {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.w4wf-card__title {
	margin: 0 0 6px;
	font-size: 1.625rem;
	line-height: 1.2;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--w4-text);
}

.w4wf-card__lead {
	margin: 0 0 20px;
	color: var(--w4-text-2);
}

.w4wf-card__links {
	margin: 18px 0 0;
	text-align: center;
	font-size: 0.9375rem;
}

/* Text links are touch targets too: at least 44px tall. */
.w4wf-card__links a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 8px;
}

.w4wf-login a {
	color: var(--w4-focus);
	text-underline-offset: 3px;
}

.w4wf-login a:hover {
	color: var(--w4-text);
}

.w4wf-login :focus-visible {
	outline: 2px solid var(--w4-focus);
	outline-offset: 2px;
}

/* Forms */

.w4wf-form {
	margin: 0;
}

.w4wf-form--inline {
	margin-top: 14px;
	display: flex;
	flex-wrap: wrap;
	gap: 4px 10px;
	align-items: baseline;
	justify-content: center;
}

.w4wf-field {
	margin: 0 0 16px;
}

.w4wf-label {
	display: block;
	margin: 0 0 6px;
	font-weight: 600;
	font-size: 0.9375rem;
	color: var(--w4-text);
}

.w4wf-input {
	display: block;
	width: 100%;
	min-height: 48px;
	padding: 12px 14px;
	font: inherit;
	font-size: 1rem;
	color: var(--w4-text);
	background: var(--w4-panel-2);
	border: 1px solid var(--w4-border-input, #686874);
	border-radius: var(--w4-radius-sm);
	transition: border-color 120ms ease, box-shadow 120ms ease;
	-webkit-appearance: none;
	appearance: none;
}

.w4wf-input::placeholder {
	color: var(--w4-muted);
}

.w4wf-input:focus {
	outline: none;
	border-color: var(--w4-purple);
	box-shadow: var(--w4-focus-ring);
}

.w4wf-input--backup {
	font-family: var(--w4-font-mono);
	font-size: 1.25rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	text-align: center;
}

/* Browsers paint autofilled fields light; keep them on the dark panel. */
.w4wf-input:-webkit-autofill,
.w4wf-input:-webkit-autofill:hover,
.w4wf-input:-webkit-autofill:focus {
	-webkit-text-fill-color: var(--w4-text);
	-webkit-box-shadow: 0 0 0 1000px var(--w4-panel-2) inset;
	caret-color: var(--w4-text);
}

.w4wf-reveal {
	position: relative;
}

.w4wf-reveal.is-enhanced .w4wf-input {
	padding-right: 76px;
}

.w4wf-reveal__toggle {
	position: absolute;
	top: 2px;
	right: 2px;
	bottom: 2px;
	min-width: 64px;
	min-height: 44px;
	padding: 0 12px;
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--w4-text-2);
	background: transparent;
	border: 0;
	border-radius: 8px;
	cursor: pointer;
}

.w4wf-reveal__toggle:hover {
	color: var(--w4-text);
	background: var(--w4-border);
}

.w4wf-check {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin: 4px 0 20px;
	min-height: 44px;
	padding: 10px 0;
	cursor: pointer;
	color: var(--w4-text-2);
}

.w4wf-check input {
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	margin: 1px 0 0;
	accent-color: var(--w4-purple);
}

.w4wf-button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
	padding: 12px 20px;
	font: inherit;
	font-size: 1.0625rem;
	font-weight: 700;
	letter-spacing: 0.01em;
	color: var(--w4-on-purple-dark);
	background: var(--w4-purple-dark);
	border: 0;
	border-radius: 999px;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 120ms ease, transform 80ms ease;
}

.w4wf-login a.w4wf-button {
	color: var(--w4-on-purple-dark);
	text-decoration: none;
}

.w4wf-button:hover {
	/* The background stays on the button color (white text on the lighter purple is under 4.5:1). */
	background: var(--w4-purple-dark);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--w4-purple) 45%, transparent);
}

.w4wf-button:active {
	transform: scale(0.99);
}

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

.w4wf-button--ghost,
.w4wf-login a.w4wf-button--ghost {
	color: var(--w4-text);
	background: transparent;
	border: 1px solid var(--w4-border);
}

.w4wf-button--ghost:hover {
	background: var(--w4-panel-2);
}

.w4wf-link-button {
	min-height: 44px;
	padding: 8px 6px;
	font: inherit;
	font-weight: 600;
	color: var(--w4-focus);
	background: none;
	border: 0;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.w4wf-link-button[disabled] {
	color: var(--w4-muted);
	text-decoration: none;
	cursor: default;
}

.w4wf-hint {
	color: var(--w4-muted);
	font-size: 0.875rem;
}

.w4wf-hooks:empty {
	display: none;
}

.w4wf-hooks {
	margin: 0 0 12px;
}

/* Notices */

.w4wf-notice {
	margin: 0 0 18px;
	padding: 12px 14px;
	border-radius: var(--w4-radius-sm);
	border: 1px solid var(--w4-border);
	background: var(--w4-panel-2);
	color: var(--w4-text);
}

.w4wf-notice p {
	margin: 0;
}

.w4wf-notice p + p {
	margin-top: 6px;
}

.w4wf-notice--error {
	border-color: color-mix(in srgb, var(--w4-red) 55%, var(--w4-border));
	background: color-mix(in srgb, var(--w4-red) 12%, var(--w4-panel-2));
}

.w4wf-notice--ok {
	border-color: color-mix(in srgb, var(--w4-green) 50%, var(--w4-border));
	background: color-mix(in srgb, var(--w4-green) 10%, var(--w4-panel-2));
}

.w4wf-notice--info {
	border-color: color-mix(in srgb, var(--w4-purple) 50%, var(--w4-border));
}

.w4wf-steps {
	margin: 0 0 20px;
	padding: 0 0 0 20px;
	color: var(--w4-text-2);
}

.w4wf-steps li + li {
	margin-top: 6px;
}

.w4wf-icon {
	display: grid;
	place-items: center;
	width: 64px;
	height: 64px;
	margin: 0 0 14px;
	border-radius: 50%;
	color: var(--w4-purple);
	background: color-mix(in srgb, var(--w4-purple) 14%, var(--w4-panel-2));
}

.w4wf-icon--warn {
	color: var(--w4-amber);
	background: color-mix(in srgb, var(--w4-amber) 14%, var(--w4-panel-2));
}

/* Two-step: method tabs */

.w4wf-tabs {
	display: flex;
	gap: 4px;
	margin: 0 0 18px;
	padding: 4px;
	background: var(--w4-panel-2);
	border: 1px solid var(--w4-border);
	border-radius: 999px;
	overflow-x: auto;
	scrollbar-width: none;
}

.w4wf-tab {
	flex: 1 0 auto;
	min-height: 44px;
	padding: 8px 12px;
	border-radius: 999px;
	text-align: center;
	font-size: 0.9375rem;
	font-weight: 600;
	white-space: nowrap;
}

.w4wf-login a.w4wf-tab {
	color: var(--w4-text-2);
	text-decoration: none;
}

.w4wf-login a.w4wf-tab.is-current {
	color: var(--w4-on-purple-dark);
	background: var(--w4-purple-dark);
}

/* Two-step: six boxes drawn behind one real field, so paste and the phone's code autofill just work. */

.w4wf-code {
	--w4-cell: clamp(2.25rem, 11vw, 3rem);
	--w4-gap: 0.5rem;
	position: relative;
	width: calc(var(--w4-cell) * 6 + var(--w4-gap) * 5);
	max-width: 100%;
	height: 3.5rem;
	margin: 0 auto;
	overflow: hidden;
	border-radius: var(--w4-radius-sm);
}

.w4wf-code__cells {
	position: absolute;
	inset: 0;
	display: grid;
	grid-template-columns: repeat(6, var(--w4-cell));
	gap: var(--w4-gap);
	pointer-events: none;
}

.w4wf-code__cells span {
	background: var(--w4-panel-2);
	border: 1px solid var(--w4-border-input, #686874);
	border-radius: var(--w4-radius-sm);
	transition: border-color 120ms ease, box-shadow 120ms ease;
}

.w4wf-code__cells span.is-active {
	border-color: var(--w4-purple);
	box-shadow: var(--w4-focus-ring);
}

.w4wf-code__cells span.is-filled {
	border-color: color-mix(in srgb, var(--w4-purple) 55%, var(--w4-border-input, #686874));
}

.w4wf-code__input {
	position: absolute;
	top: 0;
	left: 0;
	/* Wider than the boxes so the spacing after the last digit never scrolls the text. */
	width: calc(var(--w4-cell) * 6 + var(--w4-gap) * 7 + 2ch);
	height: 100%;
	margin: 0;
	padding: 0 0 0 calc((var(--w4-cell) - 1ch) / 2);
	font-family: var(--w4-font-mono);
	font-size: 1.5rem;
	font-weight: 700;
	letter-spacing: calc(var(--w4-cell) + var(--w4-gap) - 1ch);
	color: var(--w4-text);
	caret-color: var(--w4-purple);
	background: transparent;
	border: 0;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.w4wf-code:focus-within {
	outline: 2px solid var(--w4-focus);
	outline-offset: 3px;
}

/* Two-step: help */

.w4wf-help {
	margin: 20px 0 0;
	border-top: 1px solid var(--w4-border);
	padding-top: 14px;
}

.w4wf-help summary {
	min-height: 44px;
	display: flex;
	align-items: center;
	cursor: pointer;
	font-weight: 600;
	color: var(--w4-focus);
}

.w4wf-help__body {
	color: var(--w4-text-2);
	font-size: 0.9375rem;
}

.w4wf-help__body p {
	margin: 8px 0;
}

.w4wf-help__list {
	margin: 4px 0 12px;
	padding: 0;
	list-style: none;
}

.w4wf-help__list a {
	display: flex;
	align-items: center;
	min-height: 44px;
}

/* Password strength */

.w4wf-strength {
	min-height: 1.5em;
	margin: 8px 0 0;
	font-size: 0.875rem;
	color: var(--w4-muted);
}

.w4wf-strength[data-score="0"],
.w4wf-strength[data-score="1"] {
	color: #FF8A8A;
}

.w4wf-strength[data-score="2"] {
	color: var(--w4-amber);
}

.w4wf-strength[data-score="3"],
.w4wf-strength[data-score="4"] {
	color: var(--w4-green);
}

/* Footer */

.w4wf-login__footer {
	margin-top: auto;
	padding-top: 24px;
	text-align: center;
	font-size: 0.875rem;
	color: var(--w4-muted);
}

.w4wf-login__footer p {
	margin: 4px 0;
}

.w4wf-login__support a {
	font-weight: 600;
	white-space: nowrap;
}

.w4wf-login__company-line {
	letter-spacing: 0.04em;
}

.w4wf-visually-hidden {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

.w4wf-js .w4wf-js-hide {
	display: none;
}

/* The Team App's setup wizard sits inside the card. */
.w4wf-security-root:empty {
	min-height: 120px;
}

/* Phones: the card fills the width. */
@media (max-width: 480px) {
	.w4wf-login__main {
		padding-left: max(12px, env(safe-area-inset-left, 0px));
		padding-right: max(12px, env(safe-area-inset-right, 0px));
	}

	.w4wf-card {
		padding: 24px 18px 20px;
		border-radius: 14px;
	}

	.w4wf-card__title {
		font-size: 1.5rem;
	}
}

@media (min-width: 900px) {
	.w4wf-login__main {
		justify-content: center;
	}

	.w4wf-login__footer {
		margin-top: 0;
	}
}

/* ---------------------------------------------------------------- 2. Screens drawn by wp-login.php */

body.w4wf-login-core {
	background: var(--w4-bg);
	color: var(--w4-text);
	font-family: var(--w4-font);
	font-size: 16px;
}

body.w4wf-login-core::before {
	content: "";
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: var(--w4-spectrum);
	z-index: 3;
}

body.w4wf-login-core #login {
	width: 100%;
	max-width: 420px;
	padding: calc(40px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

body.w4wf-login-core.interim-login #login {
	padding-top: 24px;
}

body.w4wf-login-core .login h1 a,
body.w4wf-login-core #login h1 a {
	background-image: var(--w4-login-logo, none);
	background-size: contain;
	background-position: center;
	background-repeat: no-repeat;
	width: 200px;
	height: 72px;
	margin: 0 auto 20px;
}

body.w4wf-login-core .login form,
body.w4wf-login-core #loginform,
body.w4wf-login-core #lostpasswordform,
body.w4wf-login-core #resetpassform {
	background: var(--w4-panel);
	border: 1px solid var(--w4-border);
	border-radius: var(--w4-radius);
	box-shadow: var(--w4-shadow);
	padding: 24px 22px;
	color: var(--w4-text);
}

body.w4wf-login-core .login label,
body.w4wf-login-core .login form .forgetmenot label {
	color: var(--w4-text);
	font-size: 0.9375rem;
	font-weight: 600;
}

body.w4wf-login-core .login form .input,
body.w4wf-login-core .login input[type="text"],
body.w4wf-login-core .login input[type="password"],
body.w4wf-login-core .login input[type="email"],
body.w4wf-login-core .login input[type="number"] {
	min-height: 48px;
	font-size: 1rem;
	color: var(--w4-text);
	background: var(--w4-panel-2);
	border: 1px solid var(--w4-border-input, #686874);
	border-radius: var(--w4-radius-sm);
	box-shadow: none;
}

body.w4wf-login-core .login input:focus {
	border-color: var(--w4-purple);
	box-shadow: var(--w4-focus-ring);
	outline: none;
}

body.w4wf-login-core .login .button.wp-hide-pw {
	color: var(--w4-text-2);
	min-height: 48px;
}

body.w4wf-login-core .login .button-primary,
body.w4wf-login-core .login input[type="submit"],
body.w4wf-login-core .login button[type="submit"] {
	min-height: 48px;
	padding: 0 22px;
	font-size: 1rem;
	font-weight: 700;
	color: var(--w4-on-purple-dark);
	background: var(--w4-purple-dark);
	border: 0;
	border-radius: 999px;
	box-shadow: none;
	text-shadow: none;
}

body.w4wf-login-core .login .button-primary:hover,
body.w4wf-login-core .login .button-primary:focus {
	background: var(--w4-purple-dark);
	color: var(--w4-on-purple-dark);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--w4-purple) 45%, transparent);
}

body.w4wf-login-core .login .button-primary:focus-visible {
	outline: 2px solid var(--w4-focus);
	outline-offset: 2px;
}

body.w4wf-login-core .login .message,
body.w4wf-login-core .login .notice,
body.w4wf-login-core .login .success,
body.w4wf-login-core #login_error {
	background: var(--w4-panel-2);
	color: var(--w4-text);
	border: 1px solid var(--w4-border);
	border-left: 4px solid var(--w4-purple);
	border-radius: var(--w4-radius-sm);
	box-shadow: none;
}

body.w4wf-login-core #login_error,
body.w4wf-login-core .login .notice-error {
	border-left-color: var(--w4-red);
}

body.w4wf-login-core .login #nav,
body.w4wf-login-core .login #backtoblog,
body.w4wf-login-core .privacy-policy-page-link {
	text-align: center;
	font-size: 0.9375rem;
}

body.w4wf-login-core .login #nav a,
body.w4wf-login-core .login #backtoblog a,
body.w4wf-login-core .privacy-policy-page-link a,
body.w4wf-login-core .login a {
	color: var(--w4-focus);
}

body.w4wf-login-core .login #nav a:hover,
body.w4wf-login-core .login #backtoblog a:hover {
	color: var(--w4-text);
}

body.w4wf-login-core .login *:focus-visible {
	outline: 2px solid var(--w4-focus);
	outline-offset: 2px;
}

/* Language switcher is turned off, but some hosts print it anyway. */
body.w4wf-login-core .language-switcher {
	display: none;
}

/* ---------------------------------------------------------------- Reduced motion */

@media (prefers-reduced-motion: reduce) {
	.w4wf-card {
		animation: none;
	}

	.w4wf-login *,
	body.w4wf-login-core * {
		transition: none !important;
		animation: none !important;
		scroll-behavior: auto !important;
	}
}

/* High contrast / forced colors: keep borders visible. */
@media (forced-colors: active) {
	.w4wf-card,
	.w4wf-input,
	.w4wf-code__cells span,
	.w4wf-button {
		border: 1px solid CanvasText;
	}
}
