/* Aletheia Web — shared application shell.
   SINGLE SOURCE OF TRUTH for: reset, body, container, top nav, page header,
   and site footer. Every page links this file; page-specific rules stay inline.
   No per-template duplication of the shell. */

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Inter — self-hosted (OFL 1.1, static/fonts/OFL-inter.txt). Variable
   wght 100-900 + opsz, latin subset. Replaces the Google Fonts CDN links so
   pages make zero third-party requests for type. Added 2026-11-19. */
@font-face {
    font-family: 'Inter';
    src: url('/static/fonts/Inter-Variable.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ── Base ──────────────────────────────────────────────────────── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--a-page);
    color: var(--a-text);
    min-height: 100vh;
    line-height: 1.6;
    padding: 0;
}
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ── Layout container ──────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 720px;
    margin: 1.5rem auto 2rem;
    padding: 0 1rem;
}

/* ── Top navigation bar (compact, centered) ────────────────────── */
.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--a-nav-bg);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
    border-bottom: 1px solid var(--a-rule);
    box-shadow: 0 6px 24px var(--a-shadow);
}
.topnav-inner,
.topnav-top {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 0.6rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    flex-wrap: nowrap;
}
.topnav-inner {
    /* legacy single-row nav (kept for any template still using it) */
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
}
.topnav-inner::-webkit-scrollbar { display: none; }
.topnav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    flex-shrink: 0;
}
.topnav-brand .wordmark {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--a-wordmark-a), var(--a-wordmark-b));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: filter 0.25s ease;
}
.topnav-brand:hover .wordmark {
    filter: drop-shadow(0 0 10px var(--a-glow));
}

.topnav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
    padding: 0.15rem 1.2rem 0.55rem;
}
.topnav-links a {
    position: relative;
    color: var(--a-text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    white-space: nowrap;
    transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.topnav-links a:hover {
    color: var(--a-text);
    background: var(--a-hover-bg);
    box-shadow: 0 0 16px var(--a-glow);
    transform: translateY(-1px);
}
.topnav-links a.active {
    color: #fff;
    background: linear-gradient(120deg, var(--a-brand-a), var(--a-brand-b), var(--a-brand-a));
    background-size: 200% auto;
    box-shadow: 0 0 18px rgba(99, 102, 241, 0.45), 0 2px 12px rgba(59, 130, 246, 0.35);
    animation: nav-shimmer 3.2s ease infinite;
}
@keyframes nav-shimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.topnav-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
}
.topnav-user .email {
    color: var(--a-text-faint);
    font-size: 0.8rem;
    white-space: nowrap;
    /* The email is the only unbounded-width item in the nav, so it is the one
       that truncates. Without this it forced the whole bar off the page. */
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}
/* Credits, theme switch and logout are fixed-size affordances — they must stay
   whole. Only the email gives way. */
.topnav-user .credits,
.topnav-user .logout,
.topnav-user .theme-switch {
    flex-shrink: 0;
}

/* Compaction: the top row drops non-essentials first; the centered link row
   compresses its own padding. Both rows stay single-line at every width. */
@media (max-width: 1200px) { .topnav-user .email { display: none; } }
@media (max-width: 1000px) { .topnav-links a { padding: 0.4rem 0.6rem; font-size: 0.85rem; } }
@media (max-width: 700px)  { .topnav-links a { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
                             .topnav-links { gap: 0.1rem; }
                             .topnav-top { padding: 0.5rem 0.9rem; }
                             .topnav-links { padding: 0.1rem 0.9rem 0.45rem; } }
.topnav-user .credits {
    color: var(--a-warn-ink);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--a-edge-warn);
    background: var(--a-tint-warn);
    white-space: nowrap;
}
.topnav-user .credits.exhausted {
    color: var(--a-bad-ink);
    border-color: var(--a-edge-bad);
    background: var(--a-tint-bad);
}
.topnav-user a.logout {
    color: var(--a-bad-ink);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--a-edge-bad);
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    white-space: nowrap;
}
.topnav-user a.logout:hover {
    color: var(--a-bad-ink);
    background: var(--a-tint-bad);
    border-color: var(--a-edge-bad);
    box-shadow: 0 0 14px var(--a-edge-bad);
    transform: translateY(-1px);
}

/* ── Compact page header (tagline + divider + optional page title) ── */
.page-header {
    text-align: center;
    margin: 0 auto 1.5rem;
    padding: 0 1rem;
}
.page-header .tagline {
    color: var(--a-warn-ink);
    font-size: 0.95rem;
    font-weight: 400;
    max-width: 420px;
    margin: 0 auto;
    line-height: 1.5;
}
.page-header .divider {
    border: none;
    border-top: 1px solid var(--a-warn-ink);
    width: 60px;
    margin: 0.9rem auto 0;
    opacity: 0.6;
}
.page-header .page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--a-text);
    margin-top: 0.7rem;
    letter-spacing: -0.01em;
}

