/*
 * Split PROtocol — isolated student authentication, v2.
 * Complete replacement for auth.css. No remote assets or JS dependencies.
 * Existing --spa-* color settings remain authoritative; dark defaults are fallbacks.
 * Visibility, validation, submission and authentication stay controlled by HTML/JS.
 */

.spa-auth {
    --spa-ui-ink: var(--spa-ink, #f5f7fb);
    --spa-ui-body: var(--spa-body-ink, #dbe3ee);
    --spa-ui-panel: var(--spa-panel, #101824);
    --spa-ui-accent: var(--spa-accent, #19c9e5);
    --spa-ui-button-ink: var(--spa-button-ink, #041014);
    --spa-ui-line: color-mix(in srgb, var(--spa-ui-ink) 15%, transparent);
    --spa-ui-soft: color-mix(in srgb, var(--spa-ui-ink) 3%, var(--spa-ui-panel));
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    background-color: var(--spa-bg, #070b12);
    background-image:
        radial-gradient(ellipse at 8% 18%, #19c9e516, transparent 42%),
        radial-gradient(ellipse at 94% 85%, #ff8a3d0d, transparent 35%);
    color: var(--spa-ui-body);
    font: 16px/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-text-size-adjust: 100%;
}

@supports (color: color-mix(in srgb, red, transparent)) {
    .spa-auth {
        background-image:
            radial-gradient(ellipse at 8% 18%, color-mix(in srgb, var(--spa-ui-accent) 10%, transparent), transparent 42%),
            radial-gradient(ellipse at 94% 85%, #ff8a3d0d, transparent 35%);
    }
}

.spa-auth,
.spa-auth *,
.spa-auth *::before,
.spa-auth *::after { box-sizing: border-box; }

.spa-auth::before {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    content: "";
    background-image:
        linear-gradient(#8195ad09 1px, transparent 1px),
        linear-gradient(90deg, #8195ad09 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: linear-gradient(transparent, #000 25%, #000 75%, transparent);
}

.spa-auth a { color: inherit; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.spa-auth :is(button, input, select, textarea) { font: inherit; }
.spa-auth :is(button, a, input) { touch-action: manipulation; }
.spa-auth :focus-visible { outline: 3px solid var(--spa-ui-accent); outline-offset: 4px; }
.spa-auth [hidden] { display: none !important; }
.spa-auth input[type="hidden"] { display: none !important; }

.spa-auth .spa-skip {
    position: absolute;
    left: 20px;
    top: -120px;
    z-index: 10;
    max-width: calc(100% - 40px);
    padding: 12px 18px;
    border-radius: 10px;
    background: var(--spa-ui-panel);
    color: var(--spa-ui-ink);
}
.spa-auth .spa-skip:focus { top: 15px; }

/* Layout: two columns on desktop, compact brand signature above the form on mobile. */
.spa-auth .spa-auth-shell {
    min-height: 100vh;
    min-height: 100svh;
    max-width: 1440px;
    margin-inline: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(36px, 7vw, 104px);
    padding: clamp(32px, 5vw, 76px);
}
.spa-auth .spa-auth-brand {
    min-width: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding-block: 10px;
}
.spa-auth .spa-brand {
    display: inline-block;
    align-self: flex-start;
    max-width: 100%;
    color: var(--spa-ui-body);
    font-size: 25px;
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: -1px;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.spa-auth .spa-brand img { display: block; max-width: min(260px, 100%); max-height: 72px; object-fit: contain; }
.spa-auth .spa-brand-accent { color: var(--spa-ui-accent); }
.spa-auth .spa-auth-story { min-width: 0; margin-block: auto; }
.spa-auth .spa-eyebrow {
    display: block;
    margin-bottom: 20px;
    color: inherit;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .19em;
    line-height: 1.5;
    text-transform: uppercase;
}
.spa-auth .spa-eyebrow::before {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 10px;
    border-radius: 50%;
    background: var(--spa-ui-accent);
    vertical-align: 1px;
    content: "";
}
.spa-auth .spa-auth-story :is(h1, h2) {
    margin: 0 0 24px;
    color: inherit;
    font-size: clamp(38px, 4.5vw, 64px);
    line-height: 1.1;
    letter-spacing: -.045em;
    font-weight: 650;
    overflow-wrap: anywhere;
    text-wrap: balance;
}
.spa-auth .spa-auth-story p { max-width: 390px; margin: 0; font-size: 18px; line-height: 1.7; overflow-wrap: anywhere; }
.spa-auth .spa-method { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 34px; color: inherit; }
.spa-auth .spa-method span {
    display: grid;
    place-items: center;
    width: 43px;
    height: 44px;
    border: 1px solid #74849d55;
    border-radius: 12px;
    background: #8195ad08;
    box-shadow: 0 3px 0 #0000000f;
    font-size: 13px;
    font-weight: 700;
}
/* Equal key treatment: the login screen does not indicate a course's active stage. */
.spa-auth .spa-brand-note { margin: 0; font-size: 12px; line-height: 1.65; color: inherit; overflow-wrap: anywhere; }
.spa-auth .spa-auth-form-side { width: 100%; min-width: 0; max-width: 520px; justify-self: end; }

/* Form surface. Opaque base preserves contrast and supports configurable light palettes. */
.spa-auth .spa-auth-card {
    position: relative;
    padding: clamp(28px, 3.3vw, 46px);
    border: 1px solid #74849d40;
    border-color: var(--spa-ui-line, #74849d40);
    border-radius: 26px;
    background: var(--spa-ui-panel);
    color: var(--spa-ui-ink);
    box-shadow: 0 24px 70px #00000029, 0 3px 12px #0000000d;
}
.spa-auth .spa-auth-card::before {
    position: absolute;
    top: -1px;
    left: 12%;
    right: 12%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--spa-ui-accent), transparent);
    opacity: .65;
    pointer-events: none;
    content: "";
}
.spa-auth .spa-auth-card :is(h1, h2) {
    margin: 0 0 12px;
    color: inherit;
    font-size: clamp(27px, 2.5vw, 34px);
    line-height: 1.18;
    letter-spacing: -.035em;
    font-weight: 700;
    overflow-wrap: anywhere;
    text-wrap: balance;
}
.spa-auth .spa-description { margin: 0 0 28px; font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.spa-auth .spa-auth-form { display: flex; flex-direction: column; min-width: 0; }
.spa-auth .spa-auth-form > label { margin: 0 0 9px; font-size: 14px; font-weight: 600; }
.spa-auth .spa-auth-form > input:not([type="hidden"]):not([type="checkbox"]):not([type="submit"]),
.spa-auth .spa-password { margin-bottom: 22px; }

.spa-auth input:is(:not([type]), [type="text"], [type="email"], [type="password"], [type="tel"], [type="number"], [type="search"], [type="url"]) {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 52px;
    padding: 13px 15px;
    border: 1px solid #7c8c9f80;
    border-color: color-mix(in srgb, var(--spa-ui-ink) 30%, transparent);
    border-radius: 11px;
    background: var(--spa-ui-panel);
    background: var(--spa-ui-soft, var(--spa-ui-panel));
    color: var(--spa-ui-ink);
    font-size: 16px;
    line-height: 1.4;
    box-shadow: inset 0 1px 2px #00000008;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}
.spa-auth input::placeholder { color: inherit; opacity: .6; }
.spa-auth input:is([type="text"], [type="email"], [type="password"], [type="tel"], [type="number"], [type="search"], [type="url"], :not([type])):focus {
    border-color: var(--spa-ui-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--spa-ui-accent) 14%, transparent);
}
.spa-auth input:autofill {
    background-color: var(--spa-ui-panel);
    color: var(--spa-ui-ink);
}
.spa-auth input:-webkit-autofill {
    -webkit-text-fill-color: var(--spa-ui-ink);
    caret-color: var(--spa-ui-ink);
    -webkit-box-shadow: 0 0 0 1000px var(--spa-ui-panel) inset;
}
.spa-auth input[aria-invalid="true"] { border-color: #d36d59; }
.spa-auth input:user-invalid { border-color: #d36d59; }
.spa-auth input:disabled { opacity: .65; cursor: not-allowed; }
.spa-auth .spa-password { position: relative; min-width: 0; }
.spa-auth .spa-password input { padding-right: 94px !important; }
.spa-auth .spa-toggle {
    position: absolute;
    right: 6px;
    top: 4px;
    min-height: 44px;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.spa-auth .spa-toggle:hover { background: #8195ad15; }
.spa-auth .spa-field-help { margin: -10px 0 22px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.spa-auth .spa-form-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin: 0 0 26px; font-size: 14px; }
.spa-auth .spa-remember { display: inline-flex; align-items: center; gap: 9px; min-height: 32px; cursor: pointer; }
.spa-auth .spa-remember input { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; accent-color: var(--spa-ui-accent); }
.spa-auth .spa-form-options a { padding-block: 6px; }

.spa-auth .spa-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 54px;
    padding: 14px 18px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: var(--spa-ui-accent);
    color: var(--spa-ui-button-ink);
    box-shadow: 0 9px 25px #00000014;
    box-shadow: 0 9px 25px color-mix(in srgb, var(--spa-ui-accent) 15%, transparent);
    font-weight: 750;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}
.spa-auth a.spa-primary { color: var(--spa-ui-button-ink); }
/* Preserve nested labels, arrows and existing loading indicators. Never hide all spans. */
.spa-auth .spa-primary > span { min-width: 0; }
.spa-auth .spa-primary:disabled,
.spa-auth .spa-primary[aria-disabled="true"] { opacity: .6; cursor: not-allowed; box-shadow: none; }
.spa-auth .spa-primary[aria-busy="true"] { opacity: .78; cursor: wait; }
.spa-auth .spa-primary:is(:disabled, [aria-disabled="true"], [aria-busy="true"]) { transform: none; filter: none; }
.spa-auth .spa-action-link { display: flex; text-decoration: none; }
.spa-auth .spa-message { margin: 0 0 24px; padding: 14px 16px; border: 1px solid #74849d55; border-left-width: 3px; border-radius: 11px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.spa-auth .spa-message p:first-child { margin-top: 0; }
.spa-auth .spa-message p:last-child { margin-bottom: 0; }
.spa-auth .spa-error { border-left-color: #e08066; background: #e080660a; }
.spa-auth .spa-success { border-left-color: #46b88b; background: #46b88b0a; }
.spa-auth .spa-back-login { display: block; width: fit-content; max-width: 100%; margin-top: 16px; padding-block: 8px; font-size: 14px; }
.spa-auth .spa-secondary { display: inline-block; margin-top: 16px; padding-block: 6px; font-size: 14px; font-weight: 650; }
.spa-auth .spa-auth-support { margin-top: 26px; padding-top: 20px; border-top: 1px solid #7c8c9f33; border-top-color: var(--spa-ui-line, #7c8c9f33); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.spa-auth .spa-auth-support a { font-weight: 650; }
.spa-auth .spa-auth-bottom { margin: 20px 0 0; font-size: 12px; line-height: 1.7; text-align: center; overflow-wrap: anywhere; }
.spa-auth .spa-form-status { margin-top: 10px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.spa-auth .spa-form-status:empty { display: none; }

@media (hover: hover) and (pointer: fine) {
    .spa-auth .spa-primary:not(:disabled):not([aria-disabled="true"]):not([aria-busy="true"]):hover { filter: brightness(1.06); transform: translateY(-1px); }
    .spa-auth :is(.spa-form-options, .spa-auth-support, .spa-auth-bottom) a:hover { text-decoration-thickness: 2px; }
}

@media (max-width: 900px) {
    .spa-auth .spa-auth-shell { grid-template-columns: minmax(0, 1fr); align-content: start; gap: 20px; max-width: 560px; padding: 28px 20px 32px; }
    .spa-auth .spa-auth-brand { display: contents; }
    .spa-auth .spa-brand { order: 0; justify-self: center; align-self: center; font-size: 23px; }
    .spa-auth .spa-brand img { max-width: min(220px, 100%); max-height: 56px; }
    .spa-auth .spa-auth-story { order: 1; margin: 0; padding: 0 4px 2px; text-align: center; }
    .spa-auth .spa-eyebrow { margin-bottom: 10px; font-size: 10px; letter-spacing: .14em; }
    .spa-auth .spa-auth-story :is(h1, h2) { margin: 0 0 6px; font-size: 19px; line-height: 1.35; letter-spacing: -.025em; }
    .spa-auth .spa-auth-story :is(h1, h2) br { display: none; }
    .spa-auth .spa-auth-story p { max-width: 340px; margin-inline: auto; font-size: 13px; line-height: 1.55; }
    .spa-auth .spa-method { justify-content: center; gap: 8px; margin-top: 14px; }
    .spa-auth .spa-method span { width: 29px; height: 30px; border-radius: 8px; font-size: 11px; }
    .spa-auth .spa-auth-form-side { order: 2; max-width: none; justify-self: center; }
    .spa-auth .spa-auth-card { padding: 28px 24px; border-radius: 22px; }
    .spa-auth .spa-auth-card :is(h1, h2) { font-size: 28px; }
    .spa-auth .spa-brand-note { order: 3; padding-inline: 4px; text-align: center; font-size: 11px; }
}

@media (max-width: 360px) {
    .spa-auth .spa-auth-shell { padding: 22px 14px 28px; }
    .spa-auth .spa-auth-card { padding: 24px 18px; }
    .spa-auth .spa-auth-card :is(h1, h2) { font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
    .spa-auth .spa-primary,
    .spa-auth input { transition: none; }
    .spa-auth .spa-primary:not(:disabled):not([aria-disabled="true"]):not([aria-busy="true"]):hover { transform: none; }
}

@media (forced-colors: active) {
    .spa-auth::before,
    .spa-auth .spa-auth-card::before { display: none; }
    .spa-auth .spa-primary { border: 1px solid ButtonText; }
    .spa-auth .spa-auth-card,
    .spa-auth .spa-method span { border-color: CanvasText; }
}
