/*
 * TrainWerk Scroll to Top, Masterdesign 0.3.7-alpha.
 * Copyright (C) 2026 Hans-Josef Pesch / TrainWerk.
 * TrainWerk Open Use License 1.0 (backlink or coffee appreciated).
 */
#tw-back-to-top {
    position: fixed;
    inset-block-start: 50%;
    inset-inline-end: 16px;
    z-index: 60;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    margin: 0;
    border: 1px solid #334155;
    border-radius: 0;
    background: #020617;
    color: #ffffff;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(16px, -50%);
    transition: background-color 300ms, border-color 300ms, opacity 300ms,
                transform 300ms, visibility 0s linear 300ms;
}

#tw-back-to-top.tw-back-to-top--visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translate(0, -50%);
    transition: background-color 300ms, border-color 300ms, opacity 300ms,
                transform 300ms, visibility 0s;
}

#tw-back-to-top:hover {
    background: #f97316;
    border-color: #f97316;
}

#tw-back-to-top:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 3px;
}

#tw-back-to-top svg {
    display: block;
    width: 24px;
    height: 24px;
    pointer-events: none;
}

@media (min-width: 640px) {
    #tw-back-to-top { inset-inline-end: 24px; }
}
@media (min-width: 1024px) {
    #tw-back-to-top { inset-inline-end: 32px; }
}
/* Keep the button consistent with TrainWerk's own accessibility modes. */
html.tw-a11y-contrast-high #tw-back-to-top {
    background: #e5e7eb !important;
    color: #000000 !important;
    border-color: #111827 !important;
    box-shadow: none !important;
}
html.tw-a11y-contrast-high #tw-back-to-top:hover {
    background: #d1d5db !important;
}
html.tw-a11y-motion #tw-back-to-top,
html.tw-a11y-motion #tw-back-to-top.tw-back-to-top--visible {
    transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
    #tw-back-to-top,
    #tw-back-to-top.tw-back-to-top--visible {
        transition: none;
    }
}
@media (forced-colors: active) {
    #tw-back-to-top {
        border: 2px solid ButtonText;
        color: ButtonText;
        background: Canvas;
        forced-color-adjust: auto;
    }
}
