/* ──────────────────────────────────────────────────────────────────
   Silent Facts — global navigation
   Thin terminal command-strip. Sharp corners, 1px lines, no candy.
   Adapts to light theme via `html.light` overrides (matches theme.css).
   ────────────────────────────────────────────────────────────────── */

.sf-nav {
    --sf-nav-height: 36px;
    --sf-nav-bg: #0b1220;
    --sf-nav-border: #1e293b;
    --sf-nav-text: #64748b;
    --sf-nav-text-hover: #cbd5e1;
    --sf-nav-text-active: #e2e8f0;
    --sf-nav-sep: #1e293b;
    --sf-nav-accent: #38bdf8;
    --sf-nav-accent-glow: rgba(56, 189, 248, 0.55);
    --sf-nav-drawer-bg: #0f172a;

    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    height: var(--sf-nav-height);
    background: var(--sf-nav-bg);
    border-bottom: 1px solid var(--sf-nav-border);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 10.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    user-select: none;
}

.sf-nav__inner {
    display: flex;
    align-items: stretch;
    height: 100%;
    padding: 0 18px;
    max-width: 1920px;
    margin: 0 auto;
    gap: 0;
}

/* ── Brand lockup ───────────────────────────────────────────────── */
.sf-nav__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px 0 0;
    color: #e2e8f0;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.28em;
    font-size: 11px;
    white-space: nowrap;
    transition: color 120ms ease;
}
.sf-nav__brand:hover { color: #ffffff; }

.sf-nav__pulse {
    width: 6px;
    height: 6px;
    background: var(--sf-nav-accent);
    box-shadow: 0 0 6px var(--sf-nav-accent-glow), 0 0 12px var(--sf-nav-accent-glow);
    display: inline-block;
    animation: sf-nav-pulse 2.2s ease-in-out infinite;
}
@keyframes sf-nav-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

.sf-nav__brand-text {
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}
.sf-nav__brand-tick {
    color: var(--sf-nav-accent);
    opacity: 0.5;
    font-weight: 400;
    letter-spacing: 0;
}

/* ── Admin-mode badge (shown when current page has data-admin) ──── */
.sf-nav__mode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 8px 14px 8px 2px;
    padding: 0 9px;
    height: 20px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.4);
    text-transform: uppercase;
    white-space: nowrap;
    animation: sf-nav-mode-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sf-nav__mode[hidden] { display: none; }
.sf-nav__mode-dot {
    width: 5px;
    height: 5px;
    background: #fbbf24;
    box-shadow: 0 0 5px rgba(251, 191, 36, 0.8);
    animation: sf-nav-pulse 1.6s ease-in-out infinite;
}
.sf-nav__mode-text { letter-spacing: 0.26em; }
@keyframes sf-nav-mode-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
html.light .sf-nav__mode {
    color: #b45309;
    background: rgba(180, 83, 9, 0.06);
    border-color: rgba(180, 83, 9, 0.4);
}
html.light .sf-nav__mode-dot {
    background: #b45309;
    box-shadow: 0 0 5px rgba(180, 83, 9, 0.6);
}

/* ── Vertical separator bars ────────────────────────────────────── */
.sf-nav__sep {
    width: 1px;
    margin: 8px 4px;
    background: var(--sf-nav-sep);
}

.sf-nav__spacer {
    flex: 1;
}

/* ── Link groups ────────────────────────────────────────────────── */
.sf-nav__group {
    display: flex;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
}

.sf-nav__group li { display: flex; }

.sf-nav__group a,
.sf-nav__drawer a,
.sf-nav__admin > summary {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    height: 100%;
    color: var(--sf-nav-text);
    text-decoration: none;
    font-size: 10.5px;
    letter-spacing: 0.16em;
    transition: color 120ms ease, background 120ms ease;
    cursor: pointer;
    outline: none;
}

.sf-nav__group a::before,
.sf-nav__drawer a::before,
.sf-nav__admin > summary::before {
    /* Active-state accent bar — hidden by default, full-width sky on top edge */
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--sf-nav-accent);
    box-shadow: 0 0 10px var(--sf-nav-accent-glow), 0 3px 16px var(--sf-nav-accent-glow);
    opacity: 0;
    transform: scaleX(0.4);
    transform-origin: center;
    transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;
}

