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

:root {
    --bg-main: #030712; /* Matches the new deep black */
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #60a5fa; /* Sleeker primary accent */
    --border-color: rgba(255,255,255,0.08);
    --surface: rgba(255,255,255,0.02);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; 
}

body { 
    background-color: var(--bg-main); 
    background-image: 
        radial-gradient(80% 40% at 50% 0%, rgba(96, 165, 250, 0.08) 0%, transparent 100%),
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 100% 100%, 40px 40px, 40px 40px;
    background-attachment: fixed;
    color: var(--text-primary); 
    line-height: 1.8; 
    -webkit-font-smoothing: antialiased;
}

/* Ultra-clean Frosted Top Nav */
.top-nav { 
    padding: 16px 40px; 
    border-bottom: 1px solid rgba(255,255,255,0.05); 
    background: rgba(3, 7, 18, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    position: sticky; 
    top: 0; 
    z-index: 100;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.brand { 
    color: var(--text-primary); text-decoration: none; font-size: 1.15rem; 
    font-weight: 700; letter-spacing: -0.5px; text-transform: uppercase;
}

/* Spacious Grid Layout */
.layout-grid { 
    display: flex; max-width: 1200px; margin: 0 auto; 
    padding: 80px 20px 100px 20px; gap: 100px; 
}
.main-content { flex: 1; min-width: 0; } 
.sidebar { width: 300px; flex-shrink: 0; }

/* Breadcrumbs & Meta Data */
.breadcrumbs { 
    font-size: 0.85rem; color: var(--text-muted); margin-bottom: 30px; font-weight: 500;
}
.breadcrumbs a { color: var(--text-muted); text-decoration: none; transition: color 0.2s; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { margin: 0 12px; opacity: 0.3; }
.breadcrumbs .current { color: var(--text-primary); }

.meta-row { display: flex; align-items: center; gap: 15px; margin-bottom: 30px; }

.category-badge { 
    background: rgba(96, 165, 250, 0.1); color: var(--accent); 
    border: 1px solid rgba(96, 165, 250, 0.2); padding: 6px 14px; 
    border-radius: 30px; font-size: 0.75rem; font-weight: 700; letter-spacing: 1px;
}

.read-time { color: var(--text-muted); font-size: 0.85rem; font-weight: 500;}

/* Striking Typography */
.article-title { 
    font-size: 4rem; font-weight: 800; line-height: 1.1; margin-bottom: 50px; 
    letter-spacing: -1.5px; 
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 50%, #64748b 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

/* --- Interactive Content Tiers (Tabs) --- */
.tier-tabs-container {
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.tier-tabs {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 30px;
}

.tier-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.tier-tab:hover {
    color: white;
}

.tier-tab.active {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tier-content {
    animation: tierFadeIn 0.4s ease;
}

@keyframes tierFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-tier { margin-bottom: 40px; }
.tier-header { 
    font-size: 1.8rem; font-weight: 700; margin-bottom: 25px; 
    color: white; letter-spacing: -0.5px;
}
.content-tier p { 
    font-size: 1.15rem; color: #cbd5e1; margin-bottom: 24px; font-weight: 400; 
}

/* Beautiful Drop Cap */
.drop-cap-section p:first-of-type::first-letter {
    font-size: 4rem; float: left; margin-top: 0.05em; margin-right: 0.15em; 
    line-height: 0.8; font-weight: 800; 
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.divider { 
    border: 0; height: 1px; margin: 60px 0; 
    background: linear-gradient(to right, transparent, var(--border-color), transparent); 
}

/* Sleek Floating Sidebar */
.sidebar-card { 
    background: rgba(15, 23, 42, 0.4); border: 1px solid var(--border-color); 
    border-radius: 16px; padding: 32px; position: sticky; top: 120px; 
    backdrop-filter: blur(20px); box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.sidebar-title { 
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase; 
    letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 20px; 
}
.toc-list { list-style: none; }
.toc-list li { margin-bottom: 8px; }
.toc-list a { 
    display: block; color: var(--text-muted); text-decoration: none; 
    font-size: 0.95rem; font-weight: 500; padding: 8px 12px; 
    margin-left: -12px; border-radius: 8px; transition: all 0.2s ease; 
}
.toc-list a:hover, .toc-list a.active { 
    color: white; background: rgba(255,255,255,0.05); transform: translateX(4px); 
}
.sidebar-divider { border: 0; height: 1px; background: var(--border-color); margin: 30px 0; }

/* --- Concept Lineage Trees --- */
.lineage-tree {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.lineage-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.lineage-role {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
}
.lineage-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    background: rgba(96, 165, 250, 0.06);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(96, 165, 250, 0.15);
    transition: all 0.25s ease;
    font-size: 0.9rem;
}
.lineage-link:hover {
    background: rgba(96, 165, 250, 0.15);
    transform: translateX(-4px);
}
.lineage-name {
    color: white;
    font-weight: 700;
    font-size: 1.05rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 16px;
    border-radius: 8px;
}
.children-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.child-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}
.child-link:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
    color: var(--accent);
}
.node-dist-badge {
    font-size: 0.65rem;
    font-weight: 700;
    border: 1px solid currentColor;
    padding: 1px 6px;
    border-radius: 8px;
    text-transform: uppercase;
}

/* --- Inline Wikipedia Connections --- */
.inline-wiki-link {
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent);
    font-weight: 500;
    transition: all 0.2s;
    padding: 0 2px;
    border-radius: 2px;
}
.inline-wiki-link:hover {
    background: rgba(96, 165, 250, 0.1);
    color: var(--accent);
    border-bottom-style: solid;
}

/* --- Shared Wikipedia-style popover cards --- */
.wiki-popover {
    position: absolute;
    z-index: 9999;
    width: 290px;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    pointer-events: none;
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.wiki-popover.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.popover-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
    border: 1px solid currentColor;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}
.popover-dist {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}
.popover-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}
.popover-desc {
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.popover-footer {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Command Palette Search Modal --- */
.search-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 15vh;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.search-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.search-modal-container {
    width: 600px;
    max-width: 90vw;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
    transform: translateY(-20px) scale(0.98);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.search-modal-overlay.active .search-modal-container {
    transform: translateY(0) scale(1);
}
.search-modal-header {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.search-modal-icon {
    color: var(--text-muted);
    margin-right: 16px;
    flex-shrink: 0;
}
#modal-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 1.1rem;
    font-weight: 400;
}
#modal-search-input::placeholder {
    color: var(--text-muted);
}
#close-search-modal {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
#close-search-modal:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.modal-results-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 12px 16px;
}
.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s;
    margin-bottom: 6px;
    border: 1px solid transparent;
}
.search-result-item:hover, .search-result-item.focused {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.06);
    transform: translateX(4px);
}
.result-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.result-title {
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
}
.result-category {
    font-size: 0.65rem;
    font-weight: 700;
    border: 1px solid currentColor;
    padding: 1px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.result-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.result-badge {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}
.result-relevance {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
}
.search-no-results {
    color: var(--text-muted);
    text-align: center;
    padding: 40px 20px;
    font-size: 0.9rem;
}
.search-modal-footer {
    padding: 12px 24px;
    background: rgba(3, 7, 18, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.7rem;
    color: var(--text-muted);
}
.search-modal-footer kbd {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: inherit;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* --- Markdown Rich Text Refinements --- */
.content-tier strong, .content-tier b { color: white; font-weight: 600; }
.content-tier em, .content-tier i { color: #e2e8f0; }

.content-tier a {
    color: var(--accent); text-decoration: none; font-weight: 500;
    border-bottom: 1px solid rgba(96, 165, 250, 0.4); transition: 0.2s ease;
}
.content-tier a:hover { color: white; border-bottom-color: white; }

.content-tier ul, .content-tier ol {
    margin-bottom: 30px; padding-left: 24px; color: #cbd5e1; font-size: 1.15rem;
}
.content-tier li { margin-bottom: 12px; padding-left: 8px;}
.content-tier li::marker { color: var(--text-muted); }

/* Gorgeous Blockquotes */
.content-tier blockquote {
    position: relative; border-left: 4px solid var(--accent);
    background: linear-gradient(to right, rgba(96, 165, 250, 0.08), transparent);
    padding: 24px 32px; margin: 40px 0; border-radius: 0 16px 16px 0;
    font-style: italic; color: #e2e8f0; font-size: 1.2rem; line-height: 1.6;
}

/* High-end Inline Code (JetBrains Mono) */
.content-tier code {
    font-family: 'JetBrains Mono', monospace; font-size: 0.85em;
    background: rgba(255,255,255,0.06); color: #e2e8f0; 
    padding: 4px 8px; border-radius: 6px; 
    border: 1px solid rgba(255,255,255,0.05);
}

/* Beautiful Code Blocks */
.content-tier pre {
    background: #0f172a; padding: 20px; border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08); overflow-x: auto; margin: 30px 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.content-tier pre code {
    background: transparent; border: none; padding: 0; color: #60a5fa;
}

/* Math block containment */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 24px 0; margin: 24px 0; }

.content-tier img {
    max-width: 100%; height: auto; border-radius: 16px; margin: 50px auto; 
    display: block; border: 1px solid var(--border-color); 
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* Responsive */
@media (max-width: 900px) {
    .layout-grid { flex-direction: column; gap: 50px; padding: 40px 20px;}
    .sidebar { width: 100%; order: -1; } /* Puts sidebar TOC at the top on mobile */
    .sidebar-card { position: static; box-shadow: none; }
    .article-title { font-size: 2.8rem; }
}

/* Premium Scrollbar */
body::-webkit-scrollbar { width: 8px; }
body::-webkit-scrollbar-track { background: var(--bg-main); }
body::-webkit-scrollbar-thumb { 
    background: rgba(255,255,255,0.15); border-radius: 10px; border: 2px solid var(--bg-main);
}
body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* --- Top Nav Links --- */
.top-nav {
    display: flex; justify-content: space-between; align-items: center;
}
.nav-links { display: flex; gap: 30px; align-items: center; }
.nav-link {
    color: var(--text-muted); text-decoration: none; font-size: 0.9rem; 
    font-weight: 600; text-transform: uppercase; letter-spacing: 1px; transition: 0.2s;
    display: inline-flex;
    align-items: center;
}
.nav-link:hover, .nav-link.active { color: white; }

/* --- Sitemap Page Specific Styles --- */
.sitemap-layout {
    max-width: 1200px; margin: 0 auto; padding: 80px 20px 100px 20px;
}
.sitemap-title { margin-bottom: 15px; text-align: center; }
.sitemap-subtitle { 
    text-align: center; font-size: 1.15rem; color: var(--text-muted); margin-bottom: 80px; 
}

.sitemap-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 40px;
}

.sitemap-category-card {
    background: rgba(15, 23, 42, 0.4); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 30px; backdrop-filter: blur(20px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.sitemap-category-title {
    font-size: 1.25rem; font-weight: 700; color: white; margin-bottom: 25px;
    padding-bottom: 15px; border-bottom: 1px solid rgba(255,255,255,0.1);
    letter-spacing: 1px; text-transform: uppercase;
}

.sitemap-list { list-style: none; padding: 0; margin: 0; }
.sitemap-list li { margin-bottom: 15px; }

.sitemap-link {
    display: flex;
    align-items: center;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.sitemap-link:hover { color: var(--accent); transform: translateX(5px); }

.node-dist {
    background: rgba(255,255,255,0.05); padding: 4px 8px; border-radius: 6px;
    font-size: 0.7rem; font-weight: 700; color: var(--text-muted); 
    margin-right: 12px; border: 1px solid rgba(255,255,255,0.1);
}