/* ── Auth mode smooth switch transitions ──────────────────────────────────── */
/* Driven by .login-mode class on #auth-section                                */
/* Uses negative-margin trick to cancel flex gap on collapsed elements         */

/* ── Email field (inside .input-group, gap: 1rem) ─────────────────────────── */
#auth-section #email {
    overflow: hidden;
    transition: max-height 300ms ease, opacity 250ms ease, margin-top 300ms ease,
                padding-top 300ms ease, padding-bottom 300ms ease,
                border-color 250ms ease;
    /* Explicit expanded-state values (required for transitions to fire) */
    max-height: 60px;
    opacity: 1;
    margin-top: 0;
    padding-top: 1rem;
    padding-bottom: 1rem;
    border-color: var(--card-border);
}

#auth-section.login-mode #email {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-color: transparent;
    margin-top: -1rem;         /* cancels .input-group gap */
    pointer-events: none;
}

/* ── Forgot password (direct child of #auth-section, gap: 1.5rem) ────────── */
/* Visible in login mode (below button), collapses in register mode            */
/* Same technique as email field: padding creates cushion so text isn't clipped */
#auth-section #forgot-pw-btn {
    overflow: hidden;
    transition: max-height 300ms ease, opacity 250ms ease, margin-top 300ms ease,
                padding-top 300ms ease, padding-bottom 300ms ease;
    max-height: 50px;
    opacity: 1;
    margin-top: -0.75rem;      /* tighten gap to button */
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

#auth-section:not(.login-mode) #forgot-pw-btn {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: -1.5rem;       /* cancels .counter-card gap */
    pointer-events: none;
}

/* ── Auth error — collapse when empty, animate in when shown ─────────────── */
#auth-section #auth-error {
    min-height: 0;             /* override .error-text min-height: 1.2rem */
    overflow: hidden;
    transition: max-height 300ms ease, opacity 250ms ease, margin-top 300ms ease;
    max-height: 0;
    opacity: 0;
    margin-top: -1.5rem;       /* cancels .counter-card gap when empty */
}

#auth-section #auth-error:not(:empty) {
    max-height: 50px;
    opacity: 1;
    margin-top: 0;
}

/* ── Modal anchored to top — only bottom edge moves during height animation ─ */
#auth-section.counter-card.modal-content {
    align-self: flex-start;
    margin-top: 10vh !important;
    transition: height 300ms ease, transform 0.3s ease;
    overflow: hidden;
}

/* ── Suppress transitions during height measurement ──────────────────────── */
#auth-section.auth-no-transition,
#auth-section.auth-no-transition * {
    transition: none !important;
}
