/**
 * UpPay mini-app — единая плавающая нижняя навигация (Telegram-style).
 * Desktop (>=500px): прежние размеры; mobile: компактная капсула.
 */
:root {
    --uppay-tab-bar-clearance: calc(68px + 15px + env(safe-area-inset-bottom, 0px));
    --uppay-tab-slide-duration: 120ms;
    --uppay-tab-bar-max-width: 520px;
    --uppay-tab-icon-muted: #8a94a3;
    --uppay-tab-icon-active: #007bff;
    --uppay-tab-icon-fill-duration: 200ms;
    /* Зазор nav↔низ экрана; тот же зазор между корзиной и nav (пересчитывается в JS по DOM) */
    --uppay-stack-gap: 15px;
    --uppay-tab-float-offset: 15px;
    --uppay-tab-float-height: 68px;
    --uppay-float-above-nav: calc(
        var(--uppay-tab-float-offset) + var(--uppay-tab-float-height) + var(--uppay-stack-gap)
    );
}

html,
body {
    overflow-x: hidden;
    max-width: 100%;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 42%, #ffffff 100%);
    background-color: #f8fbff;
}

body.has-uppay-tab-bar,
body:has(.nav-wrapper .bottom-nav) {
    padding-bottom: var(--uppay-tab-bar-clearance) !important;
}

/* Единая липкая корзина (PUBG, Aion2, будущие donate-страницы) */
.cart-sticky {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: var(--uppay-float-above-nav, calc(98px));
    width: min(460px, calc(100% - 24px));
    z-index: 2500;
    background: #ffffff;
    border: 1px solid rgba(225, 232, 240, 1);
    border-radius: 14px;
    box-shadow: 0 10px 26px rgba(0, 26, 61, 0.14);
    padding: 10px;
    display: none;
    box-sizing: border-box;
}

.cart-sticky.is-visible {
    display: block;
}

.cart-sticky-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 800;
    color: #001a3d;
}

.cart-sticky-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.cart-sticky-btn {
    border-radius: 10px;
    min-height: 38px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.cart-sticky-btn--open {
    border: 1.5px solid #007bfe;
    background: #ffffff;
    color: #007bfe;
}

.cart-sticky-btn--pay {
    border: none;
    background: #00cf8f;
    color: #ffffff;
    font-weight: 800;
    box-shadow: 0 6px 16px rgba(0, 207, 143, 0.25);
}

.cart-sticky-btn--pay:disabled {
    opacity: 0.48;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none;
}

.cart-sticky-btn__pay-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.cart-sticky-btn__pay-sbp {
    height: 2cap;
    width: auto;
    flex-shrink: 0;
    object-fit: contain;
}

/* --- Floating host --- */
.nav-wrapper {
    position: fixed;
    bottom: 15px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    box-sizing: border-box;
    z-index: 2000;
    pointer-events: none;
}

.bottom-nav {
    pointer-events: auto;
    width: calc(100% - 32px);
    max-width: var(--uppay-tab-bar-max-width);
    min-width: 0;
    height: 68px;
    padding: 6px 10px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    border: 1px solid rgba(225, 232, 240, 0.82);
    box-shadow:
        0 4px 22px rgba(0, 26, 61, 0.07),
        0 1px 4px rgba(0, 26, 61, 0.04);
    backdrop-filter: blur(18px) saturate(1.18);
    -webkit-backdrop-filter: blur(18px) saturate(1.18);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* --- Tab items --- */
.nav-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: stretch;
    padding: 2px 1px;
    color: #8a94a3;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.15;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--uppay-tab-icon-fill-duration) ease-out;
}

.nav-item-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 100%;
    max-width: none;
    min-height: 44px;
    padding: 5px 6px 4px;
    border-radius: 999px;
    box-sizing: border-box;
    transition:
        background-color 0.22s ease,
        color 0.22s ease,
        transform 0.22s ease;
}

.nav-item.active {
    color: #007bff;
}

.nav-item.active .nav-item-inner {
    background: rgba(0, 123, 255, 0.12);
}

.nav-icon-slot {
    position: relative;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: block;
    overflow: visible;
}

.nav-icon-outline,
.nav-icon-fill {
    transform-box: fill-box;
    transform-origin: center;
}

.nav-icon-outline {
    opacity: 1;
    transition: opacity var(--uppay-tab-icon-fill-duration) ease-out;
}

