/* =========================================================================
   BEAMING THREADS — MOBILE APP SHELL
   A mobile-first "app" layer added on top of the existing site: a frosted
   bottom tab bar, a profile bottom-sheet, and app-grade motion.

   SCOPE: everything here is additive and gated to phones. All app chrome is
   hidden above 780px, so the desktop website renders exactly as before.
   Built on the tokens in style.css (ink / bone / brass / neon) and reuses
   the store overlays (scrim, drawers, toasts) from store.css.
   ========================================================================= */

:root {
    --app-nav-h: 62px;
    --app-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --app-blur: saturate(140%) blur(18px);
}

/* ---------------------------------------------------------------------------
   BOTTOM TAB BAR
   Hidden by default (desktop). Revealed only at phone widths so the desktop
   top-nav experience is never touched.
--------------------------------------------------------------------------- */
.app-tabbar { display: none; }

@media (max-width: 780px) {

    /* make room so fixed chrome never hides the footer / last row */
    body.has-app-nav {
        padding-bottom: calc(var(--app-nav-h) + env(safe-area-inset-bottom, 0px));
    }

    /* the bottom nav supersedes the hamburger on phones */
    body.has-app-nav .nav-toggle { display: none; }

    .app-tabbar {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 290; /* under the store scrim (300) so overlays dim it too */
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(10, 10, 11, 0.82);
        -webkit-backdrop-filter: var(--app-blur);
        backdrop-filter: var(--app-blur);
        border-top: 1px solid var(--ink-line);
        animation: appTabIn 0.5s var(--app-ease) both;
    }

    /* signature neon hairline crowning the bar */
    .app-tabbar::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: var(--gradient-neon);
        opacity: 0.9;
    }

    .app-tab {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        height: var(--app-nav-h);
        padding: 8px 4px 6px;
        border: none;
        background: transparent;
        color: var(--text-on-ink-dim);
        font-family: inherit;
        cursor: pointer;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.25s var(--app-ease), transform 0.12s var(--app-ease);
    }
    .app-tab:active { transform: scale(0.9); }

    .app-tab-ico {
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.28s var(--app-ease);
    }
    .app-tab-ico svg {
        width: 23px;
        height: 23px;
        display: block;
        stroke: currentColor;
    }

    .app-tab-lbl {
        font-family: var(--font-mono);
        font-size: 9px;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        line-height: 1;
        opacity: 0.85;
    }

    /* active-tab indicator: a neon pill that scales in above the icon */
    .app-tab-dot {
        position: absolute;
        top: 0;
        left: 50%;
        width: 26px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--gradient-neon);
        transform: translateX(-50%) scaleX(0);
        transform-origin: center;
        opacity: 0;
        transition: transform 0.3s var(--app-ease), opacity 0.3s var(--app-ease);
    }

    .app-tab.active {
        color: var(--text-on-ink);
    }
    .app-tab.active .app-tab-lbl {
        color: var(--brass-bright);
        opacity: 1;
    }
    .app-tab.active .app-tab-ico {
        transform: translateY(-1px);
        filter: drop-shadow(0 0 10px rgba(43, 232, 255, 0.45));
    }
    .app-tab.active .app-tab-dot {
        transform: translateX(-50%) scaleX(1);
        opacity: 1;
    }

    /* saved-count badge riding the heart tab */
    .app-tab-badge {
        position: absolute;
        top: 6px;
        left: calc(50% + 9px);
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 8px;
        background: var(--gradient-neon);
        color: #0b0710;
        font-family: var(--font-mono);
        font-size: 9px;
        font-weight: 700;
        line-height: 16px;
        text-align: center;
        transform: scale(0);
        transition: transform 0.25s var(--app-ease);
    }
    .app-tab-badge.show { transform: scale(1); }

    /* lift the concierge + toasts clear of the bar */
    .bot-launch {
        bottom: calc(var(--app-nav-h) + 16px + env(safe-area-inset-bottom, 0px));
    }
    .bt-toasts {
        bottom: calc(var(--app-nav-h) + 22px + env(safe-area-inset-bottom, 0px));
    }
    .bot-panel {
        bottom: calc(var(--app-nav-h) + 12px + env(safe-area-inset-bottom, 0px));
        height: min(600px, calc(100vh - var(--app-nav-h) - 70px));
    }
}

