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

:root {
    --bg-void: #030712; /* Deeper, richer black */
    --panel-bg: rgba(10, 15, 25, 0.65);
    --card-bg: rgba(255, 255, 255, 0.02);
    --text-main: #f8fafc;
    --text-muted: #8b9bb4;
    --accent: #60a5fa;
    
    /* Cyber/Neon Category Colors - Slightly brightened for glow */
    --color-cs: #fcd34d;
    --color-math: #fb7185;
    --color-physics: #60a5fa;
    --color-science: #34d399;
    --color-root: #ffffff;
}

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

body { 
    background-color: var(--bg-void); 
    color: var(--text-main); 
    overflow: hidden; 
    height: 100vh; 
    width: 100vw; 
    -webkit-font-smoothing: antialiased;
}

/* --- The Void (Upgraded Canvas with Grid) --- */
#void {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    /* Layered background: Deep radial glow + subtle dot grid */
    background: 
        radial-gradient(circle at 50% -20%, rgba(30, 41, 59, 0.8) 0%, transparent 60%),
        radial-gradient(circle at 50% 50%, var(--bg-void) 0%, #000000 100%),
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 30px 30px, 30px 30px;
    z-index: 0; 
    transition: filter 0.8s ease;
}

#brand {
    position: absolute; top: 35px; left: 45px; 
    font-size: 1.25rem; font-weight: 700;
    color: #ffffff; z-index: 10; letter-spacing: -0.5px;
    text-transform: uppercase;
    background: linear-gradient(to right, #fff, #64748b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#top-right-nav {
    position: absolute; top: 35px; right: 45px; z-index: 10;
}
#top-right-nav a {
    color: var(--text-muted); text-decoration: none; font-size: 0.9rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1px; transition: color 0.3s;
    display: inline-flex;
    align-items: center;
}
#top-right-nav a:hover {
    color: white;
}

/* --- Landing Interface --- */
#landing-container {
    position: absolute; top: 48%; left: 50%; transform: translate(-50%, -50%);
    z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#search-wrapper { 
    position: relative; display: flex; align-items: center; justify-content: center; margin-bottom: 25px; 
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Premium Glassmorphic Search Bar */
#search-bar {
    background: rgba(255, 255, 255, 0.03); 
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05); 
    color: white; 
    font-size: 1.15rem;
    font-weight: 400;
    padding: 20px 45px; 
    border-radius: 60px; 
    width: 550px; 
    max-width: 90vw; 
    text-align: left;
    outline: none; 
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

#search-bar:focus { 
    border-color: rgba(255, 255, 255, 0.3); 
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.08), inset 0 0 15px rgba(255, 255, 255, 0.02); 
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

#typewriter { 
    position: absolute; 
    left: 45px; 
    color: rgba(255,255,255,0.3); 
    font-size: 1.15rem; 
    pointer-events: none; 
    transition: opacity 0.2s ease;
    white-space: nowrap; 
    z-index: 5;
}

#typewriter::after {
    content: ''; display: inline-block; width: 2px; height: 1.2rem;
    background-color: var(--color-cs); margin-left: 4px; vertical-align: middle;
    animation: blink 1s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

#enter-hint { 
    color: rgba(255,255,255,0.3); font-size: 0.75rem; font-weight: 600; letter-spacing: 3px; 
    text-transform: uppercase; opacity: 0; transition: opacity 0.3s; margin-top: 15px;
}

#loading-dots { display: flex; gap: 8px; opacity: 1; transition: opacity 0.5s; margin-top: 15px;}
.dot { width: 6px; height: 6px; border-radius: 50%; box-shadow: 0 0 12px currentColor;}
.dot.blue { background: var(--color-physics); color: var(--color-physics);}
.dot.green { background: var(--color-science); color: var(--color-science);}
.dot.red { background: var(--color-math); color: var(--color-math);}
.dot.yellow { background: var(--color-cs); color: var(--color-cs);}

/* Morph Animation into Root Node */
#search-bar.node-zero {
    width: 14px; height: 14px; padding: 0; border-radius: 50%; color: transparent; font-size: 0;
    background: var(--color-root); border: 2px solid var(--bg-void); 
    box-shadow: 0 0 20px var(--color-root), 0 0 40px var(--color-root);
    transform: scale(1); pointer-events: none;
}

/* --- Neural Tree Graph --- */
#graph-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 5; pointer-events: auto; }
#svg-layer { width: 100%; height: 100%; position: absolute; top: 0; left: 0; filter: drop-shadow(0 0 6px rgba(255,255,255,0.15)); }