.nav-icon-fill {
    opacity: 0;
    transform: scale(1);
    transition:
        opacity var(--uppay-tab-icon-fill-duration) ease-out,
        transform var(--uppay-tab-icon-fill-duration) ease-out;
}

.nav-item.active .nav-icon-outline {
    opacity: 0;
}

.nav-item.active .nav-icon-fill {
    opacity: 1;
    transform: scale(1);
}

.nav-icon-fill .nav-icon-accent {
    fill: #fff;
}

.nav-label {
    display: block;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
    letter-spacing: -0.02em;
}

/* --- Mobile: Telegram-like compact capsule --- */
@media (max-width: 499px) {
    :root {
        --uppay-tab-bar-clearance: calc(50px + 8px + env(safe-area-inset-bottom, 0px));
        --uppay-tab-bar-max-width: min(540px, calc(100vw - 32px));
        --uppay-tab-float-offset: max(6px, env(safe-area-inset-bottom, 0px));
        --uppay-tab-float-height: 50px;
        --uppay-stack-gap: max(6px, env(safe-area-inset-bottom, 0px));
        --uppay-float-above-nav: calc(
            var(--uppay-tab-float-offset) + var(--uppay-tab-float-height) + var(--uppay-stack-gap)
        );
    }

    .nav-wrapper {
        bottom: max(6px, env(safe-area-inset-bottom, 0px));
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
    }

    .bottom-nav {
        width: calc(100% - 32px);
        height: 50px;
        padding: 3px 6px;
        gap: 2px;
        border-radius: 26px;
        border: 1px solid rgba(225, 232, 240, 0.78);
        background: rgba(255, 255, 255, 0.88);
        box-shadow:
            0 3px 18px rgba(0, 26, 61, 0.06),
            0 1px 3px rgba(0, 26, 61, 0.035);
        backdrop-filter: blur(16px) saturate(1.16);
        -webkit-backdrop-filter: blur(16px) saturate(1.16);
    }

    .nav-item {
        font-size: 10px;
        padding: 2px 0;
    }

    .nav-item-inner {
        min-height: 40px;
        padding: 4px 4px 3px;
        gap: 2px;
    }

    .nav-icon-slot {
        width: 22px;
        height: 22px;
    }

    .nav-icon {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 360px) {
    .bottom-nav {
        gap: 1px;
        padding: 3px 4px;
    }

    .nav-item {
        font-size: 9.5px;
    }

    .nav-item-inner {
        padding: 4px 3px 3px;
    }
}

/* --- Page slide transitions (clip inside viewport, no horizontal scroll) --- */
.uppay-page-root {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: clip;
    overflow-x: hidden;
    position: relative;
    background: inherit;
    min-height: 100svh;
}

html.uppay-tab-navigating .bottom-nav {
    transform: translateZ(0) scale(0.995);
    transition: transform 90ms ease, box-shadow 90ms ease;
}

html.uppay-tab-navigating .nav-item.active .nav-item-inner {
    transform: scale(0.98);
}

html.uppay-tab-slide-active,
html.uppay-tab-slide-active body {
    overflow-x: hidden;
}

html.uppay-tab-exit .uppay-page-root {
    pointer-events: none;
    will-change: auto;
}

html.uppay-tab-exit--forward .uppay-page-root {
    transform: none;
    opacity: 1;
}

html.uppay-tab-exit--back .uppay-page-root {
    transform: none;
    opacity: 1;
}

@keyframes uppay-tab-enter-forward {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes uppay-tab-enter-back {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes uppay-tab-enter-home {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

html.uppay-tab-enter .uppay-page-root {
    animation-duration: var(--uppay-tab-slide-duration);
    animation-timing-function: ease-out;
    animation-fill-mode: both;
    will-change: opacity;
}

html.uppay-tab-enter--forward .uppay-page-root {
    animation-name: uppay-tab-enter-forward;
}

html.uppay-tab-enter--back .uppay-page-root {
    animation-name: uppay-tab-enter-back;
}

html.uppay-tab-enter--to-home .uppay-page-root {
    animation-name: uppay-tab-enter-home;
    will-change: opacity;
}

@media (prefers-reduced-motion: reduce) {
    html.uppay-tab-exit .uppay-page-root {
        transition: none;
        transform: none;
        opacity: 1;
    }

    html.uppay-tab-enter .uppay-page-root {
        animation: none;
    }

    .nav-icon-outline,
    .nav-icon-fill {
        transition: none !important;
    }

    .nav-item.active .nav-icon-fill {
        transform: none;
    }
}
