/* =========================================================
   ACCOUNT GATE
   [mwd_account_gate] on /my-account/ (logged out only).
   ========================================================= */

.mwd-ag {
	--ag-navy: #0b2d3d;
	--ag-ink: #1f3a49;
	--ag-muted: #5d7686;
	--ag-accent: #01bcef;
	--ag-accent-dark: #0098c4;
	--ag-tint: #eef8fd;
	--ag-tint-strong: #ddf2fb;
	--ag-line: #e2eaef;
	--ag-line-active: #a6def3;
	--ag-panel: #f8fbfd;

	/*
	 * Heading and intro text, matched to the "Explore my free resources"
	 * block on the homepage. Those values are set on that Divi module rather
	 * than site-wide, so they can't be inherited. If anything looks off,
	 * copy the exact numbers from that module's Heading Text > H2 and Body
	 * Text settings into these.
	 */
	--ag-title-size: clamp(32px, 3.4vw, 46px);
	--ag-title-weight: 800;
	--ag-title-line: 1.15;
	--ag-title-spacing: -0.01em;
	--ag-title-colour: #15384d;
	--ag-brand-colour: #56b8ea;
	--ag-intro-size: 18px;
	--ag-intro-line: 1.7;
	--ag-intro-colour: #5a7385;

	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 48px;
	align-items: stretch;
	box-sizing: border-box;
	color: var(--ag-ink);
}

.mwd-ag *,
.mwd-ag *::before,
.mwd-ag *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------
   Intro + choice cards
   --------------------------------------------------------- */

/* Left column sits vertically centred against the panel. */
.mwd-ag__intro {
	align-self: center;
}

/* Heading keeps the site's h2 typeface; size, weight and colour as homepage. */
.mwd-ag h2.mwd-ag__title {
	margin: 0 0 14px;
	padding: 0;
	font-size: var(--ag-title-size);
	font-weight: var(--ag-title-weight);
	line-height: var(--ag-title-line);
	letter-spacing: var(--ag-title-spacing);
	color: var(--ag-title-colour);
}

.mwd-ag .mwd-ag__brand {
	color: var(--ag-brand-colour);
}

.mwd-ag p.mwd-ag__subtitle {
	margin: 0 0 40px;
	padding: 0;
	font-size: var(--ag-intro-size);
	line-height: var(--ag-intro-line);
	color: var(--ag-intro-colour);
}

/* Cards only make sense once the script is running. */
.mwd-ag:not(.is-ready) .mwd-ag__choices {
	display: none;
}

.mwd-ag__choices {
	display: grid;
	gap: 20px;
}

.mwd-ag button.mwd-ag__choice {
	display: flex;
	align-items: center;
	gap: 24px;
	width: 100%;
	margin: 0;
	padding: 24px 28px;
	font: inherit;
	text-align: left;
	color: inherit;
	background: #fff;
	border: 1px solid var(--ag-line);
	border-radius: 12px;
	box-shadow: 0 2px 10px rgba(11, 45, 61, 0.04);
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mwd-ag button.mwd-ag__choice:hover {
	border-color: var(--ag-line-active);
}

.mwd-ag button.mwd-ag__choice.is-active {
	background: var(--ag-tint);
	border-color: var(--ag-line-active);
}

.mwd-ag button.mwd-ag__choice:focus-visible,
.mwd-ag .mwd-ag__switch button:focus-visible {
	outline: 3px solid var(--ag-accent);
	outline-offset: 3px;
}

.mwd-ag__choice-icon {
	flex: none;
	display: grid;
	place-items: center;
	width: 84px;
	height: 84px;
	border-radius: 50%;
	background: var(--ag-tint);
}

.mwd-ag__choice.is-active .mwd-ag__choice-icon {
	background: var(--ag-tint-strong);
}

.mwd-ag__choice-icon svg {
	width: 40px;
	height: 40px;
}

.mwd-ag__choice-text {
	flex: 1;
	min-width: 0;
}

.mwd-ag .mwd-ag__choice-title {
	display: block;
	margin-bottom: 4px;
	font-family: var(--ag-heading-font, inherit);
	font-size: 26px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: var(--ag-title-colour);
}

.mwd-ag .mwd-ag__choice-sub {
	display: block;
	font-size: 17px;
	line-height: 1.4;
	color: var(--ag-intro-colour);
}

.mwd-ag__choice-go {
	flex: none;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: var(--ag-tint);
	transition: transform 0.15s ease, background-color 0.15s ease;
}

/* On the selected card the arrow circle fills, so it doesn't vanish into the tint. */
.mwd-ag .mwd-ag__choice.is-active .mwd-ag__choice-go {
	background: var(--ag-accent);
}

.mwd-ag .mwd-ag__choice.is-active .mwd-ag__choice-go svg {
	stroke: #fff;
}

.mwd-ag__choice:hover .mwd-ag__choice-go,
.mwd-ag__choice.is-active .mwd-ag__choice-go {
	transform: translateX(3px);
}

.mwd-ag__choice-go svg {
	width: 22px;
	height: 22px;
}

/* Forgotten password link under the cards. */
.mwd-ag p.mwd-ag__forgot {
	margin: 24px 0 0;
	padding: 0;
	font-size: 16px;
}

.mwd-ag__forgot a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
	color: var(--ag-accent-dark);
	text-decoration: none;
}