.sf-nav__group a:hover,
.sf-nav__drawer a:hover {
    color: var(--sf-nav-text-hover);
    background: rgba(56, 189, 248, 0.05);
}
.sf-nav__group a:focus-visible,
.sf-nav__drawer a:focus-visible,
.sf-nav__admin > summary:focus-visible {
    color: var(--sf-nav-text-hover);
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.4);
}

/* ── Active state — deliberately obvious (prior UX issue: users
       couldn't tell which page they were on). Top 3px accent bar +
       tinted background wedge + brighter text + weight bump. ────── */
.sf-nav__group a.is-active,
.sf-nav__drawer a.is-active,
.sf-nav__admin.has-active > summary {
    color: var(--sf-nav-text-active);
    font-weight: 600;
    background: linear-gradient(180deg, rgba(56, 189, 248, 0.16) 0%, rgba(56, 189, 248, 0.02) 90%);
}
.sf-nav__group a.is-active::before,
.sf-nav__drawer a.is-active::before,
.sf-nav__admin.has-active > summary::before {
    opacity: 1;
    transform: scaleX(1);
}
html.light .sf-nav__group a.is-active,
html.light .sf-nav__drawer a.is-active,
html.light .sf-nav__admin.has-active > summary {
    background: linear-gradient(180deg, rgba(2, 132, 199, 0.14) 0%, rgba(2, 132, 199, 0.02) 90%);
}

/* ── Admin dropdown ─────────────────────────────────────────────── */
/* Always visible today; a future auth layer will hide links by walking
   `[data-admin="true"]` on the anchors (the hook is on the links, not
   the group, so role-filtering stays granular). */
.sf-nav__admin {
    position: relative;
    display: flex;
    align-items: stretch;
}
.sf-nav__admin > summary {
    list-style: none;
    gap: 8px;
    cursor: pointer;
}
.sf-nav__admin > summary::-webkit-details-marker { display: none; }
.sf-nav__admin > summary::marker { display: none; }

.sf-nav__chev {
    opacity: 0.6;
    transition: transform 160ms ease;
}
.sf-nav__admin[open] > summary .sf-nav__chev {
    transform: rotate(180deg);
}
.sf-nav__admin[open] > summary {
    color: var(--sf-nav-text-active);
    background: rgba(56, 189, 248, 0.05);
}

.sf-nav__drawer {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: -1px;
    min-width: 180px;
    list-style: none;
    padding: 4px 0;
    background: var(--sf-nav-drawer-bg);
    border: 1px solid var(--sf-nav-border);
    border-top-color: var(--sf-nav-accent);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.2);
    animation: sf-nav-drop 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 51;
}
@keyframes sf-nav-drop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.sf-nav__drawer li {
    display: block;
}
.sf-nav__drawer a {
    height: 34px;
    width: 100%;
    padding: 0 16px;
    letter-spacing: 0.18em;
}
.sf-nav__drawer a::before {
    /* In the drawer, the accent bar becomes a LEFT edge, not top */
    top: 6px;
    bottom: 6px;
    left: 0;
    right: auto;
    height: auto;
    width: 2px;
    transform: scaleY(0.3);
    transform-origin: center;
}
.sf-nav__drawer a.is-active::before {
    transform: scaleY(1);
}

/* ── Auth slot (sign-in / account chip) ─────────────────────────── */
.sf-nav__auth {
    position: relative;
    display: flex;
    align-items: stretch;
    margin-left: auto; /* push to the right edge */
}
.sf-nav__signin[hidden],
.sf-nav__user[hidden] { display: none; }
.sf-nav__signin,
.sf-nav__user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    padding: 0 14px;
    margin: 0;
    background: transparent;
    border: 0;
    border-left: 1px solid var(--sf-nav-sep);
    color: var(--sf-nav-text);
    font: inherit;
    font-size: 10.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 120ms ease, background 120ms ease;
}
.sf-nav__signin:hover,
.sf-nav__user:hover { color: var(--sf-nav-text-hover); background: rgba(56, 189, 248, 0.05); }
.sf-nav__signin:focus-visible,
.sf-nav__user:focus-visible { outline: none; box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.4); }
.sf-nav__user[aria-expanded="true"] { color: var(--sf-nav-text-active); background: rgba(56, 189, 248, 0.05); }

