/* ════════════════════════════════════════════════════════
   МатМир — category_detail.css
════════════════════════════════════════════════════════ */

/* ── Сетка: три колонки, как в статьях ── */
.setka {
    margin: 0 auto;
    padding: 0 12px 40px;
    display: grid;
    grid-template-columns: 240px 1fr 240px;
    gap: 32px;
    align-items: start;
}

/* ════════════════════════════════════════
   ЛЕВЫЙ САЙДБАР — содержание (TOC)
════════════════════════════════════════ */
.sidebar_left {
    padding-top: 48px;
    position: sticky;
    top: 24px;
}

.toc-title {
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--gold);
    background: var(--gold-bg);
    border: 1.5px solid var(--gold-bd);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 12px 18px;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--r-xl) var(--r-xl);
    max-height: 70vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.toc-list::-webkit-scrollbar { width: 3px; }
.toc-list::-webkit-scrollbar-track { background: transparent; }
.toc-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.toc-list::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.toc-list li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    color: var(--ink2);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
    line-height: 1.3;
}
.toc-list li a:hover {
    background: var(--paper);
    color: var(--gold);
}
.toc-list li a.active {
    background: var(--gold-bg);
    color: var(--gold);
    border-left-color: var(--gold);
}

/* Подпункты h3 */
.toc-list li.toc-h3 a {
    padding-left: 28px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink3);
}
.toc-list li.toc-h3 a::before {
    content: '└';
    color: var(--gold);
    font-size: 11px;
}

/* ════════════════════════════════════════
   ОСНОВНОЙ КОНТЕНТ
════════════════════════════════════════ */
.main {
    min-width: 0;
    padding-top: 48px;
    animation: fadeUp .5s ease both;
}

.main h1 {
    font-family: var(--font-display);
    font-size: clamp(34px, 5vw, 52px);
    font-weight: 900;
    letter-spacing: -1.5px;
    line-height: 1.08;
    color: var(--ink);
    margin-bottom: 28px;
}
.main h1 em {
    color: var(--gold);
    font-style: italic;
}

/* ════════════════════════════════════════
   ПРАВЫЙ САЙДБАР — подкатегории и статьи
════════════════════════════════════════ */
.sidebar_right {
    padding-top: 48px;
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ════════════════════════════════════════
   НАВИГАЦИОННЫЙ БЛОК (общий для обоих сайдбаров)
════════════════════════════════════════ */
.side-nav {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--r-xl);
    overflow: visible;
}

.side-nav__header {
    background: var(--gold-bg);
    border-bottom: 1.5px solid var(--gold-bd);
    padding: 12px 18px;
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--gold);
}

.side-nav__list {
    padding: 6px 0;
    max-height: 70vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.side-nav__list::-webkit-scrollbar { width: 3px; }
.side-nav__list::-webkit-scrollbar-track { background: transparent; }
.side-nav__list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.side-nav__list::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.side-nav__divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.side-nav__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    color: var(--ink2);
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
    line-height: 1.3;
}
.side-nav__link:hover {
    background: var(--paper);
}
.side-nav__link.active {
    background: var(--gold-bg);
    color: var(--gold);
    border-left-color: var(--gold);
}

/* Подкатегория — золотая точка */
.side-nav__link--cat:hover { color: var(--gold); }
.side-nav__dot--cat {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--gold-bg);
    border: 2px solid var(--gold);
    flex-shrink: 0;
}

/* Статья — бирюзовая точка */
.side-nav__link--art:hover { color: var(--teal); }
.side-nav__link--art.active {
    background: var(--teal-bg);
    color: var(--teal);
    border-left-color: var(--teal);
}
.side-nav__dot--art {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--teal-bg);
    border: 2px solid var(--teal);
    flex-shrink: 0;
}

.side-nav__text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-nav__empty {
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--ink3);
    padding: 16px;
    text-align: center;
}

