/* =========================================
   FSB SOVEREIGN HELP ENGINE — CSS V3.1
   Dual-mode: supports both flat sections and
   graph nodes. The 2050 Glass Aesthetic.
   ========================================= */

:root {
    --bg-void: #05070a;
    --bg-deep: #0a0e14;
    --bg-glass: rgba(20, 26, 36, 0.65);
    --bg-glass-heavy: rgba(10, 14, 20, 0.85);
    --glass-border: rgba(120, 140, 170, 0.15);
    --glass-border-active: rgba(120, 140, 170, 0.35);
    --glass-highlight: rgba(255, 255, 255, 0.05);

    --accent: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.35);
    --cyan: #22d3ee;
    --cyan-glow: rgba(34, 211, 238, 0.4);
    --rose: #f43f5e;
    --emerald: #34d399;
    --gold: #fbbf24;
    --purple: #a855f7;

    --text-main: #f1f5f9;
    --text-muted: #64748b;
    --text-dim: #334155;

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Roboto Mono', ui-monospace, monospace;
    --font-serif: "Georgia", "Times New Roman", serif;

    --ease-fluid: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-snap: cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   BACKDROP & DRAWER
   ========================================= */
.fsb-help-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease-fluid);
}
.fsb-help-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.fsb-help-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 480px;
    height: 100%;
    height: 100dvh;
    background: var(--bg-glass);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-left: 1px solid var(--glass-border);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: right 0.4s var(--ease-fluid);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.fsb-help-drawer.open {
    right: 0;
}

/* =========================================
   HEADER
   ========================================= */
.fsb-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(10, 14, 20, 0.6);
    flex-shrink: 0;
}
.fsb-help-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fsb-help-title .help-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--accent);
}
.fsb-help-title .help-tool {
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-main);
}
.fsb-help-close {
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-main);
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.15s var(--ease-fluid);
}
.fsb-help-close:active {
    transform: scale(0.9);
    background: var(--glass-highlight);
}

/* =========================================
   SEARCH
   ========================================= */
.fsb-help-search-wrap {
    padding: 12px 20px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}
.fsb-help-search {
    width: 100%;
    background: var(--bg-glass-heavy);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.9rem;
    padding: 12px 14px;
    transition: border-color 0.2s var(--ease-fluid);
}
.fsb-help-search:focus {
    outline: none;
    border-color: var(--cyan);
}
.fsb-help-search::placeholder {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 1px;
}

/* =========================================
   BODY
   ========================================= */
.fsb-help-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 40px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* =========================================
   FLAT MODE (Legacy Accordions)
   ========================================= */
.fsb-help-section {
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(20, 26, 36, 0.5);
    margin-bottom: 10px;
    overflow: hidden;
    transition: border-color 0.2s var(--ease-fluid);
}
.fsb-help-section.open {
    border-color: rgba(34, 211, 238, 0.25);
}
.fsb-help-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    cursor: pointer;
    background: rgba(10, 14, 20, 0.4);
    transition: background 0.2s var(--ease-fluid);
    user-select: none;
}
.fsb-help-section-header:active {
    background: var(--glass-highlight);
}
.fsb-help-section-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 2.5px;
    color: var(--accent);
    text-transform: uppercase;
}
.fsb-help-section-chevron {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: transform 0.25s var(--ease-fluid);
}
.fsb-help-section.open .fsb-help-section-chevron {
    transform: rotate(90deg);
    color: var(--cyan);
}
.fsb-help-section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s var(--ease-fluid), padding 0.35s var(--ease-fluid);
    padding: 0 18px;
}
.fsb-help-section.open .fsb-help-section-body {
    max-height: 4000px;
    padding: 4px 18px 18px;
}

/* =========================================
   GRAPH MODE (DAG Nodes)
   ========================================= */
