/* SIGN-IN — the status page's iOS 27 grouped-glass language, at its quietest.
 *
 * The canvas is the shared page canvas (THE PAGE CANVAS in tokens/bridge.css), so signing in
 * lands on the same ground the board stands on. One glass card, one accent for the one action.
 * Status colours appear only where they mean something: red for a failed attempt, never green
 * for a button, because green on this product means Healthy.
 *
 * Nothing on this page reads board data. It is reachable in maintenance and before any
 * session, so it shows the brand, the form and nothing else. */
* {
    box-sizing: border-box;
    font-family: var(--font-text);
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-primary);
}

#bgCanvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    pointer-events: none;
    z-index: 0;
    opacity: 0.32;
}

.auth-shell {
    --auth-pad-top: calc(24px + env(safe-area-inset-top));
    --auth-pad-right: calc(24px + env(safe-area-inset-right));
    --auth-pad-bottom: calc(24px + env(safe-area-inset-bottom));
    --auth-pad-left: calc(24px + env(safe-area-inset-left));
    height: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding:
        var(--auth-pad-top)
        var(--auth-pad-right)
        var(--auth-pad-bottom)
        var(--auth-pad-left);
    position: relative;
    z-index: 1;
}

.auth-stack {
    width: 100%;
    max-width: 420px;
    height: 100%;
    min-height: 100%;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
    justify-items: center;
    animation: fadeInDesktop 0.4s ease-out both;
}

@keyframes fadeInDesktop {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-card {
    grid-row: 2;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    width: 100%;
    padding: 30px 28px 28px;
    border-radius: var(--radius-card);
    background: color-mix(in srgb, var(--surface-card) 78%, transparent);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    backdrop-filter: blur(24px) saturate(1.6);
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, var(--text-primary) 9%, transparent),
        0 0 0 1px color-mix(in srgb, var(--border-hairline) 14%, transparent),
        0 24px 60px rgba(0, 0, 0, 0.45);
}

/* The one decoration: a soft accent light from the card's top-left corner. */
.auth-card-wash {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(70% 60% at 0% 0%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%),
        radial-gradient(60% 50% at 100% 100%, color-mix(in srgb, var(--chart-2) 12%, transparent), transparent 70%);
}

/* D&I, then the Intelligent Operations lockup immediately beside it, on one row — the same
 * pairing the status page header carries. The row sizes to the two marks rather than to a
 * measure, so it stays centred under the card at any width.
 *
 * The bottom margin is what sets how far the pair sits above the card: the stack is the bottom
 * item of grid row 1, so growing this margin lifts it. */
.auth-logo-stack {
    grid-row: 1;
    align-self: end;
    width: auto;
    max-width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin: 0 0 48px;
}

/* One shared height, auto width. The artwork aspect ratios differ (D&I 2.85:1, the IO lockup
 * 3.4:1), so equal height is what aligns them; any fixed width stretches one of them. */
.auth-brand-mark {
    display: block;
    width: auto;
    height: 34px;
    flex-shrink: 1;
    min-width: 0;
    object-fit: contain;
}

.auth-eyebrow {
    margin: 0 0 6px;
    color: var(--text-secondary);
    font-size: var(--size-caption);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 2.1rem;
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: -0.025em;
    /* background-clip: text paints only inside the box, and a tight line-height ends the box
     * above the descenders ("g", "p", "y"), which then lose their bottom. The padding gives the
     * glyphs room; the equal negative margin keeps the layout exactly where it was. */
    padding-bottom: 0.14em;
    margin-bottom: -0.14em;
    background: linear-gradient(120deg, var(--text-primary) 40%, color-mix(in srgb, var(--accent) 65%, var(--text-primary)));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

p {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--size-body-sm);
}

.auth-lede {
    margin: 8px 0 24px;
}

#loginForm {
    display: grid;
    gap: 16px;
}

.input-group {
    display: grid;
    gap: 6px;
}

label {
    font-size: var(--size-label);
    color: var(--text-secondary);
    font-weight: var(--weight-semibold);
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input {
    width: 100%;
    min-height: 46px;
    border-radius: var(--radius-control);
    border: 1px solid color-mix(in srgb, var(--border-hairline) 28%, transparent);
    background: color-mix(in srgb, var(--surface-inset) 70%, transparent);
    color: var(--text-primary);
    padding: 12px 14px;
    font-size: var(--size-body);
    transition: var(--transition-hover), var(--transition-press);
}

.password-wrapper input {
    padding-right: 44px;
}

input:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--accent) 65%, transparent);
    background: color-mix(in srgb, var(--surface-inset) 90%, transparent);
    box-shadow: var(--focus-ring);
}

input[aria-invalid="true"] {
    border-color: color-mix(in srgb, var(--status-danger) 55%, transparent);
}

