/**
 * Zab Notes — the sign-in / sign-up dialog (views/partials/auth-modal.ejs, run
 * by assets/js/auth.js), on the home page and the pricing page.
 *
 * The home page loads components.css; the pricing page doesn't (its own .btn
 * and .btn-primary would restyle it). So the shared button and field rules the
 * dialog leans on are repeated first, under :where(), which adds no
 * specificity: on the home page they are exactly components.css's, and the
 * dialog's own rules below still win, as they did when they lived in the home
 * page. variables.css supplies the colours they name. Link this file after a
 * page's own styles.
 */

/* A page's own line height and button glow stay outside the dialog. */
.auth-modal-overlay { line-height: normal; color: #e0e0e0; }
:where(.auth-modal-overlay) .btn-primary { box-shadow: none; }

/* ── From components.css (buttons, fields), for pages without it ── */
:where(.auth-modal-overlay) .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}
:where(.auth-modal-overlay) .btn:disabled { opacity: 0.5; cursor: not-allowed; }
:where(.auth-modal-overlay) .btn-primary { background: var(--color-primary); color: var(--color-primary-text); }
:where(.auth-modal-overlay) .btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
:where(.auth-modal-overlay) .btn-secondary { background: transparent; color: var(--text-secondary); border-color: var(--border-color); }
:where(.auth-modal-overlay) .btn-secondary:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
:where(.auth-modal-overlay) .btn-full { width: 100%; }
:where(.auth-modal-overlay) .form-group { margin-bottom: 16px; }
:where(.auth-modal-overlay) .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
:where(.auth-modal-overlay) .form-group label:has(input, select, textarea) {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: normal;
}
:where(.auth-modal-overlay) .form-group input,
:where(.auth-modal-overlay) .form-group select,
:where(.auth-modal-overlay) .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
:where(.auth-modal-overlay) .form-group input:focus,
:where(.auth-modal-overlay) .form-group select:focus,
:where(.auth-modal-overlay) .form-group textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
:where(.auth-modal-overlay) .form-error { color: var(--color-danger); font-size: 0.8125rem; margin-top: 4px; min-height: 20px; }

/* ── Auth Modal ── */
.auth-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    /* Scrolls when the dialog is taller than the screen (short phones):
       centred by the card's auto margins, so nothing is cut off above. */
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms;
}
.auth-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.auth-modal-card {
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    margin: auto;
    position: relative;
    transform: scale(0.95) translateY(10px);
    transition: transform 300ms;
}
.auth-modal-overlay.active .auth-modal-card {
    transform: scale(1) translateY(0);
}
.auth-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 200ms, background 200ms;
}
.auth-modal-close:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-logo { margin-bottom: 12px; }
.auth-logo img { border-radius: 10px; }
.auth-header h1 { color: #fff; font-size: 1.25rem; font-weight: 700; }
.auth-subtitle { color: rgba(255,255,255,0.4); font-size: 0.875rem; margin-top: 4px; }
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-form h2 { color: #fff; font-size: 1.125rem; font-weight: 600; margin-bottom: 20px; }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form label {
    display: block;
    color: rgba(255,255,255,0.5);
    font-size: 0.8125rem;
    margin-bottom: 6px;
}
.auth-form input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: #fff;
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
    transition: border-color 200ms, box-shadow 200ms;
}
.auth-form input:focus {
    border-color: rgba(232,112,28,0.5);
    box-shadow: 0 0 0 3px rgba(232,112,28,0.1);
}
.auth-form input::placeholder { color: rgba(255,255,255,0.2); }
.form-error {
    color: #ef4444;
    font-size: 0.8125rem;
    margin-bottom: 12px;
    min-height: 20px;
}
.auth-form .btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #e8701c, #ff9f43);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 150ms, box-shadow 200ms;
}
.auth-form .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(232,112,28,0.4);
}
.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 0.8125rem;
    color: rgba(255,255,255,0.4);
}
.auth-switch a {
    color: #e8701c;
    text-decoration: none;
    font-weight: 500;
}
.auth-switch a:hover { text-decoration: underline; }
.auth-trial-note {
    text-align: center;
    margin-top: 12px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.02em;
}

