/* ════════════════════════════════════════
   BENCHMARK — MOBILE
   Mobile nav island, panels, bench list,
   shop, streak, bench sheet, peek card.
════════════════════════════════════════ */

/* ── BASE SHOW/HIDE ─────────────────────── */

#mobileNav,
.mob-panel {
    display: none;
}

.mob-panel.open {
    display: flex;
    flex-direction: column;
}

/* ── HEADER MOBILE RIGHT ─────────────────── */

.header-mobile-right {
    display: none;
    align-items: center;
    gap: var(--space-2);
}

#mobCoinBadge {
    height: 36px;
    display: none;
    cursor: pointer;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: rgba(77, 150, 255, 0.15);
    border-radius: var(--radius-full);
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    color: #4d96ff;
    transition: opacity 0.25s, transform 0.25s, width 0.35s cubic-bezier(0.4, 0, 0.2, 1), margin 0.35s;
}

#mobCoinBadge.search-open {
    opacity: 0;
    width: 0;
    margin-right: calc(-1 * var(--space-2));
    pointer-events: none;
    overflow: hidden;
}

/* ── MOBILE SEARCH WRAP & CHALLENGE BUTTON ── */

.mob-search-wrap {
    display: flex;
    align-items: center;
    background: var(--ui-surface-bg-soft, var(--cream));
    border: var(--ui-surface-border, 1.5px solid var(--parchment));
    border-radius: var(--ui-pill-radius, 50px);
    overflow: hidden;
    width: 36px;
    height: 36px;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.25s;
}

.mob-challenge-btn {
    background: var(--btn-color-neutral-bg);
    border: var(--btn-style-border-width) solid var(--btn-color-neutral-border);
    border-radius: var(--btn-style-radius);
    width: 36px;
    height: 36px;
    font-size: var(--btn-size-sm-font);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.25s, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.35s cubic-bezier(0.4, 0, 0.2, 1), margin 0.35s;
}

.mob-challenge-btn.search-open {
    opacity: 0;
    width: 0;
    margin-left: calc(-1 * var(--space-2));
    pointer-events: none;
    overflow: hidden;
}

.mob-search-wrap.open {
    width: 180px;
}

.mob-search-btn {
    background: var(--btn-color-neutral-bg);
    border: var(--btn-style-border-width) solid var(--btn-color-neutral-border);
    border-radius: var(--btn-style-radius);
    min-width: 34px;
    height: 34px;
    font-size: var(--btn-size-sm-font);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.mob-search-btn:active {
    transform: scale(0.88);
}

.mob-search-input {
    border: none;
    background: transparent;
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--bark);
    outline: none;
    width: 0;
    max-width: 0;
    padding: 0;
    opacity: 0;
    transition: opacity 0.25s 0.1s, max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#mobBenches .search-wrap {
    background: var(--white);
}

.mob-search-wrap.open .mob-search-input {
    width: 100%;
    max-width: 140px;
    padding: 0 var(--space-3) 0 0;
    opacity: 1;
}

/* ── MOBILE NAV ISLAND ──────────────────── */

#mobileNav {
    max-width: 440px;
    height: 60px;
    background: var(--ui-sheet-bg, var(--white));
    border-radius: 22px;
    border: var(--ui-sheet-border, 1.5px solid var(--parchment));
    box-shadow: 0 6px 28px rgba(61, 43, 31, 0.18), 0 2px 8px var(--shadow);
    z-index: var(--z-nav);
    padding: 0 var(--space-1);
    overflow: hidden;
    touch-action: pan-y;
    animation: navIslandIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

.mnav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px 0 6px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s;
}

.mnav-btn:active {
    background: var(--ui-surface-bg-soft, var(--cream));
}

.mnav-icon {
    font-size: 28px;
    line-height: 1;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mnav-label {
    font-size: var(--text-2xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--stone-dark);
    line-height: 1;
    min-height: 10px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: color 0.15s;
}

.mnav-btn.active .mnav-icon {
    transform: scale(1.1);
}

.mnav-btn.active .mnav-label {
    color: var(--moss);
}

.mnav-btn.active {
    background: none;
    border-radius: var(--radius-lg);
}

#navSlider {
    position: absolute;
    top: 4px;
    bottom: 4px;
    width: 20%;
    background: var(--moss-t12);
    border-radius: var(--radius-lg);
    pointer-events: none;
    transition: left 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
    left: 0;
}

.mnav-img {
    height: 1.1rem;
    width: auto;
}

