/* === MAIN.CSS === */
/* /assets/css/main.css */
/* НАЗНАЧЕНИЕ: layout + темы + sidebar + типографика для рендера research */
/* РАЗМЕР: ~280 строк */

:root {
    --bg-primary: oklch(0.18 0.012 250);
    --bg-secondary: oklch(0.22 0.014 250);
    --bg-elevated: oklch(0.25 0.016 250);
    --bg-hover: oklch(0.28 0.018 250);
    --border: oklch(0.32 0.014 250);
    --border-subtle: oklch(0.28 0.012 250);
    --text-primary: oklch(0.96 0.005 250);
    --text-secondary: oklch(0.72 0.012 250);
    --text-muted: oklch(0.55 0.014 250);
    --accent: oklch(0.72 0.18 250);
    --accent-hover: oklch(0.78 0.20 250);
    --accent-soft: oklch(0.72 0.18 250 / 0.12);
    --success: oklch(0.75 0.16 145);
    --warning: oklch(0.78 0.16 70);
    --danger: oklch(0.68 0.20 25);
    --code-bg: oklch(0.14 0.012 250);
    --code-border: oklch(0.30 0.014 250);
    --shadow-md: 0 4px 12px oklch(0 0 0 / 0.30);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --sidebar-width: 320px;
    --content-max: 920px;
}

[data-theme="light"] {
    --bg-primary: oklch(0.99 0.002 250);
    --bg-secondary: oklch(0.96 0.004 250);
    --bg-elevated: oklch(0.99 0.002 250);
    --bg-hover: oklch(0.94 0.006 250);
    --border: oklch(0.88 0.008 250);
    --border-subtle: oklch(0.93 0.006 250);
    --text-primary: oklch(0.20 0.012 250);
    --text-secondary: oklch(0.42 0.014 250);
    --text-muted: oklch(0.58 0.012 250);
    --accent: oklch(0.55 0.20 250);
    --accent-hover: oklch(0.48 0.22 250);
    --accent-soft: oklch(0.55 0.20 250 / 0.10);
    --code-bg: oklch(0.96 0.004 250);
    --code-border: oklch(0.88 0.008 250);
    --shadow-md: 0 4px 12px oklch(0 0 0 / 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 24px;
}

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    min-height: 100vh;
    transition: background 0.3s var(--ease-out-quart), color 0.3s var(--ease-out-quart);
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    flex-shrink: 0;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
}

.logo-mark {
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, var(--accent), oklch(0.62 0.22 290));
    border-radius: 6px;
    box-shadow: 0 0 16px var(--accent-soft);
}

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

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease-out-quart);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.nav-section {
    margin-bottom: 18px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 10px 8px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.15s var(--ease-out-quart);
    margin-bottom: 1px;
    border-left: 2px solid transparent;
}

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

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-left-color: var(--accent);
}

.nav-link-title {
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.nav-link-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
}

.nav-link.active .nav-link-meta {
    color: var(--accent);
    opacity: 0.7;
}

.sidebar-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.footer-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* === CONTENT === */
.content {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    position: relative;
}

.markdown-body {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 56px 64px 120px;
}

.scroll-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: oklch(1 0 0);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease-out-quart), transform 0.3s var(--ease-out-quart);
    z-index: 100;
}

.scroll-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.scroll-top:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        max-height: none;
    }

    .sidebar-nav {
        max-height: 320px;
    }

    .markdown-body {
        padding: 32px 24px 80px;
    }
}

@media (max-width: 640px) {
    .markdown-body {
        padding: 24px 16px 60px;
    }

    .sidebar-header {
        padding: 16px;
    }
}
