/* ===================================
   移动端专项优化样式
   解决触摸交互、性能和用户体验问题
   =================================== */

/* 触摸设备基础优化 */
@media (hover: none) and (pointer: coarse) {
    /* 移除所有悬停效果，避免触摸设备的粘滞问题 */
    .modern-repo-card:hover,
    .team-card-single:hover,
    .action-btn:hover {
        transform: none;
        box-shadow: inherit;
        background: inherit;
    }
    
    /* 添加触摸反馈 */
    .modern-repo-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    .team-card-single:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    .action-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    /* 增大触摸目标 */
    .action-btn {
        min-height: 48px;
        min-width: 48px;
        padding: 12px 20px;
    }
    
    /* 优化滑动体验 */
    .swiper-container {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
}

/* iOS Safari 专项优化 */
@supports (-webkit-touch-callout: none) {
    /* 防止iOS的橡皮筋效果 */
    body {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    .fp-section {
        -webkit-overflow-scrolling: touch;
    }
    
    /* 优化iOS的点击延迟 */
    .action-btn,
    .modern-repo-card,
    .team-card-single {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* 修复iOS的viewport问题 */
    .vlt-section {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

/* Android Chrome 专项优化 */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
    /* 优化Android的滚动性能 */
    .modern-repo-card,
    .team-card-single {
        will-change: transform;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
    
    /* 优化Android的渲染性能 */
    .repo-icon,
    .team-card-single .thumb {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* 微信浏览器专项优化 */
@media screen and (max-width: 768px) {
    /* 微信浏览器的特殊处理 */
    .vlt-section {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* 防止微信浏览器的缩放问题 */
    .modern-repo-card,
    .team-card-single {
        transform-origin: center center;
        -webkit-transform-origin: center center;
    }
    
    /* 优化微信浏览器的字体渲染 */
    .repo-name,
    .team-card-single .content h4 {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
}

/* 小屏幕设备优化 (320px - 480px) */
@media screen and (max-width: 480px) {
    /* 减少动画以提升性能 */
    .vlt-animated-block {
        animation-duration: 0.2s !important;
    }
    
    /* 优化小屏幕的布局 */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* 成员卡片小屏幕优化 - 图片占满整个卡片 */
    .team-card-single {
        width: 100%;
        max-width: 280px;
        height: 320px;
        margin: 0 auto 15px;
        position: relative;
        overflow: hidden;
    }
    
    .team-card-single .thumb {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
    }
    
    .team-card-single .content {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 40px 12px 12px;
        z-index: 2;
        color: white;
    }
    
    .team-card-single .thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .team-card-single .content h4 {
        font-size: 1rem;
        margin-bottom: 5px;
        color: white;
        text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    }
    
    .team-card-single .content p {
        font-size: 0.85rem;
        line-height: 1.4;
        color: rgba(255,255,255,0.9);
        text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    }
    
    /* 代码仓库卡片小屏幕优化 */
    .modern-repo-card {
        margin-bottom: 15px;
        padding: 16px;
    }
    
    .repo-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* 超小屏幕设备优化 (< 360px) */
@media screen and (max-width: 359px) {
    /* 进一步减少间距和尺寸 - 保持全图片布局 */
    .team-card-single {
        max-width: 260px;
        height: 280px;
    }
    
    .team-card-single .thumb {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
    }
    
    .team-card-single .content {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(transparent, rgba(0,0,0,0.8));
        padding: 35px 10px 10px;
        z-index: 2;
        color: white;
    }
    
    .team-card-single .thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .team-card-single .content h4 {
        font-size: 0.9rem;
        color: white;
        text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    }
    
    .team-card-single .content p {
        font-size: 0.8rem;
        color: rgba(255,255,255,0.9);
        text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    }
    
    .modern-repo-card {
        padding: 14px;
    }
    
    .repo-name {
        font-size: 1rem;
    }
    
    .repo-desc {
        font-size: 0.8rem;
    }
}

/* 横屏模式优化 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    /* 横屏时减少垂直空间占用 */
    .vlt-section {
        padding: 20px 0;
    }
    
    .team-card-single {
        height: auto;
        min-height: 150px;
        margin-bottom: 10px;
    }
    
    .team-card-single .thumb {
        height: 80px;
    }
    
    .team-card-single .content {
        padding: 8px;
    }
    
    .modern-repo-card {
        min-height: auto;
        padding: 12px;
        margin-bottom: 10px;
    }
    
    /* 优化导航栏 */
    .vlt-navbar {
        padding: 5px 0;
    }
}

/* 性能优化 */
@media screen and (max-width: 768px) {
    /* 禁用复杂的背景效果 */
    .star-canvas {
        display: none !important;
    }
    
    /* 简化阴影效果 */
    .modern-repo-card,
    .team-card-single {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* 禁用复杂的渐变背景 */
    .modern-repo-card::before,
    .modern-repo-card::after {
        display: none;
    }
    
    /* 简化过渡效果 */
    .modern-repo-card,
    .team-card-single,
    .action-btn {
        transition: transform 0.2s ease !important;
    }
}

/* 可访问性优化 */
@media (prefers-reduced-motion: reduce) {
    /* 为偏好减少动画的用户禁用动画 */
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .vlt-animated-block {
        animation: none !important;
    }
}

/* 高对比度模式优化 */
@media (prefers-contrast: high) {
    .modern-repo-card,
    .team-card-single {
        border: 2px solid #000;
        background: #fff;
    }
    
    .repo-name,
    .team-card-single .content h4 {
        color: #000;
    }
    
    .repo-desc,
    .team-card-single .content p {
        color: #333;
    }
}

/* 深色模式移动端优化 */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .modern-repo-card,
    .team-card-single {
        background: rgba(30, 30, 30, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .repo-name,
    .team-card-single .content h4 {
        color: #fff;
    }
    
    .repo-desc,
    .team-card-single .content p {
        color: rgba(255, 255, 255, 0.8);
    }
}

/* 网络优化 - 低带宽设备 */
@media (max-width: 768px) and (prefers-reduced-data: reduce) {
    /* 隐藏装饰性图片 */
    .vlt-section__projects-background,
    .carousel-slide img {
        display: none;
    }
    
    /* 简化背景效果 */
    .modern-repo-card,
    .team-card-single {
        background: #fff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* 电池优化 - 低电量模式 */
@media (max-width: 768px) {
    /* 减少GPU加速使用 */
    .modern-repo-card,
    .team-card-single {
        transform: none;
        will-change: auto;
    }
    
    /* 简化渲染 */
    .repo-icon,
    .team-card-single .thumb {
        transform: none;
    }
}

/* 折叠屏设备优化 */
@media screen and (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    /* 折叠屏展开状态优化 */
    [data-anchor="Members"] .col-lg-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    [data-anchor="Repository"] .col-lg-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* 刘海屏适配 */
@supports (padding: max(0px)) {
    .vlt-navbar {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .container {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}

/* PWA 支持优化 */
@media (display-mode: standalone) {
    /* PWA模式下的状态栏适配 */
    .vlt-navbar {
        padding-top: env(safe-area-inset-top);
    }
    
    /* PWA模式下的底部适配 */
    .vlt-section:last-child {
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
}