#mnav-map .mnav-img {
    height: 1.35rem;
}

.mnav-profile-img {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* ── NAV ISLAND KEYFRAME ────────────────── */

@keyframes navIslandIn {
    from {
        transform: translateX(-50%) translateY(110%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* ── STREAK KEYFRAMES ───────────────────── */

@keyframes fireBob {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-6px) scale(1.06);
    }
}

@keyframes streakPulse {
    0%, 100% {
        box-shadow: 0 3px 10px rgba(255, 107, 53, 0.45);
    }
    50% {
        box-shadow: 0 3px 22px rgba(255, 107, 53, 0.85);
        transform: scale(1.1);
    }
}

/* ── SHOP ANIMATION KEYFRAME ────────────── */

@keyframes shopItemIn {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── MOBILE RESPONSIVE OVERRIDES ─────────── */

@media (max-width: 479px) {
    #mobileLogo {
        cursor: pointer;
    }
}

@media (max-width: 1024px) {
    /* Prevent iOS auto-zoom on input focus */
    input, select, textarea {
        font-size: max(16px, 1em) !important;
    }

    .sidebar,
    .fab-group,
    .header-desktop {
        display: none !important;
    }

    body {
        height: 100dvh;
        overflow: hidden;
    }

    header {
        padding: 0 var(--space-3);
        height: 52px;
        /* Stay above mob-panels (--z-panel:300) so search stays accessible */
        z-index: calc(var(--z-panel) + 10);
        position: relative;
    }

    .app-body {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    #map-wrap {
        width: 100%;
        height: 100%;
    }

    .mob-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--white);
        z-index: var(--z-panel);
        overflow-y: auto;
        flex-direction: column;
        padding-bottom: 0;
        padding-top: 52px;
        box-sizing: border-box;
    }

    .mob-panel-spacer {
        flex-shrink: 0;
        height: calc(60px + 16px + var(--space-3) + env(safe-area-inset-bottom, 0px));
    }

    #mobBenchTabs {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        flex-shrink: 0;
        padding: var(--space-2) var(--space-3) var(--space-1);
        background: var(--cream);
    }

    #mobBenchTabs::-webkit-scrollbar { display: none; }

    #mobBenchTabs .tab {
        font-weight: var(--weight-semibold);
        transition: color 0.2s, border-color 0.2s;
        color: var(--stone-dark);
        border-bottom: none !important;
    }

    #mobBenchTabs .tab.active {
        color: var(--white) !important;
        border-bottom-color: transparent !important;
    }

    #mobBenchTabs .tab-sort-wrap {
        margin-left: auto;
    }

    #mobBenchTabs .tab-refresh {
        margin: 0;
    }

    #mobBenchTabs .tab-sort-dropdown {
        right: 4px;
    }

    #mobBenches {
        background: var(--cream);
        padding-top: 56px;
    }

    #mobBenchesList {
        flex: 1;
        overflow-y: auto;
        padding: var(--space-3);
        display: flex;
        flex-direction: column;
        gap: var(--space-5);
        background: var(--cream);
    }



    /* Leaflet zoom bottom radius restored (no longer joining our buttons) */

    .mob-fab-group {
        position: absolute;
        left: 10px;
        top: calc(20px + 60px + 20px); /* below zoom controls */
        display: flex;
        flex-direction: column;
        gap: 12px;
        z-index: var(--z-fab);
    }

    #mobLocateBtn,
    #mobBugBtn,
    #mobInfoBtn {
        display: flex;
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
        border: none !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.22) !important;
        background: var(--ui-surface-bg, #fff) !important;
        border-radius: 50% !important;
        box-sizing: content-box !important;
        align-items: center;
        justify-content: center;
    }

    .profile-actions-row {
        padding-left: var(--space-4) !important;
        padding-right: var(--space-4) !important;
    }

    #mobileNav {
        display: flex;
        position: fixed;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - var(--space-8));
        z-index: calc(var(--z-nav) + 60);
    }

    .header-mobile-right {
        display: flex !important;
    }

    /* Hide bottom island when login modal is open */
    body.login-open #mobileNav {
        display: none !important;
    }

    .logo-img {
        height: 1.6rem;
    }

    /* Keep existing non-float overlays as bottom sheets on mobile. */
    .modal-overlay:not(#confirmModal) {
        align-items: flex-end !important;
        z-index: calc(var(--z-nav) + 1) !important;
    }

    /* Confirm delete modal: always appear on top of bench sheet (which is z-max) */
    #confirmModal {
        align-items: flex-end !important;
        z-index: calc(var(--z-max) + 1) !important;
    }

    .modal-overlay:not(#confirmModal) .modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 88dvh !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        margin: 0 !important;
        padding-bottom: 90px !important;
    }


    #tncModal .modal-x {
        position: fixed;
        top: calc(16px + env(safe-area-inset-top, 0px));
        right: 16px;
        z-index: calc(var(--z-max) + 2);
    }

    .mob-peek-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease;
        /* below Leaflet marker pane (~600) so markers remain clickable */
        z-index: var(--z-panel);
    }

    .mob-peek-backdrop.is-visible {
        opacity: 1;
        pointer-events: none;
    }

    .mob-peek {
        display: block !important;
        position: fixed;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease;
        z-index: calc(var(--z-nav) + 10);
    }

    .mob-peek.is-visible {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ── MOBILE BENCH SHEET ─────────────────── */

.mob-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 55vh;
    background: var(--white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-max);
    overflow: hidden;
}