.field-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 0;
    color: color-mix(in srgb, var(--status-attention) 75%, var(--text-primary));
    font-size: var(--size-caption);
    font-weight: var(--weight-medium);
}

.field-hint::before {
    content: "";
    width: 9px;
    height: 8px;
    background: var(--status-attention);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.toggle-password {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-control);
    transition: var(--transition-hover), var(--transition-press);
    margin: 0;
}

.toggle-password:hover {
    background: color-mix(in srgb, var(--surface-hover) 10%, transparent);
    color: var(--text-primary);
}

.toggle-password:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

button[type="submit"] {
    min-height: 48px;
    margin-top: 4px;
    border: 0;
    border-radius: var(--radius-control);
    padding: 12px;
    font-weight: var(--weight-semibold);
    font-size: var(--size-body);
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text-on-accent) 22%, transparent);
    cursor: pointer;
    transition: var(--transition-hover), var(--transition-press);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button[type="submit"]:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent) 88%, var(--text-on-accent));
    box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent);
}

button[type="submit"]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

button[type="submit"]:active:not(:disabled) {
    transform: scale(0.985);
}

button[type="submit"]:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.feedback {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: var(--size-body-sm);
    line-height: 1.4;
    border-radius: var(--radius-control);
    padding: 10px 12px;
    background: color-mix(in srgb, var(--status-danger) 14%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--status-danger) 32%, transparent);
    color: var(--red-on-tint);
    animation: slideDown 0.3s ease-out;
}

/* The board's critical mark, a square: the same shape means the same thing everywhere. */
.feedback::before {
    content: "";
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    margin-top: 5px;
    border-radius: 2px;
    background: var(--status-danger);
}

.feedback.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none;
}

.auth-watermark {
    grid-row: 3;
    align-self: start;
    width: max-content;
    max-width: 100%;
    margin: 24px 0 0;
    font-size: var(--size-caption);
    color: var(--text-tertiary);
    letter-spacing: 0.03em;
    text-align: center;
}

@media (max-width: 768px) {
    .auth-shell {
        --auth-pad-top: calc(28px + env(safe-area-inset-top));
        --auth-pad-right: calc(20px + env(safe-area-inset-right));
        --auth-pad-bottom: calc(28px + env(safe-area-inset-bottom));
        --auth-pad-left: calc(20px + env(safe-area-inset-left));
    }

    .auth-stack {
        width: min(100%, 420px);
        height: 100%;
        min-height: 100%;
        animation: fadeInMobile 0.35s ease-out both;
    }

    @keyframes fadeInMobile {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

@media (max-width: 480px) {
    .auth-shell {
        --auth-pad-top: calc(24px + env(safe-area-inset-top));
        --auth-pad-right: calc(16px + env(safe-area-inset-right));
        --auth-pad-bottom: calc(24px + env(safe-area-inset-bottom));
        --auth-pad-left: calc(16px + env(safe-area-inset-left));
    }

    /* The pair stays a row down to the narrowest phone: at 28px the two marks plus the gap run
     * about 214px, which still clears a 288px content box. */
    .auth-logo-stack {
        gap: 24px;
        margin-bottom: 40px;
    }

    .auth-brand-mark {
        height: 28px;
    }

    .auth-card {
        padding: 24px 20px 22px;
    }

    h1 {
        font-size: clamp(1.6rem, 8vw, 1.9rem);
    }

    .auth-lede {
        margin-bottom: 20px;
    }

    input,
    button[type="submit"] {
        min-height: 44px;
        font-size: 16px;
        padding-top: 11px;
        padding-bottom: 11px;
    }
}

@media (max-width: 360px) {
    .auth-shell {
        --auth-pad-top: calc(12px + env(safe-area-inset-top));
        --auth-pad-right: calc(12px + env(safe-area-inset-right));
        --auth-pad-bottom: calc(12px + env(safe-area-inset-bottom));
        --auth-pad-left: calc(12px + env(safe-area-inset-left));
    }

    .auth-card {
        padding: 18px;
    }
}

@media (max-height: 720px) {
    .auth-shell {
        --auth-pad-top: calc(16px + env(safe-area-inset-top));
        --auth-pad-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .auth-logo-stack {
        margin-bottom: 36px;
    }

    .auth-watermark {
        margin-top: 16px;
    }
}

@supports (height: 100svh) and (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        .auth-shell {
            height: auto;
            min-height: 100svh;
        }

        .auth-stack {
            height: auto;
            min-height: calc(100svh - var(--auth-pad-top) - var(--auth-pad-bottom));
        }

        #bgCanvas {
            height: 100svh;
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-stack,
    .feedback,
    .spinner {
        animation: none;
    }
}