/* ── Sign-up extras: password hint, agreement, recovery key, check-your-email ── */
.auth-hint { font-size: 0.75rem; color: rgba(255,255,255,0.4); margin-top: 6px; line-height: 1.4; }
.auth-check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.8125rem; line-height: 1.45; color: rgba(255,255,255,0.6); margin: 2px 0 14px; cursor: pointer; }
.auth-form .auth-check input,
.auth-form .recovery-ack input { width: 16px; height: 16px; padding: 0; margin: 2px 0 0; flex: 0 0 auto; accent-color: #e8701c; box-shadow: none; }
.auth-check a { color: #e8701c; }
.auth-inline { display: flex; gap: 8px; align-items: stretch; margin-bottom: 8px; }
.auth-inline input { flex: 1; min-width: 0; }
.auth-form .btn.btn-secondary {
    width: auto;
    flex: 1;
    padding: 10px 14px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.14);
    font-size: 0.875rem;
    font-weight: 600;
}
.auth-form .btn.btn-secondary:hover { box-shadow: none; background: rgba(255,255,255,0.12); }
.auth-form .btn:disabled, .auth-form .btn:disabled:hover { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.auth-recover-intro { font-size: 0.875rem; color: rgba(255,255,255,0.6); margin: 0 0 14px; line-height: 1.55; }
.auth-recover-intro strong { color: #fff; }
/* Numbers are drawn inside each cell (counter, not list markers): an
   outside marker sits in the gap and collides with 8-letter words. */
.recovery-words {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 10px;
    margin: 0 0 12px;
    padding: 12px 14px;
    list-style: none;
    counter-reset: rw;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    color: #fff3e0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    user-select: all;
}
.recovery-words li { padding: 2px 0; counter-increment: rw; white-space: nowrap; }
.recovery-words li::before { content: counter(rw) "."; display: inline-block; width: 2.6ch; margin-right: 0.6ch; text-align: right; color: rgba(255,255,255,0.35); user-select: none; }
/* The landing page's dark text halo is for copy over the animation; inside
   the dialog it only blurs small text. */
.auth-modal-card, .auth-modal-card * { text-shadow: none; }
.recovery-ack { display: flex; gap: 10px; align-items: flex-start; font-size: 0.8125rem; line-height: 1.45; color: rgba(255,255,255,0.7); margin: 12px 0 16px; cursor: pointer; }
#recWords { width: 100%; padding: 10px 14px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; color: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; resize: vertical; }
.auth-pending { text-align: center; }
.auth-pending h2 { margin-bottom: 10px; }
.auth-pending-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: rgba(232,112,28,0.14); color: #ffb366; }
.auth-pending-status { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 0.8125rem; color: rgba(255,255,255,0.55); margin: 4px 0 16px; min-height: 20px; }
.auth-pending-status.done { color: #4ade80; }
.auth-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.18); border-top-color: #e8701c; animation: authSpin 0.9s linear infinite; }
.auth-pending-status.done .auth-spinner { display: none; }
@keyframes authSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auth-spinner { animation-duration: 3s; } }
.auth-pending-change { margin-top: 4px; text-align: left; }
.auth-pending-change[hidden] { display: none; }
.auth-notice { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 0.8125rem; line-height: 1.45; background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #bbf7d0; }
.auth-notice[hidden] { display: none; }

/* ── Sign-up: plan choice (shown once billing is live) ── */
.auth-plans { border: none; padding: 0; margin: 4px 0 14px; }
.auth-plans legend { font-size: 0.8125rem; color: rgba(255,255,255,0.5); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.auth-plan { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-bottom: 8px; border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; background: rgba(255,255,255,0.04); cursor: pointer; text-transform: none; letter-spacing: normal; color: rgba(255,255,255,0.85); font-size: 0.875rem; }
.auth-plan:has(input:checked) { border-color: #e8701c; box-shadow: 0 0 0 3px rgba(232,112,28,0.16); }
.auth-plan input { margin-top: 3px; accent-color: #e8701c; width: auto; }
.auth-plan strong { color: #fff; }
.auth-plan small { display: block; margin-top: 3px; color: rgba(255,255,255,0.5); font-size: 0.75rem; line-height: 1.45; }

@media (max-width: 768px) {
    .auth-modal-card { margin: auto 16px; padding: 28px 24px; }
}
