/* ── Mobile Overlay Adapter ──────────────────────
   Gmail-style list→detail navigation for overlay panels on small touch screens.
   Desktop layout is completely untouched — all rules gated behind media query.
   ──────────────────────────────────────────────── */

/* ── Mobile-only: small screen + touch ───────── */
@media (max-width: 600px) and (pointer: coarse) {

    /* ── Base layout: show list, hide detail ──── */
    .mobile-overlay .overlay-list-panel {
        width: 100% !important;
        min-width: 0 !important;
        max-height: none !important;
        flex: 1 1 auto;
        border-right: none !important;
        border-bottom: none !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-overlay .overlay-detail-panel {
        position: absolute;
        inset: 0;
        z-index: 2;
        display: flex;
        flex-direction: column;
        transform: translateX(100%);
        transition: transform 200ms ease-out;
        background: var(--t-terminal-bg);
    }

    .mobile-overlay.mobile-detail-active .overlay-detail-panel {
        transform: translateX(0);
    }

    /* ── Two-pane shell → single column ────────── */
    .mobile-overlay .overlay-shell-flex {
        flex-direction: column;
        position: relative;
        overflow: hidden;
    }

    /* ── Touch-friendly list rows ──────────────── */
    .mobile-overlay .overlay-list-panel .mobile-touch-row {
        min-height: 48px;
        display: flex;
        align-items: center;
        padding: 8px 10px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-overlay .overlay-list-panel .mobile-touch-row:active {
        background: color-mix(in srgb, var(--t-accent) 18%, transparent);
    }

    /* ── Back button (detail view) ─────────────── */
    .mobile-back-btn {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 10px 12px;
        background: none;
        border: none;
        border-bottom: 1px solid color-mix(in srgb, var(--t-accent) 50%, var(--t-panel-border));
        color: var(--t-accent);
        font-family: inherit;
        font-size: 14px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        width: 100%;
        text-align: left;
    }

    .mobile-back-btn:active {
        background: color-mix(in srgb, var(--t-accent) 12%, transparent);
    }

    .mobile-back-btn::before {
        content: '\2190'; /* ← arrow */
        font-size: 16px;
    }

    /* ── Close button (top-right of overlay) ──── */
    .mobile-close-btn {
        position: absolute;
        top: 8px;
        right: 8px;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 6px;
        background: color-mix(in srgb, var(--t-terminal-bg) 90%, var(--t-accent));
        border: 1px solid color-mix(in srgb, var(--t-accent) 50%, var(--t-panel-border));
        color: var(--t-text);
        font-size: 18px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        line-height: 1;
    }

    .mobile-close-btn:active {
        background: color-mix(in srgb, var(--t-accent) 25%, transparent);
    }

    /* ── Delete button on list rows ────────────── */
    .mobile-delete-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        margin-left: auto;
        background: none;
        border: 1px solid color-mix(in srgb, var(--t-red, #f38ba8) 40%, transparent);
        border-radius: 4px;
        color: var(--t-red, #f38ba8);
        font-size: 14px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-delete-btn:active {
        background: color-mix(in srgb, var(--t-red, #f38ba8) 20%, transparent);
    }

    /* ── Hide desktop-only footer on mobile ───── */
    .mobile-overlay .overlay-footer {
        display: none;
    }

    /* ── Reduce padding on mobile ──────────────── */
    .mobile-overlay .email-content,
    .mobile-overlay .shop-content,
    .mobile-overlay .market-content {
        padding: 6px;
    }

    /* ── Email-specific mobile tweaks ─────────── */
    .mobile-overlay .email-header {
        padding: 10px 12px;
        padding-right: 48px; /* room for close btn */
    }

    .mobile-overlay .email-row {
        min-height: 48px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 8px 10px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-overlay .email-row:active {
        background: color-mix(in srgb, var(--t-accent) 18%, transparent);
    }

    /* ── Email list: enable touch scroll ───────── */
    .mobile-overlay .email-list {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ── Email reader body: touch scroll ───────── */
    .mobile-overlay .email-reader-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Desktop: hide mobile-only elements ──────── */
@media (min-width: 601px), (pointer: fine) {
    .mobile-back-btn,
    .mobile-close-btn,
    .mobile-delete-btn {
        display: none !important;
    }
}
