/* ============================================================
   Wiki — breadcrumb & table of contents (right rail)
   ============================================================ */

/* ---------- Breadcrumb ---------- */
.wiki-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

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

.wiki-breadcrumb a:hover {
    text-decoration: underline;
}

/* ---------- Table of contents (right rail) ---------- */
.wiki-toc {
    position: sticky;
    top: calc(var(--header-h) + var(--space-5));
    max-height: calc(100vh - var(--header-h) - var(--space-8));
    overflow-y: auto;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--space-4) var(--space-5);
}

/* Tablet & mobile: full-width block above the content, not sticky */
@media (max-width: 1024px) {
    .wiki-toc {
        grid-column: 1 / -1;
        order: -1;
        position: static;
        max-height: none;
        overflow: visible;
    }
}

/* Mobile (single column): keep the article menu first, then TOC, then content */
@media (max-width: 768px) {
    .wiki-toc {
        order: 1;
        /* Chrome padding moves onto the summary row / open list below — see
           .wiki-sidebar (wiki.css) for the same collapsed-block pattern. */
        padding: var(--space-1);
    }
    .wiki-main {
        order: 2;
    }
}

/* ---------- Collapse (details/summary) — TOC on mobile ----------
   Рендерится open; ≤768px x-init закрывает, summary показан; ≥769px summary скрыт.
   Same visual pattern as .wiki-sidebar__summary (wiki.css). */
.wiki-toc__summary {
    display: none;
}

@media (max-width: 768px) {
    .wiki-toc__summary {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        min-height: var(--tap-min);
        padding-inline: var(--space-2);
        font-size: var(--fs-xs);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: var(--tracking-section);
        color: var(--text-muted);
        cursor: pointer;
        margin-bottom: 0;
        list-style: none;
    }

    .wiki-toc__summary::-webkit-details-marker {
        display: none;
    }

    .wiki-toc__summary::before {
        content: "";
        width: 6px;
        height: 6px;
        flex-shrink: 0;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(-45deg);
        transition: transform var(--dur-fast) var(--ease-standard);
    }

    .wiki-toc__collapse[open] > .wiki-toc__summary::before {
        transform: rotate(45deg);
    }

    /* Селектор с .wiki-toc__collapse — базовое `.wiki-toc__list { padding: 0;
       margin: 0 }` объявлено ниже по файлу и с равной специфичностью перебило бы
       эти значения. */
    .wiki-toc__collapse > .wiki-toc__list {
        /* Список примыкает к строке-заголовку — как в .wiki-sidebar__collapse:
           у строки --tap-min уже есть свой внутренний просвет. */
        margin-top: 0;
    }

    /* Пункт — строка-ссылка на всю ширину карточки: карточка ужата до --space-1,
       поэтому инсет и высоту тач-цели задаёт сама строка. Всё как у
       .wiki-sidebar__link. */
    .wiki-toc__collapse .wiki-toc__item a {
        display: flex;
        align-items: center;
        min-height: var(--tap-min);
        padding-inline: var(--space-3);
    }

    /* Строки в 44px не нуждаются в --space-2 между собой — тот же гэп, что
       между ссылками сайдбара. */
    .wiki-toc__collapse .wiki-toc__item + .wiki-toc__item {
        margin-top: 2px;
    }
}

.wiki-toc__list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.wiki-toc__item {
    font-size: var(--fs-sm);
    line-height: var(--lh-snug);
}

.wiki-toc__item + .wiki-toc__item {
    margin-top: var(--space-2);
}
.wiki-toc__item--h2 {
    font-weight: 600;
}
.wiki-toc__item--h3 {
    padding-left: var(--space-4);
    color: var(--text-muted);
}

.wiki-toc__item a {
    color: inherit;
    text-decoration: none;
}
.wiki-toc__item a:hover {
    color: var(--accent);
}
.wiki-toc__item--active {
    color: var(--accent);
    font-weight: 600;
}
