:root {
    /* Blue ramp based on #0284C7 (page bg), with one/two steps darker for the
       button and its hover, matching the original design's bg-lighter /
       button-darker relationship. */
    --login-bg: #0284C7;
    --btn-primary: #0369A1;
    --btn-hover: #075985;
    --panel: #FFFFFF;
    --input-bg: #F2F2F2;
    --text-main: #555555;
    --text-muted: #AAAAAA;
    --text-error: #C0392B;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    /* Each auth page carries its own background image via a body class:
       body.page-login -> static/images/auth/login-bg.png (etc.)
       Overwrite those files to change the art, no code edit needed. The
       fallback colour shows while an image is missing; the scrim keeps the
       white panel readable over any artwork. */
    background-color: var(--login-bg);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-content: center;
    place-items: center;
    padding: 24px;
    -webkit-font-smoothing: antialiased;
}

body.page-login {
    background-image: linear-gradient(rgba(23, 48, 82, 0.45), rgba(23, 48, 82, 0.45)),
        url("../images/auth/login.jpeg");
}

body.page-signup {
    background-image: linear-gradient(rgba(23, 48, 82, 0.45), rgba(23, 48, 82, 0.45)),
        url("../images/auth/signup.jpeg");
}

body.page-guardians {
    background-image: linear-gradient(rgba(23, 48, 82, 0.45), rgba(23, 48, 82, 0.45)),
        url("../images/auth/login.jpeg");
}

.otp-input {
    text-align: center;
    letter-spacing: 0.45em;
    font-size: 1.25rem;
}

/* Inline text button (used for htmx resend inside .login-register). */
.link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--btn-primary);
    cursor: pointer;
}

.link-btn:hover {
    text-decoration: underline;
}

.login-panel {
    width: min(440px, 100%);
    background-color: var(--panel);
    border-radius: 4px;
    box-shadow: 0 12px 32px rgba(15, 35, 65, 0.25);
    padding: clamp(36px, 8vw, 56px) clamp(28px, 7vw, 48px);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.form-logo-img {
    width: min(93.75px, 100%);
    height: auto;
    align-self: center;
}

.form-logo {
    min-height: 28px;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    color: var(--btn-primary);
    text-align: center;
}

.login-panel input {
    width: 100%;
    background-color: var(--input-bg);
    border: none;
    border-radius: 3px;
    padding: 18px 20px;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 300;
    color: var(--text-main);
}

/* Password field wrapper: positions the visibility toggle inside the input. */
.field {
    position: relative;
}

.login-panel .field input {
    padding-right: 56px;
}

.field-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    padding: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s ease;
}

.field-toggle:hover,
.field-toggle:focus-visible {
    color: var(--btn-primary);
}

.field-toggle .toggle-slash {
    display: none;
}

.field-toggle.is-visible .toggle-slash {
    display: inline;
}

.login-panel input::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

.login-panel input:focus {
    outline: none;
    box-shadow: inset 0 0 0 1px var(--btn-primary);
}

.login-btn {
    width: 100%;
    background-color: var(--btn-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 3px;
    padding: 18px 20px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.login-btn:hover {
    background-color: var(--btn-hover);
}

/* In-flight state: while an htmx request from this form (or button) is
   running, the button turns green and shows a spinning progress ring.
   htmx puts .htmx-request on the form for submit-triggered requests and on
   the button itself for hx-post buttons (e.g. Resend code). */
.login-btn::after {
    content: "";
    display: none;
    width: 15px;
    height: 15px;
    margin-left: 10px;
    vertical-align: -2px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
}

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

.login-panel.htmx-request .login-btn,
.login-btn.htmx-request {
    background-color: #16A34A;
    pointer-events: none;
}

.login-panel.htmx-request .login-btn::after,
.login-btn.htmx-request::after {
    display: inline-block;
}

.login-feedback {
    font-size: 0.95rem;
    text-align: center;
    color: var(--text-error);
    /* Always occupies its line so swapping a message in/out never resizes the
       panel, which keeps the form pinned at the page center. */
    min-height: 1.4em;
}

.login-register {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 300;
    color: var(--text-muted);
}

.login-register a {
    color: var(--btn-primary);
    text-decoration: none;
}

.login-register a:hover {
    text-decoration: underline;
}

.powered-by {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 300;
    color: var(--text-muted);
}

/* Responsive overrides live at the END of this file so they win the cascade
   against the base rules above. */

/* Mobile browsers misbehave with fixed attachment (jumpy/zoomed backgrounds). */
@media (max-width: 768px) {
    body {
        background-attachment: scroll;
    }
}

@media (max-width: 480px) {
    body {
        padding: 16px;
    }

    .login-panel {
        gap: 16px;
    }

    .form-logo-img {
        width: min(93.75px, 100%);
        height: auto;
    }

    .form-logo {
        min-height: 24px;
        font-size: 1.1rem;
    }

    .login-panel input,
    .login-btn {
        padding: 16px 18px;
    }
}

/* Short landscape screens: compress vertical rhythm to avoid scrolling. */
@media (max-height: 640px) {
    body {
        padding: 12px;
    }

    .login-panel {
        gap: 12px;
        padding-block: clamp(20px, 5vh, 32px);
    }

    .form-logo {
        min-height: 36px;
        font-size: 1.15rem;
    }

    .login-panel input,
    .login-btn {
        padding: 14px 18px;
    }
}
