/* ===== ПЕРЕМЕННЫЕ И БАЗОВЫЕ СТИЛИ ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #ffffff;
    --sidebar-bg: #f5f6fa;
    --sidebar-width: 270px;
    --max-layout: 1400px;
    --border: #e1e4e8;
    --text: #24292e;
    --text-muted: #586069;
    --link: #0366d6;
    --link-hover: #005cc5;
    --nav-active-bg: #dce9ff;
    --nav-active-text: #0366d6;
    --nav-hover-bg: #eaecef;
    --toc-bg: #f8f9fa;
    --code-bg: #f6f8fa;
    --accent: #0366d6;
    --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

/* ─── Центрирующий обёртка лейаута ─── */
.layout-wrapper {
    max-width: var(--max-layout);
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    display: flex;
    width: 100%;
}

/* ===== САЙДБАР ===== */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 200;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
}

.site-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.site-title-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.site-title-link:hover { text-decoration: none; }

.site-logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    color: var(--accent);
}

.site-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* Навигация */
.nav-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
    scrollbar-width: thin;
    scrollbar-color: #c1c9d2 transparent;
}

.nav-wrap::-webkit-scrollbar { width: 4px; }
.nav-wrap::-webkit-scrollbar-thumb { background: #c1c9d2; border-radius: 4px; }

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

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

.nav-list a {
    display: block;
    padding: 0.42rem 1.25rem;
    font-size: 0.9rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-right: 8px;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
    line-height: 1.4;
}

.nav-list a:hover {
    background: var(--nav-hover-bg);
    color: var(--text);
    text-decoration: none;
}

.nav-list a.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-text);
    font-weight: 600;
    border-left-color: var(--accent);
}

/* Футер сайдбара */
.sidebar-footer {
    padding: 1rem 1.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    line-height: 1.5;
    flex-shrink: 0;
}

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

/* ===== ОСНОВНОЙ КОНТЕНТ ===== */
.main-wrap {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.page-content {
    max-width: 820px;
    width: 100%;
    padding: 2.5rem 3rem 4rem;
}

/* ===== ТИПОГРАФИКА ===== */
h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.25;
    margin-bottom: 0.5rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.6rem;
}

h2 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 2.25rem;
    margin-bottom: 0.75rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.35rem;
}

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

p { margin-bottom: 1rem; }

ul, ol { padding-left: 1.75rem; margin-bottom: 1rem; }
li { margin-bottom: 0.35rem; }
li > ul, li > ol { margin-top: 0.35rem; margin-bottom: 0.35rem; }

strong { font-weight: 600; }
em { font-style: italic; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ===== ОГЛАВЛЕНИЕ (TOC) ===== */
.toc {
    background: var(--toc-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.35rem;
    margin-bottom: 2rem;
    display: inline-block;
    min-width: 220px;
    max-width: 100%;
}

.toc-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.toc > ul { list-style: none; padding-left: 0; margin-bottom: 0; }
.toc > ul li { margin-bottom: 0.25rem; }
.toc > ul li a {
    font-size: 0.88rem;
    color: var(--link);
    text-decoration: none;
    display: block;
    padding: 0.1rem 0;
}
.toc > ul li a:hover { text-decoration: underline; }
.toc > ul li.toc-h3 { padding-left: 1rem; }
.toc > ul li.toc-h3 a { font-size: 0.84rem; color: var(--text-muted); }
.toc > ul li.toc-h3 a:hover { color: var(--link); }

/* ===== КАРТОЧКИ-БЛОКИ ===== */
.info-card {
    background: #f0f7ff;
    border: 1px solid #b3d4f5;
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.warn-card {
    background: #fff8f0;
    border: 1px solid #f5c07a;
    border-left: 4px solid #e36209;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.danger-card {
    background: #fff5f5;
    border: 1px solid #f5b8b8;
    border-left: 4px solid #cb2431;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.card-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 0.4rem;
}

.info-card .card-label { color: #0366d6; }
.warn-card .card-label { color: #e36209; }
.danger-card .card-label { color: #cb2431; }

/* ===== СТРАНИЦА ЗАГРУЗОК ===== */
.download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.download-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--toc-bg);
    transition: border-color 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: var(--text);
}

.download-item:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(3,102,214,.1);
    text-decoration: none;
}

.dl-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
}

.dl-info { flex: 1; min-width: 0; }
.dl-name { font-weight: 600; font-size: 0.88rem; line-height: 1.35; }
.dl-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ===== СТРАНИЦА ССЫЛОК ===== */
.links-list { list-style: none; padding: 0; }
.links-list li {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    overflow: hidden;
}
.links-list li a {
    display: block;
    padding: 0.85rem 1.1rem;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.links-list li a:hover {
    background: var(--nav-hover-bg);
    text-decoration: none;
}
.links-list li a .link-title { font-weight: 600; font-size: 0.92rem; }
.links-list li a .link-url {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}
.link-icon { font-size: 1.1rem; flex-shrink: 0; }

/* ===== ГАМБУРГЕР ===== */
.hamburger {
    display: none;
    position: fixed;
    top: 0.9rem;
    left: 0.9rem;
    width: 42px;
    height: 42px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 300;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    box-shadow: var(--shadow);
    padding: 0;
}

.hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; }
.hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Оверлей */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 150;
}

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

/* ===== КНОПКА НАВЕРХ ===== */
.back-to-top {
    position: fixed;
    bottom: 1.75rem;
    right: 1.75rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(3,102,214,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.25s, transform 0.25s;
    z-index: 100;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--link-hover);
    transform: translateY(-2px);
}

.back-to-top svg { width: 20px; height: 20px; }

/* ===== ПАГИНАЦИЯ ===== */
.page-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    gap: 1rem;
}