.mwd-ag__forgot a:hover,
.mwd-ag__forgot a:focus-visible {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.mwd-ag__forgot svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.mwd-ag__choice svg {
	fill: none;
	stroke: var(--ag-accent);
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ---------------------------------------------------------
   Right-hand panel
   --------------------------------------------------------- */

/*
 * The panel stretches to the height of the left-hand column when that's
 * taller than the form, so its contents are centred vertically to share
 * the spare space evenly above and below.
 */
.mwd-ag__panel {
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 36px 44px;
	background: var(--ag-panel);
	border: 1px solid var(--ag-line);
	border-radius: 16px;
	scroll-margin-top: 120px;
}

/*
 * The panel fits whichever form is showing. When switching, the script
 * animates its height from one to the other so it never jumps.
 */
.mwd-ag__panel.is-resizing {
	overflow: hidden;
	transition: height 0.25s ease;
}

.mwd-ag__prompt {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
}

.mwd-ag__prompt[hidden],
.mwd-ag__pane[hidden] {
	display: none;
}

/* Colours are set on the SVG itself, so theme CSS can't knock them out. */
.mwd-ag__art {
	display: block;
	width: 100%;
	max-width: 340px;
	height: auto;
	margin: 0 auto 28px;
	overflow: visible;
}

/* Panel headings are <h3>s and take the site's h3 settings, like the h2 above. */

/* Panes */

.mwd-ag__pane.is-shown {
	animation: mwd-ag-in 0.2s ease-out;
}

@keyframes mwd-ag-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}

.mwd-ag .mwd-ag__pane-title:focus {
	outline: none;
}

.mwd-ag .mwd-ag__pane-sub {
	margin: -6px 0 20px;
	padding: 0;
	font-size: 18px;
	color: var(--ag-muted);
}

.mwd-ag .mwd-ag__switch {
	margin: 20px 0 0;
	padding: 16px 0 0;
	border-top: 1px solid var(--ag-line);
	font-size: 17px;
	color: var(--ag-muted);
}

.mwd-ag .mwd-ag__switch[hidden] {
	display: none;
}

.mwd-ag .mwd-ag__switch button {
	margin: 0;
	padding: 0;
	font: inherit;
	font-weight: 700;
	color: var(--ag-accent-dark);
	background: none;
	border: 0;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

/* ---------------------------------------------------------
   Feedback messages (account exists, wrong password...)
   --------------------------------------------------------- */

.mwd-ag__alert {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin: 0 0 22px;
	padding: 14px 16px;
	font-size: 15px;
	line-height: 1.5;
	border: 1px solid;
	border-radius: 10px;
	animation: mwd-ag-in 0.2s ease-out;
}

.mwd-ag__alert--error {
	color: #7a1d1d;
	background: #fdf0f0;
	border-color: #f2c4c4;
}

.mwd-ag__alert--notice {
	color: var(--ag-navy);
	background: var(--ag-tint);
	border-color: var(--ag-line-active);
}

.mwd-ag__alert-icon {
	flex: none;
	display: grid;
	place-items: center;
	width: 22px;
	height: 22px;
	margin-top: 1px;
}

.mwd-ag__alert-icon svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.mwd-ag__alert--error .mwd-ag__alert-icon svg  { stroke: #d64545; }
.mwd-ag__alert--notice .mwd-ag__alert-icon svg { stroke: var(--ag-accent-dark); }

.mwd-ag__alert-body {
	flex: 1;
	min-width: 0;
}

.mwd-ag .mwd-ag__alert-title {
	display: block;
	margin-bottom: 2px;
	font-weight: 700;
}

.mwd-ag__alert-text b {
	font-weight: 700;
	word-break: break-word;
}

.mwd-ag__alert-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 18px;
	margin-top: 8px;
}

.mwd-ag .mwd-ag__alert-actions a,
.mwd-ag .mwd-ag__alert-actions button {
	margin: 0;
	padding: 0;
	font: inherit;
	font-weight: 700;
	color: inherit;
	background: none;
	border: 0;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

/* LearnDash's own notices: hidden when replaced, restyled when not. */
.mwd-ag .mwd-ag__ld-notice--hidden {
	display: none !important;
}

.mwd-ag .mwd-ag__ld-notice {
	display: block;
	margin: 0 0 18px !important;
	padding: 12px 16px !important;
	font-size: 15px;
	color: #7a1d1d !important;
	background: #fdf0f0 !important;
	border: 1px solid #f2c4c4 !important;
	border-radius: 10px;
}

/* ---------------------------------------------------------
   LearnDash forms inside the panes.
   Undo LearnDash's side-by-side column sizing, then tidy the fields.
   --------------------------------------------------------- */

.mwd-ag__slot .ld-registration__login,
.mwd-ag__slot .ld-registration__register {
	display: block !important;
	flex: none !important;
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	background: none !important;
}

/*
 * LearnDash hides whichever form isn't "active". Both are ours to show now.
 * Visibility is set to inherit, never visible, so a form can't show through
 * a panel that's switched off.
 */
.mwd-ag__slot .mwd-ag__form {
	display: block !important;
	visibility: inherit !important;
	opacity: 1 !important;
}

/* ...but the forms themselves are laid out as a grid (see Fields below). */
.mwd-ag__slot form.mwd-ag__form {
	display: grid !important;
}

/* Our pane already has a heading and its own switch link. */
.mwd-ag__slot .ld-registration__heading,
.mwd-ag__slot .mwd-ag__ld-switch {
	display: none !important;
}

/*
 * Fields. Kept compact so the registration form fits a laptop screen:
 * tighter rows, first and last name side by side, the password "Show" button
 * inside the field, and smaller hint and error text.
 *
 * LearnDash's markup isn't ours, so rows are found by what they contain
 * (:has) rather than by LearnDash's class names.
 */
.mwd-ag .mwd-ag__slot form {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	column-gap: 14px;
	row-gap: 14px;
	margin: 0;
	padding: 0;
}

/* Every row spans both columns, apart from first and last name. */
.mwd-ag .mwd-ag__slot form > * {
	grid-column: 1 / -1;
	margin: 0;
	padding: 0;
}

.mwd-ag .mwd-ag__slot form > :has(input[name="first_name"]),
.mwd-ag .mwd-ag__slot form > :has(input[name="last_name"]) {
	grid-column: auto;
}

/* Hidden inputs and empty wrappers shouldn't take up a row gap. */
.mwd-ag .mwd-ag__slot form > input[type="hidden"],
.mwd-ag .mwd-ag__slot form > :is(p, div, span):empty {
	display: none;
}

.mwd-ag .mwd-ag__slot label {
	display: block;
	margin: 0 0 5px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
	color: var(--ag-navy);
}

.mwd-ag .mwd-ag__slot input[type="text"],
.mwd-ag .mwd-ag__slot input[type="email"],
.mwd-ag .mwd-ag__slot input[type="password"] {
	display: block;
	width: 100%;
	height: 46px;
	margin: 0;
	padding: 0 14px;
	font: inherit;
	font-size: 16px; /* stops iOS zooming in on focus */
	color: var(--ag-ink);
	background: #fff;
	border: 1px solid #cfdbe3;
	border-radius: 8px;
	box-shadow: none;
}

.mwd-ag .mwd-ag__slot input[type="text"]:focus,
.mwd-ag .mwd-ag__slot input[type="email"]:focus,
.mwd-ag .mwd-ag__slot input[type="password"]:focus {
	border-color: var(--ag-accent);
	outline: 3px solid rgba(1, 188, 239, 0.2);
	outline-offset: 0;
}

/*
 * Password Show / Hide button sits inside the right-hand end of the field.
 * Targeted by LearnDash's class, because clicking it switches the field
 * between type="password" and type="text".
 */
#mwd-ag-panel .ld-form__field-password-wrapper {
	position: relative !important;
	display: block !important;
}

#mwd-ag-panel .ld-form__field-password-wrapper > input {
	padding-right: 76px !important;
}

#mwd-ag-panel .ld-button__password-visibility-toggle {
	position: absolute !important;
	top: 50% !important;
	right: 6px !important;
	transform: translateY(-50%) !important;
	width: auto !important;
	min-width: 0 !important;
	height: 34px !important;
	margin: 0 !important;
	padding: 0 12px !important;
	font: inherit;
	font-size: 14px !important;
	font-weight: 600 !important;
	line-height: 1 !important;
	color: var(--ag-accent-dark) !important;
	background: transparent !important;
	border: 0 !important;
	border-radius: 6px !important;
	box-shadow: none !important;
	outline-offset: 0;
	cursor: pointer;
}

