/* ==========================================================================
   BuyFreehold — authentication screens
   Self-contained: no Bootstrap, no web fonts, no external requests, so the
   strict Content-Security-Policy in SecurityHeadersMiddleware needs no
   'unsafe-inline' escape hatch.
   ========================================================================== */

:root {
    --brand-900: #061529;
    --brand-800: #0a2340;
    --brand-700: #103156;
    --brand-600: #17416f;
    --accent-500: #c9a227;
    --accent-400: #dbb84a;

    --surface: #ffffff;
    --surface-sunken: #f4f6f9;
    --border: #d9dfe7;
    --border-strong: #b9c3d0;

    --text: #101a28;
    --text-muted: #5b6979;
    --text-inverse: #ffffff;

    --danger-600: #b42318;
    --danger-50: #fef3f2;
    --danger-200: #fecdc9;

    --warning-600: #b54708;
    --success-600: #067647;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;

    --shadow-card: 0 1px 2px rgb(16 26 40 / 6%), 0 12px 32px -8px rgb(16 26 40 / 14%);
    --ring: 0 0 0 3px rgb(23 65 111 / 22%);

    --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --surface: #101823;
        --surface-sunken: #0a121c;
        --border: #253243;
        --border-strong: #35455a;

        --text: #e8edf4;
        --text-muted: #97a5b8;

        --danger-600: #f97066;
        --danger-50: #2a1512;
        --danger-200: #6b2b25;

        --warning-600: #f5a25d;
        --success-600: #4fc98a;

        --shadow-card: 0 1px 2px rgb(0 0 0 / 40%), 0 16px 40px -12px rgb(0 0 0 / 60%);
        --ring: 0 0 0 3px rgb(201 162 39 / 30%);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body.auth-page {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--surface-sunken);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
}

/* --------------------------------------------------------------------------
   Brand panel
   -------------------------------------------------------------------------- */

.auth-brand {
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 4rem;
    color: var(--text-inverse);
    background:
        radial-gradient(120% 90% at 8% 4%, rgb(23 65 111 / 92%) 0%, transparent 58%),
        radial-gradient(90% 80% at 92% 96%, rgb(201 162 39 / 20%) 0%, transparent 60%),
        linear-gradient(150deg, var(--brand-800) 0%, var(--brand-900) 100%);
}

/* A faint blueprint grid — a nod to floor plans, quiet enough to read over. */
.auth-brand::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.12;
    background-image:
        linear-gradient(to right, rgb(255 255 255 / 55%) 1px, transparent 1px),
        linear-gradient(to bottom, rgb(255 255 255 / 55%) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(75% 75% at 30% 25%, #000 0%, transparent 78%);
}

.auth-brand__inner {
    position: relative;
    z-index: 1;
    max-width: 30rem;
}

.auth-brand__mark {
    display: flex;
    align-items: center;
    margin-bottom: 3.5rem;
}

/* The artwork is transparent gold and green, so it reads directly on the navy panel with
   no plate behind it. Height is auto from the intrinsic ratio — the width/height attributes
   on the element reserve the right box before the image loads, so nothing shifts. */
.auth-brand__logo {
    width: 11.5rem;
    height: auto;
}

/* The lockup links back to the public site. Inline-flex so the link box is the
   artwork and nothing else, and a visible ring for keyboard users. */
.auth-brand__home {
    display: inline-flex;
    border-radius: var(--radius-sm);
}

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

.auth-brand__headline {
    margin: 0 0 1.25rem;
    font-size: clamp(2rem, 3.2vw, 2.85rem);
    font-weight: 600;
    line-height: 1.12;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.auth-brand__blurb {
    margin: 0 0 2.5rem;
    max-width: 26rem;
    font-size: 1.0625rem;
    color: rgb(255 255 255 / 74%);
}

.auth-brand__points {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.9rem;
}

.auth-brand__points li {
    position: relative;
    padding-left: 1.85rem;
    font-size: 0.95rem;
    color: rgb(255 255 255 / 82%);
}

.auth-brand__points li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.45rem;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    border: 2px solid var(--accent-500);
}

.auth-brand__foot {
    margin: 4rem 0 0;
    font-size: 0.8125rem;
    color: rgb(255 255 255 / 45%);
}

/* --------------------------------------------------------------------------
   Form column
   -------------------------------------------------------------------------- */

.auth-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    background: var(--surface-sunken);
}

