/* ThaiFly Tour Engine V56.4 — Site-wide Back to Top button, mobile listing safe offset */
.tte-to-top {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 2147483200;
    width: 48px;
    min-width: 48px;
    height: 54px;
    padding: 6px 0 5px;
    border: 1px solid rgba(10, 31, 68, .10);
    border-radius: 999px;
    background: rgba(255, 255, 255, .96);
    color: #0f172a;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .16), 0 2px 8px rgba(15, 23, 42, .08);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate3d(0, 14px, 0) scale(.92);
    transition: opacity .22s ease, transform .22s ease, visibility .22s ease, background .18s ease, box-shadow .18s ease;
    -webkit-tap-highlight-color: transparent;
}

.tte-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate3d(0, 0, 0) scale(1);
}

.tte-to-top:hover {
    background: #fff;
    transform: translate3d(0, -2px, 0) scale(1.02);
    box-shadow: 0 16px 38px rgba(15, 23, 42, .20), 0 3px 10px rgba(15, 23, 42, .10);
}

.tte-to-top:active {
    transform: translate3d(0, 0, 0) scale(.97);
}

.tte-to-top:focus-visible {
    outline: 3px solid rgba(0, 122, 255, .28);
    outline-offset: 3px;
}

.tte-to-top-arrow {
    width: 24px;
    height: 22px;
    display: grid;
    place-items: center;
    line-height: 1;
}

.tte-to-top-arrow svg {
    width: 24px;
    height: 24px;
    display: block;
}

.tte-to-top-text {
    margin-top: -1px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", Arial, sans-serif;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .04em;
    line-height: 1;
}

html.tte-mobile-global-menu-lock .tte-to-top,
body.tte-mobile-global-menu-lock .tte-to-top,
html.tte-sheet-lock .tte-to-top,
body.tte-sheet-lock-body .tte-to-top {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

@media (max-width: 760px) {
    .tte-to-top {
        right: max(14px, env(safe-area-inset-right));
        bottom: calc(18px + env(safe-area-inset-bottom));
        width: 46px;
        min-width: 46px;
        height: 46px;
        padding: 0;
        border-radius: 50%;
    }

    .tte-to-top-text {
        display: none;
    }

    /* V56.4: On tour listing pages the fixed filter/sort bar sits at the bottom.
       Lift To Top above it so it never blocks the "กรองผล / เรียง" buttons.
       JS adds these classes; :has() is a fallback for modern browsers. */
    html.tte-has-mobile-filter-bar .tte-to-top,
    body.tte-has-mobile-filter-bar .tte-to-top,
    body:has(.tte-mobile-filter-bar) .tte-to-top {
        bottom: calc(88px + env(safe-area-inset-bottom)) !important;
    }

}

@media print {
    .tte-to-top {
        display: none !important;
    }
}
