/**
 * Villa Store: wp-login.php branding
 *
 * Enqueued on the login screen only, by the villa-login-branding must-use
 * plugin, with core's `login` stylesheet plus villa-fonts and villa-tokens as
 * dependencies, so this file always cascades last and can rely on the tokens.
 *
 * Presentation only. Nothing here changes authentication behaviour, and the
 * error and message boxes are restyled without altering their content or
 * keeping their meaning ambiguous: notices read blue, errors read Villa red.
 *
 * Selectors are prefixed body.login (and .button.button-primary for buttons) to
 * out-specify core's .login / .wp-core-ui rules without resorting to
 * !important.
 *
 * The logo URL is relative to this stylesheet, resolving to assets/logo/. That
 * keeps the theme path out of PHP and avoids an inline <style> block.
 */

/* -------------------------------------------------------------------------
 * 1. Page
 * ---------------------------------------------------------------------- */

/*
 * box-sizing, because style.css is NOT loaded here.
 *
 * wp-login.php is not a theme template, so it gets core's login stylesheet plus
 * this file and nothing else. The reset in style.css never runs, which means
 * padding is added to width in the default content-box model. #login below is
 * width: 100% with an inline padding, and without this the page was 32px wider
 * than a 390px viewport and scrolled sideways on a phone. That is the first
 * screen every staff member sees.
 */
body.login #login,
body.login #login * {
	box-sizing: border-box;
}

body.login {
	background-color: var(--color-surface);
	color: var(--color-text);
	font-family: var(--font-family-base);
	font-size: var(--font-size-base);
	line-height: var(--line-height-base);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

body.login #login {
	max-width: 26rem;
	padding-block: clamp(var(--space-lg), 8vh, var(--space-3xl)) var(--space-xl);
	padding-inline: var(--space-sm);
	width: 100%;
}

/* -------------------------------------------------------------------------
 * 2. Logo
 *
 * Core renders <h1 role="presentation"><a href="...">Site Name</a></h1>. The
 * link text is indented out of view and remains the link's accessible name; the
 * logo itself is this background image.
 * ---------------------------------------------------------------------- */

body.login h1 a {
	background-image: url("../logo/villa-logo-colour.svg");
	background-position: center center;
	background-repeat: no-repeat;
	background-size: contain;
	display: block;
	height: 4.5rem;
	margin: 0 auto var(--space-lg);
	max-width: 13.75rem;
	overflow: hidden;
	text-indent: -9999px;
	width: 100%;
}

body.login h1 a:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 4px;
}

/* -------------------------------------------------------------------------
 * 3. Form card
 * ---------------------------------------------------------------------- */

body.login form {
	background-color: var(--color-surface-raised);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	margin-top: 0;
	padding: var(--space-lg) var(--space-md);
}

body.login label {
	color: var(--color-text);
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-semibold);
	line-height: var(--line-height-snug);
}

body.login form .input,
body.login input[type="text"],
body.login input[type="email"],
body.login input[type="password"] {
	background-color: var(--color-bg);
	border: 1px solid var(--color-border-strong);
	border-radius: var(--radius-sm);
	box-shadow: none;
	color: var(--color-text);
	font-family: var(--font-family-base);
	font-size: var(--font-size-base);
	line-height: var(--line-height-snug);
	margin-block: var(--space-3xs) var(--space-sm);
	padding: var(--space-2xs) var(--space-xs);
	transition: border-color var(--duration-fast) var(--ease-out),
		box-shadow var(--duration-fast) var(--ease-out);
}

/*
 * The transparent outline is deliberate and follows core: Windows High Contrast
 * mode discards box-shadow but keeps outline, so the focus state survives there.
 */
body.login form .input:focus,
body.login input[type="text"]:focus,
body.login input[type="email"]:focus,
body.login input[type="password"]:focus {
	border-color: var(--color-primary);
	box-shadow: var(--shadow-focus);
	outline: 2px solid transparent;
}

/* Remember-me row: unfloated so the button below can run full width. */
body.login form .forgetmenot {
	float: none;
	margin-bottom: var(--space-sm);
}

