/* Spartan Universal Bar - Unified Navigation + Scroll + Bottom Ticker */
/* This is the SINGLE source of truth for cross-page UI standardization */

/* ====== GLOBAL SCROLL BEHAVIOR ====== */
html {
    scroll-behavior: smooth;
}

/* ====== CUSTOM SCROLLBAR (Dark Theme) ====== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0a1628;
}

::-webkit-scrollbar-thumb {
    background: #1e3a5f;
    border-radius: 4px;
    border: 1px solid rgba(255, 215, 0, 0.08);
}

::-webkit-scrollbar-thumb:hover {
    background: #2a4f7c;
    border-color: rgba(255, 215, 0, 0.2);
}

::-webkit-scrollbar-corner {
    background: #0a1628;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #1e3a5f #0a1628;
}

/* ====== UNIFIED FIXED BACK BUTTON ====== */
#spartan-unified-back {
    position: fixed;
    top: 70px;
    left: 16px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(10, 22, 40, 0.92);
    color: #FFD700;
    border: 1px solid rgba(255, 215, 0, 0.35);
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    animation: spartan-back-fadein 0.3s ease-out;
}

#spartan-unified-back:hover {
    background: rgba(15, 31, 61, 0.96);
    color: #FFD700;
    border-color: rgba(255, 215, 0, 0.7);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 12px rgba(255, 215, 0, 0.15);
}

#spartan-unified-back:active {
    transform: translateY(0);
}

#spartan-unified-back .back-arrow {
    font-size: 16px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

#spartan-unified-back:hover .back-arrow {
    transform: translateX(-3px);
}

@keyframes spartan-back-fadein {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ====== NAV BAR CLEARANCE ====== */
/* Back button is now at top:70px (below navs) — no padding-left override needed */

/* ====== HIDE ALL LEGACY BACK BUTTONS (unified system takes over) ====== */
body.spartan-unified-nav .back-button,
body.spartan-unified-nav .back-btn,
body.spartan-unified-nav .back-home,
body.spartan-unified-nav .btn-home,
body.spartan-unified-nav #universal-back-button,
body.spartan-unified-nav .spartan-back-btn,
body.spartan-unified-nav .spartan-fallback-bar {
    display: none !important;
}

/* Hide "← Back" nav links inside nav bars (but keep non-back links like Research Tools) */
body.spartan-unified-nav .spartan-nav .nav-link[href="index.html"],
body.spartan-unified-nav .spartan-nav .nav-link[href="/"],
body.spartan-unified-nav .spartan-nav a.nav-link[href*="index.html"]:not([href*="tab="]) {
    display: none !important;
}

/* ====== LEGACY BACK BUTTON (kept for pages without unified JS) ====== */
.spartan-back-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    background: rgba(10, 22, 40, 0.92);
    color: #FFD700 !important;
    border: 1px solid rgba(255, 215, 0, 0.35);
    padding: 7px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none !important;
    white-space: nowrap;
    flex-shrink: 0;
    margin-right: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.spartan-back-btn:hover {
    background: rgba(15, 31, 61, 0.96);
    border-color: rgba(255, 215, 0, 0.7);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
    transform: translateY(-1px);
}

.spartan-back-btn:active {
    transform: translateY(0);
}

/* ====== FALLBACK BAR (when no header found) ====== */
.spartan-fallback-bar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(10, 22, 40, 0.98), rgba(5, 11, 20, 0.98));
    border-bottom: 1px solid #1e3a5f;
    z-index: 10000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
}

body.has-spartan-fallback-bar {
    /* no extra padding needed - sticky bar flows with content */
}

.spartan-status-dot {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #b0b8c8;
}

.spartan-status-dot .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 6px rgba(0, 255, 136, 0.5);
    animation: spartan-pulse-dot 2s ease-in-out infinite;
}

@keyframes spartan-pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ====== BOTTOM TICKER ====== */
.spartan-ticker-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, rgba(10, 22, 40, 0.98), rgba(20, 35, 60, 0.98));
    border-top: 1px solid #1e3a5f;
    padding: 10px 0;
    z-index: 99998;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.ticker-scroll {
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
}

.ticker-items {
    display: inline-flex;
    gap: 32px;
    padding: 0 20px;
    animation: spartan-scroll-left 80s linear infinite;
}

@keyframes spartan-scroll-left {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.82em;
    white-space: nowrap;
}

.ticker-label {
    color: #8a95a8;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.82em;
    letter-spacing: 0.5px;
}

.ticker-value {
    color: #ffffff;
    font-weight: 700;
    font-size: 1.05em;
}

.ticker-value.positive { color: #00ff88; }
.ticker-value.negative { color: #FF5252; }
.ticker-value.neutral { color: #FFD700; }

.ticker-arrow {
    font-size: 1.1em;
    margin-left: 2px;
}

.ticker-composite {
    background: linear-gradient(135deg, rgba(220, 20, 60, 0.15), rgba(255, 107, 107, 0.1));
    border: 1px solid rgba(220, 20, 60, 0.35);
    padding: 6px 16px;
}

.ticker-composite .ticker-label { color: #FFD700; }
.ticker-composite .ticker-value { font-size: 1.15em; color: #FFD700; }

.ticker-items:hover {
    animation-play-state: paused;
}

/* Body padding for fixed bottom ticker */
body.has-spartan-ticker {
    padding-bottom: 55px !important;
}

/* Mobile */
@media (max-width: 768px) {
    #spartan-unified-back {
        top: 70px;
        left: 12px;
        padding: 6px 12px;
        font-size: 12px;
    }
    .spartan-back-btn {
        padding: 5px 10px;
        font-size: 12px;
        margin-right: 10px;
    }
    .spartan-fallback-bar {
        padding: 8px 12px;
    }
    .spartan-ticker-container {
        padding: 6px 0;
    }
    .ticker-item {
        padding: 4px 8px;
        font-size: 0.75em;
    }
    .ticker-items {
        gap: 16px;
    }
}

/* Print */
@media print {
    #spartan-unified-back,
    .spartan-back-btn,
    .spartan-fallback-bar,
    .spartan-ticker-container {
        display: none !important;
    }
    body.has-spartan-ticker {
        padding-bottom: 0 !important;
    }
}
