/*
 * Viking Blog Sidebar / TOC
 * Compact desktop sidebar + clean mobile behavior
 */

body.single-post .rf-sidebar-stack {
    min-width: 0;
    display: grid;
    gap: 14px;
    position: sticky;
    top: calc(var(--rf-header-h, 80px) + 16px);
    align-self: start;
}

/* Main TOC card */
body.single-post .rf-sidebar-stack .rf-toc {
    position: static !important;
    width: 100%;
    max-height: min(56vh, 560px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;

    padding: 16px 14px !important;
    margin: 0 !important;

    background: #fff;
    border: 1px solid rgba(0,0,0,.10);
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(0,0,0,.045);

    overscroll-behavior: contain;

    /* Hide ugly giant scrollbar, scrolling still works */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body.single-post .rf-sidebar-stack .rf-toc::-webkit-scrollbar {
    display: none;
}

/* TOC title */
body.single-post .rf-toc > h2,
body.single-post .rf-toc > h3,
body.single-post .rf-toc .rf-toc__title {
    margin: 0 0 10px !important;
    padding: 0 4px 10px !important;

    font-size: 14px !important;
    line-height: 1.25 !important;
    font-weight: 750 !important;
    letter-spacing: .02em;

    border-bottom: 1px solid rgba(0,0,0,.08);
}

/* Remove huge default list spacing */
body.single-post .rf-toc ul,
body.single-post .rf-toc ol {
    display: grid;
    gap: 3px;

    margin: 0 !important;
    padding: 0 !important;

    list-style: none !important;
}

body.single-post .rf-toc li {
    margin: 0 !important;
    padding: 0 !important;
}

/* Compact readable TOC links */
body.single-post .rf-toc a {
    display: block;

    margin: 0 !important;
    padding: 7px 9px !important;

    font-size: 14px !important;
    line-height: 1.32 !important;
    font-weight: 600 !important;

    color: #353535;
    text-decoration: none !important;

    border-radius: 9px;

    transition:
        background-color .16s ease,
        color .16s ease,
        transform .16s ease;
}

body.single-post .rf-toc a:hover,
body.single-post .rf-toc a:focus-visible {
    color: #111;
    background: #f3f3f3;
    transform: translateX(2px);
}

/* Nested sections */
body.single-post .rf-toc ul ul,
body.single-post .rf-toc ol ol,
body.single-post .rf-toc ul ol,
body.single-post .rf-toc ol ul {
    margin-top: 2px !important;
    padding-left: 10px !important;
}

/* Sidebar widgets below TOC */
body.single-post .rf-sidebar-stack > *:not(.rf-toc) {
    min-width: 0;
}

/* Compact CTA buttons */
body.single-post .rf-sidebar-stack .rf-btn {
    min-height: 48px;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

/* Tablet / mobile: sidebar returns to document flow */
@media (max-width: 1024px) {
    body.single-post .rf-sidebar-stack {
        position: static;
        top: auto;
        width: 100%;
    }

    body.single-post .rf-sidebar-stack .rf-toc {
        max-height: 420px !important;
    }
}

/* Mobile */
@media (max-width: 767px) {
    body.single-post .rf-sidebar-stack {
        gap: 12px;
    }

    body.single-post .rf-sidebar-stack .rf-toc {
        max-height: 320px !important;
        padding: 13px 11px !important;
        border-radius: 14px;
    }

    body.single-post .rf-toc a {
        padding: 7px 8px !important;
        font-size: 13.5px !important;
        line-height: 1.3 !important;
    }
}


/* =========================================================
   VIKING BLOG SIDEBAR V2 — hard visual override
   ========================================================= */

@media (min-width: 1025px) {

    /* Kill the tall sticky/scrolling column */
    body.single-post .rf-related-sidebar,
    body.single-post .rf-sidebar-stack {
        position: static !important;
        top: auto !important;

        max-height: none !important;
        height: auto !important;
        min-height: 0 !important;

        overflow: visible !important;
        overflow-x: visible !important;
        overflow-y: visible !important;

        scrollbar-width: none !important;

        align-self: start !important;
    }

    body.single-post .rf-related-sidebar::-webkit-scrollbar,
    body.single-post .rf-sidebar-stack::-webkit-scrollbar,
    body.single-post .rf-toc::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
    }


    /* TOC card itself */
    body.single-post .rf-related-sidebar .rf-toc,
    body.single-post .rf-sidebar-stack .rf-toc,
    body.single-post .rf-toc {
        position: static !important;

        max-height: none !important;
        height: auto !important;

        overflow: visible !important;

        padding: 14px 14px !important;
        margin: 0 !important;

        border-radius: 18px !important;
    }


    /* Reset oversized TOC typography */
    body.single-post .rf-toc ul,
    body.single-post .rf-toc ol {
        display: flex !important;
        flex-direction: column !important;
        gap: 2px !important;

        margin: 0 !important;
        padding: 0 !important;

        list-style: none !important;
    }

    body.single-post .rf-toc li {
        margin: 0 !important;
        padding: 0 !important;

        font-size: 14px !important;
        line-height: 1.25 !important;
    }

    body.single-post .rf-toc li + li {
        margin-top: 1px !important;
    }


    /* Every TOC link: force compact size */
    body.single-post .rf-toc a,
    body.single-post .rf-toc li > a,
    body.single-post .rf-toc nav a,
    body.single-post .rf-toc [class*="link"],
    body.single-post .rf-toc [class*="item"] a {
        display: block !important;

        margin: 0 !important;
        padding: 7px 9px !important;

        font-size: 14px !important;
        line-height: 1.28 !important;
        font-weight: 600 !important;

        letter-spacing: 0 !important;

        border-radius: 9px !important;

        white-space: normal !important;
        word-break: normal !important;
        overflow-wrap: normal !important;
    }


    /* Active item */
    body.single-post .rf-toc a[aria-current],
    body.single-post .rf-toc .is-active,
    body.single-post .rf-toc .active,
    body.single-post .rf-toc [class*="active"] {
        padding-top: 7px !important;
        padding-bottom: 7px !important;

        font-size: 14px !important;
        line-height: 1.25 !important;

        border-radius: 9px !important;
    }


    /* Nested headings slightly smaller */
    body.single-post .rf-toc ul ul a,
    body.single-post .rf-toc ol ol a {
        padding-left: 17px !important;
        font-size: 13px !important;
    }


    /* No huge gaps between random TOC elements */
    body.single-post .rf-toc p,
    body.single-post .rf-toc div {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }


    /* CTA section below TOC */
    body.single-post .rf-sidebar-stack .rf-btn,
    body.single-post .rf-related-sidebar .rf-btn {
        min-height: 46px !important;

        padding: 9px 12px !important;

        font-size: 14px !important;
        line-height: 1.2 !important;
    }
}


/* Tablet/mobile — completely normal document flow */
@media (max-width: 1024px) {

    body.single-post .rf-related-sidebar,
    body.single-post .rf-sidebar-stack,
    body.single-post .rf-toc {
        position: static !important;

        max-height: none !important;
        height: auto !important;

        overflow: visible !important;
    }

    body.single-post .rf-toc a,
    body.single-post .rf-toc li > a {
        font-size: 14px !important;
        line-height: 1.3 !important;
        padding: 7px 8px !important;
    }
}
