/*
 * BTP Portal — the sign-in screen at /btp-portal.
 *
 * This file has to win an argument with wp-admin/css/login.min.css, which is
 * loaded first and which styles the same elements through ID selectors:
 * `#login`, `#loginform`, `#nav`, `#backtoblog`, `#wp-submit`. A class-only
 * rule here would lose silently and the page would come out half-restyled —
 * the exact failure the theme notes on this project describe. So every rule
 * below is anchored on `body.login`, which adds a type and a class on top of
 * whatever core brought, and the ones that override an ID rule carry that ID
 * as well.
 *
 * Colours come from the LOGO, not from the dashboards. The mark is crimson
 * #c8102e and navy #12233d; admin-home.css and marketplace.css use emerald,
 * which belongs to the signed-in product and would read here as a different
 * company's login page. Emerald survives in exactly one place — the success
 * notice — because that meaning is shared.
 *
 * Layout: the brand panel is FIXED, not a grid or flex sibling of the card.
 * wp-login.php puts a screen-reader <h1>, an inline <script> and sometimes a
 * language switcher between the two elements, and those children differ per
 * action — so a layout built on sibling position works on the login screen and
 * falls apart on password reset. Taking the panel out of flow and paying for
 * it with padding on <body> is immune to all of that.
 */

/* ------------------------------------------------------------------
 * 1. Tokens
 * ------------------------------------------------------------------ */

body.login.btp-portal {
	--btp-navy: #12233d;
	--btp-navy-deep: #0a1526;
	--btp-navy-soft: #1e3a5f;
	--btp-red: #c8102e;
	--btp-red-dark: #a00c24;
	--btp-ink: #0f172a;
	--btp-muted: #64748b;
	--btp-line: #e2e8f0;
	--btp-line-strong: #cbd5e1;
	--btp-card: #ffffff;
	--btp-page: #eef1f6;
	--btp-radius: 16px;
	--btp-brand-w: clamp(380px, 42vw, 620px);
}

/* ------------------------------------------------------------------
 * 2. The page
 * ------------------------------------------------------------------ */

body.login.btp-portal {
	min-height: 100vh;
	min-height: 100dvh;
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 40px 24px;
	padding-left: calc(var(--btp-brand-w) + 40px);
	background: var(--btp-page);
	color: var(--btp-ink);
	font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

/* Core's own wrappers that would otherwise show up as flex items with a gap
 * around them. The <script> tags are display:none by the UA stylesheet. */
body.login.btp-portal > .clear {
	display: none;
}

/* Belt and braces: core defines .screen-reader-text, but if it ever stops
 * doing so on this screen the hidden <h1> becomes a visible flex item. */
body.login.btp-portal .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	border: 0;
	white-space: nowrap;
}

/* The WordPress mark. The brand panel carries the real logo, on every width. */
body.login.btp-portal h1.wp-login-logo {
	display: none;
}

/* ------------------------------------------------------------------
 * 3. Brand panel
 * ------------------------------------------------------------------ */

.btp-portal-brand {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	width: var(--btp-brand-w);
	display: flex;
	align-items: center;
	padding: 48px clamp(32px, 4vw, 64px);
	overflow: auto;
	color: #fff;
	background:
		radial-gradient(900px 460px at 8% 4%, rgba(200, 16, 46, .30), transparent 62%),
		radial-gradient(760px 520px at 92% 96%, rgba(30, 58, 95, .85), transparent 66%),
		linear-gradient(158deg, var(--btp-navy-deep) 0%, var(--btp-navy) 54%, #1b3355 100%);
}

/* A fine dot field, faded out downwards. Cheap, and it stops the panel
 * reading as a flat block of navy on a large monitor. */
.btp-portal-brand::after {
	content: "";
	position: absolute;
	inset: 0;
	background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px);
	background-size: 22px 22px;
	-webkit-mask-image: linear-gradient(to bottom, #000, transparent 78%);
	mask-image: linear-gradient(to bottom, #000, transparent 78%);
	pointer-events: none;
}

.btp-portal-brand__inner {
	position: relative;
	z-index: 1;
	max-width: 460px;
}

/* The logo is crimson-and-navy artwork on transparency: on this panel the navy
 * half would simply disappear, so it sits on a white chip. */
.btp-portal-brand__logo {
	display: inline-block;
	padding: 14px 20px;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .9);
	line-height: 0;
}

.btp-portal-brand__img {
	display: block;
	width: auto;
	max-width: 232px;
	height: auto;
}

.btp-portal-brand__wordmark {
	display: block;
	font-size: 20px;
	font-weight: 800;
	line-height: 1.2;
	color: var(--btp-navy);
	letter-spacing: -.01em;
}

.btp-portal-brand__title {
	margin: 34px 0 0;
	font-size: clamp(28px, 2.6vw, 38px);
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: -.02em;
	color: #fff;
}

.btp-portal-brand__lede {
	margin: 14px 0 0;
	font-size: 16px;
	line-height: 1.6;
	color: rgba(255, 255, 255, .76);
}

.btp-portal-brand__points {
	margin: 30px 0 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 13px;
}

.btp-portal-brand__points li {
	position: relative;
	margin: 0;
	padding-left: 32px;
	font-size: 14.5px;
	line-height: 1.5;
	color: rgba(255, 255, 255, .88);
}

/* A crimson tick, drawn in CSS so the panel carries no image request. */
.btp-portal-brand__points li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--btp-red);
	box-shadow: 0 0 0 4px rgba(200, 16, 46, .18);
}

