/* ===========================================================
   Heading anchors — SEO-friendly inline # link next to H2/H3
   =========================================================== */

/* Scroll offset — учитываем sticky header */
.entry-content h2[id],
.entry-content h3[id],
.entry-content h4[id] {
    scroll-margin-top: 90px;
}

/* Anchor link — невидимый по умолчанию, показывается на hover */
.bb26-heading-anchor {
    display: inline-block;
    margin-left: 0.4em;
    padding: 0 4px;
    color: #f0a500;
    font-weight: 400;
    text-decoration: none !important;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .2s ease, transform .2s ease, color .15s;
    vertical-align: baseline;
    line-height: 1;
    border-radius: 4px;
    user-select: none;
    position: relative;
}

.entry-content h2:hover .bb26-heading-anchor,
.entry-content h3:hover .bb26-heading-anchor,
.entry-content h4:hover .bb26-heading-anchor,
.bb26-heading-anchor:hover,
.bb26-heading-anchor:focus {
    opacity: 0.85;
    transform: translateX(0);
    outline: none;
}

.bb26-heading-anchor:hover {
    opacity: 1 !important;
    color: #d68900;
    background: rgba(240, 165, 0, 0.08);
}

.bb26-heading-anchor:focus-visible {
    outline: 2px solid #f0a500;
    outline-offset: 2px;
}

/* Mobile — всегда полу-видимый */
@media (max-width: 740px) {
    .bb26-heading-anchor {
        opacity: 0.35;
        transform: translateX(0);
        font-size: 0.85em;
    }
}

/* Copied tooltip — появляется после клика */
.bb26-heading-anchor.is-copied::after {
    content: attr(data-copy-msg);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a202c;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    animation: bb26-anchor-fade 1.8s ease-out forwards;
}

.bb26-heading-anchor.is-copied::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-bottom-color: #1a202c;
    pointer-events: none;
    z-index: 100;
    animation: bb26-anchor-fade 1.8s ease-out forwards;
}

@keyframes bb26-anchor-fade {
    0%   { opacity: 0; transform: translate(-50%, -4px); }
    10%  { opacity: 1; transform: translate(-50%, 0); }
    80%  { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -4px); }
}

/* Highlight целевого заголовка при якорь-навигации */
.entry-content h2:target,
.entry-content h3:target,
.entry-content h4:target {
    animation: bb26-target-highlight 2.4s ease-out;
}

@keyframes bb26-target-highlight {
    0%   { background-color: rgba(240, 165, 0, 0.18); }
    100% { background-color: transparent; }
}