.auth-main__mark {
    display: none;
    align-items: center;
    margin-bottom: 1.75rem;
}

.auth-main__logo {
    width: 8rem;
    height: auto;
}

.auth-card {
    width: 100%;
    max-width: 25.5rem;
    padding: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.auth-card__header {
    margin-bottom: 1.75rem;
}

.auth-card__title {
    margin: 0 0 0.4rem;
    font-size: 1.6rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--text);
}

.auth-card__subtitle {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-muted);
    text-wrap: pretty;
}

.auth-card__footer {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
}

.auth-card__footer p {
    margin: 0 0 0.4rem;
}

.auth-card__footer p:last-child {
    margin-bottom: 0;
}

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

.auth-field {
    margin-bottom: 1.15rem;
}

.auth-field--inline {
    margin-bottom: 1.5rem;
}

.auth-label,
.auth-label-row {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.875rem;
    font-weight: 550;
    color: var(--text);
}

.auth-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.auth-label-row .auth-label {
    margin-bottom: 0;
}

.auth-input {
    display: block;
    width: 100%;
    padding: 0.7rem 0.85rem;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none;
}

.auth-input::placeholder {
    color: var(--text-muted);
    opacity: 0.65;
}

.auth-input:hover {
    border-color: var(--brand-600);
}

.auth-input:focus {
    outline: none;
    border-color: var(--brand-600);
    box-shadow: var(--ring);
}

.auth-input--with-affix {
    padding-right: 3rem;
}

/* One-time codes and recovery codes: monospaced and spaced out so digits are
   easy to check against the phone in the user's other hand. */
.auth-input--code {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    letter-spacing: 0.35em;
    text-align: center;
    padding-left: 0.85rem;
}

.auth-input.input-validation-error {
    border-color: var(--danger-600);
}

.auth-input.input-validation-error:focus {
    box-shadow: 0 0 0 3px rgb(180 35 24 / 18%);
}

.auth-input-group {
    position: relative;
}

.auth-affix {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    color: var(--text-muted);
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.auth-affix:hover {
    color: var(--text);
    background: var(--surface-sunken);
}

.auth-affix:focus-visible {
    outline: none;
    color: var(--text);
    box-shadow: var(--ring);
}

.auth-affix__icon {
    width: 1.15rem;
    height: 1.15rem;
}

/* --------------------------------------------------------------------------
   Checkbox
   -------------------------------------------------------------------------- */

.auth-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    user-select: none;
}

.auth-checkbox input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.auth-checkbox__box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    flex: none;
    color: transparent;
    background: var(--surface);
    border: 1.5px solid var(--border-strong);
    border-radius: 5px;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.auth-checkbox__box svg {
    width: 0.85rem;
    height: 0.85rem;
}

.auth-checkbox input:checked + .auth-checkbox__box {
    color: var(--text-inverse);
    background: var(--brand-700);
    border-color: var(--brand-700);
}

.auth-checkbox input:focus-visible + .auth-checkbox__box {
    box-shadow: var(--ring);
}

.auth-checkbox__label {
    font-size: 0.875rem;
    color: var(--text);
}

/* --------------------------------------------------------------------------
   Button
   -------------------------------------------------------------------------- */

.auth-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    min-height: 2.85rem;
    padding: 0.7rem 1rem;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-inverse);
    background: var(--brand-700);
    border: 1px solid var(--brand-700);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.06s ease;
}

.auth-button:hover:not(:disabled) {
    background: var(--brand-600);
}

.auth-button:active:not(:disabled) {
    transform: translateY(1px);
}

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

.auth-button:disabled {
    cursor: progress;
    opacity: 0.75;
}

.auth-button--secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-strong);
}

.auth-button--secondary:hover:not(:disabled) {
    background: var(--surface-sunken);
}

.auth-button__spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgb(255 255 255 / 35%);
    border-top-color: var(--text-inverse);
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

