/* =============================================
   移动端汉堡菜单按钮
   ============================================= */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 6px;
    left: 8px;
    z-index: 1001;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--vscode-sidebar);
    border-radius: 6px;
    cursor: pointer;
    color: var(--vscode-text);
    border: 1px solid var(--vscode-border);
    font-size: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:active {
    background: var(--vscode-active);
    color: var(--vscode-accent);
}

.mobile-menu-toggle.active {
    background: var(--vscode-active);
    color: var(--vscode-accent);
}

/* =============================================
   移动端侧边栏遮罩层
   ============================================= */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    display: none;
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* 防止侧边栏打开时页面滚动 */
body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

@media screen and (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.show {
        pointer-events: auto;
    }

    /* ===== 侧边栏滑出面板 ===== */
    .sidebar-explorer {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        height: 100dvh; /* 动态视口高度，兼容移动端地址栏 */
        width: 82%;
        max-width: 320px;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    box-shadow 0.3s ease;
        background: var(--vscode-sidebar);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-right: 1px solid var(--vscode-border);
        will-change: transform;
        padding-top: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .sidebar-explorer.show {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
    }

    /* 侧边栏头部增强 */
    .explorer-header {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 14px 16px;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.05em;
        background: var(--vscode-sidebar);
        border-bottom: 1px solid var(--vscode-border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 44px;
        box-sizing: border-box;
    }

    /* 分区头部增大触摸区域 */
    .section-header {
        padding: 10px 16px;
        min-height: 40px;
        font-size: 12px;
        font-weight: 600;
        letter-spacing: 0.03em;
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background-color 0.15s ease;
        border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    }

    .section-header:active {
        background: var(--vscode-active);
    }

    /* 分区内容区域 */
    .section-content {
        padding: 4px 8px;
    }

    /* 增大所有可点击项的触摸区域 (min 44px) */
    .folder,
    .file,
    .tag-item {
        padding: 10px 12px;
        min-height: 44px;
        font-size: 14px;
        display: flex;
        align-items: center;
        gap: 10px;
        border-radius: 4px;
        -webkit-tap-highlight-color: transparent;
        transition: background-color 0.15s ease;
    }

    .folder:active,
    .file:active,
    .tag-item:active {
        background: var(--vscode-active);
    }

    .folder a,
    .file a,
    .tag-item a {
        font-size: 14px;
        line-height: 1.4;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .folder i,
    .file i,
    .tag-item i {
        font-size: 15px;
        flex-shrink: 0;
        width: 20px;
        text-align: center;
    }

    .count {
        font-size: 12px;
        flex-shrink: 0;
    }

    /* explorer-section 间距 */
    .explorer-section {
        margin: 2px 0;
    }

    /* === 移动端全宽布局 — 消除左右多余留白 === */
    .wrapper {
        max-width: 100%;
        width: 100%;
        padding: 56px 14px 40px;
        box-sizing: border-box;
    }

    /* 导航栏全宽 */
    .vs-nav {
        max-width: 100%;
        padding: 0 12px;
    }

    /* 文章卡片减少内边距 */
    .post-item {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 6px;
    }
    
    /* 优化移动端文章内容 */
    .post-content {
        padding: 0.875rem;
        overflow-x: hidden;
        width: 100%;
        box-sizing: border-box;
        border-radius: 6px;
    }

    /* 侧边栏区块减少内边距 */
    .sidebar-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    /* TOC容器优化 */
    .toc-container {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    /* 系列文章容器 */
    .series-container {
        padding: 0.75rem;
    }
    
    /* 确保链接不会溢出容器 */
    a {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* 优化代码块在移动端的显示 */
    pre {
        position: relative;
        width: 100%;
        box-sizing: border-box;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 1rem 0;
        border-radius: 4px;
        font-size: 0.9em;
        padding: 2.5em 0.5em 0.5em;
    }
    
    code {
        word-break: break-all;
        word-wrap: break-word;
        white-space: pre-wrap;
    }
    
    /* 优化表格在移动端的显示 */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    
    /* 页脚样式优化 */
    .footer {
        position: relative;  /* 改为相对定位，避免遮挡内容 */
        margin-top: 2rem;
        padding: 0.5rem 0;
    }
    
    .status-bar {
        flex-wrap: wrap;  /* 允许项目换行 */
        justify-content: center;  /* 居中对齐 */
        padding: 8px 5px;
        gap: 10px;  /* 项目之间的间距 */
    }
    
    .status-item {
        margin-right: 0;  /* 移除右边距 */
        font-size: 11px;  /* 稍微减小字体 */
    }
    
    .status-item.github {
        margin-left: 0;  /* 移除左边距 */
    }
    
    /* 确保所有状态项目样式一致 */
    .status-item, .status-item.github {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 代码内容自适应 */
    pre code, .hljs {
        width: 100%;
        max-width: 100%;
        font-size: 0.9em;
        line-height: 1.5;
        white-space: pre-wrap;
        word-break: break-word;
    }
    
    /* 长链接处理 */
    a {
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
}

@media (max-width: 768px) {
  .copy-button {
    opacity: 1;  /* 在移动端始终显示复制按钮 */
    top: 0.3em;
    right: 0.3em;
  }
  
  pre {
    padding: 2em 0.8em 0.8em;  /* 调整移动端padding */
  }
  
  /* 优化移动端图片显示 */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* 优化移动端文章标题 */
  .post-title h1, .post-title h2 {
    font-size: 1.5rem;
    word-break: break-word;
  }
  
  /* 优化移动端文章元数据 */
  .post-meta {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  /* 优化移动端内容区域 */
  .content-area {
    padding: 8px;
    box-sizing: border-box;
  }

  /* 分页容器优化 */
  .pagination-container {
    padding: 0.5rem 0.75rem;
    margin: 1rem 0;
  }
  
  /* 优化移动端代码高亮 */
  .highlight {
    margin: 0 -8px;
    border-radius: 0;
  }
  
  .highlight pre {
    border-radius: 0;
  }

  /* 文章导航（上一篇/下一篇） */
  .post-nav a {
    padding: 0.75rem;
  }
  
  /* 优化移动端TOC */
  .toc-container {
    max-height: 200px;
    overflow-y: auto;
  }
}

/* 小屏幕设备额外优化 */
@media (max-width: 480px) {
  .wrapper {
    max-width: 100%;
    padding: 52px 10px 32px;
  }

  .vs-nav {
    max-width: 100%;
    padding: 0 8px;
  }
  
  .post-content {
    padding: 0.625rem;
  }

  .post-item {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .sidebar-section {
    padding: 0.75rem;
  }
  
  pre {
    padding: 2em 0.4em 0.4em;
    font-size: 0.8em;
  }
  
  .post-title h1, .post-title h2 {
    font-size: 1.3rem;
  }
  
  /* 页脚在小屏幕上的额外优化 */
  .status-bar {
    flex-direction: column;  /* 垂直排列 */
    align-items: center;
    padding: 5px;
  }
  
  .status-item {
    margin: 3px 0;
    font-size: 10px;
  }
  
  /* 小屏幕代码块进一步优化 */
  pre code, .hljs {
    font-size: 0.8em;
    line-height: 1.4;
  }
      /* 优化移动端TOC */
  .toc-container {
    position: relative;
    top: 0;
    padding: 10px;
    margin: 10px 0;
  }

  .toc-content {
    max-height: 50vh; /* 使用视口高度的50%，更灵活地适应不同设备 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* VS Code风格推荐文章移动端优化 */
@media (max-width: 768px) {
  /* 推荐文章网格改为双列 */
  .vs-recommended-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  /* 减小内边距 */
  .vs-recommended-link {
    padding: 0.75rem;
  }
  
  /* 隐藏文章摘要，节省空间 */
  .vs-recommended-excerpt {
    display: none;
  }
  
  /* 调整标题大小 */
  .vs-recommended-title {
    font-size: 0.875rem;
  }
  
  
  /* 元数据样式调整 */
  .vs-recommended-meta {
    font-size: 0.625rem;
    gap: 0.25rem;
  }
  
  .vs-series-badge {
    font-size: 0.625rem;
    padding: 0.1rem 0.375rem;
  }
  
  .vs-tags-preview {
    display: none; /* 移动端隐藏标签预览 */
  }
  
  /* 时间信息调整 */
  .vs-meta-info {
    gap: 0.5rem;
  }
  
  .vs-date i,
  .vs-reading-time i {
    display: none; /* 隐藏图标，只显示文字 */
  }
}

/* 小屏幕设备（手机） */
@media (max-width: 480px) {
  /* 改为单列布局 */
  .vs-recommended-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  /* 进一步调整内边距 */
  .vs-recommended-posts {
    margin-top: 2rem;
    padding-top: 1rem;
  }
  
  .vs-recommended-link {
    padding: 0.5rem;
  }
  
  /* 显示精简版摘要 */
  .vs-recommended-excerpt {
    display: block;
    -webkit-line-clamp: 2;
    font-size: 0.75rem;
  }
  
  /* 标题样式 */
  .vs-recommended-title {
    font-size: 0.875rem;
  }
  
  .vs-recommended-title i {
    font-size: 0.75rem;
  }
  
  
  /* 查看更多按钮 */
  .vs-view-more {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
  }
  
  .vs-view-more i {
    font-size: 0.625rem;
  }
  
  /* 调整section header */
  .vs-recommended-header .section-header {
    font-size: 0.625rem;
  }
  
  .vs-recommended-header .section-header i {
    font-size: 0.75rem;
  }
  
  /* 元数据只显示日期 */
  .vs-series-badge,
  .vs-reading-time {
    display: none;
  }
  
  /* 触摸优化 */
  .vs-recommended-item {
    min-height: 60px; /* 确保足够的触摸目标大小 */
  }
}

/* =============================================
   辅助功能：减少动画
   ============================================= */
@media (prefers-reduced-motion: reduce) {
  .sidebar-explorer,
  .sidebar-overlay,
  .mobile-menu-toggle,
  .folder,
  .file,
  .tag-item,
  .section-header {
    transition: none !important;
  }
}
