/* iPad2 兼容性优化样式 */

/* 针对iPad2的性能优化 */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
    /* 减少动画和过渡效果以提升性能 */
    .time-transition {
        transition: none !important;
    }
    
    /* 简化渐变背景 */
    body {
        background: #667eea !important;
    }
    
    body.dark-theme {
        background: #2c3e50 !important;
    }
    
    body.light-theme {
        background: #f093fb !important;
    }
    
    body.classic-theme {
        background: #4facfe !important;
    }
}

/* iPad2 特定分辨率优化 (1024x768) */
@media screen and (device-width: 768px) and (device-height: 1024px) {
    /* 横屏模式 */
    @media (orientation: landscape) {
        .time {
            font-size: 9rem;
            line-height: 1.1;
        }
        
        .date {
            font-size: 2.8rem;
            margin-top: 10px;
        }
        
        .time-display {
            margin-bottom: 40px;
        }
    }
    
    /* 竖屏模式 */
    @media (orientation: portrait) {
        .time {
            font-size: 6.5rem;
            line-height: 1.1;
        }
        
        .date {
            font-size: 2.2rem;
            margin-top: 15px;
        }
        
        .time-display {
            margin-bottom: 50px;
        }
    }
}

/* 老版本Safari兼容性 */
@supports not (backdrop-filter: blur(10px)) {
    .control-btn {
        background: rgba(255, 255, 255, 0.25) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}

/* 禁用可能导致性能问题的CSS属性 */
@media screen and (-webkit-max-device-pixel-ratio: 1) {
    * {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    /* 简化文字阴影 */
    .time {
        text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5) !important;
    }
    
    /* 移除复杂动画 */
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* 触摸优化 */
.control-btn {
    min-height: 44px;
    min-width: 44px;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
    -webkit-touch-callout: none;
}

/* 防止文本选择 */
.time, .date {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* iOS Safari 特定修复 */
@supports (-webkit-overflow-scrolling: touch) {
    body {
        -webkit-overflow-scrolling: touch;
        -webkit-text-size-adjust: 100%;
    }
    
    /* 修复iOS Safari的100vh问题 */
    .clock-container {
        height: 100vh;
        height: -webkit-fill-available;
    }
}

/* 低分辨率设备优化 */
@media screen and (max-device-pixel-ratio: 1) {
    .time {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* 内存优化 - 减少重绘 */
.clock-container {
    will-change: auto;
}

.time, .date {
    will-change: contents;
}

/* 强制硬件加速（谨慎使用） */
@media screen and (min-device-width: 768px) {
    .time {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}

/* 修复iPad2上的字体渲染问题 */
@media screen and (-webkit-min-device-pixel-ratio: 1) and (max-device-pixel-ratio: 1) {
    .time {
        font-weight: 500;
        letter-spacing: 0.05em;
    }
    
    .date {
        font-weight: 400;
    }
}

/* 全屏模式优化 */
.fullscreen .controls {
    transition: opacity 0.5s ease;
}

/* 减少重排和重绘 */
.control-btn:active {
    transform: none !important;
}

/* iPad2 Safari 特定样式 */
@media screen and (-webkit-device-pixel-ratio: 1) {
    /* 优化渲染性能 */
    body {
        -webkit-font-feature-settings: "liga" off;
        font-feature-settings: "liga" off;
    }
    
    /* 简化按钮样式 */
    .control-btn {
        border-radius: 20px;
        box-shadow: none;
    }
}

/* 处理旧版本CSS Grid不支持的情况 */
@supports not (display: grid) {
    .clock-container {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
    }
}

/* 修复可能的内存泄漏 */
@media screen and (max-device-width: 1024px) {
    * {
        -webkit-transform-style: flat;
        transform-style: flat;
    }
}