/* ── Mobil pastki navigatsiya ──
   Shisha panel + suzuvchi indikator. Faqat transform/opacity animatsiya qilinadi (GPU), layout o'zgarmaydi. */

.ks-tabbar,
.ks-tabbar *,
.ks-tabbar *::before,
.ks-tabbar *::after { box-sizing: border-box; }

.ks-tabbar {
    --ks-tab-ease: cubic-bezier(.34, 1.42, .52, 1);   /* yengil "prujina" */
    --ks-tab-glass: rgb(var(--ink-950-rgb) / .58);
    --ks-tab-edge: rgb(255 255 255 / .09);
    --ks-tab-hi: rgb(255 255 255 / .14);
    position: fixed;
    z-index: 40;
    left: max(.625rem, env(safe-area-inset-left));
    right: max(.625rem, env(safe-area-inset-right));
    bottom: calc(.5rem + env(safe-area-inset-bottom, 0px));
    max-width: 30rem;
    margin-inline: auto;
    height: 3.75rem;
    border-radius: 1.375rem;
    background: var(--ks-tab-glass);
    -webkit-backdrop-filter: blur(20px) saturate(170%);
    backdrop-filter: blur(20px) saturate(170%);
    border: 1px solid var(--ks-tab-edge);
    box-shadow:
        0 18px 40px -14px rgb(0 0 0 / .65),
        0 2px 8px -2px rgb(0 0 0 / .35),
        inset 0 1px 0 var(--ks-tab-hi);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transform: translate3d(0, 0, 0);
    transition: transform .42s var(--ks-tab-ease), opacity .3s ease;
    contain: layout paint;
    isolation: isolate;
}

/* Yuqori qirradagi nozik yorug'lik chizig'i — faol tab rangida */
.ks-tabbar::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(120deg, rgb(var(--ks-tab-accent) / .45), transparent 35%, transparent 65%, rgb(var(--ks-tab-accent) / .25));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: .9;
    /* rang almashuvi darhol — gradient animatsiyasi har kadrda qayta chiziladi */
}

html.light:not(.force-dark) .ks-tabbar {
    --ks-tab-glass: rgb(255 255 255 / .62);
    --ks-tab-edge: rgb(12 28 54 / .1);
    --ks-tab-hi: rgb(255 255 255 / .9);
    box-shadow: 0 16px 36px -16px rgb(12 28 54 / .35), 0 2px 6px -2px rgb(12 28 54 / .12), inset 0 1px 0 var(--ks-tab-hi);
}

/* Blur ishlamaydigan brauzerlarda panel to'qroq bo'ladi */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .ks-tabbar { --ks-tab-glass: rgb(var(--ink-950-rgb) / .94); }
}

.ks-tabbar.is-tucked { transform: translate3d(0, calc(100% + 1.25rem + env(safe-area-inset-bottom, 0px)), 0); opacity: 0; }
.ks-tabbar.is-entering { animation: ks-tabbar-in .7s var(--ks-tab-ease) both; }

@keyframes ks-tabbar-in {
    from { transform: translate3d(0, 120%, 0) scale(.94); opacity: 0; }
    to { transform: translate3d(0, 0, 0) scale(1); opacity: 1; }
}

.ks-tabbar__inner {
    position: relative;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: 100%;
    padding: .3125rem;
}

/* ── Suzuvchi faol indikator ── */
.ks-tabbar__blob {
    position: absolute;
    top: .3125rem;
    bottom: .3125rem;
    left: .3125rem;
    width: calc((100% - .625rem) / 5);
    transform: translate3d(calc(var(--ks-tab-i, 0) * 100%), 0, 0);
    transition: transform .55s var(--ks-tab-ease);
    pointer-events: none;
    z-index: 0;
}

.ks-tabbar__blob i {
    position: absolute;
    inset: 0 .1875rem;
    border-radius: 1rem;
    background:
        radial-gradient(120% 90% at 50% 0%, rgb(var(--ks-tab-accent) / .32), transparent 70%),
        rgb(var(--ks-tab-accent) / .12);
    border: 1px solid rgb(var(--ks-tab-accent) / .32);
    box-shadow: 0 0 22px -4px rgb(var(--ks-tab-accent) / .55), inset 0 1px 0 rgb(255 255 255 / .12);
    /* rang darhol almashadi: indikator suzayotganda ko'zga sezilmaydi, asosiy oqim bo'sh qoladi */
}