.fsb-help-node {
    animation: helpNodeIn 0.4s var(--ease-fluid);
}
@keyframes helpNodeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fsb-help-node .fsb-help-title {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 10px;
    line-height: 1.15;
    color: var(--text-main);
}
.fsb-help-node .fsb-help-desc {
    font-size: 0.92rem;
    color: var(--text-muted);
    line-height: 1.65;
    margin-bottom: 20px;
    font-family: var(--font-main);
}
.fsb-help-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
@media (min-width: 600px) {
    .fsb-help-options { grid-template-columns: repeat(2, 1fr); }
}
.fsb-help-option {
    position: relative;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%),
        rgba(10, 14, 20, 0.7);
    border: 1px solid var(--glass-border);
    border-left: 3px solid var(--accent);
    border-radius: 12px;
    padding: 16px 18px;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.25s var(--ease-fluid);
    overflow: hidden;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 2px 12px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.04);
}
.fsb-help-option::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
    pointer-events: none;
}
.fsb-help-option::after {
    content: '›';
    position: absolute;
    right: 16px; top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    color: var(--text-muted);
    transition: all 0.25s var(--ease-fluid);
    pointer-events: none;
}
.fsb-help-option:hover {
    background:
        linear-gradient(135deg, rgba(245, 158, 11, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%),
        rgba(10, 14, 20, 0.9);
    border-color: var(--glass-border-active);
    border-left-color: var(--accent);
    transform: translateX(2px);
}
.fsb-help-option:hover::after {
    color: var(--accent);
    transform: translateY(-50%) translateX(4px);
}
.fsb-help-option:active { transform: scale(0.985); }
.fsb-help-option-label {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: 0.02em;
    padding-right: 20px;
}

/* =========================================
   THE FIVE VOICES
   ========================================= */
.voice-companion .fsb-help-title { color: var(--cyan); text-shadow: 0 0 20px var(--cyan-glow); }
.voice-companion .fsb-help-option { border-left-color: var(--cyan); }
.voice-companion .fsb-help-option:hover::after { color: var(--cyan); }
.voice-companion .fsb-help-option-label { color: var(--cyan); }

.voice-engineer .fsb-help-title { color: var(--text-main); font-size: 1.15rem; letter-spacing: 0.08em; }
.voice-engineer .fsb-help-desc { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.02em; }
.voice-engineer .fsb-help-option { border-left-color: var(--accent); }
.voice-engineer .fsb-help-option:hover::after { color: var(--accent); }
.voice-engineer .fsb-help-option-label { color: var(--accent); }

.voice-steady_hand .fsb-help-title { color: var(--gold); text-shadow: 0 0 20px rgba(251, 191, 36, 0.35); }
.voice-steady_hand .fsb-help-desc { font-style: italic; color: #cbd5e1; }
.voice-steady_hand .fsb-help-option { border-left-color: var(--gold); }
.voice-steady_hand .fsb-help-option:hover::after { color: var(--gold); }
.voice-steady_hand .fsb-help-option-label { color: var(--gold); }

.voice-cipher .fsb-help-title { color: var(--rose); text-shadow: 0 0 20px rgba(244, 63, 94, 0.35); }
.voice-cipher .fsb-help-desc { color: #fca5a5; }
.voice-cipher .fsb-help-option { border-left-color: var(--rose); }
.voice-cipher .fsb-help-option:hover::after { color: var(--rose); }
.voice-cipher .fsb-help-option-label { color: var(--rose); }

.voice-historian .fsb-help-title { color: var(--purple); font-family: var(--font-serif); text-transform: none; letter-spacing: 0; font-size: 1.5rem; text-shadow: 0 0 20px rgba(168, 85, 247, 0.35); }
.voice-historian .fsb-help-desc { font-family: var(--font-serif); color: #e2e8f0; font-size: 0.95rem; }
.voice-historian .fsb-help-option { border-left-color: var(--purple); }
.voice-historian .fsb-help-option:hover::after { color: var(--purple); }
.voice-historian .fsb-help-option-label { font-family: var(--font-serif); font-size: 0.95rem; font-weight: 700; color: var(--purple); }

/* =========================================
   CONTENT STYLES (inside both modes)
   ========================================= */
.fsb-help-content,
.fsb-help-terminal {
    font-family: var(--font-main);
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-main);
}

.fsb-help-content p,
.fsb-help-terminal p {
    margin-bottom: 12px;
    color: rgba(241, 245, 249, 0.85);
}

.fsb-help-content strong,
.fsb-help-terminal strong {
    color: var(--cyan);
    font-weight: 700;
}

.fsb-help-content em,
.fsb-help-terminal em {
    color: var(--accent);
    font-style: normal;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.5px;
}

.fsb-help-content h4,
.fsb-help-terminal h4 {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--cyan);
    text-transform: uppercase;
    margin: 16px 0 8px;
}

.fsb-help-content ul,
.fsb-help-content ol,
.fsb-help-terminal ul,
.fsb-help-terminal ol {
    margin: 8px 0 14px 20px;
    color: rgba(241, 245, 249, 0.85);
}

.fsb-help-content li,
.fsb-help-terminal li {
    margin-bottom: 6px;
}

.fsb-help-content li strong,
.fsb-help-terminal li strong {
    color: var(--text-main);
}

.fsb-help-content code,
.fsb-help-terminal code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: rgba(34, 211, 238, 0.1);
    color: var(--cyan);
    padding: 2px 6px;
    border-radius: 4px;
}

.help-callout {
    border-left: 2px solid var(--accent);
    background: rgba(251, 146, 60, 0.08);
    padding: 10px 14px;
    border-radius: 6px;
    margin: 12px 0;
    font-size: 0.82rem;
    color: rgba(241, 245, 249, 0.85);
}
.help-callout.danger {
    border-left-color: var(--rose);
    background: rgba(239, 68, 68, 0.08);
}
.help-callout.ok {
    border-left-color: var(--emerald);
    background: rgba(52, 211, 153, 0.08);
}

/* =========================================
   NO RESULTS / EMPTY
   ========================================= */
.fsb-help-empty {
    text-align: center;
    padding: 40px 20px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--text-muted);
}