#mwd-ag-panel .ld-button__password-visibility-toggle:hover,
#mwd-ag-panel .ld-button__password-visibility-toggle:focus-visible {
	background: var(--ag-tint) !important;
}

/*
 * From here on, rules target LearnDash's actual markup (ld-form, ld-terms-
 * checkboxes, ld-password-strength...). Where LearnDash's own styles would
 * win, the panel's id (#mwd-ag-panel) is used to outrank them.
 */

/* LearnDash's field wrappers carry their own margins; the form's grid gap replaces them. */
#mwd-ag-panel .ld-form__field-outer-wrapper,
#mwd-ag-panel .ld-form__field-wrapper,
#mwd-ag-panel .ld-form p {
	margin: 0 !important;
	padding: 0 !important;
}

/* Password strength meter: bars and the "Weak" / "Strong" label on one line. */
/*
 * LearnDash shows and hides the meter itself and fills it as you type, so
 * it's never hidden here. Once it has bars in it, they go on one line with
 * the label.
 */
#mwd-ag-panel .ld-password-strength:has(> span) {
	display: flex !important;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin: 10px 0 0 !important;
}

/* The label always goes on its own line under the bars, flush left. */
#mwd-ag-panel .ld-password-strength__descriptor {
	display: block;
	flex-basis: 100%;
	margin: 2px 0 0 !important;
	padding: 0 !important;
	text-indent: 0 !important;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
}

