@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================
   Vex Library - Monochrome Charcoal Theme
   ============================================ */

/* CSS Variables - Dark mode (default) */
:root {
    --bg-primary: #1c1c1e;
    --bg-secondary: #222224;
    --bg-card: #2a2a2c;
    --bg-card-hover: #323234;
    --bg-code: #161618;
    --text-primary: #e5e5e5;
    --text-secondary: #b0b0b0;
    --text-muted: #8a8a8a;
    --text-code: #d0d8e0;
    --border: #363638;
    --border-color: #363638;
    --code-keyword: #c586c0;
    --code-string: #9bc0ab;
    --code-comment: #8a8a8a;
    --code-attribute: #d4a76a;
    --code-number: #7eb8c9;
    --code-function: #b0b0b0;
    --code-type: #c586c0;
    --sidebar-width: 260px;
    --header-height: auto;
    --transition: 0.2s ease;
}

/* Light mode */
[data-theme="light"] {
    --bg-primary: #f5f5f3;
    --bg-secondary: #eaeae8;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f0ee;
    --bg-code: #f0f0ee;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #888888;
    --text-code: #1a1a1a;
    --border: #d5d5d3;
    --border-color: #d5d5d3;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--text-secondary);
}

/* Header */
.site-header {
    background: var(--bg-secondary);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-title {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-title h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.header-title .subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.header-title .tagline {
    display: block;
    width: 100%;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.recommendation-banner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.6rem 2rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.recommendation-banner a {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.header-stats {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.stat-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.header-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.header-nav a {
    color: var(--text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.header-nav a:hover,
.header-nav a.active {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* Search */
.search-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.2rem 2rem;
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 90;
}

.search-wrapper {
    position: relative;
    max-width: 700px;
    margin: 0 auto;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 0.9rem 1rem 0.9rem 1rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition);
}

#search-input:focus {
    border-color: var(--text-muted);
}

#search-input::placeholder {
    color: var(--text-muted);
}

.search-results-info {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Layout */
.main-layout {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 0;
    min-height: calc(100vh - 200px);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 130px;
    height: calc(100vh - 130px);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar h3 {
    padding: 0.5rem 1.2rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 1.2rem;
    cursor: pointer;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    font-size: 0.9rem;
}

.sidebar-item:hover {
    background: var(--bg-card-hover);
    border-left-color: var(--text-muted);
}

.sidebar-item.active {
    background: var(--bg-card-hover);
    border-left-color: var(--text-primary);
    color: var(--text-primary);
    font-weight: 600;
}

.sidebar-item .count {
    background: var(--bg-card);
    color: var(--text-muted);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    min-width: 24px;
    text-align: center;
}

.sidebar-item.active .count {
    background: var(--text-primary);
    color: var(--bg-primary);
}

/* Content */
.content {
    flex: 1;
    padding: 1.5rem 2rem;
    min-width: 0;
}

.content-header {
    margin-bottom: 1.5rem;
}

.content-header h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
}

/* Snippet Cards */
.snippet-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: border-color var(--transition);
}

.snippet-card:hover {
    border-color: var(--text-muted);
}

.snippet-header {
    padding: 1rem 1.2rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.snippet-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.snippet-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-source {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

a.badge-link {
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

a.badge-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.badge-category {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.badge-wrangle {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.snippet-description {
    padding: 0 1.2rem 0.8rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.snippet-tags {
    padding: 0 1.2rem 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.tag {
    background: var(--bg-primary);
    color: var(--text-muted);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* Code Block */
.code-container {
    position: relative;
    background: var(--bg-code);
    border-top: 1px solid var(--border-color);
}

.code-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.8rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.code-lang {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.copy-btn {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.75rem;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.copy-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

.copy-btn.copied {
    background: #4a8c5c;
    border-color: #4a8c5c;
    color: #fff;
}

pre.code-block {
    padding: 1rem 1.2rem;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-code);
    tab-size: 4;
    margin: 0;
}

/* Syntax Highlighting */
.hl-keyword { color: var(--code-keyword); font-weight: 600; }
.hl-type { color: var(--code-type); }
.hl-string { color: var(--code-string); }
.hl-comment { color: var(--code-comment); font-style: italic; }
.hl-attribute { color: var(--code-attribute); }
.hl-number { color: var(--code-number); }
.hl-function { color: var(--code-function); }
.hl-preprocessor { color: var(--code-keyword); }

/* Theme Toggle */
.theme-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    transition: border-color 0.2s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--text-muted);
}

.theme-toggle__thumb {
    position: absolute;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform 0.2s ease;
}

[data-theme="light"] .theme-toggle__thumb {
    transform: translateX(18px);
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all var(--transition);
    z-index: 200;
}

.back-to-top:hover {
    transform: translateY(-3px);
    background: var(--text-muted);
    color: var(--bg-primary);
}

.back-to-top.visible {
    display: flex;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.no-results h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Sidebar mobile toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 2rem;
    left: 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ============================================
   Glossary Page Styles
   ============================================ */

.glossary-layout {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

.glossary-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.glossary-nav a {
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.glossary-nav a:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.glossary-section {
    margin-bottom: 2.5rem;
}

.glossary-section h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.glossary-entry {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 0.75rem;
    transition: border-color var(--transition);
}

.glossary-entry:hover {
    border-color: var(--text-muted);
}

.glossary-entry .func-signature {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.glossary-entry .func-desc {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
}

.glossary-entry .func-example {
    background: var(--bg-code);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--text-code);
    margin-bottom: 0.3rem;
    overflow-x: auto;
}

.glossary-entry .func-return {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        height: 100vh;
        z-index: 150;
        transition: left 0.3s ease;
        box-shadow: none;
        padding-top: 5rem;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 140;
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .main-layout {
        flex-direction: column;
    }

    .content {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-container {
        padding: 0.8rem 1rem;
    }
}

@media (max-width: 600px) {
    .header-title h1 {
        font-size: 1.3rem;
    }

    .snippet-header {
        flex-direction: column;
    }

    pre.code-block {
        font-size: 0.78rem;
    }

    .glossary-layout {
        padding: 1rem;
    }
}