.btp-portal-brand__points li::after {
	content: "";
	position: absolute;
	left: 6px;
	top: 7px;
	width: 5px;
	height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.btp-portal-brand__foot {
	margin: 38px 0 0;
	font-size: 13.5px;
	color: rgba(255, 255, 255, .6);
}

.btp-portal-brand__foot a {
	color: #fff;
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-color: rgba(255, 255, 255, .45);
}

.btp-portal-brand__foot a:hover,
.btp-portal-brand__foot a:focus {
	text-decoration-color: #fff;
}

/* ------------------------------------------------------------------
 * 4. The card — #login, restyled
 * ------------------------------------------------------------------ */

body.login.btp-portal #login {
	width: min(430px, 100%);
	max-width: 100%;
	margin: 0;
	padding: 30px 30px 24px;
	background: var(--btp-card);
	border: 1px solid var(--btp-line);
	border-radius: var(--btp-radius);
	box-shadow:
		0 1px 2px rgba(10, 21, 38, .04),
		0 18px 44px -20px rgba(10, 21, 38, .28);
}

/* Core gives the form its own white box, border and shadow. Inside a card that
 * is a box in a box. */
body.login.btp-portal #login form {
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	overflow: visible;
}

body.login.btp-portal #login form > p,
body.login.btp-portal #login form > div {
	margin: 0 0 15px;
}

body.login.btp-portal #login form > p.submit,
body.login.btp-portal #login form > p:last-child {
	margin-bottom: 0;
}

/* Card header */

.btp-portal-head {
	margin: 0 0 20px;
}

.btp-portal-head__eyebrow {
	margin: 0;
	font-size: 11.5px;
	font-weight: 700;
	letter-spacing: .13em;
	text-transform: uppercase;
	color: var(--btp-red);
}

.btp-portal-head__title {
	margin: 7px 0 0;
	font-size: 23px;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -.01em;
	color: var(--btp-navy);
}

.btp-portal-head__sub {
	margin: 6px 0 0;
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--btp-muted);
}

/* ------------------------------------------------------------------
 * 6. Fields
 * ------------------------------------------------------------------ */

body.login.btp-portal #login label {
	display: block;
	margin: 0 0 6px;
	font-size: 12.5px;
	font-weight: 600;
	line-height: 1.4;
	color: var(--btp-navy);
}

body.login.btp-portal #login input[type="text"],
body.login.btp-portal #login input[type="email"],
body.login.btp-portal #login input[type="password"],
body.login.btp-portal #login input[type="search"],
body.login.btp-portal #login .input {
	display: block;
	width: 100%;
	height: 46px;
	margin: 0;
	padding: 0 14px;
	font-size: 15px;
	line-height: 44px;
	color: var(--btp-ink);
	background: #fff;
	border: 1.5px solid var(--btp-line-strong);
	border-radius: 11px;
	box-shadow: none;
	outline: 0;
	transition: border-color .15s ease, box-shadow .15s ease;
}

