/* Shared shape and glyph. The active theme supplies the paper, outline and ink. */
:root {
    --back-top-right: clamp(14px, 2vw, 28px);
    --back-top-bottom: clamp(16px, 2vw, 28px);
    --back-top-surface: var(--air-surface-solid, #fff);
    --back-top-surface-hover: var(--air-surface-soft, #eff3f9);
    --back-top-icon: var(--air-primary, #365678);
    --back-top-border: var(--air-line, #d6dfe9);
}
html[data-blog-theme="dark"] {
    --back-top-surface: var(--air-surface-solid, #1b2735);
    --back-top-surface-hover: var(--air-surface-soft, #27364a);
    --back-top-icon: var(--air-primary, #bad3f1);
    --back-top-border: var(--air-line, #4a5b70);
}

/* Older themes style these IDs with !important, including the article's quick-action dial. */
body :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top),
body .article-speed-dial #scroll-to-top-btn {
    --return-target: clamp(44px, 3.4vw, 48px);
    box-sizing: border-box !important;
    display: grid !important;
    place-items: center !important;
    width: var(--return-target) !important;
    min-width: var(--return-target) !important;
    height: var(--return-target) !important;
    min-height: var(--return-target) !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid var(--back-top-border) !important;
    border-radius: 50% !important;
    background: var(--back-top-surface) !important;
    color: var(--back-top-icon) !important;
    box-shadow: 0 2px 7px rgb(18 32 48 / 10%) !important;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
body :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top):not(.article-speed-action) {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    right: max(var(--back-top-right), env(safe-area-inset-right)) !important;
    bottom: max(var(--back-top-bottom), calc(env(safe-area-inset-bottom) + 12px)) !important;
    z-index: 10000 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(5px) !important;
    transition: opacity .16s ease, visibility .16s ease, transform .16s ease, background-color .16s ease !important;
}
body :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top).visible:not(.article-speed-action) {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
}
body :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top)::before,
body :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top)::after {
    content: none !important;
    display: none !important;
}
/* Standalone pages keep their own scroll handler and the older icon element. */
.back-to-top > i.fa-chevron-up::before { content: none; }
.back-top-glyph,
.back-to-top > i.fa-chevron-up {
    display: block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    --return-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 4.5h14M12 20V9m-5 5 5-5 5 5'/%3E%3C/svg%3E");
    -webkit-mask: var(--return-arrow) center / contain no-repeat;
    mask: var(--return-arrow) center / contain no-repeat;
}
@media (hover: hover) and (pointer: fine) {
    body :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top):hover {
        background: var(--back-top-surface-hover) !important;
        border-color: var(--back-top-icon) !important;
    }
}
body :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top):focus-visible {
    outline: 2px solid currentColor !important;
    outline-offset: 3px !important;
}
body.air-modal-open :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top),
body.air-modal-open :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top).visible:not(.article-speed-action) {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
@media (prefers-reduced-motion: reduce) {
    body :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top):not(.article-speed-action) {
        transition: none !important;
    }
}
@media (prefers-reduced-transparency: reduce) {
    body :is(.back-to-top, #back-to-top, #backToTop, #scroll-to-top-btn, #air-global-back-to-top) {
        background: var(--air-surface-solid, Canvas) !important;
    }
}
@media (forced-colors: active) {
    .back-top-glyph, .back-to-top > i.fa-chevron-up { background: ButtonText; forced-color-adjust: none; }
}
