/* 
 * 响应式布局 - 移动端适配
 * 用于多端适配（PC、平板、手机）
 */

/* 超大屏幕（大桌面显示器, 1200px 以上） */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* 大屏幕（桌面显示器, 992px 到 1200px） */
@media (max-width: 1200px) {
    .container {
        max-width: 960px;
    }
    
    .article-detail-layout,
    .encyclopedia-detail-layout,
    .library-detail-layout {
        grid-template-columns: 1fr 280px;
    }
}

/* 中等屏幕（平板, 768px 到 992px） */
@media (max-width: 992px) {
    .container {
        max-width: 720px;
    }
    
    /* 侧边栏堆叠 */
    .article-detail-layout,
    .encyclopedia-detail-layout,
    .library-detail-layout {
        grid-template-columns: 1fr;
    }
    
    .article-toc-sidebar,
    .encyclopedia-sidebar,
    .library-sidebar {
        position: static;
        margin-top: 2rem;
    }
    
    /* 相册详情布局 */
    .album-detail-header {
        flex-direction: column;
    }
    
    .album-detail-cover {
        width: 100%;
        height: 300px;
    }
    
    /* 图片网格 */
    .image-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* 统计信息 */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 小屏幕（手机横屏, 576px 到 768px） */
@media (max-width: 768px) {
    .container {
        max-width: 540px;
        padding: 0 1rem;
    }
    
    /* 导航栏 */
    .navbar-menu {
        display: none;
    }
    
    .navbar-toggle {
        display: block;
    }
    
    /* 筛选栏 */
    .filter-row {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-select {
        width: 100%;
    }
    
    /* 卡片网格 */
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* 图片网格 */
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* 相册列表 */
    .album-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* 文章列表 */
    .article-list {
        grid-template-columns: 1fr;
    }
    
    /* 百科列表 */
    .encyclopedia-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* 图书馆列表 */
    .library-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* 详情页 */
    .article-title,
    .encyclopedia-title,
    .library-title,
    .album-detail-title {
        font-size: 1.5rem;
    }
    
    /* 评论区 */
    .comment-item {
        flex-direction: column;
    }
    
    .comment-avatar {
        margin-bottom: 0.5rem;
    }
}

/* 超小屏幕（手机竖屏, 小于 576px） */
@media (max-width: 576px) {
    /* 卡片网格单列 */
    .card-grid,
    .album-grid,
    .encyclopedia-grid,
    .library-grid {
        grid-template-columns: 1fr;
    }
    
    /* 图片网格 */
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* 相册封面 */
    .album-detail-cover {
        height: 200px;
    }
    
    /* 统计信息单列 */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* 按钮组 */
    .album-detail-actions,
    .article-actions,
    .encyclopedia-actions,
    .library-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* 分页 */
    .pagination {
        flex-wrap: wrap;
    }
    
    .page-link {
        min-width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
    
    /* TOC 侧边栏 */
    .toc-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    .toc-sidebar.active {
        transform: translateX(0);
    }
}

/* 打印样式 */
@media print {
    .navbar,
    .footer,
    .article-actions,
    .article-comments,
    .encyclopedia-actions,
    .encyclopedia-comments,
    .library-actions,
    .library-comments,
    .album-detail-actions,
    .image-modal {
        display: none !important;
    }
    
    .article-detail-layout,
    .encyclopedia-detail-layout,
    .library-detail-layout {
        display: block;
    }
    
    .article-body,
    .encyclopedia-body,
    .library-body {
        max-width: 100%;
    }
}

/* 暗色主题 - 移动端适配 */
[data-theme="dark"] .toc-sidebar {
    background: #1a1a1a;
    border-left: 1px solid #333;
}

[data-theme="dark"] .comment-item {
    border-bottom: 1px solid #333;
}

/* 工具类 - 响应式 */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: block !important;
    }
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .card,
    .page-link {
        min-height: 44px; /* 苹果推荐触摸目标大小 */
    }
    
    .btn-icon {
        width: 44px;
        height: 44px;
    }
    
    input,
    select,
    textarea {
        font-size: 16px; /* 防止 iOS 缩放 */
    }
}

/* 横屏优化 */
@media (orientation: landscape) and (max-height: 500px) {
    .navbar {
        padding: 0.5rem 0;
    }
    
    .hero-section {
        padding: 2rem 0;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

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

/* 深色模式系统偏好 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --color-bg: #f8f9fa;
        --color-bg-secondary: #ffffff;
        --color-text: #333333;
        --color-text-secondary: #666666;
        --color-border: #e0e0e0;
    }
    
    [data-theme="dark"]:not([data-theme]) {
        --color-bg: #1a1a1a;
        --color-bg-secondary: #2d2d2d;
        --color-text: #e0e0e0;
        --color-text-secondary: #a0a0a0;
        --color-border: #333333;
    }
}