body.login form .forgetmenot label {
	font-weight: var(--font-weight-regular);
}

body.login form p.submit {
	margin-bottom: 0;
}

/* Show/hide password toggle sits inside the field wrapper. */
body.login .wp-pwd button.wp-hide-pw {
	color: var(--color-muted);
}

body.login .wp-pwd button.wp-hide-pw:hover {
	color: var(--color-primary);
}

body.login .wp-pwd button.wp-hide-pw:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 0;
}

/* -------------------------------------------------------------------------
 * 4. Primary button
 * ---------------------------------------------------------------------- */

body.login .button.button-primary {
	background-color: var(--color-primary);
	border: 1px solid var(--color-primary);
	border-radius: var(--radius-sm);
	box-shadow: none;
	color: var(--color-on-primary);
	float: none;
	font-family: var(--font-family-base);
	font-size: var(--font-size-base);
	font-weight: var(--font-weight-semibold);
	height: auto;
	line-height: var(--line-height-snug);
	margin: 0;
	padding: var(--space-2xs) var(--space-sm);
	text-shadow: none;
	transition: background-color var(--duration-fast) var(--ease-out),
		border-color var(--duration-fast) var(--ease-out);
	width: 100%;
}

body.login .button.button-primary:hover,
body.login .button.button-primary:active {
	background-color: var(--color-primary-hover);
	border-color: var(--color-primary-hover);
	color: var(--color-on-primary);
}

body.login .button.button-primary:focus-visible {
	box-shadow: none;
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * 5. Supporting links
 *
 * Core prints three things under the card, as separate siblings: #nav, then a
 * <script>, then #backtoblog, then .privacy-policy-page-link. Only the first is
 * wanted.
 * ---------------------------------------------------------------------- */

/*
 * "Lost your password?" as a button, at the client's request.
 *
 * A secondary one: outlined rather than filled, so it stays clearly the lesser of
 * the two actions next to the solid Log In directly above it. Making it as heavy
 * as the primary would give the screen two equal calls to action, and the common
 * case is signing in.
 *
 * Styling #nav a rather than the specific link covers the other login screens for
 * free: the same element carries "Log in" and "Register" on the lost-password and
 * registration views, and they want the same treatment.
 */
body.login #nav {
	margin: var(--space-sm) 0 0;
	padding: 0;
}

body.login #nav a {
	background-color: var(--color-bg);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
	color: var(--color-text);
	display: block;
	font-size: var(--font-size-base);
	font-weight: var(--font-weight-semibold);
	line-height: var(--line-height-snug);
	padding: var(--space-2xs) var(--space-sm);
	/*
	 * The button centres its own label. It used to inherit centring from #login,
	 * which was only there to lay out the two links that have since been removed.
	 */
	text-align: center;
	text-decoration: none;
	transition: background-color var(--duration-fast) var(--ease-out),
		border-color var(--duration-fast) var(--ease-out),
		color var(--duration-fast) var(--ease-out);
	width: 100%;
}

body.login #nav a:hover {
	background-color: var(--color-surface);
	border-color: var(--color-primary);
	color: var(--color-primary);
}

body.login #nav a:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

/*
 * "Go to VilaCrop" and "Privacy Policy" are removed, at the client's request.
 *
 * Done in CSS rather than PHP because core prints #backtoblog inline inside
 * login_footer() and offers no filter to unhook it. display: none takes both out
 * of the accessibility tree and out of the tab order, so they are genuinely gone
 * for every visitor rather than merely invisible.
 *
 * The privacy link does have a proper filter, the_privacy_policy_link, which would
 * drop it from the markup altogether. It is deliberately not used, so that both
 * links stay governed by one rule in one place instead of two mechanisms in two
 * files.
 *
 * To bring them back, delete this rule and restore the one-row layout described
 * under "Login screen, 0.22.0" in HANDOVER.md. The part that is easy to miss:
 * .privacy-policy-page-link needs width: auto, because core sets it to 100% and a
 * full-width inline-block still takes a line to itself.
 */