/* ════════════════════════════════════════
   КОНТЕНТ КАТЕГОРИИ
════════════════════════════════════════ */
.cat-content {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.85;
    color: var(--ink2);
}
.cat-content h2 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 900;
    letter-spacing: -.5px;
    color: var(--ink);
    margin: 44px 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.cat-content h2::before {
    content: '';
    display: block;
    width: 4px; height: 26px;
    border-radius: 2px;
    background: var(--gold);
    flex-shrink: 0;
}
.cat-content h3 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    margin: 28px 0 10px;
}
.cat-content h4 {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--ink3);
    margin: 20px 0 8px;
}
.cat-content p { margin-bottom: 16px; }
.cat-content p:last-child { margin-bottom: 0; }
.cat-content strong { color: var(--ink); font-weight: 700; }
.cat-content em { font-style: italic; }
.cat-content a {
    color: var(--gold);
    text-decoration: none;
    border-bottom: 1px solid var(--gold-bd);
    transition: border-color .2s;
}
.cat-content a:hover { border-color: var(--gold); }
.cat-content ul,
.cat-content ol {
    margin: 12px 0 16px;
    padding-left: 0;
    list-style: none;
}
.cat-content ul li,
.cat-content ol li {
    position: relative;
    padding-left: 22px;
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--ink2);
}
.cat-content ul li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--gold);
    font-size: 13px;
    font-family: var(--font-ui);
    font-weight: 800;
}
.cat-content ol { counter-reset: item; }
.cat-content ol li::before {
    content: counter(item) '.';
    counter-increment: item;
    position: absolute;
    left: 0;
    color: var(--gold);
    font-size: 13px;
    font-family: var(--font-mono);
    font-weight: 600;
}
.cat-content blockquote {
    border-left: 4px solid var(--gold);
    background: var(--gold-bg);
    border-radius: 0 var(--r-md) var(--r-md) 0;
    padding: 16px 20px;
    margin: 20px 0;
    font-style: italic;
    color: var(--ink2);
}
.cat-content table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-ui);
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 1.5px solid var(--border);
    margin: 20px 0;
}
.cat-content thead tr { background: var(--navy); }
.cat-content th {
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,.7);
    text-align: left;
}
.cat-content td {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    color: var(--ink2);
}
.cat-content tr:last-child td { border-bottom: none; }
.cat-content tr:nth-child(even) td { background: var(--paper); }
.cat-content code {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 2px 7px;
    color: var(--ink);
}
.cat-content pre {
    background: var(--navy);
    border-radius: var(--r-lg);
    padding: 20px 24px;
    margin: 20px 0;
    overflow-x: auto;
}
.cat-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--gold2);
    font-size: 14px;
}

/* ════════════════════════════════════════
   ПУСТОЕ СОСТОЯНИЕ
════════════════════════════════════════ */
.cat-empty {
    text-align: center;
    padding: 64px 24px;
    background: var(--white);
    border: 2px dashed var(--border);
    border-radius: var(--r-xl);
    margin-top: 32px;
}
.cat-empty__icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: .4;
}
.cat-empty p {
    font-family: var(--font-body);
    font-size: 17px;
    color: var(--ink3);
    margin-bottom: 0;
}

/* ════════════════════════════════════════
   АНИМАЦИЯ
════════════════════════════════════════ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════
   АДАПТИВ
════════════════════════════════════════ */

/* Планшет — сужаем колонки */
@media (max-width: 1100px) {
    .setka {
        grid-template-columns: 200px 1fr 200px;
        gap: 32px;
        padding: 0 20px 60px;
    }
}

/* 860px — убираем левый сайдбар, правый рядом */
@media (max-width: 860px) {
    .setka {
        grid-template-columns: 1fr 190px;
        grid-template-areas: "main right";
        gap: 24px;
        padding: 0 16px 60px;
        align-items: start;
    }

    .sidebar_left { display: none; }

    .main {
        grid-area: main;
        padding-top: 32px;
    }

    .sidebar_right {
        grid-area: right;
        position: sticky;
        top: 24px;
        padding-top: 32px;
    }
}

/* 700px — одна колонка, сайдбар СВЕРХУ компактной полоской */
@media (max-width: 700px) {
    .setka {
        grid-template-columns: 1fr;
        grid-template-areas:
            "main"
            "right";

        padding: 0 14px 48px;
        gap: 0;
    }

    .sidebar_left { display: none; }

    .main {
        grid-area: main;
        padding-top: 20px;
    }

    .sidebar_right {
        grid-area: right;
        position: static;
        padding-top: 20px;
        padding-bottom: 4px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Каждый блок side-nav — горизонтальная полоска */
    .side-nav {
        flex: 1 1 100%;
    }

    .side-nav__list {
        display: flex;
        flex-wrap: wrap;
        padding: 8px;
        gap: 6px;
    }

    .side-nav__link {
        border-left: none;
        border: 1.5px solid var(--border);
        border-radius: var(--r-pill);
        padding: 5px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

    .side-nav__link--art.active {
        border-color: var(--teal);
    }

    .side-nav__link--cat.active {
        border-color: var(--gold-bd);
    }

    .side-nav__divider { display: none; }

    .main h1 { font-size: 28px; }
}