/* ============================================================
   CrossWord — auth.css
   Auth modal styles. Loaded as an external stylesheet so the
   cascade order is correct. Uses display:none (not transform)
   to guarantee the modal is invisible when not .open.
   ============================================================ */

/* ── Overlay ─────────────────────────────────────────────── */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 37, 72, 0.65);
    z-index: 500;
    display: none;
    backdrop-filter: blur(2px);
}
.auth-overlay.visible {
    display: block;
}

/* ── Modal shell ─────────────────────────────────────────── */
.auth-modal {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    z-index: 501;
    max-height: 92dvh;
    overflow-y: auto;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    box-shadow: 0 -6px 40px rgba(17, 37, 72, 0.3);
}
.auth-modal.open {
    display: block;
    animation: authSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* Desktop — centered dialog */
@media (min-width: 768px) {
    .auth-modal {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        width: 400px;
        border-radius: var(--r-xl);
        max-height: 90dvh;
        transform: translate(-50%, -50%);
    }
    .auth-modal.open {
        animation: authFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    }
    @keyframes authFadeIn {
        from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
        to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    }
}

/* ── Handle (mobile only) ────────────────────────────────── */
.auth-modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: var(--r-pill);
    margin: 16px auto 0;
}
@media (min-width: 768px) {
    .auth-modal-handle { display: none; }
}

/* ── Header ──────────────────────────────────────────────── */
.auth-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}
.auth-modal-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 0.06em;
    color: var(--navy);
}
.auth-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 4px;
    line-height: 1;
    border-radius: var(--r-sm);
    transition: color 0.15s;
}
.auth-modal-close:hover { color: var(--text-primary); }

/* ── Tabs ────────────────────────────────────────────────── */
.auth-tabs {
    display: flex;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-light);
    margin-top: 16px;
}
.auth-tab-btn {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 0;
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -1px;
}
.auth-tab-btn.active {
    color: var(--navy);
    border-bottom-color: var(--gold);
}

/* ── Panels ──────────────────────────────────────────────── */
.auth-panel {
    padding: 24px 24px 8px;
}
.auth-field {
    margin-bottom: 16px;
}
.auth-label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.auth-input {
    width: 100%;
    background: var(--surface-panel);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 11px 14px;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-input:focus {
    outline: none;
    border-color: var(--navy-mid);
    box-shadow: 0 0 0 3px rgba(27, 58, 107, 0.1);
}
.auth-input::placeholder { color: var(--text-muted); opacity: 0.6; }

/* ── Error ───────────────────────────────────────────────── */
.auth-error {
    background: var(--red-light);
    border: 1px solid rgba(139, 32, 32, 0.2);
    border-radius: var(--r-md);
    color: var(--red);
    font-size: 0.87rem;
    padding: 10px 14px;
    margin-bottom: 16px;
}

/* ── Submit button ───────────────────────────────────────── */
.auth-submit {
    width: 100%;
    background: var(--navy);
    color: var(--parchment);
    border: none;
    border-radius: var(--r-md);
    padding: 13px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    margin-top: 4px;
}
.auth-submit:hover:not(:disabled) { background: var(--navy-mid); }
.auth-submit:active:not(:disabled) { transform: scale(0.98); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Switch link ─────────────────────────────────────────── */
.auth-switch {
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted);
    padding: 16px 24px 0;
}
.auth-switch button {
    background: none;
    border: none;
    color: var(--navy-mid);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 0;
}

/* ── Header button when signed in ────────────────────────── */
#header-auth-btn.authenticated {
    background: var(--gold);
    color: var(--navy-deep);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0;
}

/* ── User dropdown menu ──────────────────────────────────── */
.user-menu {
    position: absolute;
    top: calc(var(--header-height) - 4px);
    right: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 200;
    overflow: hidden;
    animation: popupIn 0.18s var(--ease-spring);
}
.user-menu-name {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--navy);
    padding: 14px 16px 2px;
    font-weight: 600;
}
.user-menu-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0 16px 12px;
}
.user-menu-divider {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 0;
}
.user-menu-item {
    display: block;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s;
}
.user-menu-item:hover { background: var(--surface-panel); }
