/* LearnDash layer 6/6 (part): login modal (+ privacy note added by sddsg-core). The modal always lives inside .learndash-wrapper. See base.css. */
.learndash-wrapper .sddsg-privacy-note { font-size: 0.875em; color: var(--wp--preset--color--muted); }
.learndash-wrapper .ld-login-modal .sddsg-privacy-note a { text-decoration: underline; text-decoration-thickness: var(--sddsg-link-thickness, 1px); }
/* Remember-me checkbox themed like wp-login (AUT-06) */
.learndash-wrapper .ld-login-modal #rememberme { inline-size: 1.5rem; block-size: 1.5rem; accent-color: var(--wp--preset--color--primary); border-radius: .25rem; }

/* register panel: navy in both schemes (so the focus ring inside is gold, like on every always-dark surface) */
.ld-login-modal .ld-login-modal-register { background: var(--wp--preset--color--hero) !important; color: var(--wp--preset--color--on-hero); --wp--preset--color--focus: var(--sddsg-ring-on-dark); --sddsg-ring: var(--sddsg-ring-width) solid var(--sddsg-ring-on-dark); }
.ld-login-modal .ld-login-modal-register .ld-button { background: var(--wp--preset--color--accent) !important; color: var(--wp--preset--color--on-accent) !important; }
/* Its button is the portal's primary button. LearnDash's inline colour CSS turns every .ld-button navy on hover with
   !important (0,5,0) and its "reverse" style adds a white halo: strong tier, same hover as every gold button. */
.learndash-wrapper:not(#_) .ld-login-modal.ld-modal .ld-login-modal-register .ld-button {
	box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; min-block-size: var(--sddsg-btn-h); padding: var(--sddsg-btn-pad);
	border: 0; border-radius: var(--sddsg-btn-radius); font-size: var(--sddsg-btn-size); font-weight: var(--sddsg-btn-weight); line-height: 1.2; text-align: center; opacity: 1; box-shadow: none;
	&:is(:hover, :focus-visible, :active) { background-color: var(--wp--preset--color--accent) !important; color: var(--wp--preset--color--on-accent) !important; opacity: 1; box-shadow: none; filter: var(--sddsg-btn-hover); }
	&:active { filter: var(--sddsg-btn-press); }
}

/* mode switch for the two colours that differ between light and dark (tokens only cover one value each) */
.ld-login-modal {
	--sddsg-modal-link: var(--wp--preset--color--link); /* same link colour as the rest of the dialog in both schemes (DSN-06) */
	--sddsg-modal-logo: none;
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .ld-login-modal { --sddsg-modal-link: var(--wp--preset--color--link); --sddsg-modal-logo: brightness(0) invert(17%) sepia(36%) saturate(1500%) hue-rotate(178deg) brightness(95%); } }
:root[data-theme="light"] .ld-login-modal { --sddsg-modal-link: var(--wp--preset--color--link); --sddsg-modal-logo: brightness(0) invert(17%) sepia(36%) saturate(1500%) hue-rotate(178deg) brightness(95%); }