/* Tepasidagi yorug' nuqta */
.ks-tabbar__blob i::after {
    content: "";
    position: absolute;
    top: -1px;
    left: 50%;
    width: 1.5rem;
    height: 2px;
    margin-left: -.75rem;
    border-radius: 2px;
    background: rgb(var(--ks-tab-accent));
    box-shadow: 0 0 10px 1px rgb(var(--ks-tab-accent) / .8);
}

.ks-tabbar__blob.is-hidden { opacity: 0; }
.ks-tabbar.is-instant .ks-tabbar__blob,
.ks-tabbar.is-instant .ks-tabbar__blob i,
.ks-tabbar.is-instant .ks-tab__icon { transition: none !important; }

/* ── Tab ── */
.ks-tab {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .1875rem;
    min-width: 0;
    border-radius: 1rem;
    color: rgb(var(--mist-rgb) / .9);
    text-decoration: none;
    overflow: hidden;
    outline: none;
    touch-action: manipulation;
    /* rang darhol: color animatsiyasi har kadrda qayta chizish talab qiladi */
}

.ks-tab:focus-visible { box-shadow: 0 0 0 2px rgb(var(--ks-accent) / .8); }

.ks-tab__icon {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.5rem;
    transition: transform .4s var(--ks-tab-ease);
    will-change: transform;
}

.ks-tab__icon svg {
    width: 1.3rem;
    height: 1.3rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    overflow: visible;
}

.ks-tab__fill { fill: currentColor; fill-opacity: 0; }
.ks-tab__dots { stroke-width: 2.6; opacity: 0; transition: opacity .3s ease; }

.ks-tab__avatar {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 999px;
    object-fit: cover;
    box-shadow: 0 0 0 1.5px rgb(var(--mist-rgb) / .45);

}

.ks-tab__label {
    max-width: 100%;
    padding-inline: .125rem;
    font-size: .625rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform .4s var(--ks-tab-ease), opacity .3s ease;
    opacity: .82;
}

/* Faol tab */
.ks-tab.is-active { color: rgb(var(--ks-accent)); }
.ks-tab.is-active .ks-tab__icon { transform: translate3d(0, -1px, 0) scale(1.08); animation: ks-tab-pop .6s var(--ks-tab-ease); }
.ks-tab.is-active .ks-tab__icon svg { stroke-width: 2.1; filter: drop-shadow(0 0 6px rgb(var(--ks-accent) / .55)); }
.ks-tab.is-active .ks-tab__fill { fill-opacity: .22; }
.ks-tab.is-active .ks-tab__dots { opacity: 1; }
.ks-tab.is-active .ks-tab__avatar { box-shadow: 0 0 0 2px rgb(var(--ks-accent)), 0 0 12px rgb(var(--ks-accent) / .6); }
.ks-tab.is-active .ks-tab__label { opacity: 1; font-weight: 700; }

html.light:not(.force-dark) .ks-tab.is-active { color: rgb(var(--ks-accent) / 1); filter: saturate(1.3) brightness(.78); }

@keyframes ks-tab-pop {
    0% { transform: translate3d(0, 2px, 0) scale(.78) rotate(-8deg); }
    45% { transform: translate3d(0, -3px, 0) scale(1.2) rotate(4deg); }
    75% { transform: translate3d(0, 0, 0) scale(1.02) rotate(-1deg); }
    100% { transform: translate3d(0, -1px, 0) scale(1.08) rotate(0); }
}

/* Bosish va kursor (planshetda) */
.ks-tab:active .ks-tab__icon { transform: scale(.86); transition-duration: .12s; }
@media (hover: hover) {
    .ks-tab:not(.is-active):hover { color: rgb(var(--paper-rgb)); }
    .ks-tab:not(.is-active):hover .ks-tab__icon { transform: translate3d(0, -2px, 0) scale(1.06); }
}

/* Bosilgan joydan tarqaladigan to'lqin */
.ks-tab__ripple {
    position: absolute;
    width: 6rem;
    height: 6rem;
    margin: -3rem 0 0 -3rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgb(var(--ks-accent) / .38), rgb(var(--ks-accent) / 0) 65%);
    transform: scale(0);
    pointer-events: none;
    animation: ks-tab-ripple .55s ease-out forwards;
}

@keyframes ks-tab-ripple {
    to { transform: scale(1.6); opacity: 0; }
}

/* Harakat kamaytirilgan rejim: hamma narsa joyida, animatsiyasiz */
html[data-motion-level="minimal"] .ks-tabbar,
html[data-motion-level="minimal"] .ks-tabbar * { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
    .ks-tabbar, .ks-tabbar * { animation: none !important; transition: none !important; }
    .ks-tabbar.is-tucked { transform: none; opacity: 1; }
}

@media (min-width: 1024px) {
    .ks-tabbar { display: none; }
}
