/* variables.css */
:root {
    --font-family-base: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --color-background: #1b1e24;
    --color-background-gradient-start: #22262d;
    --color-background-gradient-end: #1a1b21;
    --color-surface: #202329;
    --color-border: #363b44;
    --color-border-subtle: rgba(255, 255, 255, .015);

    --color-text: #f4f7fb;
    --color-text-heading: #f2f4f8;
    --color-text-muted: #858b95;
    --color-text-placeholder: #777d87;

    --color-primary: #2878d8;
    --color-primary-hover: #3186e8;
    --color-link: #48d9ff;
    --color-success: #35e66b;
    --color-warning: #f4f84a;
    --color-caution: #ffad4d;
    --color-danger: #dc0a52;
    --color-danger-hover: #ee1762;
    --color-focus: rgba(44, 127, 223, .14);
    --color-focus-strong: rgba(72, 217, 255, .35);

    --color-error: #ffb3b3;
    --color-error-border: rgba(255, 111, 111, .32);
    --color-error-background: rgba(145, 39, 39, .14);
    --color-white: #fff;

    --shadow-card: 0 12px 30px rgba(7, 9, 13, .13);
}

/* base.css */
:root {
    color-scheme: dark;
    font-family: var(--font-family-base);
    color: var(--color-text);
    background: var(--color-background);
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

html[data-session-ready="false"] [data-page-content] {
    visibility: hidden;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background: var(--color-background);
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
}

input {
    font: inherit;
}

/* components/preloader.css */
[data-component="preloader"] {
    .preloader {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: .75rem;
        color: var(--color-text-muted);
        transition: opacity .18s ease, visibility .18s ease;

        &[data-active="false"] {
            display: none;
        }

        &[data-variant="fullscreen"] {
            position: fixed;
            z-index: 9999;
            inset: 0;
            flex-direction: column;
            background: linear-gradient(to bottom right, var(--color-background-gradient-start), var(--color-background-gradient-end));

            .preloader-spinner {
                width: 2.5rem;
                height: 2.5rem;
            }
        }

        &[data-variant="section"] {
            width: 100%;
            min-height: 8rem;
            border-radius: .75rem;
            background: color-mix(in srgb, var(--color-surface) 92%, transparent);
        }

        .preloader-spinner {
            width: 1.5rem;
            height: 1.5rem;
            border: 3px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
            border-top-color: var(--color-primary);
            border-radius: 50%;
            animation: preloader-spin .75s linear infinite;
        }

        .preloader-message {
            font-size: .78rem;
        }
    }
}

html[data-session-ready="true"] [data-global-preloader="true"] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

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

@media (prefers-reduced-motion: reduce) {
    [data-component="preloader"] .preloader-spinner {
        animation-duration: 1.5s;
    }
}

/* components/auth-screen.css */
[data-component="auth-screen"] {
    .auth-screen {
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        justify-content: center;
        padding: clamp(3rem, 9vh, 5.35rem) 1.5rem 2rem;
        background: linear-gradient(to bottom right, var(--color-background-gradient-start), var(--color-background-gradient-end));

        .auth-content {
            width: min(100%, 380px);
        }
    }

    @media (max-width: 480px) {
        .auth-screen {
            align-items: flex-start;
            padding: 2.5rem 1rem 1.5rem;
        }
    }
}

/* components/auth-brand.css */
[data-component="auth-brand"] {
    .auth-brand {
        margin-bottom: 1.55rem;
        text-align: center;

        img {
            display: block;
            width: 175px;
            height: auto;
            margin: 0 auto .55rem;
        }

        h1 {
            margin: 0;
            color: var(--color-text-heading);
            font-size: 1rem;
            font-weight: 400;
            line-height: 1.5;
        }
    }

    @media (max-width: 480px) {
        .auth-brand img {
            width: 160px;
        }
    }
}

/* components/text-form.css */
[data-component="text-form"] {
    .text-form-card {
        position: relative;
        padding: 2rem;
        border: 1px solid var(--color-border-subtle);
        border-radius: 1.5rem;
        background: var(--color-surface);
        box-shadow: var(--shadow-card);

        .form-error {
            margin: 0 0 1rem;
            padding: .75rem .9rem;
            border: 1px solid var(--color-error-border);
            border-radius: .5rem;
            background: var(--color-error-background);
            color: var(--color-error);
            font-size: .82rem;
            line-height: 1.4;
        }

        > [data-component="action-button"] {
            margin-top: 1.9rem;
        }

        > [data-component="login-options"] + [data-component="action-button"] {
            margin-top: 0;
        }
    }

    @media (max-width: 480px) {
        .text-form-card {
            padding: 1.5rem;
            border-radius: 1.15rem;
        }
    }
}

/* components/form-field.css */
[data-component="form-field"] {
    & + [data-component="form-field"] {
        margin-top: 1.15rem;
    }

    label {
        display: block;
        margin-bottom: .55rem;
        font-size: .86rem;
        font-weight: 500;
    }

    .input-control {
        position: relative;

        .field-icon {
            position: absolute;
            top: 50%;
            left: .8rem;
            width: 1rem;
            height: 1rem;
            transform: translateY(-50%);
            background: var(--color-text-muted);
            mask-position: center;
            mask-repeat: no-repeat;
            mask-size: contain;
            pointer-events: none;

            &[data-icon="mail"] {
                mask-image: url("/assets/mail.svg");
            }

            &[data-icon="lock"] {
                mask-image: url("/assets/lock.svg");
            }
        }

        input {
            width: 100%;
            height: 2.35rem;
            padding: 0 .8rem 0 2.25rem;
            border: 1px solid var(--color-border);
            border-radius: .38rem;
            outline: none;
            background: var(--color-surface);
            color: var(--color-text);
            font-size: .78rem;
            transition: border-color .16s ease, box-shadow .16s ease;

            &::placeholder {
                color: var(--color-text-placeholder);
            }

            &:focus {
                border-color: var(--color-primary);
                box-shadow: 0 0 0 3px var(--color-focus);
            }
        }
    }
}

/* components/action-button.css */
[data-component="action-button"] {
    display: block;

    .action-button {
        width: 100%;
        min-height: 2.5rem;
        border: 0;
        border-radius: .55rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .6rem;
        color: var(--color-white);
        font-weight: 700;
        text-decoration: none;
        cursor: pointer;
        transition: background .16s ease, opacity .16s ease, transform .16s ease;
    }

    .action-button-primary {
        background: var(--color-primary);

        &:hover:not(:disabled) {
            background: var(--color-primary-hover);
            transform: translateY(-1px);
        }
    }

    .action-button-danger {
        background: var(--color-danger);

        &:hover:not(:disabled) {
            background: var(--color-danger-hover);
            transform: translateY(-1px);
        }
    }

    .action-button:focus-visible {
        outline: 3px solid var(--color-focus-strong);
        outline-offset: 2px;
    }

    .action-button:disabled {
        cursor: wait;
        opacity: .72;
        transform: none;
    }

    .action-button-spinner {
        display: none;
        width: 1rem;
        height: 1rem;
        border: 2px solid color-mix(in srgb, var(--color-white) 35%, transparent);
        border-top-color: var(--color-white);
        border-radius: 50%;
        animation: action-button-spin .7s linear infinite;
    }

    .action-button[aria-busy="true"] .action-button-spinner {
        display: block;
    }
}

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

@media (prefers-reduced-motion: reduce) {
    [data-component="action-button"] .action-button-spinner {
        animation-duration: 1.4s;
    }
}

/* components/auth-prompt.css */
[data-component="auth-prompt"] {
    .auth-prompt {
        margin: 1.4rem 0 0;
        text-align: center;
        font-size: .72rem;

        a {
            color: var(--color-link);

            &:hover,
            &:focus-visible {
                text-decoration: underline;
            }
        }
    }
}

/* components/auth-footer.css */
[data-component="auth-footer"] {
    .auth-footer {
        display: flex;
        justify-content: center;
        gap: .35rem;
        margin-top: 1.25rem;
        color: var(--color-text-muted);
        font-size: .68rem;

        a {
            &:hover,
            &:focus-visible {
                color: var(--color-text);
            }
        }
    }
}