body.login #backtoblog,
body.login .privacy-policy-page-link {
	display: none;
}

/* -------------------------------------------------------------------------
 * 6. Notices
 *
 * Restyled, not rewritten. Core still decides what is said and when.
 * ---------------------------------------------------------------------- */

body.login .message,
body.login .success,
body.login #login_error {
	background-color: var(--color-surface-raised);
	border: 1px solid var(--color-border);
	border-inline-start: 4px solid var(--color-primary);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-xs);
	color: var(--color-text);
	font-size: var(--font-size-sm);
	margin-inline-start: 0;
	padding: var(--space-xs) var(--space-sm);
}

body.login #login_error {
	border-inline-start-color: var(--color-accent);
}

body.login .message a,
body.login #login_error a {
	color: var(--color-primary);
}

/* -------------------------------------------------------------------------
 * 7. Entrance animation
 *
 * Opt-in rather than opt-out: the animation only exists inside the
 * no-preference query, so anyone asking for reduced motion gets a static page
 * with nothing to override. CSS only, no GSAP on the login screen.
 * ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
	@keyframes villa-login-enter {
		from {
			opacity: 0;
			transform: translateY(8px);
		}

		to {
			opacity: 1;
			transform: none;
		}
	}

	body.login #login {
		animation: villa-login-enter var(--duration-slow) var(--ease-out) both;
	}
}

/* -------------------------------------------------------------------------
 * 8. Microsoft sign-in
 *
 * Every rule here is scoped to body.villa-sso, which the villa-sso must-use
 * plugin adds only once SSO is fully configured. Until then the plugin's button
 * is unhooked and none of this applies, so the screen is exactly sections 1 to 7.
 *
 * Order on screen: logo, Microsoft button, hint, then the password card. The
 * Microsoft button becomes the filled primary action and Log In drops to the
 * outlined secondary style of #nav a, so there is still only one solid call to
 * action. Log In stays visible because it is the break-glass route for
 * administrators.
 *
 * The plugin prints the wrapper with an inline style="margin: 1em 0;
 * text-align: center;". That spacing is acceptable and is left alone rather than
 * fought with !important.
 * ---------------------------------------------------------------------- */

body.login.villa-sso .openid-connect-login-button a.button {
	background-color: var(--color-primary);
	border: 1px solid var(--color-primary);
	border-radius: var(--radius-sm);
	box-shadow: none;
	color: var(--color-on-primary);
	display: block;
	font-family: var(--font-family-base);
	font-size: var(--font-size-base);
	font-weight: var(--font-weight-semibold);
	height: auto;
	line-height: var(--line-height-snug);
	min-height: 0;
	padding: var(--space-2xs) var(--space-sm);
	text-shadow: none;
	transition: background-color var(--duration-fast) var(--ease-out),
		border-color var(--duration-fast) var(--ease-out);
	white-space: normal;
	width: 100%;
}

body.login.villa-sso .openid-connect-login-button a.button:hover,
body.login.villa-sso .openid-connect-login-button a.button:active {
	background-color: var(--color-primary-hover);
	border-color: var(--color-primary-hover);
	color: var(--color-on-primary);
}

body.login.villa-sso .openid-connect-login-button a.button:focus {
	box-shadow: none;
}

body.login.villa-sso .openid-connect-login-button a.button:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

body.login.villa-sso .villa-sso-hint {
	color: var(--color-muted);
	font-size: var(--font-size-sm);
	line-height: var(--line-height-snug);
	margin: 0 0 var(--space-md);
	text-align: center;
}

/* Log In, demoted to match the outlined #nav a button in section 5. */
body.login.villa-sso .button.button-primary {
	background-color: var(--color-bg);
	border-color: var(--color-border);
	color: var(--color-text);
}

body.login.villa-sso .button.button-primary:hover,
body.login.villa-sso .button.button-primary:active {
	background-color: var(--color-surface);
	border-color: var(--color-primary);
	color: var(--color-primary);
}