body.login.btp-portal #login input[type="text"]:hover,
body.login.btp-portal #login input[type="email"]:hover,
body.login.btp-portal #login input[type="password"]:hover,
body.login.btp-portal #login .input:hover {
	border-color: #94a3b8;
}

body.login.btp-portal #login input[type="text"]:focus,
body.login.btp-portal #login input[type="email"]:focus,
body.login.btp-portal #login input[type="password"]:focus,
body.login.btp-portal #login .input:focus {
	border-color: var(--btp-navy);
	box-shadow: 0 0 0 3px rgba(18, 35, 61, .14);
}

/* Password field: core drops an absolutely positioned eye button inside. */
body.login.btp-portal #login .wp-pwd {
	position: relative;
}

body.login.btp-portal #login .wp-pwd input[type="password"],
body.login.btp-portal #login .wp-pwd input[type="text"] {
	padding-right: 48px;
}

body.login.btp-portal #login .wp-hide-pw {
	position: absolute;
	top: 0;
	right: 0;
	width: 44px;
	height: 46px;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--btp-muted);
	background: none;
	border: 0;
	border-radius: 0 11px 11px 0;
	box-shadow: none;
	line-height: 1;
}

body.login.btp-portal #login .wp-hide-pw:hover,
body.login.btp-portal #login .wp-hide-pw:focus {
	color: var(--btp-navy);
	background: #f1f5f9;
	box-shadow: none;
	outline: 0;
}

body.login.btp-portal #login .wp-hide-pw:focus-visible {
	outline: 2px solid var(--btp-navy);
	outline-offset: -2px;
}

body.login.btp-portal #login .wp-hide-pw .dashicons {
	width: 20px;
	height: 20px;
	font-size: 20px;
}

/* Remember me */
body.login.btp-portal #login .forgetmenot {
	float: none;
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 18px;
	font-size: 0;
}

body.login.btp-portal #login .forgetmenot label {
	display: inline;
	margin: 0;
	font-size: 13px;
	font-weight: 500;
	color: var(--btp-muted);
	cursor: pointer;
}

body.login.btp-portal #login input[type="checkbox"] {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	margin: 0;
	border: 1.5px solid var(--btp-line-strong);
	border-radius: 5px;
	background: #fff;
	box-shadow: none;
	transition: background-color .15s ease, border-color .15s ease;
}

body.login.btp-portal #login input[type="checkbox"]:checked {
	background: var(--btp-navy);
	border-color: var(--btp-navy);
}

body.login.btp-portal #login input[type="checkbox"]:checked::before {
	content: "";
	display: block;
	width: 4px;
	height: 8px;
	margin: 2px 0 0 5px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
	background: none;
	color: transparent;
	float: none;
}

body.login.btp-portal #login input[type="checkbox"]:focus-visible {
	outline: 2px solid var(--btp-navy);
	outline-offset: 2px;
}

/*
 * The "Remember Me" help tip. WordPress 7.1 ships it as a .wp-tooltip button
 * plus a native [popover]; left alone it is a heavy black dashicon next to a
 * muted label. Note that .forgetmenot sets font-size:0 to kill the whitespace
 * between the checkbox and its label, so both the icon and the popover need an
 * explicit size or the panel opens empty-looking.
 */
body.login.btp-portal #login .wp-tooltip {
	display: inline-flex;
	align-items: center;
}

body.login.btp-portal #login .wp-tooltip__toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	padding: 0;
	color: #94a3b8;
	background: none;
	border: 0;
	border-radius: 50%;
	box-shadow: none;
	cursor: pointer;
}

body.login.btp-portal #login .wp-tooltip__toggle:hover {
	color: var(--btp-navy);
	background: #eef2f7;
}

body.login.btp-portal #login .wp-tooltip__toggle:focus-visible {
	outline: 2px solid var(--btp-navy);
	outline-offset: 1px;
}

body.login.btp-portal #login .wp-tooltip__toggle .dashicons {
	width: 17px;
	height: 17px;
	font-size: 17px;
}

body.login.btp-portal #login [popover] {
	max-width: 270px;
	padding: 10px 12px;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--btp-ink);
	background: #fff;
	border: 1px solid var(--btp-line);
	border-radius: 10px;
	box-shadow: 0 12px 30px -14px rgba(10, 21, 38, .55);
}

