/*
 * Auth pages: login, sign-up, password reset, two-step verification, email verification.
 * Mobile first: one column on phones, a brand panel beside the form from 1024px.
 * Colours are checked for WCAG AA: text >= 4.5:1, control borders >= 3:1.
 */

:root {
    color-scheme: light dark;

    --auth-brand-red: #ed1c24;
    --auth-brand-green: #006a4e;

    --auth-bg: #f5f6f8;
    --auth-surface: #ffffff;
    --auth-ink: #14161a;
    --auth-muted: #5b6270;
    --auth-border: #8a909a;
    --auth-divider: #e3e5e9;
    --auth-field-bg: #ffffff;

    --auth-primary: #d3121b;
    --auth-primary-hover: #b10e16;
    --auth-primary-ink: #ffffff;
    --auth-link: #b8111a;
    --auth-focus: rgba(211, 18, 27, 0.28);

    --auth-danger: #b42318;
    --auth-danger-bg: #fef3f2;
    --auth-danger-border: #fecdca;
    --auth-success: #067647;
    --auth-success-bg: #ecfdf3;
    --auth-success-border: #abefc6;

    --auth-radius: 12px;
    --auth-radius-sm: 10px;
    --auth-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px -12px rgba(16, 24, 40, 0.14);

    --auth-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", "Hind Siliguri", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --auth-bg: #0f1115;
        --auth-surface: #171a20;
        --auth-ink: #eef0f3;
        --auth-muted: #a3a9b4;
        --auth-border: #687080;
        --auth-divider: #2a2f38;
        --auth-field-bg: #11141a;

        --auth-link: #ff6b70;
        --auth-focus: rgba(255, 107, 112, 0.35);

        --auth-danger: #fda29b;
        --auth-danger-bg: rgba(240, 68, 56, 0.12);
        --auth-danger-border: rgba(240, 68, 56, 0.4);
        --auth-success: #75e0a7;
        --auth-success-bg: rgba(23, 178, 106, 0.12);
        --auth-success-border: rgba(23, 178, 106, 0.4);

        --auth-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -16px rgba(0, 0, 0, 0.6);
    }
}

/* ------------------------------------------------------------------ base */

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

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

body.auth {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--auth-surface);
    color: var(--auth-ink);
    font-family: var(--auth-font);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Zero specificity, so component rules below always win. */
:where(.auth) :where(h1, h2, p, ul, ol) {
    margin: 0;
}

:where(.auth) img {
    display: block;
    max-width: 100%;
    height: auto;
}

.auth [hidden] {
    display: none !important;
}

.auth-icon {
    width: 1.25em;
    height: 1.25em;
    flex: none;
}

/* ---------------------------------------------------------------- layout */

.auth-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

.auth-brand {
    display: none;
}

.auth-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding:
        max(16px, env(safe-area-inset-top))
        max(20px, env(safe-area-inset-right))
        max(20px, env(safe-area-inset-bottom))
        max(20px, env(safe-area-inset-left));
}

.auth-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    max-width: 440px;
    margin-bottom: 28px;
}

.auth-top__logo img {
    width: auto;
    height: 32px;
    max-width: 180px;
    object-fit: contain;
}

.auth-top__home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 4px;
    color: var(--auth-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    border-radius: 8px;
}

@media (max-width: 359px) {
    .auth-top__logo img {
        height: 26px;
    }
}

.auth-top__home:hover {
    color: var(--auth-ink);
}

.auth-top__home .auth-icon {
    width: 1rem;
    height: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
}

.auth-card--wide {
    max-width: 640px;
}

.auth-card--wide ~ .auth-foot,
.auth-top:has(~ .auth-card--wide) {
    max-width: 640px;
}

.auth-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 10px;
    margin-top: auto;
    padding-top: 32px;
    color: var(--auth-muted);
    font-size: 0.8125rem;
}

.auth-foot a {
    color: inherit;
    text-decoration: none;
}

.auth-foot a:hover {
    color: var(--auth-ink);
    text-decoration: underline;
}

@media (min-width: 640px) {
    body.auth {
        background: var(--auth-bg);
    }

    .auth-main {
        justify-content: center;
        padding-top: max(32px, env(safe-area-inset-top));
    }

    .auth-top {
        margin-bottom: 24px;
    }

    .auth-card {
        padding: 36px 40px;
        background: var(--auth-surface);
        border: 1px solid var(--auth-divider);
        border-radius: 20px;
        box-shadow: var(--auth-shadow);
    }

    .auth-foot {
        margin-top: 0;
        padding-top: 24px;
    }
}

