/*
 * Unified animated auth screen
 */

body.auth-page:not(.auth-ready) #app-content {
    visibility: hidden;
}

body.auth-page .content-wrapper {
    opacity: 1;
    transform: none;
    animation: none;
}

.auth-stage {
    width: min(100%, 1040px) !important;
    max-width: 1040px !important;
    min-height: auto !important;
    margin: 0 auto !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    transform: none !important;
}

.auth-shell {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 570px;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-xl, 0 20px 60px rgba(0, 0, 0, 0.35));
    isolation: isolate;
}

.auth-tabs {
    display: none;
}

.auth-forms {
    position: relative;
    z-index: 2;
    font: inherit;
    font-weight: var(--font-weight-semibold);
    min-height: 570px;
    background: var(--panel);
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-form {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    width: 100%;
    height: 100%;
    padding: clamp(28px, 5vw, 54px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-20px) scale(0.985);
    transition:
        opacity 0.2s ease,
        visibility 0s linear 0.2s,
        transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-form-head {
    margin-bottom: 4px;
}

.auth-kicker {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-form h1,
.auth-side h2 {
    margin: 0;
    line-height: 1.08;
}

.auth-form h1 {
    color: var(--text);
    font-size: clamp(2rem, 3.5vw, 2.65rem);
}

.auth-form p,
.auth-side p,
.auth-inline-action {
    color: var(--muted);
    font-size: 0.95rem;
}

.auth-form-head p {
    max-width: 34rem;
    margin: 10px 0 0;
}

.auth-field {
    display: grid;
    gap: 6px;
}

.auth-field label {
    margin: 0;
}

.auth-field input {
    min-height: 46px;
    border-radius: 8px;
}

.auth-code-field {
    display: grid;
    gap: 10px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.auth-code-field legend {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 700;
}

.auth-code-digits {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}

.auth-code-digit {
    width: 100%;
    min-width: 0;
    aspect-ratio: 1;
    min-height: 48px;
    padding: 0;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    caret-color: var(--accent);
}

.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 2px;
}

.auth-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.auth-check input {
    flex: 0 0 auto;
    margin: 0;
    margin-top: 0.25em;
}

.auth-legal {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-soft, rgba(255, 255, 255, 0.04));
}

.auth-submit {
    width: 100%;
    min-height: 46px;
    margin-top: 4px;
}

.auth-inline-action {
    margin: 0;
    text-align: center;
}

.auth-side {
    position: relative;
    z-index: 3;
    display: flex;
    min-height: 570px;
    overflow: hidden;
    color: #ffffff;
    background: var(--auth-gradient);
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-side::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.14) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255, 255, 255, 0.11) 1px, transparent 1px);
    background-size: 34px 34px;
    opacity: 0.22;
}

.auth-side-panel {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    font: inherit;
    font-weight: var(--font-weight-semibold);
    padding: clamp(32px, 5vw, 58px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(18px);
    transition:
        opacity 0.2s ease,
        visibility 0s linear 0.2s,
        transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-side .auth-kicker,
.auth-side p {
    color: rgba(255, 255, 255, 0.82);
}

.auth-side h2 {
    max-width: 12ch;
    color: #ffffff;
    font-size: clamp(2.25rem, 4vw, 3.35rem);
}

.auth-side p {
    max-width: 28rem;
    margin: 0;
}

.auth-side button {
    width: fit-content;
    min-width: 170px;
    margin-top: 8px;
    border-color: rgba(255, 255, 255, 0.72);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    box-shadow: none;
}

.auth-side button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.auth-stage[data-auth-mode="register"] .auth-forms {
    transform: translateX(100%);
}

.auth-stage[data-auth-mode="register"] .auth-side {
    transform: translateX(-100%);
}

.auth-stage[data-auth-mode="login"] .auth-form[data-auth-panel="login"],
.auth-stage[data-auth-mode="code"] .auth-form[data-auth-panel="code"],
.auth-stage[data-auth-mode="register"] .auth-form[data-auth-panel="register"],
.auth-stage[data-auth-mode="forgot"] .auth-form[data-auth-panel="forgot"],
.auth-stage[data-auth-mode="login"] .auth-side-panel[data-auth-side="login"],
.auth-stage[data-auth-mode="code"] .auth-side-panel[data-auth-side="code"],
.auth-stage[data-auth-mode="register"] .auth-side-panel[data-auth-side="register"],
.auth-stage[data-auth-mode="forgot"] .auth-side-panel[data-auth-side="forgot"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0) scale(1);
}

.auth-stage[data-auth-mode="register"] .auth-form[data-auth-panel="login"],
.auth-stage[data-auth-mode="code"] .auth-form[data-auth-panel="login"],
.auth-stage[data-auth-mode="forgot"] .auth-form[data-auth-panel="login"] {
    transform: translateX(22px) scale(0.985);
}

@media (max-width: 860px) {
    .auth-stage {
        width: min(100%, 560px) !important;
    }

    .auth-shell {
        display: block;
        min-height: auto;
        overflow: visible;
    }

    .auth-tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        padding: 12px;
        border-bottom: 1px solid var(--line);
        background: var(--panel-strong, rgba(0, 0, 0, 0.12));
    }

    .auth-tabs a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 38px;
        padding: 6px 8px;
        border: 1px solid transparent;
        border-radius: 8px;
        color: var(--muted);
        font-size: 0.86rem;
        font-weight: 600;
        text-align: center;
    }

    .auth-tabs a[aria-current="page"] {
        border-color: var(--line);
        background: var(--panel);
        color: var(--text);
    }

    .auth-forms,
    .auth-stage[data-auth-mode="register"] .auth-forms {
        min-height: auto;
        transform: none;
    }

    .auth-form {
        position: static;
        display: none;
        min-height: auto;
        padding: clamp(22px, 7vw, 36px);
    }

    .auth-stage[data-auth-mode="login"] .auth-form[data-auth-panel="login"],
    .auth-stage[data-auth-mode="code"] .auth-form[data-auth-panel="code"],
    .auth-stage[data-auth-mode="register"] .auth-form[data-auth-panel="register"],
    .auth-stage[data-auth-mode="forgot"] .auth-form[data-auth-panel="forgot"] {
        display: flex;
    }

    .auth-side {
        display: none;
    }
}

@media (max-width: 520px) {
    .auth-stage {
        width: 100% !important;
    }

    .auth-shell {
        border-radius: 8px;
    }

    .auth-options {
        align-items: flex-start;
        flex-direction: column;
    }

    .auth-code-digits {
        gap: clamp(3px, 1.5vw, 6px);
    }

    .auth-code-digit {
        min-height: 0;
        padding: 0;
        font-size: clamp(1rem, 5vw, 1.25rem);
    }

    .auth-tabs {
        gap: 4px;
        padding: 8px;
    }

    .auth-tabs a {
        min-width:0;
        padding-inline:4px;
        overflow-wrap:anywhere;
    }

    .auth-form {
        max-width:100%;
        padding:clamp(18px,5vw,24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-forms,
    .auth-form,
    .auth-side,
    .auth-side-panel {
        transition: none;
    }
}
