/* 移动设备响应式样式 */

/* 基础移动设备适配 */
@media (max-width: 768px) {
    /* 容器调整 */
    .container {
        width: 100%;
        padding: 10px;
    }
    
    /* 标题调整 */
    .header h1 {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    /* 搜索框调整 */
    .search-box {
        width: 100%;
        flex-direction: row;
    }
    
    #number-input {
        width: 100%;
        font-size: 1rem;
    }
    
    /* 结果展示调整 */
    .result-card {
        padding: 15px;
    }
    
    .result-header h2 {
        font-size: 1.3rem;
    }
    
    /* 事实卡片调整为垂直排列 */
    .fact-cards {
        flex-direction: column;
    }
    
    .fact-card {
        width: 100%;
        margin: 10px 0;
    }
    
    /* π更多信息部分调整 */
    .pi-more-info {
        padding: 15px;
    }
    
    .stats-counter {
        flex-direction: column;
    }
    
    .stat {
        margin: 10px 0;
    }
    
    /* 历史记录调整 */
    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .history-position {
        margin-top: 5px;
    }
    
    /* 底部留出空间，避免被底部菜单遮挡 */
    footer {
        margin-bottom: 60px;
    }
}

/* 小型移动设备适配 */
@media (max-width: 480px) {
    /* 更小尺寸的字体 */
    .header h1 {
        font-size: 2rem;
    }
    
    /* 紧凑型搜索框 */
    .search-box {
        height: 45px;
    }
    
    #number-input {
        font-size: 0.9rem;
    }
    
    /* 更紧凑的结果显示 */
    .result-content p {
        font-size: 0.9rem;
    }
    
    .pi-visualization {
        font-size: 0.9rem;
        overflow-x: auto;
        white-space: nowrap;
        padding: 10px;
    }
    
    /* 调整主题切换按钮位置 */
    #theme-toggle {
        top: 10px;
        right: 10px;
        font-size: 1rem;
        width: 35px;
        height: 35px;
    }
}

/* 触摸屏优化 */
@media (hover: none) {
    /* 增大可点击区域 */
    .search-button {
        min-width: 50px;
        min-height: 50px;
    }
    
    #search-button {
        min-width: 45px;
    }
    
    .history-item, #clear-history, #close-help {
        min-height: 44px;
    }
    
    /* 增强触摸反馈 */
    .history-item:active, #search-button:active, #theme-toggle:active, #close-help:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .fact-cards {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .fact-card {
        width: calc(50% - 20px);
        margin: 10px;
    }
    
    .stats-counter {
        flex-direction: row;
    }
}

/* 动画优化 - 降低复杂度以提高移动设备性能 */
@media (max-width: 768px) {
    @keyframes pulse {
        0%, 100% {
            color: #e74c3c;
        }
        50% {
            color: #c0392b;
        }
    }
    
    .highlight::after {
        animation: none;
    }
    
    /* 减少动画数量 */
    .fade-in {
        animation-duration: 0.2s;
    }
}

/* 安全区域适配 (针对全面屏手机) */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    /* 底部固定元素安全区域 */
    footer {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    /* 移动操作菜单安全区域 */
    .mobile-action-menu {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* 黑暗模式优化 - 降低亮度以保护眼睛 */
@media (prefers-color-scheme: dark) {
    body.dark-theme {
        background-color: #121212;
    }
    
    body.dark-theme .pi-visualization {
        background-color: #1a1a1a;
    }
}

/* 移动端底部操作菜单 */
.mobile-action-menu {
    display: none; /* 默认隐藏，只在移动设备显示 */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.mobile-action-menu button {
    background: none;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    color: #3498db;
    transition: background-color 0.2s, transform 0.2s;
}

.mobile-action-menu button:active {
    background-color: rgba(52, 152, 219, 0.1);
    transform: scale(0.95);
}

/* 只在移动设备上显示操作菜单 */
@media (min-width: 769px) {
    .mobile-action-menu {
        display: none;
    }
}

/* 暗色主题下的移动菜单 */
body.dark-theme .mobile-action-menu {
    background-color: #1a1a2e;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

body.dark-theme .mobile-action-menu button {
    color: #3498db;
}

body.dark-theme .mobile-action-menu button:active {
    background-color: rgba(52, 152, 219, 0.2);
}

/* 固定元素的滚动问题修复 */
.pi-visualization {
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
}

/* 移动设备上禁用某些悬停效果 */
@media (max-width: 768px) {
    .fact-card:hover {
        transform: none;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
}

/* 添加下拉刷新提示 */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(52, 152, 219, 0.1);
    transform: translateY(-100%);
    transition: transform 0.3s;
    z-index: 999;
}

.pull-to-refresh.active {
    transform: translateY(0);
}

.pull-to-refresh i {
    color: #3498db;
    font-size: 1.2rem;
    animation: spin 1s linear infinite;
}

/* 移动设备上优化字体加载 */
@media (max-width: 768px) {
    body {
        font-display: swap;
    }
} 