/* ======================================================================
 * Auth screens — scoped to `.auth-page`
 * ----------------------------------------------------------------------
 * One centred form and the developer's name under it. Nothing else is on
 * these pages, so nothing else is styled here.
 *
 * The fields are Bootstrap's documented `.form-floating` with Metronic's
 * `.form-control-solid`, so there is no floating-label CSS here and no JS
 * driving it. Colours come from Metronic's `--bs-*` variables, or from a
 * white at low alpha over the page's own dark ground.
 *
 * No animation, no transitions — as everywhere else in this app.
 * ====================================================================== */

.auth-page {
    margin: 0;
    color-scheme: dark;
    background-color: var(--bs-app-blank-bg-color);
    /* A brand tint in two corners, so the form sits on a surface rather than
       in a flat black rectangle. */
    background-image:
        radial-gradient(circle at 15% 20%, rgba(27, 132, 255, 0.16), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(114, 57, 234, 0.14), transparent 45%);
    background-attachment: fixed;
}

/* ----------------------------------------------------------------------
 * The page
 * ------------------------------------------------------------------- */

.auth-page .auth-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    /* `svh` is the small viewport height: on a phone the browser's own bars
       are already taken out of it, so the form is not pushed under them. */
    min-height: 100vh;
    min-height: 100svh;
    padding: 32px 16px;
}

.auth-page .auth-card {
    width: 100%;
    /*
     * Sizes that decide the layout are written in pixels on purpose: Metronic
     * scales the root font size with the viewport (12px on a phone, 13px on a
     * laptop), so a card measured in `rem` came out narrowest on the screen
     * that needed it widest. Type still scales; the box does not.
     */
    max-width: 320px;
    /*
     * No box at all: no background, no border, no shadow. What is on the page
     * is the form itself, sitting on the page's own ground — the fields carry
     * their own surface, and nothing is drawn around them.
     */
    padding: 0;
}

.auth-page .auth-card-head {
    text-align: center;
    margin-bottom: 28px;
}

.auth-page .auth-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    border-radius: 14px;
    background: rgba(var(--bs-primary-rgb), 0.14);
    color: var(--bs-primary);
}

.auth-page .auth-title {
    margin: 0;
    /* Metronic's dark theme inverts the grey ramp: `gray-100` is nearly black
       there, and `gray-900` is the near-white this needs. */
    color: var(--bs-gray-900);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.3;
}

.auth-page .auth-alt {
    margin: 20px 0 0;
    text-align: center;
    font-size: 0.9375rem;
    color: var(--bs-gray-600);
}

/*
 * The developer's name, in the bottom-left corner with its own mark.
 *
 * It reads left to right in either language, so the corner is the physical
 * left one rather than the start of the text direction.
 */
.auth-page .auth-credit {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 3;
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    direction: ltr;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bs-gray-600);
}

.auth-page .auth-credit img {
    height: 20px;
    width: auto;
}

/* ----------------------------------------------------------------------
 * The flip: sign in and sign up, back to back
 * ----------------------------------------------------------------------
 * Both forms are on the page; the link between them turns the card over
 * instead of fetching another one. The two faces share one grid cell, so
 * the container is as tall as the taller of them and the turn does not
 * change the page's height half way through.
 * ------------------------------------------------------------------- */

.auth-page .auth-flip {
    width: 100%;
    /* A sign-in form is a short column, not a page-wide bar: past about this
       width the two fields read as a stretched table rather than a form. */
    max-width: 320px;
    perspective: 1600px;
}

.auth-page .auth-flip-inner {
    display: grid;
    transform-style: preserve-3d;
    /* The one deliberate movement in this app: turning the card is the whole
       point of putting the two forms on one page. */
    transition: transform 0.55s ease;
}

.auth-page .auth-flip[data-auth-side="register"] .auth-flip-inner {
    transform: rotateY(180deg);
}

