/* ===== 移动端专用样式 ===== */

/* 基础移动端适配 */
@media screen and (max-width: 768px) {
    /* 容器适配 */
    .container {
        padding: 0 10px;
        margin: 0 auto;
    }
    
    /* 头部导航优化 */
    #header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .header-content {
        padding: 0.75rem 0;
        flex-wrap: wrap;
    }
    
    .site-branding {
        flex: 1;
        min-width: 0;
    }
    
    .site-title {
        font-size: 1.2rem !important;
        line-height: 1.2;
        margin: 0;
    }
    
    .site-subtitle {
        font-size: 0.8rem;
        display: none; /* 在移动端隐藏副标题以节省空间 */
    }
    
    .site-logo {
        width: 35px;
        height: 35px;
    }
    
    /* 搜索框移动端优化 */
    .search-box {
        display: none; /* 默认隐藏，通过JS控制显示 */
        width: 100%;
        margin: 0.5rem 0 0 0;
        order: 3;
    }
    
    .search-box.show {
        display: flex;
    }
    
    #search-input {
        width: 100%;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    /* 移动端菜单样式优化 */
    .mobile-menu-toggle {
        display: flex;
        z-index: 1001;
    }
    
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    .mobile-menu {
        position: fixed;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #ebebeb;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
    
    .mobile-menu.show {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .mobile-nav-menu {
        padding: 1rem 0;
    }
    
    .mobile-nav-link {
        display: block;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid #f5f5f5;
        font-size: 1.1rem;
        transition: all 0.3s ease;
    }
    
    .mobile-nav-link:hover {
        background: #f8f9fa;
        color: #0084ff;
        padding-left: 2rem;
    }
    
    /* 主要内容区域适配 */
    #main {
        padding-top: 80px; /* 为固定头部留出空间 */
        padding-bottom: 1rem;
    }
    
    /* 文章列表卡片适配 */
    .posts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 2rem;
    }
    
    .post-card {
        margin-bottom: 1rem;
        border-radius: 12px;
        overflow: hidden;
    }
    
    .post-cover {
        height: 180px;
    }
    
    .post-content {
        padding: 1rem;
    }
    
    .post-title {
        font-size: 1.1rem;
        line-height: 1.4;
        margin-bottom: 0.75rem;
    }
    
    .post-excerpt {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-bottom: 0.75rem;
        /* 限制显示行数 */
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .post-meta {
        font-size: 0.8rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .post-tags {
        gap: 0.25rem;
    }
    
    .tag {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }
    
    /* 文章详情页适配 */
    .post .post-title {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }
    
    .post .post-content {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .post .post-content h1 {
        font-size: 1.4rem;
        margin: 1.5rem 0 1rem 0;
    }
    
    .post .post-content h2 {
        font-size: 1.2rem;
        margin: 1.25rem 0 0.75rem 0;
    }
    
    .post .post-content h3 {
        font-size: 1.1rem;
        margin: 1rem 0 0.5rem 0;
    }
    
    .post .post-content p {
        margin-bottom: 1rem;
    }
    
    .post .post-content img {
        margin: 1rem 0;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* 代码块移动端优化 */
    .post .post-content pre {
        font-size: 0.85rem;
        line-height: 1.4;
        padding: 1rem;
        border-radius: 8px;
        overflow-x: auto;
        /* 确保在移动端可以水平滚动 */
        white-space: pre;
        word-wrap: normal;
    }
    
    .copy-code-btn {
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    
    /* 表格移动端适配 */
    .post .post-content table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        border-radius: 8px;
    }
    
    /* Mermaid图表移动端适配 */
    .mermaid {
        margin: 1rem 0;
        text-align: center;
        overflow-x: auto;
        max-width: 100%;
    }
    
    .mermaid svg {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* 五行图移动端适配 */
    .wuxing-container {
        margin: 1rem 0;
        padding: 1rem 0.5rem;
    }
    
    .wuxing-diagram-new {
        width: 100%;
        max-width: 300px;
        height: 300px;
        margin: 0 auto;
    }
    
    .wuxing-element-new {
        width: 50px;
        height: 50px;
        font-size: 0.8rem;
    }
    
    .element-name-new {
        font-size: 0.9rem;
        font-weight: 600;
    }
    
    .element-nature-new {
        font-size: 0.7rem;
        margin-top: 0.25rem;
    }
    
    .wuxing-center-new {
        width: 40px;
        height: 40px;
        font-size: 0.7rem;
    }
    
    .wuxing-title-new {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }
    
    .wuxing-subtitle-new {
        font-size: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .wuxing-legend-new {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .legend-item-new {
        font-size: 0.8rem;
        gap: 0.5rem;
    }
    
    .wuxing-explanation {
        margin-top: 1.5rem;
        padding: 0.5rem;
    }
    
    .explanation-section {
        margin-bottom: 1rem;
    }
    
    .explanation-section h4 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .relation-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .relation-item {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    /* 侧边栏移动端适配 */
    .col-sidebar {
        width: 100%;
        order: 2;
        margin-top: 2rem;
    }
    
    .widget {
        margin-bottom: 1.5rem;
        border-radius: 12px;
        padding: 1rem;
    }
    
    .widget-title {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    /* 分页按钮适配 */
    .pagination {
        margin: 2rem 0;
        gap: 0.25rem;
    }
    
    .pagination .page-number,
    .pagination .prev,
    .pagination .next {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        min-width: 44px; /* 确保触摸友好 */
        text-align: center;
    }
    
    /* 页脚适配 */
    #footer {
        padding: 1.5rem 0;
        text-align: center;
    }
    
    .social-links {
        gap: 1rem;
        justify-content: center;
        margin-bottom: 1rem;
    }
    
    .social-link {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    /* 回到顶部按钮适配 */
    #back-to-top {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    /* 搜索页面适配 */
    .search-input-wrapper {
        margin-bottom: 1.5rem;
    }
    
    #search-input-main {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 1rem;
    }
    
    .search-result-item {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .result-title {
        font-size: 1.1rem;
        line-height: 1.3;
    }
    
    .result-meta {
        font-size: 0.8rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    /* Hero横幅移动端适配 */
    .hero-banner {
        padding: 2rem 0;
        margin: -1rem 0 2rem 0;
    }
    
    .hero-title {
        font-size: 1.8rem;
        margin-bottom: 0.75rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .hero-actions {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }
    
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        max-width: 200px;
        text-align: center;
    }
}

/* 小屏幕手机优化 (iPhone SE等) */
@media screen and (max-width: 375px) {
    .container {
        padding: 0 8px;
    }
    
    .header-content {
        padding: 0.5rem 0;
    }
    
    .site-title {
        font-size: 1.1rem !important;
    }
    
    .site-logo {
        width: 30px;
        height: 30px;
    }
    
    .post-card {
        border-radius: 8px;
    }
    
    .post-cover {
        height: 150px;
    }
    
    .post-content {
        padding: 0.75rem;
    }
    
    .post-title {
        font-size: 1rem;
    }
    
    .post-excerpt {
        font-size: 0.85rem;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
    }
}

/* 横屏模式优化 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    #header {
        position: relative;
    }
    
    #main {
        padding-top: 1rem;
    }
    
    .hero-banner {
        padding: 1.5rem 0;
        margin: 0 0 1.5rem 0;
    }
    
    .hero-title {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增加点击目标大小 */
    .nav-link,
    .mobile-nav-link,
    .btn,
    .tag,
    .social-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 移除hover效果，使用active效果 */
    .post-card:hover {
        transform: none;
        box-shadow: 0 1px 3px rgba(26,26,26,0.1);
    }
    
    .post-card:active {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(26,26,26,0.15);
    }
    
    .btn:hover {
        transform: none;
    }
    
    .btn:active {
        transform: scale(0.98);
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .mobile-menu {
        background: #1a1a1a;
        border-top-color: #333;
    }
    
    .mobile-nav-link {
        color: #e5e5e5;
        border-bottom-color: #333;
    }
    
    .mobile-nav-link:hover {
        background: #2a2a2a;
        color: #0084ff;
    }
}

/* 减少动画效果（用户偏好） */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
} 