.page-nav a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    color: var(--link);
    text-decoration: none;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: background 0.15s, border-color 0.15s;
}

.page-nav a:hover {
    background: var(--toc-bg);
    border-color: var(--accent);
    text-decoration: none;
}

.page-nav-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); display: block; }
.page-nav-title { font-weight: 600; }
.page-nav-next { text-align: right; margin-left: auto; }

/* ===== АДАПТИВ ===== */
@media (max-width: 900px) {
    .page-content { padding: 2rem 2rem 3rem; }
}

@media (max-width: 768px) {
    .layout-wrapper {
        max-width: 100%;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }
    .main-wrap {
        margin-left: 0;
    }
    .page-content {
        padding: 4.5rem 1.25rem 3rem;
    }
    .hamburger {
        display: flex;
    }
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.25rem; }
    .download-grid { grid-template-columns: 1fr; }
}

/* ─── Q&A блоки ─── */
.qa-block {
    border: 1px solid var(--border);
    border-left: 4px solid var(--link);
    border-radius: 8px;
    margin: 1rem 0;
    overflow: hidden;
}
.qa-question {
    background: var(--sidebar-bg);
    padding: 0.85rem 1rem;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    cursor: default;
    line-height: 1.45;
}
.qa-answer {
    padding: 0.85rem 1rem 1rem;
    font-size: 0.9rem;
    line-height: 1.7;
}
.qa-answer p { margin: 0 0 0.5rem; }
.qa-answer ul { margin: 0.25rem 0 0 1.2rem; padding: 0; }
.qa-answer li { margin-bottom: 0.35rem; }

/* ─── Страница «О сайте» ─── */
.about-meta-table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1.5rem;
    font-size: 0.92rem;
}
.about-meta-table th, .about-meta-table td {
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.about-meta-table th {
    background: var(--toc-bg);
    font-weight: 600;
    width: 35%;
    color: var(--text-muted);
}
.disclaimer-block {
    background: #fff8f0;
    border: 1px solid #f5c07a;
    border-left: 4px solid #e36209;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
}
.disclaimer-block .disclaimer-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #e36209;
    margin-bottom: 0.6rem;
}
.tool-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: var(--toc-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    margin: 0.25rem 0.25rem 0.25rem 0;
}
.tool-badge:hover { background: var(--nav-hover-bg); text-decoration: none; }

/* ===== ЛАЙТБОКС (LIGHTBOX) ===== */
.lightbox-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.lightbox-overlay.active {
    display: flex;
    opacity: 1;
}
.lightbox-img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    transform: scale(0.95);
    transition: transform 0.25s ease;
}
.lightbox-overlay.active .lightbox-img {
    transform: scale(1);
}
.infographic-wrapper {
    margin: 1.5rem 0;
    text-align: center;
}
.infographic-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: zoom-in;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.infographic-img:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
