/* Shared page-scroll controls, using the portal palette and typography. */
.portal-page .portal-scroll-progress {
    position: fixed;
    inset: 0 0 auto;
    height: 3px;
    z-index: 52;
    pointer-events: none;
    background: #30343c66;
}
.portal-page .portal-scroll-progress__fill {
    display: block;
    width: 100%;
    height: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, #e99229, var(--portal-accent, #f5a53b));
    box-shadow: 0 0 9px #f5a53b40;
}
.portal-page .portal-scroll-top {
    --scroll-progress: 0;
    position: fixed;
    right: max(24px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 48;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 64px;
    height: 80px;
    min-width: 0;
    padding: 9px 8px 7px;
    border: 1px solid #f5a53b55;
    border-radius: 18px;
    background: #1b1e23;
    color: var(--portal-accent, #f5a53b);
    box-shadow: 0 8px 24px #0005;
    font: 700 12px/1 var(--font, "Segoe UI", Arial, sans-serif);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color .18s, border-color .18s, box-shadow .18s;
}
.portal-page .portal-scroll-top[hidden],
.portal-page.portal-nav-open .portal-scroll-top {
    display: none;
}
.portal-page .portal-scroll-top:hover {
    background: #22262d;
    border-color: var(--portal-accent, #f5a53b);
    box-shadow: 0 8px 28px #0006, 0 0 0 3px #f5a53b12;
}
.portal-page .portal-scroll-top:focus-visible {
    outline: 2px solid var(--portal-accent, #f5a53b);
    outline-offset: 4px;
}
.portal-page .portal-scroll-top__dial {
    position: relative;
    display: grid;
    place-items: center;
    flex: none;
    width: 38px;
    height: 38px;
}
.portal-page .portal-scroll-top__ring {
    position: absolute;
    inset: 0;
    width: 38px;
    height: 38px;
    overflow: visible;
    fill: none;
    stroke-width: 2;
}
.portal-page .portal-scroll-top__track { stroke: #383b40; }
.portal-page .portal-scroll-top__value {
    stroke: currentColor;
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: calc(100 - var(--scroll-progress));
    transform: rotate(-90deg);
    transform-origin: center;
}
.portal-page .portal-scroll-top__arrow {
    position: relative;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.portal-page .portal-scroll-top__percent { color: #e5b777; }
/* Keep the final sidebar action reachable behind the floating control. */
@media (min-width: 1281px) {
    .portal-page .portal-right-sidebar { padding-bottom: 120px; }
}
@media (max-width: 1280px) {
    .portal-page .portal-footer { padding-bottom: 120px !important; }
}
@media (max-width: 720px) {
    .portal-page .portal-scroll-top {
        right: max(14px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
        width: 58px;
        height: 74px;
        border-radius: 16px;
        font-size: 11px;
    }
}
@media (prefers-reduced-motion: reduce) {
    html.portal-dark { scroll-behavior: auto; }
    .portal-page .portal-scroll-top { transition: none; }
}