/* Glowing Neural Signal Pulse lines */
@keyframes neural-pulse {
    from {
        stroke-dashoffset: 20;
    }
    to {
        stroke-dashoffset: 0;
    }
}
.path-line { 
    fill: none; 
    stroke-width: 2px; 
    opacity: 0.6; 
    transition: opacity 0.3s, stroke 0.3s;
}
.path-line.pulsing {
    animation: neural-pulse 1.5s linear infinite;
}

#nodes-layer { width: 100%; height: 100%; position: absolute; }

/* Glowing Force-Directed Orb Nodes */
.node {
    position: absolute; 
    width: 14px; 
    height: 14px; 
    border-radius: 50%;
    transform: translate(-50%, -50%); 
    transition: opacity 0.3s, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    pointer-events: auto; 
    cursor: pointer; 
    border: 2px solid rgba(0,0,0,0.8); 
    box-shadow: inset 0 0 4px #fff, 0 0 15px currentColor;
    z-index: 10;
}

.node.root-node {
    width: 22px;
    height: 22px;
    box-shadow: 0 0 35px var(--color-root), 0 0 15px #ffffff, inset 0 0 6px #fff;
    border-color: #000000;
}

.node-label {
    position: absolute; top: -38px; left: 50%; transform: translateX(-50%);
    font-size: 0.8rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; 
    pointer-events: none; transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    background: rgba(15, 23, 42, 0.85); padding: 5px 12px; border-radius: 6px;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.node-label.bottom { top: auto; bottom: -38px; }
.node:hover .node-label { color: white; border-color: rgba(255,255,255,0.25); transform: translate(-50%, -3px); }

/* Cinematic Focus/Dimming effect on Graph hover */
#graph-container:has(.node:hover) .path-line { opacity: 0.08 !important; }
#graph-container:has(.node:hover) .node { opacity: 0.15 !important; }
#graph-container .node:hover {
    opacity: 1 !important; 
    transform: translate(-50%, -50%) scale(1.6);
    box-shadow: inset 0 0 6px #fff, 0 0 30px currentColor; 
    z-index: 25;
}

/* --- Floating Graph Control Panel --- */
#graph-controls {
    position: absolute;
    bottom: 45px;
    left: 45px;
    background: var(--panel-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 40px;
    padding: 8px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 15;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ctrl-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, transform 0.1s, color 0.2s;
}
.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: scale(1.1);
}
.ctrl-btn:active {
    transform: scale(0.95);
}

.control-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.12);
}

.filter-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.filter-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}
.filter-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.05);
}

/* --- 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;
}
#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);
}

/* --- Plausibility Panel --- */
#plausibility-panel {
    position: absolute; top: 0; right: -450px; width: 420px; height: 100%;
    background: var(--panel-bg); backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
    border-left: 1px solid rgba(255,255,255,0.05); padding: 50px 35px;
    z-index: 20; transition: right 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto; pointer-events: auto;
    box-shadow: -20px 0 60px rgba(0,0,0,0.8);
}

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; }
.panel-header h3 { font-size: 1.15rem; font-weight: 600; color: white; letter-spacing: -0.5px;}

#median-badge {
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main); padding: 6px 12px; border-radius: 8px; font-size: 0.75rem; font-weight: 600;
}

/* Beautiful Staggered Cards */
.card {
    background: linear-gradient(145deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 24px; margin-bottom: 16px; border-radius: 16px; cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    position: relative; overflow: hidden; opacity: 0;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.card:hover { 
    transform: translateY(-4px) scale(1.02); 
    border-color: rgba(255,255,255,0.15); 
    background: linear-gradient(145deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
    box-shadow: 0 15px 35px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}

.card-dist { font-size: 0.7rem; font-weight: 700; letter-spacing: 1.5px; margin-bottom: 12px; text-transform: uppercase;}
.card-title { font-size: 1.2rem; font-weight: 500; color: white; letter-spacing: -0.3px;}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}

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

#hero-text {
    font-size: 3.2rem;
    font-weight: 700;
    letter-spacing: -1.5px;
    margin-bottom: 40px;
    text-align: center;
    background: linear-gradient(135deg, #ffffff 20%, #94a3b8 60%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0px 4px 30px rgba(96, 165, 250, 0.2));
    opacity: 0;
    transform: translateY(20px);
    animation: heroFadeIn 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

@keyframes heroFadeIn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    #hero-text {
        font-size: 2.2rem;
        padding: 0 20px;
    }
}