/* ── Intro Animation ───────────────────────────────────── */

/* above .auth-view (z-index 1), which itself sits above the fixed .page-logo */
.intro {
    position: fixed;
    inset: 0;
    z-index: 2;
    background-color: var(--color-primary);
    transition: opacity 400ms ease-in-out, visibility 0s linear 400ms;
}

.intro-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    aspect-ratio: 101 / 122;
    transform: translate(-50%, -50%);
    transition: top 600ms ease-in-out, left 600ms ease-in-out, width 600ms ease-in-out, transform 600ms ease-in-out;
}

.intro-logo-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.intro-logo-img-dark {
    opacity: 0;
}

.intro-animate .intro-logo {
    top: var(--auth-logo-offset);
    left: var(--auth-content-inset);
    width: var(--auth-logo-size);
    transform: translate(0, 0);
}

.intro-hidden {
    opacity: 0;
    visibility: hidden;
}

/* ── Page ──────────────────────────────────────────────── */

.page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* .page-logo is position:fixed (so it can hand off seamlessly from the intro
   animation) and doesn't occupy flow space on its own — reserve its footprint
   here so auth content never renders underneath it, e.g. once
   .signup-hint-header disappears below 530px and this header would otherwise
   collapse to 0 height. */
.page-header {
    min-height: calc(var(--auth-logo-offset) * 2 + var(--auth-logo-size));
}

.page-logo {
    position: fixed;
    top: var(--auth-logo-offset);
    left: var(--auth-content-inset);
    width: var(--auth-logo-size);
    aspect-ratio: 101 / 122;
    object-fit: contain;
}

.page-footer {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-sm);
}

.page-footer a {
    font-size: 16px;
    color: var(--color-text-muted);
}

.page-footer a:hover {
    color: var(--color-link);
}

/* ── Sign-up Hint ──────────────────────────────────────── */

.signup-hint {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 16px;
    color: var(--color-text);
}

.signup-hint-card .btn {
    padding: 15px 22px;
}

.signup-hint-header {
    position: fixed;
    top: var(--auth-logo-offset);
    right: var(--auth-content-inset);
    display: none;
}

/* ── Auth Cards ────────────────────────────────────────── */

.auth {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-view {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    z-index: 1;
}

.auth-card {
    width: 100%;
    max-width: 650px;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: 1rem clamp(var(--space-xs), 4vw, var(--space-lg));
    background: var(--color-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-card);
}

/* Fluidly scales 32px/16px (320px viewport) to 48px/115px (1024px+
   viewport) instead of jumping at a breakpoint. */
.auth-card-login {
    padding: clamp(32px, 24.73px + 2.27vw, 48px) clamp(16px, 14.06vw - 29px, 115px);
}

/* Same fluid scaling as .auth-card-login, just with the signup card's own
   32px/16px (320px) to 48px/88px (1024px+) target padding. */
.auth-card-signup {
    padding: clamp(32px, 24.73px + 2.27vw, 48px) clamp(16px, 10.23vw - 16.73px, 88px);
}

.is-hidden {
    display: none;
}

/* ── Role Choice ───────────────────────────────────────── */

/* body.is-dark is set while the role choice is visible (see auth.js #show) */
body.is-dark {
    background: var(--color-primary);
}

.page-logo-light,
.is-dark .page-logo-dark {
    display: none;
}

.is-dark .page-logo-light {
    display: block;
}

.is-dark .page-footer a,
.is-dark .page-footer a:hover {
    font-family: var(--font-open-sans);
    color: var(--color-white);
}

.role-view {
    gap: 18px;
}

.signup-hint-light {
    gap: var(--space-sm);
    font-family: var(--font-open-sans);
    color: var(--color-white);
}

.signup-link {
    padding: 0;
    border: none;
    background: none;
    font-family: inherit;
    color: var(--color-white);
    cursor: pointer;
}

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

.role-card {
    max-width: 789px;
    min-height: 400px;
    gap: 0;
    padding: var(--space-card-y) var(--space-card-x);
    box-shadow: var(--shadow-card-strong);
}

/* .role-card raises specificity over .auth-title, which is defined further down */
.role-card .role-title {
    /* 16px gap from the text to the 3px accent line drawn in the padding */
    padding-bottom: calc(var(--space-sm) + 3px);
    font-family: var(--font-open-sans);
    font-size: var(--fs-title-lg);
    color: var(--color-primary);
}

.role-intro {
    margin-top: var(--space-md);
    font-family: var(--font-open-sans);
    font-size: var(--fs-body-lg);
    color: var(--color-primary);
    text-align: center;
}

.role-options {
    display: flex;
    flex-direction: column;
    gap: 70px;
    margin-top: 56px;
}

.role-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.role-option-label {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    font-family: var(--font-open-sans);
    font-size: var(--fs-label-lg);
    color: var(--color-primary);
}

.role-icon {
    width: 18px;
    height: 18px;
}

.role-icon-group {
    width: 22px;
}

.role-option .btn {
    min-width: 180px;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--fs-body-lg);
    font-weight: var(--font-weight-regular);
}

.auth-title {
    position: relative;
    align-self: center;
    padding-bottom: var(--space-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
}

.auth-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: clamp(4rem, 12vw, 8rem);
    height: 3px;
    background: var(--color-accent);
    border-radius: var(--border-radius-sm);
    transform: translateX(-50%);
}

.auth-card-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card-head .close-btn {
    position: absolute;
    left: 0;
}

.auth-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2xs);
}

/* Renders the LOGIN_ERROR_MESSAGE's \n as a real line break and reserves its
   two-line height only on narrow screens, where the generic login error
   would otherwise wrap unpredictably or shift the layout when it appears. */
#loginPasswordError {
    white-space: pre-line;
    min-height: 2.4em;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    justify-content: center;
}

.auth-buttons .btn {
    flex: 1 1 auto;
    width: 180px;
    padding: 16px 24px;
}

/* ── Breakpoints ───────────────────────────────────────── */

@media (min-width: 768px) {
    .intro {
        background-color: var(--color-bg);
    }

    .intro-logo-img-light {
        opacity: 0;
    }

    .intro-logo-img-dark {
        opacity: 1;
    }

    .page-footer {
        padding: var(--space-md);
    }

    .signup-hint-card {
        display: none;
    }

    .signup-hint-card .btn {
        padding: 15px 16px;
    }

    .signup-hint-header {
        display: flex;
    }

    .auth-card-login {
        max-height: 500px;
    }

    .auth-card {
        gap: var(--space-lg);
    }

    /* the role card spaces its content with margins, not the card gap */
    .role-card {
        gap: 0;
    }

    .is-dark .signup-hint-header {
        display: none;
    }

    #loginPasswordError {
        white-space: normal;
        min-height: 1.2em;
    }

    .auth-buttons {
        flex-direction: row;
        margin-top: var(--space-md);
    }

    .auth-buttons .btn {
        width: auto;
        padding: 12px 24px;
    }

    .role-options {
        flex-direction: row;
        justify-content: center;
        gap: var(--space-xl);
    }

    .role-option {
        align-items: flex-start;
        gap: var(--space-md);
    }
}

@media (min-width: 1024px) {

    .is-dark .page-logo-light,
    .signup-hint-light {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {

    .intro,
    .intro-logo {
        transition-duration: 0s;
    }
}

@media (scripting: none) {
    .intro {
        display: none;
    }
}