.auth-page .auth-face {
    grid-area: 1 / 1;
    /* Chrome needs the prefix for a face to hide when it turns away. */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.auth-page .auth-face-register {
    transform: rotateY(180deg);
}

/* The face that is turned away takes no clicks and no tab stops. */
.auth-page .auth-face[aria-hidden="true"] {
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .auth-page .auth-flip-inner {
        transition: none;
    }
}

/* ----------------------------------------------------------------------
 * Fields
 * ------------------------------------------------------------------- */

/* A field can hold either script; let each value read in its own direction. */
.auth-page .form-control {
    unicode-bidi: plaintext;
    text-align: start;
}

.auth-page .auth-field + .auth-field {
    margin-top: 16px;
}

/*
 * One dark surface per field.
 *
 * Bootstrap floats the label by painting a patch of `--bs-body-bg` behind it,
 * so the word can sit over the control's top edge. Metronic's
 * `.form-control-solid` fills the control with `--bs-gray-100`, which is a
 * step lighter — so on this dark page the floated label wore a visible darker
 * smudge, and the field read as two colours rather than one.
 *
 * Taking the label's own colour for the control settles it: the patch and the
 * field become the same near-black, and the label simply sits on the field.
 */
.auth-page .form-floating > .form-control,
.auth-page .form-floating > .form-control:focus,
.auth-page .form-floating > .form-control:hover {
    background-color: var(--bs-body-bg);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 10px;
    color: var(--bs-gray-900);
}

.auth-page .form-floating > .form-control:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

/*
 * Focus, in the page's own colours.
 *
 * The app's blue ring belongs on a blue-accented screen; here the page is a
 * dark ground with one blue thing on it — the button — and a blue box around a
 * field competed with it. The focused field simply comes forward instead: a
 * brighter edge and a faint halo, both plain white at low alpha.
 */
.auth-page .form-floating > .form-control:focus {
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06);
}

.auth-page .auth-submit {
    width: 100%;
    margin-top: 24px;
    /* A comfortable target on a touch screen, and a solid bar on a desktop. */
    min-height: 48px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
}

/* The eye button sits inside the control, so the text must not run under it. */
.auth-page .auth-password-toggle {
    position: absolute;
    inset-inline-end: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--bs-gray-600);
}

.auth-page .auth-password-toggle:hover,
.auth-page .auth-password-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    color: var(--bs-gray-800);
}

/* Keenicons paints its own grey on every `.ki-*`, so an icon takes the colour
   of the thing it belongs to only when told to. */
.auth-page .auth-password-toggle > i,
.auth-page .auth-field-warning > i {
    color: inherit;
}

.auth-page .form-floating:has(.auth-password-toggle) .form-control {
    padding-inline-end: 52px;
}

.auth-page .auth-field-hint,
.auth-page .auth-field-warning {
    margin: 8px 0 0;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.auth-page .auth-field-hint {
    color: var(--bs-gray-600);
}

.auth-page .auth-field-warning {
    display: flex;
    align-items: center;
    color: var(--bs-warning);
}

/*
 * A field the server rejected. The `:focus` selector is here so the rejection
 * outranks the focus border: a failed sign-in flags both fields and puts the
 * cursor in the first, which would otherwise show blue and leave only one of
 * the two marked. Focus is still legible — it keeps its ring.
 */
.auth-page .auth-field-invalid .form-control,
.auth-page .auth-field-invalid .form-control:focus {
    border-color: var(--bs-danger);
}

.auth-page .auth-field-invalid .form-control:focus {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-danger-rgb), 0.25);
}

/* Bootstrap recolours a floating label on focus, so the focused case is named
   here too — otherwise one rejected field's label is red and the other's grey. */
.auth-page .auth-field-invalid label,
.auth-page .auth-field-invalid .form-control:focus ~ label {
    color: var(--bs-danger);
}

/*
 * Chrome paints autofilled inputs with its own yellow and ignores
 * `background-color`. The inset shadow trick is the only way to keep a dark
 * field dark; the 99999s transition stops Chrome re-applying its colour.
 */
.auth-page input:-webkit-autofill,
.auth-page input:-webkit-autofill:hover,
.auth-page input:-webkit-autofill:focus,
.auth-page input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--bs-body-bg) inset !important;
    -webkit-text-fill-color: var(--bs-body-color) !important;
    caret-color: var(--bs-body-color);
    transition: background-color 99999s ease-out 0s !important;
}

/* ----------------------------------------------------------------------
 * Small and short screens
 * ------------------------------------------------------------------- */

@media (max-width: 575.98px) {
    .auth-page .auth-title {
        font-size: 1.5rem;
    }

    /*
     * 16px exactly, not `1rem`: iOS Safari zooms the page when a field's text
     * is under 16px, and Metronic's root size on a phone makes `1rem` 12px.
     */
    .auth-page .form-floating > .form-control,
    .auth-page .form-floating > label {
        font-size: 16px;
    }

    .auth-page .form-floating > .form-control {
        height: 56px;
        min-height: 56px;
    }
}

/*
 * A short window — a laptop in landscape with the browser bars, or a phone
 * lying down. Centring would clip the top of the card, so the page starts at
 * the top and scrolls instead, and the credit stops being fixed: pinned to a
 * corner of a scrolling page it would sit on top of the form.
 */
@media (max-height: 700px) {
    .auth-page .auth-main {
        justify-content: flex-start;
    }

    .auth-page .auth-credit {
        position: static;
    }
}
