/* Login - mirrors lib/screens/login_screen.dart.
   Both themes share one layout: a brand band in the sidebar colour carries the
   white logo, and the form sits on the card surface below it. Only tokens differ. */

:root {
    --login-bg:
        radial-gradient(900px 520px at 85% -10%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 70%),
        radial-gradient(700px 480px at -10% 110%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
        linear-gradient(160deg, #F7F9FD, #E8EFFA);
    --login-card-line: rgba(16, 33, 56, 0.08);
    --login-card-shadow: 0 1px 2px rgba(16, 33, 56, 0.06), 0 28px 60px -28px rgba(20, 52, 128, 0.45);
    --login-title: #DCE7FF;
    --login-rule-blue: #0D2F7E;
    --login-blob-a: color-mix(in srgb, var(--primary) 16%, transparent);
    --login-blob-b: color-mix(in srgb, var(--accent) 14%, transparent);
}
:root[data-theme="dark"] {
    --login-bg:
        radial-gradient(900px 520px at 85% -10%, color-mix(in srgb, var(--primary) 20%, transparent), transparent 70%),
        radial-gradient(700px 480px at -10% 110%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
        linear-gradient(160deg, #101A30, #0A1120);
    --login-card-line: rgba(233, 241, 255, 0.12);
    --login-card-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 30px 70px -30px rgba(0, 0, 0, 0.8);
    --login-title: #8DBBFF;
    --login-rule-blue: #2F6FE0;
    --login-blob-a: color-mix(in srgb, var(--primary) 14%, transparent);
    --login-blob-b: color-mix(in srgb, var(--accent) 8%, transparent);
}

.login-body {
    min-height: calc(100vh / var(--ui-scale, 1));
    overflow-x: hidden;
    background: var(--login-bg);
}

.login-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }

.login-blob {
    position: absolute;
    border-radius: 50%;
    animation: drift 18s ease-in-out infinite alternate;
}
.login-blob--primary {
    top: -80px; right: -40px; width: 240px; height: 240px;
    background: var(--login-blob-a);
}
.login-blob--tertiary {
    bottom: -90px; left: -30px; width: 210px; height: 210px;
    background: var(--login-blob-b);
    animation-duration: 22s;
    animation-direction: alternate-reverse;
}
@keyframes drift {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(-14px, 18px) scale(1.06); }
}

/* Theme toggle: sidebar-coloured disc with the amber icon used in the sidebar. */
.login-theme {
    position: fixed;
    top: 12px;
    right: 14px;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: var(--nav-bg);
    color: #FCD34D;
    cursor: pointer;
    box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.45);
    transition: transform .15s var(--ease-out), box-shadow .2s ease;
}
.login-theme:hover { box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.5); }
.login-theme:active { transform: scale(.92); }
.login-theme .ms { font-size: 22px; }

.login-wrap {
    position: relative;
    display: grid;
    place-items: center;
    min-height: calc(100vh / var(--ui-scale, 1));
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    padding: 26px 28px 28px;
    overflow: hidden;
    border-color: var(--login-card-line);
    box-shadow: var(--login-card-shadow);
    --label-gap: var(--surface);
}

.js .login-card { animation: card-in .6s var(--ease-out) both; }
.js .login-card > * { animation: rise .5s var(--ease-out) both; }
.js .login-card > :nth-child(2) { animation-delay: 60ms; }
.js .login-card > :nth-child(3) { animation-delay: 110ms; }
.js .login-card > :nth-child(4) { animation-delay: 150ms; }
.js .login-card > :nth-child(n+5) { animation-delay: 190ms; }
@keyframes card-in {
    from { opacity: 0; transform: translateY(16px) scale(.985); filter: blur(4px); }
}

/* Brand band, same surface as the sidebar in each theme. */
.login-brand {
    position: relative;
    margin: -26px -28px 0;
    padding: 24px 28px 6px;
    background: var(--nav-bg);
}
/* Four-colour rule taken from the logo tiles. */
.login-brand::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 4px;
    background: linear-gradient(90deg, #D7262D 0 25%, var(--login-rule-blue) 25% 50%, #F4C430 50% 75%, #22B455 75%);
}

.login-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--login-title);
    letter-spacing: 0;
}

.login-logo {
    display: grid;
    place-items: center;
    height: 180px;
    margin-top: 8px;
}
.login-logo img {
    width: 300px;
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.login-lede { margin-top: 22px; font-size: 13px; color: var(--text-2); }

.login-busy {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 12px;
    border-radius: var(--radius-card);
    border: 1px solid var(--line);
    font-size: 14px;
}
.login-spinner {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
    border-top-color: var(--primary);
    animation: spin .8s linear infinite;
}

.login-fields { display: grid; gap: 14px; margin-top: 18px; }

.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--error) 14%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--error) 25%, transparent);
    color: color-mix(in srgb, var(--error) 75%, var(--text));
    font-size: 13px;
    animation: shake .4s var(--ease-out);
}
.login-error .ms { font-size: 18px; }
@keyframes shake {
    0%, 100% { transform: none; }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
}

.login-submit { width: 100%; height: 48px; margin-top: 30px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
    .login-blob { animation: none; }
}
