/* ==========================================================================
   Tooltip component (term + ? icon + bubble).
   ========================================================================== */

.bb26-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: help;
    outline: none;
    border-bottom: 1px dashed var(--bb-accent-dark);
    padding-bottom: 1px;
}

.bb26-tip__term {
    color: inherit;
    font-weight: 600;
}

.bb26-tip__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--bb-accent);
    color: var(--bb-text);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.bb26-tip__bubble {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    transform-origin: bottom center;
    width: max-content;
    max-width: 280px;
    padding: 10px 14px;
    background: var(--bb-text);
    color: #fff;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    font-weight: 400;
    box-shadow: var(--bb-shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s var(--bb-ease), transform 0.18s var(--bb-ease);
    z-index: 50;
    text-align: left;
}

.bb26-tip__bubble::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--bb-text);
}

.bb26-tip:hover .bb26-tip__bubble,
.bb26-tip:focus .bb26-tip__bubble,
.bb26-tip.is-active .bb26-tip__bubble {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    pointer-events: auto;
}

@media (max-width: 480px) {
    .bb26-tip__bubble {
        max-width: 240px;
        font-size: 12px;
    }
}

/* TOC sidebar — кнопка по левому краю, чтобы не конфликтовать с чат-bubble справа */

.bb26-toc-tag {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 99;
    background: var(--bb-text);
    color: #fff;
    border: 0;
    padding: 14px 10px;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    writing-mode: vertical-rl;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: padding-right 0.2s var(--bb-ease), background 0.18s var(--bb-ease);
}

.bb26-toc-tag:hover {
    background: var(--bb-accent-dark);
    color: var(--bb-text);
    padding-right: 14px;
}

.bb26-toc-tag__icon {
    writing-mode: horizontal-tb;
    font-size: 18px;
}

.bb26-toc-tag__text {
    transform: rotate(180deg);
}

@media (max-width: 640px) {
    /* На мобиле плавающая TOC-закладка ВСЕГДА скрыта —
       заменена кнопкой 📖 в sticky bottom bar (рендерится через sticky-mobile-nav.php) */
    .bb26-toc-tag {
        display: none !important;
    }
    /* Сайдбар TOC должен подниматься над sticky bottom bar */
    .bb26-toc-sidebar {
        bottom: var(--bb-mobile-bar-height, 64px);
    }
}

.bb26-toc-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 360px;
    max-width: 86vw;
    background: var(--bb-panel);
    box-shadow: var(--bb-shadow-lg);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s var(--bb-ease);
    overflow-y: auto;
}

.bb26-toc-sidebar.is-active {
    transform: translateX(0);
}

.bb26-toc-sidebar__header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--bb-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bb26-toc-sidebar__label {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.bb26-toc-sidebar__close {
    background: transparent;
    border: 0;
    font-size: 28px;
    cursor: pointer;
    color: var(--bb-text-secondary);
    line-height: 1;
}

.bb26-toc-sidebar__content {
    padding: 8px 0;
}

.bb26-toc-sidebar__content .bb26-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bb26-toc-sidebar__content a {
    display: block;
    padding: 10px 20px;
    color: var(--bb-text);
    text-decoration: none;
    border-left: 3px solid transparent;
    font-size: 15px;
    line-height: 1.4;
}

.bb26-toc-sidebar__content a:hover,
.bb26-toc-sidebar__content a.is-active {
    background: var(--bb-accent-soft);
    border-left-color: var(--bb-accent);
}

.bb26-toc-sidebar__content .toc-item-h3 a {
    padding-left: 36px;
    font-size: 14px;
    color: var(--bb-text-secondary);
}

.bb26-toc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,32,44,0.4);
    z-index: 195;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--bb-ease);
}

.bb26-toc-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}