/* ------------------------------------------------------------------
 * 7. Submit
 * ------------------------------------------------------------------ */

body.login.btp-portal #login .submit,
body.login.btp-portal #login p.submit {
	margin: 0;
}

body.login.btp-portal #login #wp-submit,
body.login.btp-portal #login .button-primary {
	display: block;
	float: none;
	width: 100%;
	height: 48px;
	margin: 0;
	padding: 0 18px;
	font-size: 15px;
	font-weight: 650;
	line-height: 48px;
	letter-spacing: .01em;
	text-align: center;
	text-shadow: none;
	color: #fff;
	background: linear-gradient(180deg, var(--btp-navy-soft) 0%, var(--btp-navy) 100%);
	border: 0;
	border-radius: 12px;
	box-shadow: 0 10px 22px -12px rgba(18, 35, 61, .9);
	cursor: pointer;
	transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
}

body.login.btp-portal #login #wp-submit:hover,
body.login.btp-portal #login .button-primary:hover {
	filter: brightness(1.12);
	box-shadow: 0 14px 26px -12px rgba(18, 35, 61, .95);
}

body.login.btp-portal #login #wp-submit:active,
body.login.btp-portal #login .button-primary:active {
	transform: translateY(1px);
	box-shadow: 0 6px 14px -10px rgba(18, 35, 61, .9);
}

body.login.btp-portal #login #wp-submit:focus-visible,
body.login.btp-portal #login .button-primary:focus-visible {
	outline: 2px solid var(--btp-red);
	outline-offset: 2px;
}

/* Secondary buttons — "Get New Password", "Generate Password" */
body.login.btp-portal #login .button-secondary:not(.wp-hide-pw) {
	height: 40px;
	line-height: 38px;
	padding: 0 14px;
	color: var(--btp-navy);
	background: #fff;
	border: 1.5px solid var(--btp-line-strong);
	border-radius: 10px;
	box-shadow: none;
	font-weight: 600;
}

/* ------------------------------------------------------------------
 * 8. Notices
 *
 * Core marks the failed-login box as #login_error and, since 6.5, also as
 * .notice.notice-error; "You are now logged out." arrives as p.message. All
 * three shapes are covered, then tinted by kind.
 * ------------------------------------------------------------------ */

body.login.btp-portal #login .notice,
body.login.btp-portal #login #login_error,
body.login.btp-portal #login .message,
body.login.btp-portal #login .success {
	margin: 0 0 18px;
	padding: 12px 14px;
	font-size: 13px;
	line-height: 1.55;
	color: var(--btp-ink);
	background: #f8fafc;
	border: 1px solid var(--btp-line);
	border-left: 4px solid var(--btp-navy);
	border-radius: 10px;
	box-shadow: none;
	word-break: break-word;
}

body.login.btp-portal #login .notice p,
body.login.btp-portal #login #login_error p {
	margin: 0;
	padding: 0;
}

body.login.btp-portal #login .notice + .notice,
body.login.btp-portal #login .message + .notice {
	margin-top: -6px;
}

body.login.btp-portal #login #login_error,
body.login.btp-portal #login .notice-error {
	color: #7f1020;
	background: #fef4f5;
	border-color: #f6d2d7;
	border-left-color: var(--btp-red);
}

body.login.btp-portal #login .message,
body.login.btp-portal #login .notice-info {
	background: #f2f6fc;
	border-color: #dbe5f2;
	border-left-color: var(--btp-navy);
}

/* The one place emerald survives — "success" means the same thing here as it
 * does on the dashboards. */
body.login.btp-portal #login .success,
body.login.btp-portal #login .notice-success {
	background: #f0fdf5;
	border-color: #c9efdb;
	border-left-color: #10b981;
}

body.login.btp-portal #login .notice a,
body.login.btp-portal #login #login_error a,
body.login.btp-portal #login .message a {
	color: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* ------------------------------------------------------------------
 * 9. Card footer — #nav and #backtoblog
 * ------------------------------------------------------------------ */

body.login.btp-portal #login #nav,
body.login.btp-portal #login #backtoblog {
	margin: 0;
	padding: 0;
	font-size: 13px;
	line-height: 1.5;
	text-align: center;
	text-shadow: none;
}