/* Desktop: brand panel on the left, form on the right. */
@media (min-width: 1024px) {
    .auth-brand {
        position: sticky;
        top: 0;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        gap: 48px;
        width: min(44vw, 560px);
        height: 100vh;
        height: 100dvh;
        padding: 48px clamp(40px, 4vw, 64px);
        overflow: hidden;
        color: #ffffff;
        background:
            radial-gradient(120% 80% at 100% 0%, rgba(237, 28, 36, 0.38) 0%, rgba(237, 28, 36, 0) 55%),
            radial-gradient(110% 70% at 0% 100%, rgba(0, 106, 78, 0.55) 0%, rgba(0, 106, 78, 0) 60%),
            #121418;
        isolation: isolate;
    }

    .auth-brand::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        background-image:
            linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
            linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
        background-size: 44px 44px;
        mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0) 75%);
        -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0) 75%);
    }

    .auth-brand__logo img {
        width: auto;
        height: 40px;
        max-width: 240px;
        object-fit: contain;
    }

    .auth-brand__body {
        max-width: 420px;
    }

    .auth-brand__eyebrow {
        margin-bottom: 14px;
        color: #ff8a8f;
        font-size: 0.8125rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .auth-brand__title {
        font-size: clamp(1.75rem, 2.4vw, 2.25rem);
        font-weight: 700;
        line-height: 1.2;
        letter-spacing: -0.02em;
    }

    .auth-brand__points {
        display: grid;
        gap: 14px;
        margin-top: 32px;
        padding: 0;
        list-style: none;
        color: #d5d9df;
    }

    .auth-brand__points li {
        display: flex;
        align-items: flex-start;
        gap: 12px;
    }

    .auth-brand__points .auth-icon {
        width: 22px;
        height: 22px;
        padding: 3px;
        color: #ffffff;
        background: rgba(255, 255, 255, 0.12);
        border-radius: 999px;
    }

    .auth-brand__steps {
        display: grid;
        gap: 22px;
        margin-top: 32px;
        padding: 0;
        list-style: none;
        counter-reset: none;
    }

    .auth-brand__steps li {
        display: flex;
        gap: 14px;
        color: #c1c6ce;
        font-size: 0.9375rem;
    }

    .auth-brand__steps li > span {
        display: grid;
        place-items: center;
        flex: none;
        width: 32px;
        height: 32px;
        color: #ffffff;
        font-size: 0.875rem;
        font-weight: 700;
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 999px;
    }

    .auth-brand__steps li.is-current > span {
        background: var(--auth-brand-red);
        border-color: var(--auth-brand-red);
    }

    .auth-brand__steps strong {
        display: block;
        color: #ffffff;
        font-weight: 600;
    }

    .auth-brand__foot {
        color: #9aa1ab;
        font-size: 0.8125rem;
    }

    .auth-main {
        padding: 40px clamp(32px, 5vw, 80px);
    }

    /* The brand panel carries the logo on desktop. */
    .auth-top {
        justify-content: flex-end;
    }

    .auth-top__logo {
        display: none;
    }
}

/* --------------------------------------------------------------- heading */

.auth-heading {
    margin-bottom: 28px;
}

.auth-heading h1 {
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.auth-heading p {
    margin-top: 8px;
    color: var(--auth-muted);
}

.auth-heading p.auth-heading__step {
    margin: 0 0 8px;
    color: var(--auth-link);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.auth-heading strong {
    color: var(--auth-ink);
    font-weight: 600;
}

.auth-badge {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 18px;
    color: var(--auth-primary);
    background: color-mix(in srgb, var(--auth-primary) 10%, transparent);
    border-radius: 14px;
}

.auth-badge .auth-icon {
    width: 24px;
    height: 24px;
}

@media (prefers-color-scheme: dark) {
    .auth-badge {
        color: var(--auth-link);
    }
}

@media (min-width: 640px) {
    .auth-heading h1 {
        font-size: 1.75rem;
    }
}

/* ----------------------------------------------------------------- forms */

.auth-form {
    display: grid;
    gap: 18px;
}

.auth-field {
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
}

.auth-label {
    font-size: 0.9375rem;
    font-weight: 600;
}

.auth-input {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    color: var(--auth-ink);
    font: inherit;
    /* 16px keeps iOS Safari from zooming the page when a field is focused. */
    font-size: 1rem;
    background: var(--auth-field-bg);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

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

.auth-input:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 4px var(--auth-focus);
}

.auth-input[aria-invalid="true"] {
    border-color: var(--auth-danger);
}

.auth-input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--auth-danger) 25%, transparent);
}

.auth-input[type="date"] {
    min-width: 0;
}

