/* Agent OS — login page styles.
   Tailwind handles the card layout. This file owns: background, ghost brand,
   shake animation, focus rings, lockout overlay. */

/* --- Background gradient + dot grid --- */

.login-bg {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 0%, rgba(99, 102, 241, 0.25), transparent 50%),
        radial-gradient(circle at 80% 100%, rgba(56, 189, 248, 0.18), transparent 50%),
        linear-gradient(180deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    color: #e2e8f0;
    /* Flex column so <main> can grow and <footer> flows naturally below. */
    display: flex;
    flex-direction: column;
}

/* Dot grid overlay */
.login-bg::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    z-index: 0;
}

/* --- Ghost wordmark behind card --- */

.brand-ghost {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(4rem, 12vw, 11rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: rgba(255, 255, 255, 0.045);
    pointer-events: none;
    z-index: 0;
    user-select: none;
    white-space: nowrap;
    text-align: center;
    line-height: 1;
}

/* --- Card --- */

main {
    /* Grow to fill space so the footer sits at the bottom of natural flow. */
    flex: 1;
}

.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 1rem;
    padding: 2rem 1.75rem;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.06);
    color: #0f172a;
}

@media (max-width: 640px) {
    /* Dynamic viewport height: iOS Safari's 100vh includes the URL bar,
       inflating the layout and pushing the card past the visible area.
       100dvh reports the *visible* viewport. Fallback for older browsers. */
    .login-bg {
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
    }
    main {
        min-height: 100vh;
        min-height: 100dvh;
        flex: 1;
        /* Respect iOS home indicator / Android gesture bar. The max() clamps
           to at least 1rem so older devices (no safe-area support) still
           get sensible padding. */
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    /* Centre the card naturally on mobile too. Removed the bottom-pinning
       + bottom-sheet aesthetic that hid the Sign in button behind the
       browser toolbar on small viewports. */
    .login-card {
        max-width: 420px;
        width: 100%;
        padding: 1.5rem 1.25rem;
        border-radius: 1rem;
    }
    /* Tone down the ghost wordmark — at clamp(4rem, 12vw, 11rem) on a
       390px screen it's 47px which dominates the viewport. */
    .brand-ghost {
        font-size: clamp(3rem, 18vw, 6rem);
    }
}

/* --- Inputs --- */

.input {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.9375rem;
    line-height: 1.25rem;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
.input[aria-invalid="true"] {
    border-color: #ef4444;
}
.input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}
.input:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

/* --- Submit button --- */

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.75rem 1rem;
    background: linear-gradient(180deg, #4f46e5 0%, #4338ca 100%);
    color: #ffffff;
    font-weight: 600;
    border-radius: 0.5rem;
    border: none;
    font-size: 0.9375rem;
    cursor: pointer;
    box-shadow: 0 4px 14px -4px rgba(67, 56, 202, 0.5);
    transition: transform 80ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px -4px rgba(67, 56, 202, 0.6);
}
.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}
.btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- Error / amber banners --- */

.error-banner {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.amber-banner {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}
.amber-banner code {
    background: rgba(146, 64, 14, 0.08);
    padding: 0 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

/* --- Footer --- */

.footer-meta {
    text-align: center;
    color: rgba(226, 232, 240, 0.4);
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    padding: 0.75rem;
    /* Respect iOS home indicator / Android gesture bar. */
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    pointer-events: none;
}

/* --- Shake animation on failed submit --- */

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
    20%, 40%, 60%, 80% { transform: translateX(6px); }
}

.shake {
    animation: shake 420ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* --- Lockout overlay --- */

.lockout-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lockout-card {
    background: #ffffff;
    border-radius: 1rem;
    padding: 2rem 2.5rem;
    text-align: center;
    max-width: 360px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
    .shake,
    .btn-primary,
    .input {
        animation: none !important;
        transition: none !important;
    }
}