/*! nju.atlas - mobile.css 移动端性能与体验优化 */

@media (max-width: 768px) {
    /* 单一滚动容器：锁定视口高度，让 content-area 承担纵向滚动 */
    .app-layout.mobile-layout {
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }
    .main-content {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding-bottom: 0;
    }
    .content-area {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
    }
    .content-area > .page.active-page {
        overflow: visible;
    }

    /* 关闭 enhance 层在触摸端的昂贵渲染 */
    html {
        text-rendering: auto;
    }
    body {
        scroll-behavior: auto;
    }
    html .modal {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    html .partner-brief-card,
    html .guide-card,
    html .home-feat-card,
    html .guide-card .guide-img,
    html .primary-btn,
    html .ai-send-btn,
    html .secondary-btn,
    html .home-brand-btn {
        transition: none !important;
    }
    html .partner-brief-card:hover,
    html .guide-card:hover,
    html .home-feat-card:hover {
        transform: none !important;
        box-shadow: var(--atlas-shadow) !important;
    }

    html .guide-card .guide-img,
    html .guide-card,
    html .msg-convo-item,
    html .msg-friend-item,
    html .msg-tab {
        transition: none !important;
    }
    html .guide-card:hover .guide-img {
        transform: none !important;
    }

    /* backdrop-filter 在移动端 GPU 开销极大 */
    .top-bar,
    .bottom-tab-bar,
    html .modal,
    .guide-refresh-btn,
    .partner-search-bar,
    .ai-sidebar,
    .ai-chat-head {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    .top-bar {
        background: var(--atlas-card) !important;
    }
    .bottom-tab-bar {
        background: var(--atlas-card) !important;
        transition: transform 0.22s ease, opacity 0.18s ease !important;
    }

    /* 页面切换动画：移动端直接显示，减少 compositor 压力 */
    .page.active-page {
        animation: none !important;
    }

    /* 首页：关闭粒子画布；背景网格去 mask、减图片并发 */
    .home-particles {
        display: none !important;
    }
    .home-mobile-grid {
        -webkit-mask-image: none !important;
        mask-image: none !important;
        grid-template-rows: repeat(5, 1fr);
        height: 42vh;
        min-height: 240px;
    }
    .home-mobile-grid .mg-cell {
        background-color: var(--bg-tertiary);
    }

    /* contain / content-visibility 在 WebKit 上易致滚动掉帧 */
    .partner-waterfall {
        contain: none;
    }
    .partner-card,
    .msg-convo-item,
    .msg-friend-item,
    .msg-notif-item {
        content-visibility: visible;
        contain-intrinsic-size: auto;
    }

    /* 减少 hover/transform 过渡在触摸设备上的误触发 */
    html .primary-btn:hover,
    html .ai-send-btn:hover,
    html .home-feat-card:hover {
        transform: none;
        box-shadow: none;
    }

    /* 模态框动画简化 */
    .modal-card {
        animation: none !important;
    }

    html .ai-welcome-avatar img,
    html .guide-prefetch-hint {
        animation: none !important;
    }

    html .ai-msg {
        animation: none !important;
    }

    /* 聊天发送中：不用 opacity/filter 整泡变暗，转圈样式见 messages.css */
    .msg-bubble-row.is-pending .msg-bubble {
        filter: none;
    }

    /* 更快点击响应 */
    button,
    .tab-item,
    .msg-tab,
    .filter-chip,
    .guide-chip {
        touch-action: manipulation;
    }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
