﻿/* ============================================================================
   mobile.css — the phone experience.
   Loaded LAST in index.html so every rule here wins the cascade without !important
   wars. Everything lives behind media queries, so desktop is untouched.
   Primary breakpoint: 640px (phones). Touch affordances also key off
   (pointer: coarse) where it matters.
   ============================================================================ */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@media (max-width: 640px) {

    /* ── Base type scale ─────────────────────────────────────────────────────
       The desktop scale (15px body, lots of .75–.85rem labels) is what makes
       the phone feel like a shrunken desktop site. Bump the floor. */
    body {
        font-size: 16px;
        line-height: 1.55;
    }

    button, input, select, textarea {
        font-size: 16px; /* <16px triggers focus auto-zoom on mobile browsers */
    }

    /* ── Auth modal — full-screen sheet on phones ───────────────────────────── */
    .auth-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .auth-card {
        max-width: none;
        width: 100%;
        min-height: 100dvh;
        border-radius: 0;
        border-left: none;
        border-right: none;
        display: flex;
        flex-direction: column;
        animation: none;
    }

    .auth-brand {
        padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem 1rem;
    }

    .auth-brand-title {
        font-size: 1.5rem;
    }

    .auth-brand-sub {
        font-size: 1rem;
    }

    .auth-form-body {
        padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
        flex: 1;
    }

    .auth-input {
        padding: 1.05rem 1.15rem;
        margin-bottom: 0.9rem;
    }

    .auth-tab-btn {
        padding: 1.05rem 0.5rem;
        font-size: 1.05rem;
    }

    .auth-action-btn {
        padding: 1.1rem 1.25rem;
        font-size: 1.1rem;
    }

    .auth-error-box,
    .auth-info-box {
        font-size: 0.95rem;
    }

    /* ── Match hub (Start / Join) ───────────────────────────────────────────── */
    .mlv-hub {
        padding: max(16px, env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
        gap: 16px;
    }

    .mlv-hub__header h3 {
        font-size: 1.3rem;
    }

    .mlv-hub__blurb {
        font-size: 1.05rem;
        line-height: 1.5;
    }

    .mlv-hub__panel {
        margin-top: 2vh;
        gap: 14px;
    }

    .mlv-field {
        font-size: 1rem;
        gap: 8px;
    }

        .mlv-field input,
        .mlv-field select {
            padding: 14px 12px;
        }

    #mlvJoinCode {
        font-size: 1.7rem;
        padding: 16px 12px;
        letter-spacing: .3em;
    }

    .mlv-bigbtn {
        padding: 16px 18px;
        font-size: 1.1rem;
        min-height: 54px;
    }

    .mlv-linkbtn {
        font-size: 1rem;
        padding: 12px;
    }

    .mlv-seat {
        min-height: 46px;
        font-size: 1rem;
    }

    #mlvSeatsCustom {
        min-height: 46px;
    }

    /* ── Match lobby ────────────────────────────────────────────────────────── */
    .mlv-topbar {
        padding: 12px 14px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .mlv-topbar__title {
        font-size: 1.1rem;
    }

    .mlv-topbar__meta {
        font-size: 0.85rem;
    }

    .mlv-iconbtn {
        width: 44px;
        height: 44px;
    }

        .mlv-iconbtn svg {
            width: 22px;
            height: 22px;
        }

    .mlv-lobby {
        gap: 16px;
        padding: 16px 14px calc(20px + env(safe-area-inset-bottom));
    }

    .mlv-code-card {
        padding: 20px 16px;
    }

    .mlv-code-card__label {
        font-size: 0.85rem;
    }

    .mlv-code-card__code {
        font-size: 2.7rem;
    }

    /* Stacked full-width action chips — the wrapped side-by-side chips are the
       misaligned buttons on small screens. */
    .mlv-code-card__actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 8px;
    }

        .mlv-code-card__actions .mlv-chipbtn {
            justify-content: center;
            padding: 13px 14px;
            font-size: 1rem;
            border-radius: 12px;
        }

    .mlv-code-card__hint {
        font-size: 0.9rem;
        max-width: none;
    }

    .mlv-lobby-players h4,
    .mlv-lobby-deck h4 {
        font-size: 1.05rem;
    }

    .mlv-lobby-player {
        padding: 12px 4px;
        gap: 12px;
    }

    .mlv-lobby-player__name {
        font-size: 1.05rem;
    }

    .mlv-lobby-player__deck {
        font-size: 0.9rem;
    }

    /* Deck row: select on its own line, quick-deck button full width below. */
    .mlv-lobby-deck__row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

        .mlv-lobby-deck__row select {
            width: 100%;
            padding: 14px 12px;
        }

        .mlv-lobby-deck__row .mlv-chipbtn {
            justify-content: center;
            padding: 13px 14px;
            font-size: 1rem;
            border-radius: 12px;
        }

    /* ── Live match table ───────────────────────────────────────────────────── */
    .mlv-banner {
        padding: 12px 14px;
        font-size: 0.95rem;
        gap: 10px;
    }

        .mlv-banner span {
            flex-basis: 100%;
        }

        .mlv-banner .mlv-chipbtn {
            flex: 1;
            justify-content: center;
            padding: 12px 10px;
            font-size: 0.95rem;
        }

    .mlv-player {
        padding: 14px 8px;
        gap: 6px;
    }

    .mlv-player__name {
        font-size: 0.95rem;
    }

    .mlv-player__life {
        font-size: 2.4rem;
    }

    .mlv-player__sub {
        font-size: 0.85rem;
        min-height: 20px;
    }

        .mlv-player__sub svg {
            width: 15px;
            height: 15px;
        }

    /* My panel extras: stack cleanly instead of wrapping into a jumble. */
    .mlv-me__extras {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    }

    .mlv-extra {
        justify-content: space-between;
    }

    .mlv-extra__label {
        font-size: 1rem;
    }

    .mlv-extra__value {
        font-size: 1.15rem;
        min-width: 34px;
    }

    .mlv-chipbtn--report {
        margin-left: 0;
        width: 100%;
        justify-content: center;
        padding: 14px;
        font-size: 1.05rem;
        border-radius: 12px;
    }

    .mlv-me__label {
        font-size: 0.85rem;
    }

    .mlv-me__steps .mlv-step {
        min-width: 52px;
        min-height: 48px;
        font-size: 1.15rem;
    }

    /* ── Player / report sheet ──────────────────────────────────────────────── */
    .mlv-sheet {
        gap: 16px;
        padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
    }

    .mlv-sheet__head strong {
        font-size: 1.1rem;
    }

    .mlv-sheet__label {
        font-size: 1rem;
    }

    .mlv-sheet__value {
        font-size: 2.3rem;
    }

    .mlv-sheet__stepper .mlv-step {
        min-width: 56px;
        min-height: 52px;
        font-size: 1.3rem;
    }

    .mlv-sheet__hint {
        font-size: 0.9rem;
    }

    .mlv-sheet__deal input {
        padding: 14px 12px;
        font-size: 1.15rem;
    }

    .mlv-dealbtn {
        padding: 14px;
        min-height: 52px;
    }

    .mlv-final-row {
        font-size: 1.05rem;
    }

    /* ── Kard confirm/prompt modals ─────────────────────────────────────────── */
    .kard-modal {
        width: calc(100vw - 24px);
        max-width: 420px;
    }

    .kard-modal__title {
        font-size: 1.15rem;
    }

    .kard-modal__message {
        font-size: 1rem;
    }

    .kard-modal button {
        min-height: 48px;
        font-size: 1rem;
    }

    /* ── Card detail modal ──────────────────────────────────────────────────── */
    .card-modal-grid {
        gap: 0.75rem;
    }

    #modalCardName {
        font-size: 1.25rem;
    }

    /* ── Toasts ─────────────────────────────────────────────────────────────── */
    #toastContainer .toast {
        font-size: 1rem;
        padding: 12px 16px;
    }
}