/* ── Site footer (logo + wordmark + optional note + copyright) ─── */
.site-footer {
    text-align: center;
    margin-top: 1rem;
    padding: 1rem 1rem 1rem;
}
.site-footer .footer-logo {
    width: 144px;
    height: 144px;
    object-fit: contain;
    display: block;
    margin: 0 auto 0.6rem;
    filter: drop-shadow(0 8px 24px var(--a-shadow-soft));
}
.site-footer .footer-wordmark {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, var(--a-wordmark-a), var(--a-wordmark-b));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.35rem;
}
.site-footer .footer-note {
    font-size: 0.75rem;
    color: var(--a-text-faint);
    margin: 0.3rem 0;
}
.site-footer .copyright {
    font-size: 0.75rem;
    color: var(--a-text-faint);
}

/* ── Auth pages (login / register / verify) — shared card + header ── */
/* SINGLE SOURCE OF TRUTH for the standalone auth pages. Each page includes
   _auth_header.html and applies these classes; only truly page-specific
   rules (e.g. password toggle) remain inline in the individual templates. */

body.auth-page {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--a-card);
    border: 1px solid var(--a-rule);
    border-radius: 16px;
    padding: 2rem;
    max-width: 520px;
    width: 92%;
}

.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo img {
    width: 144px;
    height: 144px;
    object-fit: contain;
    display: block;
    margin: 0 auto 1rem;
    filter: drop-shadow(0 8px 24px var(--a-shadow-soft));
}
.auth-logo h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--a-wordmark-a), var(--a-wordmark-b));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}
/* Footer legal links (privacy/terms/compliance/IP) */
.footer-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 1.2rem;
    margin: 0.8rem 0 0.5rem;
    font-size: 0.82rem;
}
.footer-legal a { color: var(--a-text-dim); }
.footer-legal a:hover { color: var(--a-link); }

/* Legal pages: meta line + long-form document rhythm */
.legal-meta {
    color: var(--a-text-dim);
    font-size: 0.9rem;
    margin-bottom: 1.4rem;
}
.help-article h2 { margin-top: 1.8rem; }
.help-article table { margin: 1rem 0; }

/* Signup clickwrap: 18+ / US resident / policies assent (James, 2026-11-19) */
.auth-agree {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    margin: 0.9rem 0 1.1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--a-text-dim);
    cursor: pointer;
}
.auth-agree input[type="checkbox"] {
    margin-top: 0.2rem;
    accent-color: var(--a-link);
    flex: none;
}
.auth-agree a { color: var(--a-link); }

.auth-sub {
    color: var(--a-warn-ink);
    font-size: 0.95rem;
    margin-top: 0.3rem;
    line-height: 1.5;
}
.auth-divider {
    border: none;
    border-top: 1px solid var(--a-warn-ink);
    width: 60px;
    margin: 0 auto 1.5rem;
    opacity: 0.6;
}

.auth-error {
    color: var(--a-bad-ink);
    font-size: 0.82rem;
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--a-tint-bad);
    border-radius: 6px;
}
.auth-warn {
    color: var(--a-warn-ink);
    font-size: 0.85rem;
    text-align: center;
    padding: 0.75rem;
    background: var(--a-tint-warn);
    border: 1px solid var(--a-edge-warn);
    border-radius: 8px;
    margin-bottom: 1rem;
}
.auth-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--a-text-dim);
    margin-bottom: 0.4rem;
}
.auth-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--a-rule);
    background: var(--a-page);
    color: var(--a-text);
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 1rem;
    box-sizing: border-box;
}

/* ── Password show/hide fields (login + reset forms) ───────────────────── */
.pw-wrapper { position: relative; }
.pw-wrapper .auth-input { padding-right: 2.8rem; margin-bottom: 0; }
.pw-wrapper { margin-bottom: 1rem; } /* replaces removed input margin */
.pw-toggle {
    position: absolute; right: 0; top: 0; width: 2.6rem; height: calc(100% - 1px);
    background: none; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--a-text-faint); padding: 0;
}
.pw-toggle:hover { color: var(--a-text-dim); transform: none; box-shadow: none; }

/* Submit-button visual feedback: pressed state + brief "working" label */
.auth-btn:active { transform: translateY(1px); filter: brightness(1.15); }
.auth-btn.is-busy { opacity: 0.7; pointer-events: none; }

.pw-toggle:focus { outline: none; }

/* Kill browser autofill/autocomplete chrome (pale-blue fill in dark mode) */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--a-text);
    -webkit-box-shadow: 0 0 0 1000px var(--a-page) inset;
    caret-color: var(--a-text);
    transition: background-color 99999s ease-in-out 0s;
}
.auth-input:autofill {
    -webkit-text-fill-color: var(--a-text);
    -webkit-box-shadow: 0 0 0 1000px var(--a-page) inset;
}

.auth-input:focus {
    outline: none;
    border-color: var(--a-brand-a);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.auth-btn {
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--a-brand-a), var(--a-brand-b));
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
}
.auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}
.auth-btn.btn-link {
    width: auto;
    padding: 0;
    background: none;
    border: none;
    color: var(--a-wordmark-a);
    font-size: inherit;
    font-weight: 600;
    text-decoration: underline;
}
.auth-btn.btn-link:hover { transform: none; box-shadow: none; color: var(--a-link); }
.auth-hint {
    color: var(--a-text-faint);
    font-size: 0.75rem;
    text-align: center;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}
