/* Shared bottom navigation styles */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* Cap safe-area to avoid absurd WebView values causing a "second screen" nav */
    padding: 8px 10px calc(8px + min(env(safe-area-inset-bottom), 14px));
    background:
        linear-gradient(180deg, rgba(10, 90, 170, 0.72), rgba(10, 40, 110, 0.92));
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,0.14);
    z-index: 999;
}

.bottom-nav-inner {
    max-width: 520px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
}

.nav-item {
    text-decoration: none;
    color: rgba(255,255,255,0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 7px 4px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    font-size: 11px;
    min-width: 0;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), 
                filter 0.15s ease, 
                background 0.15s ease,
                box-shadow 0.2s ease;
}

.nav-item > div {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-item:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.12);
}

.nav-item:active {
    transform: translateY(1px) scale(0.96);
    filter: brightness(0.95);
}

.nav-item .icon {
    font-size: 18px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item:hover .icon {
    transform: scale(1.15);
}

.nav-item.nav-item-primary {
    transform: translateY(-10px) scale(1.08);
    background: linear-gradient(180deg, rgba(127, 227, 255, 0.32), rgba(47, 182, 255, 0.26));
    border-color: rgba(255,255,255,0.22);
    box-shadow:
        0 10px 26px rgba(0,0,0,0.30),
        inset 0 1px 0 rgba(255,255,255,0.22);
    padding: 10px 6px;
    font-size: 12px;
    filter: saturate(1.12);
    animation: navPulse 1.6s ease-in-out infinite;
}

@media (max-width: 360px) {
    .nav-item {
        font-size: 10px;
        padding: 7px 3px;
    }

    .nav-item .icon { font-size: 17px; }

    .nav-item.nav-item-primary {
        transform: translateY(-9px) scale(1.06);
        padding: 10px 5px;
    }

    /* On very small screens keep labels only for primary */
    .nav-item:not(.nav-item-primary) > div:last-child {
        display: none;
    }
}

@media (max-height: 740px) {
    .bottom-nav {
        padding: 6px 10px calc(6px + min(env(safe-area-inset-bottom), 12px));
    }

    .nav-item {
        padding: 6px 4px;
    }

    .nav-item.nav-item-primary {
        transform: translateY(-8px) scale(1.06);
        padding: 9px 6px;
        animation: none;
    }
}

.nav-item.nav-item-primary .icon {
    font-size: 20px;
}

.nav-item.nav-item-primary:active {
    transform: translateY(-8px) scale(1.06);
}

@keyframes navPulse {
    0% {
        box-shadow:
            0 10px 26px rgba(0,0,0,0.30),
            0 0 0 0 rgba(127, 227, 255, 0.0),
            inset 0 1px 0 rgba(255,255,255,0.22);
        filter: brightness(1.0);
    }
    60% {
        box-shadow:
            0 12px 30px rgba(0,0,0,0.34),
            0 0 0 14px rgba(127, 227, 255, 0.12),
            inset 0 1px 0 rgba(255,255,255,0.22);
        filter: brightness(1.05);
    }
    100% {
        box-shadow:
            0 10px 26px rgba(0,0,0,0.30),
            0 0 0 0 rgba(127, 227, 255, 0.0),
            inset 0 1px 0 rgba(255,255,255,0.22);
        filter: brightness(1.0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-item.nav-item-primary {
        animation: none;
    }
}

.nav-item.active {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.10));
    border-color: rgba(255, 255, 255, 0.26);
    color: #fff;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}

.nav-item.active .icon {
    transform: scale(1.1);
}

.nav-item.nav-item-primary.active {
    background: linear-gradient(180deg, rgba(127, 227, 255, 0.52), rgba(47, 182, 255, 0.34));
    border-color: rgba(255,255,255,0.34);
}

/* Ripple effect on tap */
.nav-item {
    position: relative;
    overflow: hidden;
}

.nav-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease-out, height 0.4s ease-out, opacity 0.4s ease-out;
    opacity: 0;
    pointer-events: none;
}

.nav-item:active::after {
    width: 100px;
    height: 100px;
    opacity: 1;
    transition: none;
}
