/**
 * Ghost TOC — Frontend Styles
 *
 * Styled to look and feel like a standard TOC (clickable links, hover states,
 * active section highlighting) while using <span> elements instead of <a href>.
 * No anchor links = no fragment URLs in Google's Protocol Buffers.
 *
 * @since 2.0.0
 */

/* Scroll offset for fixed headers */
[id] {
    scroll-margin-top: var(--tsma-toc-scroll-offset, 80px);
}

/* TOC Container */
.tsma-ghost-toc {
    background: var(--tsma-toc-bg, #f8f9fa);
    border: 1px solid var(--tsma-toc-border, #e2e8f0);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0 2rem;
    max-width: 100%;
    font-size: 0.95em;
    line-height: 1.6;
}

/* Title */
.tsma-toc-title {
    font-weight: 600;
    font-size: 1.05em;
    margin-bottom: 0.75rem;
    color: var(--tsma-toc-title-color, #1a202c);
    letter-spacing: -0.01em;
}

/* Collapsible summary */
.tsma-ghost-toc details > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tsma-ghost-toc details > summary::before {
    content: '\25B6';
    font-size: 0.7em;
    transition: transform 0.2s ease;
}

.tsma-ghost-toc details[open] > summary::before {
    transform: rotate(90deg);
}

/* List */
.tsma-toc-list {
    margin: 0;
    padding-left: 1.25rem;
}

.tsma-toc-list .tsma-toc-sub {
    padding-left: 1.25rem;
    margin-top: 0.25rem;
}

/* Items */
.tsma-toc-item {
    margin-bottom: 0.35rem;
}

/* Ghost TOC links — <span> elements styled to look like links */
.tsma-toc-link {
    color: var(--tsma-toc-link-color, #2563eb);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s ease;
    /* Make span behave like an inline link */
    display: inline;
}

.tsma-toc-link:hover {
    color: var(--tsma-toc-link-hover, #1d4ed8);
    text-decoration: underline;
}

/* Focus state for keyboard accessibility */
.tsma-toc-link:focus {
    outline: 2px solid var(--tsma-toc-link-color, #2563eb);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Active section highlighting (set by ghost-toc.js scroll spy) */
.tsma-toc-link.tsma-toc-active {
    color: var(--tsma-toc-active-color, #1d4ed8);
    font-weight: 600;
}

/* H3 items slightly smaller */
.tsma-toc-h3 {
    font-size: 0.92em;
    opacity: 0.9;
}

/* Kadence theme compatibility */
.entry-content .tsma-ghost-toc {
    font-family: inherit;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .tsma-ghost-toc {
        background: var(--tsma-toc-bg-dark, #1a202c);
        border-color: var(--tsma-toc-border-dark, #2d3748);
    }
    .tsma-toc-title {
        color: var(--tsma-toc-title-color-dark, #e2e8f0);
    }
    .tsma-toc-link {
        color: var(--tsma-toc-link-color-dark, #63b3ed);
    }
    .tsma-toc-link.tsma-toc-active {
        color: var(--tsma-toc-active-color-dark, #90cdf4);
    }
}