.learndash-wrapper .ld-login-modal.ld-modal {
	/* centred in the viewport (LD30 positions it absolutely with an offset that can push it off-screen); scrolls inside */
	position: fixed !important; inset: 0 !important; margin: auto !important; transform: none !important;
	block-size: fit-content; inline-size: min(64rem, calc(100vw - 2rem)); max-block-size: calc(100dvh - 2rem); overflow: auto;
	border-radius: var(--sddsg-card-radius); box-shadow: var(--sddsg-dialog-shadow);
	background: var(--wp--preset--color--surface-raised) !important; color: var(--wp--preset--color--contrast); /* LD inline */
	.ld-login-modal-login, .ld-login-modal-wrapper { background: var(--wp--preset--color--surface-raised) !important; color: var(--wp--preset--color--contrast); }
	.ld-login-modal-wrapper { border-radius: var(--sddsg-ld-radius); }
	.ld-login-modal-login .ld-login-modal-wrapper { padding-block: 1.75rem; }
	.ld-login-modal-login .ld-modal-heading { margin-block: 0 1rem; line-height: 1.2; }
	.ld-modal-heading { font-size: var(--wp--preset--font-size--large); font-weight: 700; } /* SPEC: dialog title = large, 700 (LD30: 40px / 300) */
	.ld-login-modal-branding { text-align: center; margin-block: 1rem 0.5rem; }
	.ld-login-modal-branding img { max-inline-size: 11rem; block-size: auto; margin-inline: auto; filter: var(--sddsg-modal-logo); } /* logo is the white variant: tint navy on light */
	.ld-login-modal-form form { display: grid; gap: 1rem; max-inline-size: 26rem; margin-inline: auto; }
	.ld-login-modal-form form p { margin: 0; }
	:is(input[type="text"], input[type="password"], input[type="email"]) {
		background: var(--wp--preset--color--base) !important; color: var(--wp--preset--color--contrast) !important;
		border: var(--sddsg-field-border) !important; border-radius: var(--sddsg-field-radius);
	}
	:is(input[type="text"], input[type="password"], input[type="email"]):hover { border-color: var(--sddsg-field-border-hover) !important; }
	/* Field icons (LD30 ::before, absolute at a fixed top offset): anchor them to the input instead of the label
	   and reserve room so typed text never runs under the icon. */
	.ld-login-modal-form :is(.login-username, .login-password) input {
		box-sizing: border-box; block-size: 2.75rem; margin: 0 !important;
		padding-block: 0 !important; padding-inline: 2.625rem 0.875rem !important;
	}
	.ld-login-modal-form :is(.login-username, .login-password)::before {
		top: auto !important; bottom: 1.375rem; inset-inline: 0.875rem auto !important;
		transform: translateY(50%); line-height: 1; font-size: 1rem; pointer-events: none;
		color: var(--wp--preset--color--muted) !important;
	}
	.ld-login-modal-form label { display: block; text-align: start; margin-block-end: 0.375rem; font-size: 0.875rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--wp--preset--color--contrast) !important; }
	.ld-login-modal-form .login-remember label { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 500; margin: 0; }
	.ld-login-modal-form .login-submit { text-align: center; }
	.ld-forgot-password-link { display: block; text-align: center; margin-block: 0.75rem 1rem; color: var(--sddsg-modal-link) !important; text-decoration: none; font-weight: 600; }
	.ld-forgot-password-link:is(:hover, :focus-visible) { text-decoration: underline; text-underline-offset: 0.25em; }
	/* register panel: always navy with light text (both modes) */
	.ld-login-modal-register .ld-login-modal-wrapper { background: rgb(255 255 255 / 0.06) !important; color: var(--wp--preset--color--on-hero) !important; }
	.ld-login-modal-register :is(.ld-modal-heading, .ld-modal-text) { color: var(--wp--preset--color--on-hero) !important; }
}
.learndash-wrapper:not(.sddsg-b) .ld-login-modal.ld-modal {
	.ld-login-modal-login .ld-modal-heading { color: var(--wp--preset--color--heading) !important; }
	.ld-login-modal-form input[type="submit"]#wp-submit { /* gold primary button; beats LD's inline !important background */
		background-color: var(--wp--preset--color--accent) !important; color: var(--wp--preset--color--on-accent) !important;
		box-sizing: border-box; min-block-size: var(--sddsg-btn-h); min-inline-size: 12rem; padding: var(--sddsg-btn-pad);
		border: 0; border-radius: var(--sddsg-btn-radius); font-size: var(--sddsg-btn-size); font-weight: var(--sddsg-btn-weight); line-height: 1.2; cursor: pointer; box-shadow: var(--sddsg-btn-edge);
		transition: filter var(--sddsg-ease), box-shadow var(--sddsg-ease);
		&:hover { opacity: 1; filter: var(--sddsg-btn-hover); box-shadow: var(--sddsg-btn-shadow-hover); } /* opacity: LD fades buttons on hover */
		&:focus-visible { outline: var(--sddsg-ring); outline-offset: var(--sddsg-ring-offset); }
	}
}
@media (prefers-reduced-motion: reduce) { .learndash-wrapper .ld-login-modal.ld-modal input#wp-submit { transition: none; } }

/* ---------- Dialog behaviour (assets/js/login-modal.js): backdrop, close button, scroll lock, error ---------- */
/* Backdrop: dims and blocks the page; a click closes the dialog. Scroll lock = html.sddsg-modal-open (style.css). */
.learndash-wrapper-login-modal .sddsg-modal-backdrop { display: none; position: fixed; inset: 0; z-index: 99998; background: var(--sddsg-backdrop); }
.learndash-wrapper-login-modal.ld-modal-open .sddsg-modal-backdrop { display: block; }
.learndash-wrapper-login-modal.ld-modal-open .ld-login-modal.ld-modal { z-index: 99999; overscroll-behavior: contain; }
.learndash-wrapper .ld-login-modal.ld-modal:focus { outline: none; } /* container focus is only a fallback target */
/* Close control: 44px target in the corner, visible focus ring, hover/pressed feedback. */
.learndash-wrapper .ld-login-modal.ld-modal .ld-modal-closer {
	position: absolute; inset-block-start: 0.5rem; inset-inline-end: 0.5rem; inset-inline-start: auto; z-index: 2;
	display: grid; place-items: center; inline-size: 44px; block-size: 44px; margin: 0; padding: 0;
	border-radius: 50%; cursor: pointer; font-size: 1rem; line-height: 1;
	/* own chip: readable on the white login panel (phones, panels stacked) and on the navy register panel (desktop) */
	color: var(--wp--preset--color--contrast); background: var(--wp--preset--color--surface); border: 1px solid var(--wp--preset--color--border-strong);
}
.learndash-wrapper .ld-login-modal.ld-modal .ld-modal-closer:hover { background: var(--wp--preset--color--base); border-color: var(--wp--preset--color--contrast); }
.learndash-wrapper .ld-login-modal.ld-modal .ld-modal-closer:active { background: var(--wp--preset--color--border); }
.learndash-wrapper .ld-login-modal.ld-modal .ld-modal-closer:focus-visible { outline: var(--sddsg-ring); outline-offset: var(--sddsg-ring-offset); box-shadow: 0 0 0 7px var(--wp--preset--color--surface-raised); } /* ring + light halo: visible on the white and on the navy panel */
.learndash-wrapper .ld-login-modal.ld-modal .ld-login-modal-register .ld-button:focus-visible { outline: var(--sddsg-ring); outline-offset: var(--sddsg-ring-offset); }
.learndash-wrapper .ld-login-modal.ld-modal .login-remember :is(label, input) { cursor: pointer; }
.learndash-wrapper .ld-login-modal.ld-modal .login-remember input[type="checkbox"] { accent-color: var(--wp--preset--color--primary); } /* checked state in the portal's colour, like every checkbox */
/* Pressed feedback */
.learndash-wrapper:not(.sddsg-b) .ld-login-modal.ld-modal .ld-login-modal-form input[type="submit"]#wp-submit:active { opacity: 1; filter: var(--sddsg-btn-press); box-shadow: var(--sddsg-btn-edge); }
.learndash-wrapper .ld-login-modal.ld-modal :is(.ld-forgot-password-link, .sddsg-privacy-note a):active { opacity: 0.7; }
/* Failed attempt: message in the theme's danger tokens (text stays LearnDash's masked wording). */
.learndash-wrapper .ld-login-modal.ld-modal .ld-login-modal-login .ld-alert[role="alert"] {
	background: var(--wp--preset--color--danger-bg) !important; color: var(--wp--preset--color--contrast) !important;
	border: 1px solid var(--wp--preset--color--danger) !important; border-radius: var(--wp--custom--radius--sm);
}
.learndash-wrapper .ld-login-modal.ld-modal :is(input[type="text"], input[type="password"])[aria-invalid="true"] { border-color: var(--wp--preset--color--danger) !important; }
.learndash-wrapper .ld-login-modal.ld-modal :is(input[type="text"], input[type="password"]):focus-visible { outline: var(--sddsg-ring); outline-offset: var(--sddsg-ring-offset); }
.learndash-wrapper .ld-login-modal .sddsg-privacy-note a:is(:hover, :focus-visible) { color: var(--wp--preset--color--link-hover); text-decoration-thickness: 2px; }