.sf-nav__user-dot {
    width: 6px; height: 6px;
    background: var(--sf-nav-accent);
    box-shadow: 0 0 6px var(--sf-nav-accent-glow);
}
.sf-nav__user-email {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.12em;
    text-transform: none;
    font-size: 10.5px;
}

.sf-nav__user-drawer {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: -1px;
    min-width: 160px;
    list-style: none;
    padding: 4px 0;
    background: var(--sf-nav-drawer-bg);
    border: 1px solid var(--sf-nav-border);
    border-top-color: var(--sf-nav-accent);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.2);
    animation: sf-nav-drop 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 51;
    margin-block: 0;
}
.sf-nav__user-drawer li { display: block; }
.sf-nav__user-drawer a {
    display: flex;
    align-items: center;
    height: 34px;
    padding: 0 16px;
    color: var(--sf-nav-text);
    text-decoration: none;
    font-size: 10.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}
.sf-nav__user-drawer a:hover { color: var(--sf-nav-text-hover); background: rgba(56, 189, 248, 0.05); }

/* Admin dropdown hides entirely unless the user is an admin (real auth)
   OR the legacy preview flag is on. Both paths set html.admin-mode. */
.sf-nav__admin[data-admin-only] { display: none; }
html.admin-mode .sf-nav__admin[data-admin-only] { display: flex; }

/* ──────────────────────────────────────────────────────────────────
   Light theme overrides — match the pattern used in theme.css
   ────────────────────────────────────────────────────────────────── */
html.light .sf-nav {
    --sf-nav-bg: #ffffff;
    --sf-nav-border: #e2e8f0;
    --sf-nav-text: #64748b;
    --sf-nav-text-hover: #1e293b;
    --sf-nav-text-active: #0f172a;
    --sf-nav-sep: #e2e8f0;
    --sf-nav-accent: #0284c7;
    --sf-nav-accent-glow: rgba(2, 132, 199, 0.35);
    --sf-nav-drawer-bg: #ffffff;
}
html.light .sf-nav__brand { color: #0f172a; }
html.light .sf-nav__brand:hover { color: #000000; }
html.light .sf-nav__brand-text {
    text-shadow: none;
}
html.light .sf-nav__drawer {
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.04);
}
html.light .sf-nav__group a:hover,
html.light .sf-nav__drawer a:hover {
    background: rgba(2, 132, 199, 0.06);
}
html.light .sf-nav__group a.is-active,
html.light .sf-nav__drawer a.is-active,
html.light .sf-nav__admin.has-active > summary {
    /* Phase-4 founder QA: the 0.08 tint (which cascade-overrode the 0.14
       rule above) made the selected item near-invisible on white. */
    background: linear-gradient(180deg, rgba(2, 132, 199, 0.18) 0%, rgba(2, 132, 199, 0.03) 90%);
}

/* ──────────────────────────────────────────────────────────────────
   Responsive (≥1024 is primary; below, scroll horizontally rather
   than collapse — this is a desktop-first investor tool)
   ────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
    .sf-nav__inner {
        padding: 0 10px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .sf-nav__inner::-webkit-scrollbar { display: none; }
    .sf-nav__brand { padding-right: 12px; }
    .sf-nav__group a,
    .sf-nav__admin > summary { padding: 0 10px; }
}

/* ── Theme toggle (nav-hosted since light-mode Phase 1, 2026-07-12) ──
   Base look lives in theme.css (#theme-toggle); this only handles nav
   layout so the button sits cleanly between the help "?" and auth slot. */
.sf-nav #theme-toggle {
    margin-right: 10px;
    flex-shrink: 0;
}
