/* Product section links sit directly beneath the site header. */
html[data-product-detail] {
    --product-site-header-height: 1.02rem;
    --product-chapters-height: 0px;
    --product-navigation-offset: calc(var(--product-site-header-height) + var(--product-chapters-height));
    scroll-padding-top: var(--product-site-header-height) !important;
}

[data-product-detail] [data-product-chapters] {
    position: sticky !important;
    top: var(--product-site-header-height) !important;
    z-index: 98 !important;
}

[data-product-detail] [data-product-chapters][data-product-chapters-pinned] {
    position: fixed !important;
    inset-inline: 0;
    margin-top: 0 !important;
}

[data-product-chapters-spacer] {
    height: var(--product-chapters-height);
}

[data-product-chapters-spacer][data-product-fixed-header] {
    height: var(--product-navigation-offset);
}

[data-product-chapter-target] {
    scroll-margin-top: calc(var(--product-chapters-height) + 12px) !important;
}

@media (max-width: 1024px) {
    html[data-product-detail] { --product-site-header-height: 50px; }
    [data-product-detail] body > .header {
        visibility: hidden;
        pointer-events: none;
        overflow: clip;
    }

    [data-product-detail] :is(.product-template-anchor, .ru-grease-anchor)[data-product-chapters] .links {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        padding: 4px 2px;
    }

    [data-product-detail] :is(.product-template-anchor, .ru-grease-anchor)[data-product-chapters] .links a {
        display: inline-flex;
        flex: none;
        align-items: center;
        min-height: 32px;
        font-size: 12px;
    }
}
