:root {
    --scroll-offset: 88px;
    --scroll-ui-accent: var(--accent, #4ef1e8);
    --scroll-ui-bg: rgba(8, 14, 22, 0.82);
    --scroll-ui-line: rgba(255, 255, 255, 0.14);
    --scroll-ui-line-strong: rgba(255, 255, 255, 0.22);
    --scroll-ui-text: rgba(235, 243, 251, 0.88);
    --scroll-ui-muted: rgba(190, 204, 220, 0.76);
    --scrollbar-thumb: rgba(255, 255, 255, 0.2);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.34);
}

html[data-theme="light"] {
    --scroll-ui-bg: rgba(245, 248, 252, 0.86);
    --scroll-ui-line: rgba(17, 24, 39, 0.12);
    --scroll-ui-line-strong: rgba(17, 24, 39, 0.2);
    --scroll-ui-text: rgba(24, 39, 62, 0.9);
    --scroll-ui-muted: rgba(57, 74, 98, 0.76);
    --scrollbar-thumb: rgba(17, 24, 39, 0.18);
    --scrollbar-thumb-hover: rgba(17, 24, 39, 0.3);
}

html {
    scroll-behavior: smooth !important;
    scrollbar-gutter: stable both-edges;
}

html,
body {
    overscroll-behavior-x: none;
}

body {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

body::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

body::-webkit-scrollbar-track {
    background: transparent;
}

body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--scrollbar-thumb), rgba(255, 255, 255, 0.08));
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--scrollbar-thumb-hover), rgba(255, 255, 255, 0.12));
}

:where(main, section, article, div, nav)[id],
:where(h1, h2, h3, h4, h5, h6)[id] {
    scroll-margin-top: var(--scroll-offset);
}

.scroll-progress {
    position: fixed;
    inset: 0 0 auto;
    z-index: 9800;
    height: 4px;
    pointer-events: none;
    opacity: 1;
    transition: opacity 180ms ease;
}

.scroll-progress.is-hidden {
    opacity: 0;
}

.scroll-progress__bar {
    width: 100%;
    height: 100%;
    transform-origin: left center;
    transform: scaleX(0);
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--scroll-ui-accent) 88%, white 12%), var(--scroll-ui-accent)),
        linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent);
    box-shadow: 0 0 18px color-mix(in srgb, var(--scroll-ui-accent) 34%, transparent);
    transition: transform 120ms ease-out;
}

@media (max-width: 900px) {
    .scroll-progress {
        height: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }

    .scroll-progress,
    .scroll-progress__bar {
        transition: none !important;
    }
}