body.login.btp-portal #login #nav {
	margin-top: 20px;
	padding-top: 17px;
	border-top: 1px solid var(--btp-line);
}

body.login.btp-portal #login #backtoblog {
	margin-top: 9px;
}

body.login.btp-portal #login #nav a,
body.login.btp-portal #login #backtoblog a,
body.login.btp-portal #login .privacy-policy-page-link a {
	color: var(--btp-muted);
	text-decoration: none;
	font-weight: 500;
}

body.login.btp-portal #login #nav a:hover,
body.login.btp-portal #login #nav a:focus,
body.login.btp-portal #login #backtoblog a:hover,
body.login.btp-portal #login #backtoblog a:focus {
	color: var(--btp-red);
	text-decoration: underline;
	text-underline-offset: 3px;
}

body.login.btp-portal #login .privacy-policy-page-link {
	margin: 10px 0 0;
	text-align: center;
	font-size: 12.5px;
}

/* ------------------------------------------------------------------
 * 10. Page footer
 * ------------------------------------------------------------------ */

.btp-portal-foot {
	margin: 0;
	font-size: 12px;
	line-height: 1.5;
	text-align: center;
	color: #7c8ba1;
}

/* Language switcher, if the site ever runs more than one locale. */
body.login.btp-portal .language-switcher {
	margin: 0;
}

body.login.btp-portal .language-switcher form {
	background: none;
	border: 0;
	box-shadow: none;
	padding: 0;
	margin: 0;
}

/* ------------------------------------------------------------------
 * 11. The "session expired" modal
 *
 * When an admin's cookie lapses mid-edit, WordPress opens the login screen in
 * a small iframe over the page and marks it body.interim-login. A fixed brand
 * panel inside a 300px iframe would cover the form completely, so the portal
 * strips itself back to the card for that one case.
 * ------------------------------------------------------------------ */

body.login.btp-portal.interim-login {
	display: block;
	min-height: 0;
	padding: 0;
	background: transparent;
}

body.login.btp-portal.interim-login .btp-portal-brand,
body.login.btp-portal.interim-login .btp-portal-foot {
	display: none;
}

body.login.btp-portal.interim-login #login {
	width: auto;
	margin: 0;
	padding: 20px;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

/* ------------------------------------------------------------------
 * 12. Narrow screens
 *
 * Below 1024px the panel rejoins the flow. It is already the first element in
 * the document, so it needs no reordering — only its marketing half removed,
 * because three selling points above a password field is three scrolls before
 * the thing the visitor came to do.
 * ------------------------------------------------------------------ */

@media (max-width: 1023px) {

	body.login.btp-portal {
		justify-content: flex-start;
		gap: 0;
		padding: 0 0 32px;
	}

	.btp-portal-brand {
		position: static;
		width: 100%;
		display: block;
		padding: 30px 24px 34px;
		overflow: visible;
		border-radius: 0 0 22px 22px;
	}

	.btp-portal-brand__inner {
		max-width: 460px;
		margin: 0 auto;
		text-align: center;
	}

	.btp-portal-brand__logo {
		padding: 11px 16px;
	}

	.btp-portal-brand__img {
		max-width: 190px;
	}

	.btp-portal-brand__title {
		margin-top: 20px;
		font-size: 22px;
	}

	.btp-portal-brand__lede,
	.btp-portal-brand__points,
	.btp-portal-brand__foot {
		display: none;
	}

	body.login.btp-portal #login {
		margin: -20px auto 0;
		width: min(430px, calc(100% - 32px));
	}

	.btp-portal-foot {
		margin-top: 20px;
		padding: 0 24px;
	}
}

@media (max-width: 420px) {

	body.login.btp-portal #login {
		padding: 24px 20px 20px;
	}
}

/* ------------------------------------------------------------------
 * 13. Preferences
 * ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {

	body.login.btp-portal * {
		transition-duration: .001ms !important;
		animation-duration: .001ms !important;
	}
}

@media (prefers-contrast: more) {

	body.login.btp-portal #login {
		border-color: var(--btp-navy);
	}

	body.login.btp-portal #login input[type="text"],
	body.login.btp-portal #login input[type="email"],
	body.login.btp-portal #login input[type="password"],
	body.login.btp-portal #login .input {
		border-color: var(--btp-navy);
	}
}
