/* ============================================
   MSA Sidebar TOC v3.0 — Styles
   NASA.gov-inspired sticky sidebar with
   social sharing, article meta, and TOC
   ============================================ */

:root {
    --msa-toc-accent: #e03c31;
    --msa-toc-text: #1b1b1b;
    --msa-toc-text-muted: #5c5c5c;
    --msa-toc-text-light: #6b7280;
    --msa-toc-bg: #ffffff;
    --msa-toc-border: #d1d5db;
    --msa-toc-divider: #e5e7eb;
    --msa-toc-hover-bg: #f3f4f6;
    --msa-toc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --msa-toc-width: 260px;
    --msa-toc-gap: 2.5rem;
}

/* ── Shortcode mode: sidebar in Elementor column ── */

.msa-toc-sidebar {
    width: var(--msa-toc-width);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

/* ── Auto-inject mode: fixed sidebar via wp_footer ── */

.msa-toc-sidebar--auto {
    position: fixed;
    top: 100px;
    left: max(16px, calc((100vw - 1200px) / 2 - var(--msa-toc-width) - 40px));
    width: var(--msa-toc-width);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    z-index: 100;
}

/* ── The sidebar nav container ──────────────── */

.msa-toc {
    font-family: var(--msa-toc-font);
    font-size: 14px;
    line-height: 1.5;
    padding: 0;
}

/* ── Dividers ────────────────────────────────── */

.msa-toc__divider {
    border: none;
    border-top: 1px solid var(--msa-toc-divider);
    margin: 16px 0;
}

/* ═══════════════════════════════════════════════
   SOCIAL SHARING ICONS
   ═══════════════════════════════════════════════ */

.msa-toc__social {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 0 0 0;
    flex-wrap: wrap;
}

.msa-toc__social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--msa-toc-text-muted);
    text-decoration: none;
    transition: color 0.2s ease,
                background-color 0.2s ease;
}

.msa-toc__social-link:hover,
.msa-toc__social-link:focus {
    color: var(--msa-toc-accent);
    background-color: var(--msa-toc-hover-bg);
}

.msa-toc__social-link:focus-visible {
    outline: 2px solid var(--msa-toc-accent);
    outline-offset: 2px;
}

.msa-toc__social-link svg {
    display: block;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   ARTICLE META — Author, Date, Label, Read Time
   ═══════════════════════════════════════════════ */

.msa-toc__meta {
    padding: 0;
}

/* Reading time badge — styled like NASA's "5 min read" */
.msa-toc__reading-time {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--msa-toc-text);
    background: var(--msa-toc-hover-bg);
    border-radius: 3px;
    padding: 3px 8px;
    margin-bottom: 10px;
}

/* Author name */
.msa-toc__author {
    font-size: 14px;
    font-weight: 600;
    color: var(--msa-toc-text);
    margin-bottom: 2px;
    line-height: 1.4;
}

/* Publication date */
.msa-toc__date {
    font-size: 13px;
    color: var(--msa-toc-text-muted);
    margin-bottom: 4px;
    line-height: 1.4;
}

/* Post type label (e.g. "Article") */
.msa-toc__label {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    color: var(--msa-toc-text-light);
    text-transform: capitalize;
    letter-spacing: 0.01em;
    padding: 2px 0;
    margin-top: 2px;
    border-bottom: 1px solid var(--msa-toc-accent);
}

/* ═══════════════════════════════════════════════
   TABLE OF CONTENTS
   ═══════════════════════════════════════════════ */

/* Section header */
.msa-toc__header {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--msa-toc-text-light);
    padding: 0 0 10px 0;
    margin: 0;
}

/* List */
.msa-toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 3px solid var(--msa-toc-divider);
}

.msa-toc__item {
    margin: 0;
    padding: 0;
    position: relative;
}

/* Sub-heading indent */
.msa-toc__item--sub .msa-toc__link {
    padding-left: 32px;
    font-size: 13px;
}

/* Links */
.msa-toc__link {
    display: block;
    padding: 7px 12px 7px 16px;
    color: var(--msa-toc-text-muted);
    text-decoration: none;
    border-left: 3px solid transparent;
    margin-left: -3px;
    transition: color 0.2s ease,
                border-color 0.2s ease,
                background-color 0.15s ease;
    cursor: pointer;
    line-height: 1.45;
}

.msa-toc__link:hover {
    color: var(--msa-toc-text);
    background-color: var(--msa-toc-hover-bg);
}

/* Active / current section */
.msa-toc__link.is-active {
    color: var(--msa-toc-text);
    font-weight: 600;
    border-left-color: var(--msa-toc-accent);
}

.msa-toc__text {
    display: inline;
}

/* ── Scrollbar styling for long TOCs ────────── */

.msa-toc-sidebar::-webkit-scrollbar {
    width: 4px;
}

.msa-toc-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.msa-toc-sidebar::-webkit-scrollbar-thumb {
    background: var(--msa-toc-border);
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .msa-toc-sidebar--auto {
        display: none;
    }

    .msa-toc__list {
        border-left: none;
        border-bottom: 2px solid var(--msa-toc-divider);
        display: flex;
        flex-wrap: wrap;
        gap: 0;
        padding-bottom: 8px;
    }

    .msa-toc__link {
        margin-left: 0;
        border-left: none;
        border-bottom: 2px solid transparent;
        margin-bottom: -2px;
        padding: 6px 12px;
        white-space: nowrap;
    }

    .msa-toc__link.is-active {
        border-left: none;
        border-bottom-color: var(--msa-toc-accent);
    }

    .msa-toc__social {
        justify-content: flex-start;
    }
}

@media (max-width: 600px) {
    .msa-toc__list {
        flex-direction: column;
    }

    .msa-toc__link {
        white-space: normal;
        border-bottom: none;
        border-left: 3px solid transparent;
        margin-bottom: 0;
    }

    .msa-toc__link.is-active {
        border-bottom: none;
        border-left-color: var(--msa-toc-accent);
    }
}

/* ═══════════════════════════════════════════════
   DARK THEME SUPPORT
   ═══════════════════════════════════════════════ */

.msa-toc--dark,
body.dark-mode .msa-toc,
[data-theme="dark"] .msa-toc {
    --msa-toc-text: #e5e7eb;
    --msa-toc-text-muted: #9ca3af;
    --msa-toc-text-light: #6b7280;
    --msa-toc-bg: transparent;
    --msa-toc-border: #374151;
    --msa-toc-divider: #374151;
    --msa-toc-hover-bg: rgba(255, 255, 255, 0.06);
}

.msa-toc--dark .msa-toc__reading-time,
body.dark-mode .msa-toc__reading-time,
[data-theme="dark"] .msa-toc__reading-time {
    background: rgba(255, 255, 255, 0.08);
}
