/* ═══════════════════════════════════════════════════════════
   CogSmith — Auth Layer Styles
   Reuses the design tokens defined in styles.css (--clr-*, --radius*,
   --shadow, --transition, .btn/.modal/.badge vocabulary). Loaded after
   styles.css so these tokens are already in scope.
   ═══════════════════════════════════════════════════════════ */

/* ──────────────── AUTH SCREEN ──────────────── */
#auth-screen {
    justify-content: center;
    min-height: 100vh;
}

.auth-card {
    background: var(--clr-card);
    border: 1px solid rgba(127, 90, 240, 0.15);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 0.25rem;
}

.auth-header .logo {
    font-size: 2.2rem;
    margin-bottom: 0.3rem;
}

.auth-header .tagline {
    font-size: 0.9rem;
}

/* ──────────────── TABS ──────────────── */
.auth-tabs {
    display: flex;
    gap: 0.4rem;
    background: var(--clr-surface);
    padding: 0.3rem;
    border-radius: var(--radius-sm);
}

.auth-tab {
    flex: 1;
    background: transparent;
    color: var(--clr-text-muted);
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
}

.auth-tab:hover {
    color: var(--clr-text);
}

.auth-tab.active {
    background: var(--clr-primary);
    color: #fff;
}

/* ──────────────── PANELS / FORMS ──────────────── */
.auth-panel {
    display: none;
    flex-direction: column;
    gap: 0.9rem;
}

.auth-panel.active {
    display: flex;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.auth-form.hidden {
    display: none;
}

.auth-label {
    font-size: 0.75rem;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-input {
    background: var(--clr-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--clr-text);
    font-family: inherit;
    font-size: 1rem;
    padding: 0.7rem 0.9rem;
    transition: var(--transition);
    width: 100%;
}

.auth-input:focus {
    outline: none;
    border-color: var(--clr-primary);
}

.auth-otp-input {
    letter-spacing: 0.6rem;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    /* Tabular figures so the six digits do not shift sideways as they are
       typed — a code field that jitters reads as broken. */
    font-variant-numeric: tabular-nums;
}

/* ──────────────── OTP STEP ──────────────── */

/* Always name the destination. "We sent a code" without an address is how
   people end up waiting on the wrong inbox or the wrong number. */
.auth-otp-hint {
    font-size: 0.85rem;
    color: var(--clr-text-muted);
    line-height: 1.5;
    text-align: center;
    margin-bottom: 0.2rem;
    /* Two lines of room, reserved. The hint is written after the step opens,
       and a card that grows a line at that moment shifts the field the user
       is already reaching for. */
    min-height: 2.6em;
}

.auth-otp-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.35rem;
}

.auth-otp-actions .auth-link {
    margin-left: 0;
}

/* The resend button counts down rather than vanishing, so its disabled state
   has to stay legible — this is a deliberate wait, not a dead control. */
.auth-otp-actions .auth-link:disabled {
    color: var(--clr-text-dim);
    cursor: default;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}

.auth-alt {
    text-align: center;
    font-size: 0.85rem;
    margin-top: 0.1rem;
}

.auth-alt.hidden {
    display: none;
}

.auth-submit {
    width: 100%;
    margin-top: 0.2rem;
}

.auth-submit:disabled,
.auth-guest:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-switch {
    text-align: center;
    font-size: 0.85rem;
    color: var(--clr-text-muted);
}

.auth-link {
    background: none;
    border: none;
    color: var(--clr-secondary);
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0;
    margin-left: 0.3rem;
    text-decoration: underline;
    transition: var(--transition);
}

.auth-link:hover {
    color: var(--clr-primary);
}

/* ──────────────── ERROR / DIVIDER ──────────────── */
.auth-error {
    min-height: 1.2rem;
    color: var(--clr-danger);
    font-size: 0.85rem;
    text-align: center;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--clr-text-dim);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.auth-guest {
    width: 100%;
}

/* Invisible reCAPTCHA host for Firebase phone auth — kept off-screen */
#recaptcha-container {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ──────────────── PROFILE CHIP (menu header) ────────────────
   The chip is a button: it opens the profile modal. It is a flex item in
   the .app-bar row (see the APP BAR block in styles.css) — it was
   previously position:absolute inside a shrink-wrapped header, which
   dropped it on top of the wordmark on every desktop width.
   ─────────────────────────────────────── */
.profile-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    /* Never let the chip be the thing that overflows the bar. */
    flex: 0 0 auto;
    min-height: var(--tap-min);
    background: var(--clr-surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50px;
    padding: 0.45rem 0.9rem;
    font-family: inherit;
    color: var(--clr-text);
    cursor: pointer;
    transition: var(--transition);
}

.profile-chip:hover,
.profile-chip:focus-visible {
    background: var(--clr-surface-alt);
    border-color: rgba(127, 90, 240, 0.5);
}

.profile-chip-caret {
    color: var(--clr-text-muted);
    font-size: 1.1rem;
    line-height: 1;
}

.profile-chip-avatar {
    font-size: 1.1rem;
    line-height: 1;
}

.profile-chip-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--clr-text);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* On a narrow phone the wordmark and a full-width chip together exceed
   the viewport, so the chip drops its name label and keeps the avatar —
   still a 44px target, still opens the same modal, and the name is the
   first thing the profile modal shows anyway. */