#mwd-ag-panel .ld-password-strength__error {
	display: inline !important;
	margin: 0 !important;
	font-size: inherit;
	font-weight: 400;
}

/* The password tip. */
#mwd-ag-panel .ld-password-strength__hint {
	font-size: 13px;
	line-height: 1.45;
	color: var(--ag-muted);
}

/* Field error messages: small, tight under the field or checkbox they belong to. */
#mwd-ag-panel .ld-form__field-error-message {
	display: block;
	margin: 4px 0 0 !important;
	padding: 0 !important;
	font-size: 13px;
	line-height: 1.4;
}

/* Terms and Privacy: a column with even gaps; an error tucks under its checkbox. */
#mwd-ag-panel .ld-terms-checkboxes {
	display: flex !important;
	flex-direction: column;
	gap: 12px;
	margin: 0 !important;
	padding: 0 !important;
}

#mwd-ag-panel .ld-terms-checkboxes .ld-form__field-error-message {
	margin: -8px 0 0 30px !important;
}

/* Remember me on the left, Forgot password? on the right, one row. */
#mwd-ag-panel .ld-registration__login_options_wrapper {
	display: flex !important;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin: 0 !important;
	padding: 0 !important;
}

#mwd-ag-panel .ld-registration__forgot-password a {
	font-size: 15px;
	font-weight: 600;
	color: var(--ag-accent-dark);
	text-decoration: none;
}

#mwd-ag-panel .ld-registration__forgot-password a:hover {
	text-decoration: underline;
}

/* Checkbox rows: <label><input type="checkbox"><span>text</span></label>. */
#mwd-ag-panel .ld-form label:has(> input[type="checkbox"]) {
	display: flex !important;
	align-items: flex-start;
	gap: 10px;
	margin: 0 !important;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.5;
	color: var(--ag-ink);
	cursor: pointer;
}

