/* ═══════════════════════════════════════════════════════════
   Brain — Knowledge Base Stylesheet
   Dark theme, minimal, readable. brain.gartu.xyz
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg:           #0d1117;
    --bg-surface:   #161b22;
    --bg-elevated:  #1c2128;
    --border:       #30363d;
    --text:         #e6edf3;
    --text-dim:     #8b949e;
    --text-muted:   #6e7681;
    --accent:       #58a6ff;
    --accent-hover: #79c0ff;
    --accent-dim:   #1f6feb;
    --green:        #3fb950;
    --red:          #f85149;
    --yellow:       #d29922;
    --purple:       #bc8cff;
    --code-bg:      #161b22;
    --max-width:    800px;
    --sidebar-width: 280px;
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* ─── Layout ────────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
}

.sidebar-close { display: none; }

/* ─── Search ────────────────────────────────────────────── */
.search-container {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

#search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

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

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

.search-results {
    position: absolute;
    left: 1.5rem;
    right: 1.5rem;
    top: 100%;
    margin-top: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.search-results.visible { display: block; }

.search-result {
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-surface); }

.search-result-title {
    font-weight: 600;
    color: var(--text);
    font-size: 0.875rem;
}

.search-result-section {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 2px;
}

.search-result-desc {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-empty {
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
}

/* ─── Navigation ────────────────────────────────────────── */
.nav-sections {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.nav-section { margin-bottom: 0.5rem; }

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.5rem 1.5rem 0.25rem;
}

.nav-section ul { list-style: none; }

.nav-section a {
    display: block;
    padding: 0.35rem 1.5rem;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.875rem;
    transition: all 0.15s;
    border-left: 2px solid transparent;
}

.nav-section a:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.nav-section a.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--bg-elevated);
}

.nav-subsection { padding-left: 1rem; }
.nav-subsection .nav-section-title { font-size: 0.7rem; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
}

.sidebar-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.sidebar-footer a:hover { color: var(--text-dim); }

/* ─── Content ───────────────────────────────────────────── */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-header {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
}

.breadcrumbs {
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb.current { color: var(--text-dim); font-weight: 500; }

/* ─── Article ───────────────────────────────────────────── */
.article {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2.5rem 2rem;
    flex: 1;
}

.article h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text);
    line-height: 1.3;
}

.article h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.article h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.article h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.article p {
    margin-bottom: 1rem;
    color: var(--text);
}

.article ul, .article ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.article li { margin-bottom: 0.5rem; }

.article a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.article a:hover { border-bottom-color: var(--accent); }

.article code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    background: var(--bg-elevated);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.875em;
    color: var(--purple);
}

.article pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.article pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--text);
}

.article blockquote {
    border-left: 3px solid var(--accent-dim);
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    background: var(--bg-surface);
    border-radius: 0 6px 6px 0;
    color: var(--text-dim);
}

.article blockquote p:last-child { margin-bottom: 0; }

.article table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.article th, .article td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.article th {
    background: var(--bg-surface);
    font-weight: 600;
}

.article tr:nth-child(even) { background: var(--bg-surface); }

.article img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.article hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* ─── Tags ──────────────────────────────────────────────── */
.tags {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* ─── Footer ────────────────────────────────────────────── */
.footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer p {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.footer a { color: var(--accent); text-decoration: none; }

/* ─── Overlay (mobile) ──────────────────────────────────── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

.overlay.show { display: block; }

/* ─── Highlight (codehilite) ────────────────────────────── */
.highlight .k { color: var(--purple); }
.highlight .s { color: var(--green); }
.highlight .n { color: var(--text); }
.highlight .c { color: var(--text-muted); font-style: italic; }
.highlight .nf { color: var(--accent); }
.highlight .nc { color: var(--yellow); }
.highlight .o { color: var(--red); }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }

    .sidebar.open { transform: translateX(0); }

    .sidebar-close {
        display: block;
        background: none;
        border: none;
        color: var(--text);
        font-size: 1.25rem;
        cursor: pointer;
    }

    .content { margin-left: 0; }

    .menu-toggle { display: block; }

    .article { padding: 1.5rem 1rem; }

    .article h1 { font-size: 1.5rem; }

    .page-header { padding: 0.75rem 1rem; }
}

@media (max-width: 480px) {
    .article { padding: 1rem 0.75rem; }
    .article h1 { font-size: 1.35rem; }
    .article h2 { font-size: 1.25rem; }
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
