/* Public site: #site-scroll fills viewport below fixed header (no padding-top gap). */

html:has(body.has-site-header) {
    height: 100%;
    overflow: hidden;
}

body.has-site-header {
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
    padding-top: 0;
}

body.has-site-header .site-scroll {
    position: fixed;
    top: var(--site-nav-height);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    --site-scroll-anchor: 1rem;
}

body.has-site-header:has(.site-scroll) {
    padding-top: 0;
}

/* One primary scrollbar: let long sidebars grow with the scrollport */
body.has-site-header .blog-cat-list {
    max-height: none;
    overflow-y: visible;
}

body.has-site-header .site-scroll .blog-sidebar--sticky,
body.has-site-header .site-scroll .article-toc {
    top: var(--site-scroll-anchor);
}

body.has-site-header .site-scroll .article-toc-card {
    max-height: calc(100dvh - var(--site-nav-height) - 2 * var(--site-scroll-anchor));
}

body.has-site-header .site-scroll .article-content h2,
body.has-site-header .site-scroll .article-content h3,
body.has-site-header .site-scroll .article-content h4 {
    scroll-margin-top: var(--site-scroll-anchor);
}

@media (min-width: 768px) {
    body.has-site-header .site-scroll .blog-sidebar--sticky {
        top: var(--site-scroll-anchor);
    }

    body.has-site-header .site-scroll .article-toc {
        top: var(--site-scroll-anchor);
    }

    body.has-site-header .site-scroll .article-toc-card {
        max-height: calc(100dvh - var(--site-nav-height) - 2 * var(--site-scroll-anchor));
    }
}

@media (prefers-reduced-motion: no-preference) {
    body.has-site-header .site-scroll {
        scroll-behavior: smooth;
    }
}
