/* Documentation module — Phase 1 typography and rhythm */

body.documentation-page .doc-prose {
    max-width: 70ch;
}

body.documentation-page .markdown-content p,
body.documentation-page .markdown-content ul,
body.documentation-page .markdown-content ol,
body.documentation-page .markdown-content blockquote,
body.documentation-page .markdown-content pre,
body.documentation-page .markdown-content table {
    margin-bottom: 0.875rem;
}

body.documentation-page .markdown-content li {
    margin-bottom: 0.375rem;
}

body.documentation-page .markdown-content h2 {
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
    scroll-margin-top: 5rem;
}

body.documentation-page .markdown-content h1 + h2,
body.documentation-page .markdown-content .documentation-content > h2:first-child {
    margin-top: 1.75rem;
}

body.documentation-page .markdown-content h2 .doc-heading-anchor {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.35rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color, #6c757d);
    opacity: 0;
    vertical-align: middle;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s ease, color 0.15s ease;
}

body.documentation-page .markdown-content h2 .doc-heading-anchor .bi {
    font-size: 0.95em;
}

body.documentation-page .markdown-content h2:hover .doc-heading-anchor,
body.documentation-page .markdown-content h2:focus-within .doc-heading-anchor {
    opacity: 1;
}

body.documentation-page .markdown-content h2 .doc-heading-anchor:hover,
body.documentation-page .markdown-content h2 .doc-heading-anchor:focus {
    color: var(--bs-primary, #0d6efd);
    outline: none;
}

body.documentation-page .markdown-content h2 .doc-heading-anchor:focus-visible {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: 2px;
    border-radius: 2px;
}

#docAnchorToast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 1080;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    background: var(--bs-dark, #212529);
    color: #fff;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#docAnchorToast.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Phase 2 — layout, TOC, search */

body.documentation-page .documentation-layout__grid {
    display: block;
}

@media (min-width: 992px) {
    body.documentation-page .documentation-layout__grid {
        display: grid;
        grid-template-columns: minmax(0, 90ch) max-content;
        width: fit-content;
        max-width: 100%;
        margin-inline: auto;
        gap: 1.25rem 2rem;
    }

    body.documentation-page .documentation-layout__main {
        min-width: 0;
        max-width: 90ch;
    }

    body.documentation-page .documentation-layout__toc {
        position: sticky;
        top: 80px;
        align-self: start;
        width: max-content;
        max-width: 24rem;
        height: fit-content;
        max-height: calc(100vh - 96px);
    }

    body.documentation-page .doc-toc-card {
        width: max-content;
        max-width: 100%;
        max-height: calc(100vh - 96px);
    }

    body.documentation-page .doc-toc-card .card-body {
        padding: 0.65rem 0.85rem;
        max-height: inherit;
        overflow-y: auto;
    }

    body.documentation-page .doc-prose {
        max-width: none;
    }
}

body.documentation-page .doc-toc {
    overflow: visible;
}

body.documentation-page .doc-toc__title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 0.75rem;
}

body.documentation-page .doc-toc__item + .doc-toc__item {
    margin-top: 0.35rem;
}

body.documentation-page .doc-toc__link {
    display: block;
    font-size: 0.8125rem;
    line-height: 1.35;
    color: var(--bs-secondary-color, #6c757d);
    text-decoration: none;
    padding: 0.15rem 0;
    border-left: 2px solid transparent;
    margin-left: -0.5rem;
    padding-left: calc(0.5rem - 2px);
    white-space: nowrap;
}

body.documentation-page .doc-toc__link:hover {
    color: var(--bs-primary, #0d6efd);
}

body.documentation-page .doc-toc__link.is-active {
    color: var(--bs-primary, #0d6efd);
    font-weight: 600;
    border-left-color: var(--bs-primary, #0d6efd);
}

body.documentation-page .doc-section-jump-bar {
    position: sticky;
    top: 64px;
    z-index: 1020;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0 0.75rem;
    background: var(--bs-body-bg, #fff);
}

body.documentation-page .doc-section-jump {
    max-width: none;
    margin-bottom: 0;
}

@media (max-width: 991.98px) {
    body.documentation-page .markdown-content h2 {
        scroll-margin-top: 7.5rem;
    }
}

#searchResults .search-result-group + .search-result-group {
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}

#searchResults .search-result-module {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--bs-secondary-color, #6c757d);
    background: var(--bs-tertiary-bg, #f8f9fa);
}

#searchResults .search-result-item.is-active,
#searchResults .search-result-item:hover {
    background-color: var(--bs-tertiary-bg, #f8f9fa);
}

#searchResults .search-result-heading {
    font-weight: 600;
    margin-bottom: 0.2rem;
    font-size: 0.9rem;
}

#searchResults .search-result-excerpt {
    font-size: 0.8125rem;
    color: var(--bs-secondary-color, #6c757d);
    line-height: 1.35;
}

#searchResults mark {
    background-color: #fff3cd;
    padding: 0;
}

.side-nav [data-doc-navigation] > .nav-submenu > .nav-submenu-title,
.side-nav [data-doc-navigation] li.nav-submenu > .nav-submenu-title {
    cursor: pointer;
}

body.documentation-page .side-nav .doc-sidebar-item i.bi,
body.documentation-page .side-nav .doc-sidebar-item i[class*=" bi-"] {
    display: inline-block;
    vertical-align: middle;
}