#mwd-ag-panel .ld-form label:has(> input[type="checkbox"]) > span {
	margin: 0 !important;
	padding: 0 !important;
}

/*
 * The checkbox is drawn here at a fixed 20px, replacing LearnDash's own
 * oversized box, which spilled over onto the text.
 */
#mwd-ag-panel input[type="checkbox"] {
	-webkit-appearance: none !important;
	appearance: none !important;
	position: relative;
	flex: none;
	width: 20px !important;
	height: 20px !important;
	min-width: 0 !important;
	margin: 1px 0 0 !important;
	padding: 0 !important;
	background: #fff center / 14px 14px no-repeat !important;
	border: 2px solid #9aabb6 !important;
	border-radius: 5px !important;
	box-shadow: none !important;
	transform: none !important;
	scale: none !important;
	zoom: 1 !important;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

#mwd-ag-panel input[type="checkbox"]::before,
#mwd-ag-panel input[type="checkbox"]::after {
	content: none !important;
	display: none !important;
}

#mwd-ag-panel input[type="checkbox"]:checked {
	background-color: var(--ag-accent) !important;
	border-color: var(--ag-accent) !important;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
}

#mwd-ag-panel input[type="checkbox"]:focus-visible {
	outline: 3px solid rgba(1, 188, 239, 0.35) !important;
	outline-offset: 2px;
}

#mwd-ag-panel input[type="checkbox"].ld-form__field--error:not(:checked) {
	border-color: #d64545 !important;
}

/* LearnDash keeps Register disabled until the form is valid. Show that. */
.mwd-ag .mwd-ag__slot input[type="submit"]:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.mwd-ag .mwd-ag__slot input[type="submit"],
.mwd-ag .mwd-ag__slot button[type="submit"] {
	width: 100%;
	height: 48px;
	margin: 4px 0 0;
	padding: 0 22px;
	font: inherit;
	font-size: 17px;
	font-weight: 700;
	color: #fff;
	background: var(--ag-accent);
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.mwd-ag .mwd-ag__slot input[type="submit"]:hover,
.mwd-ag .mwd-ag__slot button[type="submit"]:hover {
	background: var(--ag-accent-dark);
}

/* ---------------------------------------------------------
   Smaller screens
   --------------------------------------------------------- */

@media (max-width: 1100px) {
	.mwd-ag__choice-icon     { width: 68px; height: 68px; }
	.mwd-ag__choice-icon svg { width: 32px; height: 32px; }
	.mwd-ag .mwd-ag__choice-title { font-size: 23px; }
	.mwd-ag .mwd-ag__choice-sub   { font-size: 16px; }
	.mwd-ag__panel           { padding: 32px; }
}

@media (max-width: 860px) {
	.mwd-ag {
		grid-template-columns: minmax(0, 1fr);
		gap: 32px;
	}

	.mwd-ag p.mwd-ag__subtitle { margin-bottom: 28px; }
	.mwd-ag__choices        { gap: 16px; }

	/* On a phone, the "choose an option" placeholder just pushes things down. */
	.mwd-ag.is-ready:not([data-ag-state]) .mwd-ag__panel {
		display: none;
	}

	.mwd-ag__panel {
		padding: 28px 22px;
	}
}

@media (max-width: 520px) {
	.mwd-ag .mwd-ag__slot form > :has(input[name="first_name"]),
	.mwd-ag .mwd-ag__slot form > :has(input[name="last_name"]) { grid-column: 1 / -1; }
	.mwd-ag button.mwd-ag__choice { gap: 16px; padding: 18px; }
	.mwd-ag__choice-icon     { width: 56px; height: 56px; }
	.mwd-ag__choice-icon svg { width: 28px; height: 28px; }
	.mwd-ag .mwd-ag__choice-title { font-size: 21px; }
	.mwd-ag .mwd-ag__choice-sub   { font-size: 15px; }
	.mwd-ag__choice-go       { width: 40px; height: 40px; }
	.mwd-ag__choice-go svg   { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
	.mwd-ag__pane.is-shown,
	.mwd-ag__choice,
	.mwd-ag__choice-go {
		animation: none;
		transition: none;
	}
}