/* =========================================
   NAVIGATION (Back / Home)
   ========================================= */
.fsb-help-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--glass-border);
    background: linear-gradient(0deg, var(--bg-void) 0%, var(--bg-glass) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.fsb-help-btn {
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 900;
    padding: 11px 18px;
    border-radius: 10px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s var(--ease-snap);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.fsb-help-btn:hover {
    background: rgba(34, 211, 238, 0.08);
    border-color: var(--cyan);
    color: var(--cyan);
}
.fsb-help-btn:active { transform: scale(0.96); }
.fsb-help-btn.hidden { visibility: hidden; }

.fsb-help-btn#fsb-help-home {
    background: linear-gradient(135deg, var(--accent) 0%, #d97706 100%);
    border-color: transparent;
    color: #0a0e14;
    box-shadow: 0 4px 18px var(--accent-glow);
    margin-left: auto;
}
.fsb-help-btn#fsb-help-home:hover {
    box-shadow: 0 6px 24px rgba(245, 158, 11, 0.55);
    background: linear-gradient(135deg, #fbbf24 0%, var(--accent) 100%);
    color: #0a0e14;
}

/* =========================================
   LANDSCAPE
   ========================================= */
@media (orientation: landscape) and (min-width: 640px) {
    .fsb-help-drawer { max-width: 500px; }
}

/* =========================================
   REDUCED MOTION
   ========================================= */
@media (prefers-reduced-motion: reduce) {
    .fsb-help-backdrop,
    .fsb-help-drawer,
    .fsb-help-section-chevron,
    .fsb-help-section-body,
    .fsb-help-option,
    .fsb-help-btn {
        animation: none !important;
        transition: none !important;
    }
}