.mob-sheet.open {
    transform: translateY(0);
}

.mob-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--stone);
    border-radius: 2px;
    margin: var(--space-3) auto 0;
    flex-shrink: 0;
}

.mob-sheet-header {
    padding: var(--space-3) var(--space-4);
    border-bottom: var(--border-divider);
}

.mob-sheet-actions {
    margin-left: auto;
}

.mob-sheet-actions .btn-share {
    height: 32px;
    padding: 0 var(--space-3);
}

#mobBenchSheet {
    display: none;
    height: 75vh;
    z-index: var(--z-max);
}

.mob-sheet-handle-wrap {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    padding: var(--space-2) 0 0;
}

.mob-sheet-close {
    width: 32px;
    height: 32px;
}

.mob-sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-4) var(--space-5);
}

.mob-sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: calc(var(--z-max) - 2);
}

/* ── MOBILE BENCH SHEET RESPONSIVE HIDE ─── */

@media (min-width: 1025px) {
    #mobBenchSheet,
    #mobBenchSheetBg {
        display: none !important;
    }
}

/* ── MOBILE SHOP ────────────────────────── */

.mob-shop-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: auto;
    gap: 0;
    padding: 0;
}

.mob-shop-card {
    border-radius: 0;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.18s, box-shadow 0.18s;
    min-height: 180px;
}

.mob-shop-card:hover {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.mob-shop-card:active,
.mob-shop-buy-btn:active {
    transform: scale(0.97);
}

.mob-shop-card-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: var(--space-3) var(--space-2) var(--space-2);
    text-align: center;
    background: var(--mob-shop-gradient);
    animation: shopItemIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.mob-shop-rarity {
    top: 12px;
    left: 12px;
    font-size: var(--text-2xs);
    font-weight: var(--weight-extrabold);
    padding: var(--space-2);
    margin: var(--space-1);
    border-radius: 4px;
    letter-spacing: 1px;
    background: rgba(0, 0, 0);
}

.mob-shop-rarity.rarity-legendary {
    color: #c77dff;
}

.mob-shop-rarity.rarity-epic {
    color: #ff6b35;
}

.mob-shop-rarity.rarity-rare {
    color: #4d96ff;
}

.mob-shop-rarity.rarity-uncommon {
    color: #6bcb77;
}

.mob-shop-rarity.rarity-common {
    color: #aaa;
}

.mob-shop-owned {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: var(--text-xs);
    font-weight: var(--weight-extrabold);
    padding: var(--space-1) var(--space-2);
    border-radius: 4px;
    background: rgba(31, 125, 62, 0.8);
    color: white;
}

.mob-shop-icon {
    font-size: 29px;
    margin-bottom: 4px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
    animation: fireBob 2s ease-in-out infinite;
}

.mob-shop-name {
    font-family: var(--font-primary);
    font-size: 12px;
    color: var(--mob-shop-text, #fff);
    margin-bottom: 4px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    line-height: 1.2;
}

.mob-shop-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.3;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mob-shop-buy-btn {
    font-family: var(--font-primary);
    width: 100%;
    margin-top: auto;
    padding: 3px 6px;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: var(--weight-extrabold);
    font-size: 12px;
    background: rgba(255, 255, 255, 0.95);
    color: #1f7d3e;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.mob-shop-buy-btn.is-owned {
    background: rgba(255, 255, 255, 0.2);
    color: var(--mob-shop-text, #fff);
}

.mob-shop-footnote {
    grid-column: 1 / -1;
    flex-shrink: 0;
    text-align: center;
    padding: var(--space-2) var(--space-4) var(--space-4);
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.35);
    line-height: 1.5;
}

/* ── MOBILE PEEK CARD ───────────────────── */

.mob-peek-backdrop,
.mob-peek {
    display: none;
}

.mob-peek-card {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    align-items: start;
    column-gap: var(--space-3);
    row-gap: var(--space-2);
    padding: var(--space-3);
    background: var(--ui-sheet-bg, var(--white));
    border: var(--ui-sheet-border, 1.5px solid var(--parchment));
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 26px rgba(61, 43, 31, 0.2), 0 2px 6px rgba(0, 0, 0, 0.08);
    position: relative;
}

.mob-peek-main {
    padding-right: 30px;
}

.mob-peek-close-btn {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 26px;
    height: 26px;
    border: 1.5px solid rgba(255,255,255,0.35);
    background: rgba(0,0,0,0.50);
    color: #fff;
    font-size: 14px;
    font-weight: var(--weight-bold);
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    opacity: 1;
    transition: background 0.15s;
    flex-shrink: 0;
    z-index: 2;
}

.mob-peek-close-btn:hover,
.mob-peek-close-btn:active {
    background: rgba(0,0,0,0.75);
}

/* Docked mode — bench is off-screen, peek snaps to screen edge */
#mobBenchPeek.is-docked {
    width: auto !important;
    min-width: 120px;
    max-width: 180px;
    border-radius: var(--radius-lg);
    cursor: pointer;
}

#mobBenchPeek.is-docked .mob-peek-thumb-wrap,
#mobBenchPeek.is-docked .mob-peek-rating,
#mobBenchPeek.is-docked .mob-peek-details-btn,
#mobBenchPeek.is-docked .mob-peek-close-btn {
    display: none;
}