.auth-button.is-busy .auth-button__spinner {
    display: block;
}

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

/* --------------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------------- */

.auth-alert {
    display: flex;
    gap: 0.7rem;
    margin-bottom: 1.5rem;
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
}

.auth-alert--error {
    color: var(--danger-600);
    background: var(--danger-50);
    border-color: var(--danger-200);
}

.auth-alert__icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: none;
    margin-top: 0.1rem;
}

.auth-alert__body ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-alert__body li + li {
    margin-top: 0.35rem;
}

.auth-error {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    color: var(--danger-600);
}

/* jquery-validation adds this class to spans with no message; keep the layout
   from jumping by collapsing them. */
.auth-error:empty,
.field-validation-valid {
    display: none;
}

.auth-hint {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.45rem 0 0;
    font-size: 0.8125rem;
    color: var(--warning-600);
}

.auth-hint svg {
    width: 0.95rem;
    height: 0.95rem;
    flex: none;
}

.auth-note {
    margin: 0.9rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-wrap: pretty;
}

.is-hidden {
    display: none !important;
}

/* --------------------------------------------------------------------------
   Password strength (advisory only — the server is the authority)
   -------------------------------------------------------------------------- */

.auth-strength {
    margin-top: 0.6rem;
}

.auth-strength__track {
    height: 4px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.auth-strength__bar {
    width: 0;
    height: 100%;
    background: var(--danger-600);
    border-radius: 999px;
    transition: width 0.25s ease, background-color 0.25s ease;
}

.auth-strength[data-level="2"] .auth-strength__bar {
    background: var(--warning-600);
}

.auth-strength[data-level="3"] .auth-strength__bar {
    background: var(--accent-500);
}

.auth-strength[data-level="4"] .auth-strength__bar {
    background: var(--success-600);
}

.auth-strength__label {
    margin: 0.35rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Status pages (lockout, access denied, confirmations)
   -------------------------------------------------------------------------- */

.auth-status {
    text-align: center;
}

.auth-status__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    margin-bottom: 1.15rem;
    border-radius: 50%;
}

.auth-status__icon svg {
    width: 1.65rem;
    height: 1.65rem;
}

.auth-status__icon--warning {
    color: var(--warning-600);
    background: rgb(181 71 8 / 12%);
}

.auth-status__icon--success {
    color: var(--success-600);
    background: rgb(6 118 71 / 12%);
}

.auth-status__icon--info {
    color: var(--brand-600);
    background: rgb(23 65 111 / 12%);
}

.auth-status .auth-card__subtitle {
    margin-top: 0.5rem;
}

/* --------------------------------------------------------------------------
   Links
   -------------------------------------------------------------------------- */

.auth-link {
    color: var(--brand-600);
    font-weight: 550;
    text-decoration: none;
    border-radius: 4px;
}

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

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

.auth-link--muted {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.auth-linkbutton {
    padding: 0;
    font: inherit;
    font-size: 0.875rem;
    color: var(--brand-600);
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: underline;
}

.auth-inline-form {
    display: inline;
}

@media (prefers-color-scheme: dark) {
    .auth-link,
    .auth-linkbutton,
    .auth-status__icon--info {
        color: var(--accent-400);
    }
}

/* --------------------------------------------------------------------------
   Motion — a short shake draws the eye to a failed attempt without a redirect
   -------------------------------------------------------------------------- */

.auth-shake {
    animation: auth-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 62rem) {
    .auth-brand {
        padding: 3rem;
    }

    .auth-brand__points,
    .auth-brand__foot {
        display: none;
    }
}

@media (max-width: 48rem) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-brand {
        display: none;
    }

    .auth-main__mark {
        display: inline-flex;
    }

    .auth-main {
        padding: 2rem 1rem;
    }

    .auth-card {
        padding: 1.75rem 1.35rem;
        border-radius: var(--radius);
    }
}

/* Forced-colours mode strips our palette; restore the affordances that matter. */
@media (forced-colors: active) {
    .auth-card,
    .auth-input,
    .auth-checkbox__box {
        border: 1px solid CanvasText;
    }

    .auth-button {
        border: 1px solid ButtonText;
    }
}