@media (max-width: 480px) {
    .profile-chip-name {
        display: none;
    }

    .profile-chip {
        padding: 0.45rem 0.65rem;
    }
}

/* ──────────────── PROFILE MODAL ──────────────── */

.profile-body {
    margin-top: 0.5rem;
}

.profile-identity {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.profile-avatar {
    font-size: 2.75rem;
    line-height: 1;
}

.profile-name {
    font-size: 1.25rem;
    font-weight: 700;
    /* A display name can be long and unbroken; never let it widen the modal. */
    max-width: 100%;
    overflow-wrap: anywhere;
    text-align: center;
}

.profile-method {
    font-size: 0.8rem;
    color: var(--clr-text-muted);
}

.profile-section {
    margin-top: 1.4rem;
}

.profile-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--clr-text-dim);
    margin-bottom: 0.6rem;
}

.profile-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.profile-row-label {
    font-size: 0.85rem;
    color: var(--clr-text-muted);
    flex-shrink: 0;
}

.profile-row-value {
    font-size: 0.9rem;
    font-weight: 600;
    text-align: right;
    overflow-wrap: anywhere;
}

.profile-empty {
    font-size: 0.85rem;
    color: var(--clr-text-dim);
}

/* Backup state. The dot is colour-coded, but the label always states the
   status in words, so colour is never the only signal (WCAG 1.4.1). */
.profile-sync {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    background: var(--clr-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
}

.profile-sync-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    margin-top: 0.45rem;
    flex-shrink: 0;
    background: var(--clr-text-dim);
}

.profile-sync-ok .profile-sync-dot { background: var(--clr-secondary); }
.profile-sync-pending .profile-sync-dot { background: var(--clr-accent); }
.profile-sync-warn .profile-sync-dot { background: var(--clr-danger); }

.profile-sync-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.profile-sync-label {
    font-weight: 700;
    font-size: 0.92rem;
}

.profile-sync-detail {
    font-size: 0.8rem;
    color: var(--clr-text-muted);
    line-height: 1.5;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.6rem;
}

.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    background: var(--clr-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.5rem;
}

.profile-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--clr-primary);
}

.profile-stat-label {
    font-size: 0.7rem;
    color: var(--clr-text-muted);
    text-align: center;
}

.profile-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.6rem;
}

/* There is no global `.hidden` in this project — only scoped ones — so the
   delete button needs its own, or it would render for guests. */
.profile-delete.hidden {
    display: none;
}

.profile-legal {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.8rem;
}

.profile-legal a {
    color: var(--clr-text-muted);
    text-decoration: underline;
}

.profile-legal a:hover {
    color: var(--clr-secondary);
}