.auth-input--code {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.4em;
    /* Balance the trailing letter-spacing so the digits sit visually centred. */
    text-indent: 0.4em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.auth-hint {
    color: var(--auth-muted);
    font-size: 0.8125rem;
}

.auth-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    color: var(--auth-danger);
    font-size: 0.875rem;
    font-weight: 500;
}

.auth-error .auth-icon {
    width: 1rem;
    height: 1rem;
    margin-top: 0.15em;
}

.auth-password {
    position: relative;
}

.auth-password .auth-input {
    padding-right: 52px;
}

.auth-password__toggle {
    position: absolute;
    top: 2px;
    right: 2px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--auth-muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.auth-password__toggle:hover {
    color: var(--auth-ink);
}

.auth-password__toggle span {
    display: flex;
}

.auth-password__toggle .auth-password__hide,
.auth-password__toggle[aria-pressed="true"] .auth-password__show {
    display: none;
}

.auth-password__toggle[aria-pressed="true"] .auth-password__hide {
    display: flex;
}

.auth-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
}

.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 0.9375rem;
    cursor: pointer;
}

.auth-check input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--auth-primary);
    cursor: pointer;
}

.auth-section {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.auth-section + .auth-section {
    padding-top: 22px;
    border-top: 1px solid var(--auth-divider);
}

/* Floated so the legend leaves the fieldset border and lays out like a normal heading. */
.auth-section legend {
    float: left;
    width: 100%;
    margin: 0 0 14px;
    padding: 0;
    color: var(--auth-muted);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.auth-section legend + * {
    clear: both;
}

.auth-grid {
    display: grid;
    gap: 16px;
}

@media (min-width: 640px) {
    .auth-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .auth-grid__full {
        grid-column: 1 / -1;
    }
}

.auth-captcha {
    min-height: 78px;
    overflow: hidden;
}

/* The reCAPTCHA widget is a fixed 304px; shrink it rather than overflow small phones. */
@media (max-width: 359px) {
    .auth-captcha > div {
        transform: scale(0.86);
        transform-origin: 0 0;
    }
}

.auth-fineprint,
.auth-note {
    color: var(--auth-muted);
    font-size: 0.875rem;
}

.auth-note {
    margin-bottom: 18px;
}

/* --------------------------------------------------------------- buttons */

.auth-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 12px 18px;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--auth-radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.auth-btn:active {
    transform: translateY(1px);
}

.auth-btn--primary {
    color: var(--auth-primary-ink);
    background: var(--auth-primary);
}

.auth-btn--primary:hover {
    background: var(--auth-primary-hover);
}

.auth-btn--social {
    color: var(--auth-ink);
    background: var(--auth-surface);
    border-color: var(--auth-border);
}

.auth-btn--social:hover {
    background: color-mix(in srgb, var(--auth-ink) 5%, var(--auth-surface));
}

.auth-btn.is-loading {
    color: transparent;
    pointer-events: none;
}

.auth-btn.is-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--auth-primary-ink);
    border-right-color: transparent;
    border-radius: 999px;
    animation: auth-spin 0.7s linear infinite;
}

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

.auth-social {
    display: grid;
    gap: 10px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 22px 0;
    color: var(--auth-muted);
    font-size: 0.8125rem;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--auth-divider);
}

/* ----------------------------------------------------------------- links */

.auth-link {
    color: var(--auth-link);
    font-weight: 600;
    text-decoration: none;
    text-underline-offset: 3px;
}

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

.auth-link--back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.auth-link--back .auth-icon {
    width: 1rem;
    height: 1rem;
}

.auth-link--button {
    padding: 0;
    font: inherit;
    font-weight: 600;
    background: none;
    border: 0;
    cursor: pointer;
}

.auth-switch {
    display: grid;
    gap: 10px;
    margin-top: 24px;
    padding-top: 22px;
    color: var(--auth-muted);
    font-size: 0.9375rem;
    text-align: center;
    border-top: 1px solid var(--auth-divider);
}

.auth-switch a,
.auth-switch button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
}

.auth-break {
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- alerts */

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 14px;
    font-size: 0.9375rem;
    border: 1px solid;
    border-radius: var(--auth-radius-sm);
}

.auth-alert .auth-icon {
    margin-top: 0.1em;
}

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

.auth-alert--success {
    color: var(--auth-success);
    background: var(--auth-success-bg);
    border-color: var(--auth-success-border);
}

/* ---------------------------------------------------------- focus, motion */

.auth a:focus-visible,
.auth button:focus-visible,
.auth-check input:focus-visible {
    outline: 3px solid var(--auth-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .auth *,
    .auth *::before,
    .auth *::after {
        transition-duration: 0.01ms !important;
    }

    .auth-btn.is-loading::after {
        animation-duration: 1.6s;
    }
}