/* ---------------------------------------------------------------------------
   PROFILE BOTTOM-SHEET
   Reachable only from the Profile tab (phones). Slides up over the store
   scrim. Reuses .bt-x, .btn, and store state; adds no product data.
--------------------------------------------------------------------------- */
.app-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 330; /* above scrim (300), like the modal */
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--bone);
    color: var(--text-on-bone);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -24px 70px rgba(0, 0, 0, 0.45);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.42s var(--app-ease), visibility 0.42s var(--app-ease);
    padding-bottom: calc(26px + env(safe-area-inset-bottom, 0px));
}
.app-sheet.open {
    transform: translateY(0);
    visibility: visible;
}
.app-sheet::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 3px;
    background: var(--bone-line);
    margin: 12px auto 4px;
}

.app-prof-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px 20px;
}
.app-prof-ava {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--bone-line);
    flex: none;
}
.app-prof-id h3 {
    font-size: 22px;
    line-height: 1.1;
}
.app-prof-id p {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-on-bone-dim);
    margin-top: 5px;
}
.app-prof-head .bt-x { margin-left: auto; }

/* live stat tiles (saved / cart / spend) built from store state */
.app-prof-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--bone-line);
    border-top: 1px solid var(--bone-line);
    border-bottom: 1px solid var(--bone-line);
}
.app-prof-stat {
    background: var(--bone);
    padding: 18px 12px;
    text-align: center;
}
.app-prof-stat .n {
    font-family: var(--font-display);
    font-size: 26px;
    color: var(--brass-deep);
    line-height: 1;
}
.app-prof-stat .l {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-on-bone-dim);
    margin-top: 7px;
}

/* free-shipping progress meter */
.app-prof-ship {
    margin: 20px 24px 4px;
}
.app-prof-ship .cap {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-on-bone-dim);
    margin-bottom: 8px;
}
.app-prof-track {
    height: 6px;
    border-radius: 4px;
    background: var(--bone-soft);
    overflow: hidden;
}
.app-prof-fill {
    height: 100%;
    width: 0;
    border-radius: 4px;
    background: var(--gradient-neon);
    transition: width 0.6s var(--app-ease);
}

/* menu rows */
.app-prof-menu {
    list-style: none;
    margin: 18px 0 0;
    padding: 0 12px;
}
.app-prof-menu li + li { border-top: 1px solid var(--bone-line); }
.app-prof-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 16px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    color: inherit;
    font-family: inherit;
    transition: background 0.18s var(--app-ease);
}
.app-prof-row:active { background: var(--bone-soft); }
.app-prof-row .ico {
    width: 20px;
    height: 20px;
    flex: none;
    color: var(--brass-deep);
}
.app-prof-row .ico svg { width: 20px; height: 20px; display: block; stroke: currentColor; }
.app-prof-row .lbl {
    flex: 1;
    font-size: 15px;
    font-family: var(--font-display);
}
.app-prof-row .meta {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--text-on-bone-dim);
}
.app-prof-row .chev {
    color: var(--text-on-bone-dim);
    font-size: 18px;
    line-height: 1;
}

.app-prof-note {
    margin: 18px 24px 0;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    line-height: 1.7;
    color: var(--text-on-bone-dim);
    text-align: center;
}

/* the sheet is a phone affordance; never let it show on desktop */
@media (min-width: 781px) {
    .app-sheet { display: none; }
}

/* ---------------------------------------------------------------------------
   MOTION PREFERENCES
--------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .app-tabbar { animation: none; }
    .app-tab,
    .app-tab-ico,
    .app-tab-dot,
    .app-tab-badge,
    .app-sheet,
    .app-prof-fill { transition: none; }
}

@keyframes appTabIn {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