#mobBenchPeek.is-docked .mob-peek-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: var(--text-sm);
}

#mobBenchPeek[data-dock-side="left"] .mob-peek-card {
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    border-left-color: transparent;
}

#mobBenchPeek[data-dock-side="right"] .mob-peek-card {
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    border-right-color: transparent;
}

.mob-peek-thumb-wrap {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--ui-surface-bg-soft, var(--cream));
}

.mob-peek-thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mob-peek-thumb:not([hidden]) + .mob-peek-thumb-fallback {
    display: none;
}

.mob-peek-thumb-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: var(--text-2xl);
}

.mob-peek-rating {
    margin-top: 2px;
}

.mob-peek-stars {
    font-size: var(--text-base);
    letter-spacing: 0.4px;
    color: #f6b300;
    line-height: 1;
}

.mob-peek-rating-count {
    white-space: nowrap;
}

.mob-peek-distance {
    white-space: nowrap;
}

/* CTA row — spans both grid columns, centres the button */
.mob-peek-cta {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding-top: var(--space-2);
}

.mob-peek-details-btn {
    border: none;
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-5);
    background: var(--moss);
    color: var(--white);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    cursor: pointer;
    min-width: 120px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(31, 125, 62, 0.28);
    transition: transform 0.2s, opacity 0.2s;
}

.mob-peek-details-btn:active {
    transform: scale(0.96);
}

/* ── PEEK SMALL SCREEN TWEAKS ───────────── */

@media (max-width: 479px) {
    .mob-peek-card {
        grid-template-columns: 48px minmax(0, 1fr);
        column-gap: var(--space-2);
        padding: var(--space-2) var(--space-3);
        border-radius: var(--radius-md);
    }

    .mob-peek-main {
        padding-right: 26px;
    }

    .mob-peek-thumb-wrap {
        width: 48px;
        height: 48px;
    }

    .mob-peek-name {
        font-size: var(--text-base);
    }

    .mob-peek-rating {
        font-size: var(--text-sm);
    }

    .mob-peek-stars {
        font-size: var(--text-sm);
    }

    .mob-peek-details-btn {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-sm);
    }
}

/* ── PEEK DESKTOP HIDE ──────────────────── */

@media (min-width: 1025px) {
    #mobBenchPeek,
    #mobPeekBackdrop {
        display: none !important;
    }
}

/* ── DESKTOP SEARCH EXPANSION ──────────── */

@media (min-width: 1025px) {
    #desktopLocationSearchWrap.open {
        width: 280px;
    }

    #desktopLocationSearchWrap.open .mob-search-input {
        max-width: 240px;
    }
}