.auth-hint.error { color: var(--a-bad-ink); }
.auth-secondary {
    text-align: center;
    color: var(--a-text-faint);
    font-size: 0.8rem;
    margin-top: 1.25rem;
}
.auth-secondary a { color: var(--a-wordmark-a); text-decoration: none; }
.auth-secondary a:hover { color: var(--a-link); }
.auth-footer-text {
    text-align: center;
    color: var(--a-text-faint);
    font-size: 0.7rem;
    margin-top: 1.25rem;
}
.auth-badge { text-align: center; font-size: 2.2rem; margin-bottom: 0.5rem; }
.auth-h2 { color: var(--a-text); font-size: 1.25rem; text-align: center; margin: 0 0 0.75rem; }
.auth-p { color: var(--a-text-dim); font-size: 0.92rem; line-height: 1.6; text-align: center; margin: 0 0 1rem; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .topnav-user .email { display: none; }
    .topnav-inner { gap: 0.25rem; padding: 0.5rem 0.75rem; flex-wrap: wrap; }
    .topnav-links { margin-left: 0; order: 3; width: 100%; justify-content: center; }
    .topnav-links a { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
}

/* ── Help center: About + User Guide (Phase 1.5, 2026-08-30) ───────────── */

.auth-links {
    display: flex;
    justify-content: center;
    gap: 1.4rem;
    margin-bottom: 0.9rem;
    font-size: 0.9rem;
}
.auth-links a {
    color: var(--a-text-dim);
    text-decoration: none;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
}
.auth-links a:hover {
    color: var(--a-text);
    background: var(--a-hover-bg);
}

.help-main {
    max-width: 860px;
    margin: 0 auto;
    padding: 1.6rem 1.1rem 3rem;
}
.help-article h1 {
    font-size: 1.7rem;
    margin: 0.4rem 0 0.8rem;
}
.help-article h2 {
    font-size: 1.2rem;
    margin: 1.6rem 0 0.6rem;
}
.help-article h3 {
    font-size: 1.02rem;
    margin: 1.1rem 0 0.4rem;
}
.help-article p, .help-article li, .help-article dd {
    line-height: 1.65;
}
.help-article .tagline {
    color: var(--a-warn-ink);
    font-weight: 600;
    letter-spacing: 0.06em;
}
.help-article .gold { color: var(--a-warn-ink); }
.help-article ul, .help-article ol, .help-article dl {
    margin: 0.5rem 0 0.9rem 1.3rem;
}
.help-article dt { font-weight: 600; margin-top: 0.7rem; }
.help-article a { color: var(--a-link); }

.help-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.9rem 0 1.2rem;
    font-size: 0.92rem;
}
.help-table th, .help-table td {
    border: 1px solid var(--a-rule);
    padding: 0.45rem 0.6rem;
    text-align: left;
}
.help-table th { background: var(--a-hover-bg); }

.guide-toc {
    background: var(--a-card);
    border: 1px solid var(--a-rule);
    border-radius: 10px;
    padding: 0.2rem 1.2rem 0.7rem;
    margin: 1.1rem 0;
}
.guide-crumb {
    font-size: 0.85rem;
    color: var(--a-text-dim);
    margin-bottom: 0.6rem;
}
.guide-crumb a { color: var(--a-text-dim); }
.guide-pager {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    gap: 1rem;
}
.guide-pager a {
    color: var(--a-link);
    text-decoration: none;
    font-weight: 600;
}
.help-cta {
    margin-top: 1.4rem;
    padding: 0.8rem 1rem;
    background: var(--a-card);
    border: 1px solid var(--a-rule);
    border-radius: 10px;
}
.help-article .note {
    font-size: 0.92rem;
    color: var(--a-text-dim);
    font-style: italic;
}

/* ---- About page: Contact Support form ---- */
.support-divider {
    margin: 2.5rem 0;
    border: 0;
    border-top: 1px solid var(--a-border, var(--a-text-dim));
    opacity: 0.4;
}
.support-section h2 { margin-top: 0; }
.support-section .support-textarea {
    resize: vertical;
    min-height: 8rem;
    font-family: inherit;
}
.support-section .auth-btn { margin-top: 0.75rem; }
.support-ok {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--a-edge-good);
    color: var(--a-edge-good);
    background: var(--a-tint-good);
}
.support-err {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--a-edge-bad);
    color: var(--a-edge-bad);
    background: var(--a-tint-bad);
}

/* ── Public landing (2026-11-24) — reuses help layout, real tokens only ── */
.landing { max-width: 720px; margin: 0 auto; padding: 2.5rem 0 1rem; }
.landing .tagline { color: var(--a-text-dim); letter-spacing: 0.18em; }
.landing-lead { font-size: 1.05rem; line-height: 1.65; max-width: 62ch; }
.landing-axes { padding-left: 1.25rem; display: grid; gap: 0.5rem; }
.landing-cta-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-top: 1.5rem; }
.landing-more { color: var(--a-link); }