/* Coarse-pointer affordances regardless of width — tablets in portrait etc. */
@media (pointer: coarse) {
    .mlv-step,
    .mlv-seat,
    .mlv-iconbtn {
        min-width: 44px;
        min-height: 44px;
    }

    .mlv-player {
        min-height: 96px;
    }
}

/* ============================================================================
   Phase E — phone app shell: bottom tab bar, compact header, onboarding polish
   ============================================================================ */

.mobile-tabbar {
    display: none;
}

@media (max-width: 640px) {

    /* ── Bottom tab bar ─────────────────────────────────────────────────── */
    .mobile-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 900;
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        background: var(--bg-card);
        border-top: 1px solid var(--border-default);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -4px 16px var(--shadow-light);
    }

    .mtab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        background: none;
        border: none;
        color: var(--text-tertiary);
        font-size: .66rem;
        font-weight: 600;
        padding: 6px 0;
        min-height: 52px;
        cursor: pointer;
    }

        .mtab svg {
            width: 22px;
            height: 22px;
        }

        .mtab.active {
            color: var(--accent-blue);
        }

    .mtab--match {
        flex: 0 0 62px;
        margin-top: -22px;
        background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple, #b197fc));
        border-radius: 50%;
        width: 58px;
        height: 58px;
        min-height: 58px;
        align-self: center;
        color: #fff;
        box-shadow: 0 6px 16px rgba(59, 130, 246, .45);
    }

        .mtab--match svg {
            width: 26px;
            height: 26px;
        }

        .mtab--match:active {
            transform: scale(.94);
        }

    /* Content clears the bar */
    .content-body {
        padding-bottom: calc(96px + env(safe-area-inset-bottom));
    }

    /* ── Compact header: title row, then full-width search row ──────────── */
    .content-header {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 10px;
        align-items: center;
        padding: 10px 12px;
        height: auto;
        min-height: 0;
        position: sticky;
        top: 0;
        z-index: 120;
        background: var(--bg-card);
    }

    .header-left {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .page-title {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-description {
        display: none;
    }

    .header-right {
        gap: 4px;
    }

        .header-right .icon-btn {
            width: 40px;
            height: 40px;
        }

    .global-search-wrapper {
        order: 3;
        flex-basis: 100%;
        display: flex;
        align-items: center;
        gap: 6px;
        min-width: 0;
    }

    .super-search-btn {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    .search-box {
        flex: 1;
        min-width: 0;
        height: 40px;
    }

        .search-box input {
            width: 100%;
            min-width: 0;
        }

    .search-scope-toggle {
        flex-shrink: 0;
    }

        .search-scope-toggle .scope-opt {
            width: 30px;
            height: 30px;
        }

            .search-scope-toggle .scope-opt svg {
                width: 14px;
                height: 14px;
            }

    /* ── Home Pod: single column, breathing room ────────────────────────── */
    .user-stats-row {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .feed-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* ── Filter bar scrolls instead of wrapping ─────────────────────────── */
    #filterBar {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

        #filterBar::-webkit-scrollbar {
            display: none;
        }

        #filterBar .filter-tag {
            flex-shrink: 0;
        }

    /* ── First-deck onboarding CTA ──────────────────────────────────────── */
    .empty-state--cta {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 14px;
        padding: 2.5rem 1rem;
        font-size: 1.05rem;
    }

    .empty-cta-btn {
        padding: 15px 26px;
        font-size: 1.05rem;
        min-height: 52px;
        border-radius: 12px;
    }

    /* ── Deck / collection sub-views ────────────────────────────────────── */
    .collection-view-header,
    .deck-view-header {
        padding: .9rem 1rem;
    }

    .deck-title-input,
    #collectionTitleInput {
        font-size: 1.05rem;
    }

    /* ── Generic modals: near-full-screen sheets ────────────────────────── */
    .modal-content {
        width: calc(100vw - 16px);
        max-width: none;
        max-height: 92dvh;
        overflow-y: auto;
    }

    /* ── Landing: readable hero, stacked CTAs, decluttered nav ──────────── */
    .landing-nav__links {
        display: none;
    }

    .landing-hero__title {
        font-size: 1.85rem;
        line-height: 1.2;
    }

    .landing-hero__sub {
        font-size: 1rem;
        line-height: 1.55;
    }

    .landing-hero__ctas {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

        .landing-hero__ctas .landing-btn-lg {
            justify-content: center;
            padding: 16px 20px;
            font-size: 1.1rem;
            min-height: 54px;
        }

    .landing-stats {
        flex-wrap: wrap;
        gap: 12px;
        justify-content: center;
    }

    .landing-badge__detail {
        font-size: .9rem;
    }

    /* Stats cards on Home Pod */
    .stats-card-top {
        flex-wrap: wrap;
        gap: 6px;
    }
}

/* ── Tablets (641–1024): two-column middle ground, no tab bar ───────────── */
@media (min-width: 641px) and (max-width: 1024px) {
    .user-stats-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .content-body {
        padding: 18px;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .user-stats-row {
        grid-template-columns: 1fr;
    }
}
