/* GEX mobile shell (phones and small tablets, up to 799px), modelled on dacby.com:
   bottom bar (Home/Back, Sell, Shop/Filter, Repair, Search), search sheet, bottom sheets for
   Filters / Sell / Repair, and a header with the cart button (no search, Sell or Repair there). */

/* ---------- Bottom bar ---------- */
#gex-nav, #gex-search, #gex-shop-backdrop, #gex-shop-sheet { display: none; }
@media (max-width: 799px) {
    #gex-nav {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 240;
        height: calc(100px + env(safe-area-inset-bottom, 0px));
        pointer-events: none;
        transition: transform .28s ease;
        font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }
    #gex-nav.kb { visibility: hidden; }
    body.gex-has-nav { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
    .gex-nav-bar {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: calc(65px + env(safe-area-inset-bottom, 0px));
        display: flex;
        filter: drop-shadow(0 -5px 5px rgba(0, 0, 0, .06));
        pointer-events: auto;
    }
    .gex-nav-l, .gex-nav-r { flex: 1 1 0; background: #fff; }
    .gex-nav-notch { flex: 0 0 auto; align-self: flex-start; fill: #fff; }
    .gex-nav-bar::after { content: ""; position: absolute; inset: 65px 0 -120px; background: #fff; }
    .gex-nav-items { position: absolute; left: 0; right: 0; top: 0; height: 65px; display: flex; align-items: center; z-index: 1; }
    .gex-nav-i {
        flex: 1 1 0;
        align-self: stretch;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: none;
        box-shadow: none;
        color: #6b6b6b;
        font: inherit;
        font-size: 10px;
        font-weight: 500;
        line-height: 1.2;
        text-decoration: none;
        text-transform: none;
        letter-spacing: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .gex-nav-i svg { display: block; }
    .gex-nav-i.on { color: var(--gexc-purple, #6C2EB5); font-weight: 600; }
    .gex-nav-i:active { color: var(--gexc-purple, #6C2EB5); }
    .gex-nav-gap { flex: 1 1 0; }
    .gex-nav-fab {
        position: absolute;
        left: 50%;
        top: 3px;
        transform: translateX(-50%);
        z-index: 2;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        width: 67px;
        height: 67px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: var(--gexc-purple, #6C2EB5);
        color: #fff;
        font: inherit;
        font-size: 16px;
        font-weight: 700;
        line-height: 1;
        text-decoration: none;
        text-transform: none;
        letter-spacing: 0;
        cursor: pointer;
        box-shadow: 0 6px 16px rgba(108, 46, 181, .38);
        pointer-events: auto;
        -webkit-tap-highlight-color: transparent;
    }
    .gex-nav-fab svg { display: block; }
    /* Page link colours (account page) must not turn the label purple on purple. */
    html:root body a.gex-nav-fab, html:root body button.gex-nav-fab { color: #fff !important; }
    .gex-nav-fab.has-icon { font-size: 11px; font-weight: 600; }
    .gex-nav-fab:active { background: var(--gexc-purple-dark, #4E1F87); }

    /* Shop category sheet */
    body.gex-shopping { overflow: hidden; }
    #gex-shop-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 244;
        background: rgba(0, 0, 0, .42);
        opacity: 0;
        pointer-events: none;
        transition: opacity .24s ease;
    }
    body.gex-shopping #gex-shop-backdrop { opacity: 1; pointer-events: auto; }
    #gex-shop-sheet {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 245;
        max-height: 75vh;
        background: #fff;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -6px 20px rgba(0, 0, 0, .14);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        transform: translateY(100%);
        transition: transform .26s cubic-bezier(.22, .61, .36, 1);
        font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }
    body.gex-shopping #gex-shop-sheet { transform: none; }
    .gex-shop-head {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 14px 12px 12px 16px;
        border-bottom: 1px solid #ececec;
        flex: none;
    }
    .gex-shop-title {
        flex: 1 1 auto;
        margin: 0;
        font-size: 16px;
        font-weight: 600;
        color: #111;
        line-height: 1.3;
        text-transform: none;
        letter-spacing: 0;
    }
    .gex-shop-back, .gex-shop-close {
        flex: none;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: #f4f4f4;
        color: #111;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .gex-shop-back[hidden] { display: none; }
    .gex-shop-back:active, .gex-shop-close:active { background: #e6e6e6; }
    .gex-shop-viewport {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }
    .gex-shop-track {
        display: flex;
        align-items: flex-start;
        transition: transform .26s cubic-bezier(.22, .61, .36, 1);
        height: 100%;
    }
    .gex-shop-panel {
        flex: 0 0 100%;
        width: 100%;
        max-height: calc(75vh - 64px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
        padding: 6px 0 16px;
    }
    .gex-shop-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        box-sizing: border-box;
        margin: 0;
        padding: 13px 18px;
        border: 0;
        border-bottom: 1px solid #f2f2f2;
        background: #fff;
        color: #111;
        font: inherit;
        font-size: 15px;
        font-weight: 500;
        line-height: 1.3;
        text-align: left;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .gex-shop-item:active { background: #f6f6f6; }
    .gex-shop-all { color: var(--gexc-purple, #6C2EB5); font-weight: 600; }
    .gex-shop-meta {
        display: flex;
        align-items: center;
        gap: 6px;
        color: #777;
        flex: none;
    }
    .gex-shop-count {
        font-size: 12px;
        font-weight: 500;
        color: #777;
        background: #f3f3f3;
        padding: 2px 8px;
        border-radius: 999px;
    }

    /* Search: the bar slides down, a bar-sized search sheet slides up; closing reverses both. */
    body.gex-searching #gex-nav { transform: translateY(calc(100% + 6px)); }
    #gex-search {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        position: fixed;
        left: 0;
        right: 0;
        bottom: var(--gex-kb, 0px);
        z-index: 245;
        box-sizing: border-box;
        margin: 0;
        padding: 0;
        background: #fff;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -5px 14px rgba(0, 0, 0, .08);
        transform: translateY(calc(100% + 8px));
        transition: transform .28s ease;
        font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }
    body.gex-searching #gex-search { transform: none; transition-delay: .05s; }
    #gex-search .gex-search-row {
        display: flex;
        align-items: center;
        gap: 8px;
        box-sizing: border-box;
        height: calc(65px + env(safe-area-inset-bottom, 0px));
        padding: 0 8px env(safe-area-inset-bottom, 0px) 16px;
    }
    #gex-search .gex-search-panel {
        box-sizing: border-box;
        max-height: min(50vh, calc(var(--gex-vh, 100vh) - 170px));
        overflow-y: auto;
        padding: 18px 16px 4px;
        border-bottom: 1px solid #ececec;
    }
    #gex-search .gex-search-panel h3 { margin: 0 0 10px; color: #111; font-size: 16px; font-weight: 500; line-height: 1.3; text-transform: none; letter-spacing: 0; }
    #gex-search .gex-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
    #gex-search .gex-chip {
        display: inline-block;
        padding: 9px 16px;
        border-radius: 999px;
        background: #f4f4f4;
        color: #111;
        font-size: 14px;
        line-height: 1.2;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    #gex-search .gex-chip:active { background: #e6e6e6; }
    #gex-search .gex-search-field {
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 8px;
        height: 44px;
        padding: 0 14px;
        border-radius: 22px;
        background: #f3f3f3;
        color: #6b6b6b;
    }
    #gex-search .gex-search-field svg { flex: none; }
    #gex-search input[type="search"] {
        flex: 1 1 auto;
        min-width: 0;
        height: 44px;
        margin: 0;
        padding: 0;
        border: 0;
        outline: 0;
        background: none;
        box-shadow: none;
        color: #111;
        font: inherit;
        font-size: 16px;
        -webkit-appearance: none;
        appearance: none;
    }
    #gex-search input[type="search"]::-webkit-search-cancel-button { display: none; }
    #gex-search .gex-search-close {
        flex: none;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: none;
        box-shadow: none;
        color: #111;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    #gex-search .gex-search-close:active { background: #f3f3f3; }
}
