@import "dist-style.css";

/* * 航通社全站统一样式表
 * 架构: Tailwind Reset -> Base Variables -> Global Components -> Page Styles -> Dark Mode
 */

/* =========================================
   1. 基础变量 (CSS Variables)
   ========================================= */
:root {
  /* 主色调 */
  --primary-blue: #347df8;
  --primary-blue-light: #4d8fff;
  --primary-blue-dark: #2768d9;
  --primary-blue-hover: #4d8fff;
  
  /* 背景色系 */
  --bg-primary: #F7FAFC;
  --bg-secondary: #EDF2F7;
  --bg-tertiary: #E2E8F0;
  --bg-white: #FFFFFF;
  --bg-hover: #EDF2F7;
  
  /* 文字色系 */
  --text-primary: #1A202C;
  --text-secondary: #718096;
  --text-muted: #A0AEC0;
  --text-white: #FFFFFF;
  
  /* 边框与阴影 */
  --border-light: #E2E8F0;
  --border-medium: #CBD5E0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  
  /* 尺寸系统 */
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-full: 9999px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  
  /* 字体系统 */
  --font-family: "Noto Sans SC", "Source Han Sans", -apple-system, sans-serif;
  --font-weight-medium: 500;
  --font-weight-bold: 700;
  --font-size-sm: 0.875rem;
  --font-size-md: 1rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  
  --duration-normal: 200ms;
}

/* 全局重置 */
body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }

/* =========================================
   2. 通用组件 (Switch, Buttons, Animations)
   ========================================= */

/* Toggle Switch (通用开关) */
.toggle-switch {
  position: relative; width: 44px; height: 24px; flex-shrink: 0;
  display: inline-block; vertical-align: middle;
}
.toggle-switch input {
  position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 2; margin: 0; top: 0; left: 0;
}
.toggle-slider {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-medium); border-radius: var(--radius-full);
  pointer-events: none; transition: background-color var(--duration-normal);
}
.toggle-slider::before {
  content: ''; position: absolute; height: 20px; width: 20px; left: 2px; bottom: 2px;
  background-color: white; border-radius: 50%;
  transition: transform var(--duration-normal); box-shadow: var(--shadow-sm);
}
.toggle-switch input:checked + .toggle-slider { background-color: var(--primary-blue); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* 开关容器块 */
.theme-toggle, .original-image-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4); background-color: var(--bg-secondary);
  border-radius: var(--radius-md); margin-bottom: var(--space-4);
}
.toggle-label { display: flex; align-items: center; justify-content: space-between; width: 100%; cursor: pointer; margin: 0; }
.toggle-text { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--text-primary); }

/* 浮动按钮组 */
.floating-buttons {
  position: fixed; bottom: 32px; right: 32px; z-index: 9999;
  display: flex; flex-direction: column; gap: 12px;
  pointer-events: auto;
}
.floating-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--bg-white); color: var(--primary-blue);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.2s, background-color 0.2s; padding: 0;
}
.floating-btn:hover { transform: translateY(-4px); background: var(--primary-blue); color: white; }
.floating-btn svg { width: 24px; height: 24px; stroke-width: 2px; }

/* 滚动回顶部按钮逻辑 */
#scrollToTopBtn { display: none; }
#scrollToTopBtn.show { display: flex !important; }

/* 动画工具 */
.fadeIn { animation: fadeIn 0.5s forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* =========================================
   3. 侧边栏布局 (Sidebar)
   ========================================= */
.blog-sidebar {
  width: 280px; background-color: var(--bg-white); border-right: 1px solid var(--border-light);
  box-shadow: var(--shadow-md); position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100; display: flex; flex-direction: column;
}
.blog-sidebar-header {
  padding: var(--space-6); border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: var(--space-3);
}
.sidebar-logo-image { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.blog-sidebar-title { font-weight: var(--font-weight-bold); font-size: var(--font-size-xl); }
.blog-sidebar-body { padding: var(--space-4); overflow-y: auto; flex: 1; }

/* 侧边栏元素 */
.search-input {
  width: 100%; padding: var(--space-3) var(--space-4); margin-bottom: var(--space-6);
  border: 1px solid var(--border-medium); border-radius: var(--radius-md);
  font-size: var(--font-size-sm); background: var(--bg-white); color: var(--text-primary);
}

.aigc-link-section { margin-bottom: var(--space-6); }
.aigc-link {
  display: flex; align-items: center; justify-content: center; width: 100%;
  padding: var(--space-3) var(--space-4); background-color: var(--bg-secondary);
  color: var(--text-primary); border-radius: var(--radius-md);
  font-size: var(--font-size-sm); font-weight: var(--font-weight-medium);
  transition: all 0.2s; border: 1px solid transparent;
}
.aigc-link:hover {
  background-color: var(--primary-blue); color: var(--text-white);
  transform: translateY(-2px); box-shadow: var(--shadow-sm);
}

.year-list, .nav-links { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--space-6); }
.year-link, .nav-link {
  display: block; padding: 8px 12px; font-size: var(--font-size-sm);
  color: var(--text-primary); border-radius: var(--radius-md); transition: background-color 0.2s;
}
.year-link:hover, .nav-link:hover { background-color: var(--bg-hover); color: var(--primary-blue); }

.section-label {
  font-size: var(--font-size-xs); color: var(--text-secondary); margin-bottom: var(--space-3);
  display: block; font-weight: var(--font-weight-bold);
}
.tag-btn {
  display: inline-block; padding: 4px 12px; font-size: var(--font-size-sm);
  border: 1px solid var(--border-light); border-radius: var(--radius-full);
  margin: 0 4px 4px 0; transition: background-color 0.2s;
}
.tag-btn:hover { background-color: var(--bg-hover); }

/* =========================================
   4. 主区域与文章卡片 (Main & Cards)
   ========================================= */
.blog-container { display: flex; min-height: 100vh; background-color: var(--bg-primary); }
.blog-main { margin-left: 280px; padding: var(--space-8); flex: 1; }

.filter-header {
  margin-bottom: var(--space-6); padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}
.filter-title {
  font-size: var(--font-size-2xl); font-weight: var(--font-weight-bold);
  color: var(--text-primary); margin: 0; line-height: 1.2;
}

#postsContainer {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-6);
}

.post-card {
  background: var(--bg-white); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: transform 0.2s; display: flex; flex-direction: column;
}
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.post-card-image { height: 200px; background: var(--bg-secondary); overflow: hidden; }
.post-card-image img { width: 100%; height: 100%; object-fit: cover; }
.post-card-content { padding: var(--space-6); flex: 1; display: flex; flex-direction: column; }
.post-card-title {
  font-size: var(--font-size-xl); font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-3); line-height: 1.3;
}
.post-card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-3); font-size: var(--font-size-sm); color: var(--text-secondary);
}
.post-card-date {
  color: var(--text-muted); font-family: monospace; padding-right: var(--space-2);
  border-right: 1px solid var(--border-light); line-height: 1;
}
.post-tag {
  background-color: var(--bg-secondary); padding: 2px 8px; border-radius: var(--radius-md);
  font-size: 0.85em; transition: color 0.2s;
}
.post-tag:hover { color: var(--primary-blue); background-color: var(--bg-hover); }
.post-card-excerpt {
  color: var(--text-secondary); font-size: var(--font-size-sm); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: auto;
}

/* =========================================
   5. 文章详情页 (Post Detail)
   ========================================= */
.post-detail-header {
  background: var(--bg-white); padding: var(--space-6); border-radius: var(--radius-lg);
  margin-bottom: var(--space-8); display: flex; gap: var(--space-8);
}
.post-header-image { width: 300px; height: 300px; border-radius: var(--radius-md); overflow: hidden; flex-shrink: 0; }
.post-header-image img { width: 100%; height: 100%; object-fit: cover; }
.post-header-content { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.post-header-top { display: flex; justify-content: space-between; margin-bottom: var(--space-4); }

.post-header-share { display: flex; gap: var(--space-2); }
.share-icon {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); background-color: var(--bg-secondary);
  color: var(--text-secondary); border: none; cursor: pointer; transition: all 0.2s;
}
.share-icon:hover { background-color: var(--primary-blue); color: white; }
.share-icon svg { width: 20px; height: 20px; fill: currentColor; }

.post-header-title { font-size: 2.5rem; font-weight: 900; line-height: 1.2; margin: var(--space-4) 0; }

.post-detail-wrapper {
  background: var(--bg-white); padding: var(--space-8);
  border-radius: var(--radius-lg); border: 1px solid var(--border-light);
}

.post-detail-article { font-size: 16px; line-height: 1.8; color: var(--text-primary); }

.post-detail-article h1, 
.post-detail-article h2, 
.post-detail-article h3, 
.post-detail-article h4 {
  font-weight: var(--font-weight-bold); line-height: 1.3; color: var(--text-primary);
  margin-top: 1.5em; margin-bottom: 0.8em;
}
.post-detail-article h1 { font-size: 2em; border-bottom: 1px solid var(--border-light); padding-bottom: 0.3em; }
.post-detail-article h2 { font-size: 1.75em; border-bottom: 1px solid var(--border-light); padding-bottom: 0.3em; }
.post-detail-article h3 { font-size: 1.5em; }

.post-detail-article p { margin-bottom: 1.2em; }
.post-detail-article a { color: var(--primary-blue); text-decoration: underline; text-underline-offset: 2px; }
.post-detail-article a:hover { color: var(--primary-blue-dark); }

.post-detail-article ul { list-style-type: disc; padding-left: 1.5em; margin-bottom: 1.2em; }
.post-detail-article ol { list-style-type: decimal; padding-left: 1.5em; margin-bottom: 1.2em; }
.post-detail-article li { margin-bottom: 0.5em; }

.post-detail-article blockquote {
  border-left: 4px solid var(--primary-blue); background: var(--bg-secondary);
  padding: 1em 1.2em; margin: 1.5em 0; color: var(--text-secondary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.post-detail-article img { max-width: 100%; height: auto; border-radius: var(--radius-md); margin: 1.5em auto; display: block; }
.post-detail-article pre {
  background-color: var(--bg-secondary); padding: 1em; border-radius: var(--radius-md);
  overflow-x: auto; margin-bottom: 1.2em; font-family: monospace; font-size: 0.9em;
}
.post-detail-article code {
  background-color: var(--bg-secondary); padding: 0.2em 0.4em; border-radius: var(--radius-sm);
  font-family: monospace; font-size: 0.9em;
}

.post-navigation {
  display: flex; justify-content: space-between; gap: var(--space-4);
  margin-top: var(--space-8); padding-top: var(--space-8); border-top: 1px solid var(--border-light);
}
.post-nav-link {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4);
  background-color: var(--bg-white); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
  color: var(--text-primary); transition: all 0.2s; flex: 1; max-width: 48%;
}
.post-nav-link:hover {
  background-color: var(--bg-hover); border-color: var(--primary-blue);
  transform: translateY(-2px); box-shadow: var(--shadow-sm);
}
.post-nav-link svg { width: 24px; height: 24px; flex-shrink: 0; }
.post-nav-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.post-nav-next { text-align: right; justify-content: flex-end; }
.post-nav-next span { order: -1; }

/* =========================================
   6. 移动端适配 (Mobile) - 核心修复
   ========================================= */
.mobile-header { display: none; }

/* 遮罩层 (用于手机端侧边栏打开时) */
.sidebar-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0,0,0,0.5); z-index: 90; opacity: 0; transition: opacity 0.3s ease;
}
.sidebar-overlay.active { display: block; opacity: 1; }

@media (max-width: 768px) {
  /* [修复] 移动端顶栏样式 */
  .mobile-header {
    display: flex; position: fixed; top: 0; left: 0; right: 0; height: 64px;
    background: var(--bg-white); z-index: 200; padding: 0 var(--space-4);
    align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
  }
  
  .mobile-header-logo {
    display: flex; align-items: center; gap: var(--space-2);
  }
  
  .mobile-header-logo .logo-image {
    width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  }
  
  .mobile-header-logo .logo-text {
    font-size: var(--font-size-lg); font-weight: var(--font-weight-bold);
    color: var(--text-primary);
  }
  
  /* 汉堡菜单按钮 */
  .hamburger-button {
    display: flex; flex-direction: column; justify-content: space-between;
    width: 24px; height: 18px; background: transparent; border: none; padding: 0; cursor: pointer;
  }
  
  .hamburger-line {
    width: 100%; height: 2px; background-color: var(--text-primary);
    border-radius: 2px; transition: all 0.2s;
  }
  
  /* [修复] 侧边栏移动端交互 */
  .blog-sidebar {
    transform: translateX(-100%); transition: transform 0.3s ease;
    z-index: 300; /* 确保高于遮罩层(90)和顶栏(200) */
  }
  .blog-sidebar.mobile-open { transform: translateX(0) !important; }
  
  .blog-main { margin-left: 0; padding-top: 84px; } /* 64px header + 20px padding */
  
  #postsContainer { grid-template-columns: 1fr; }
  .post-detail-header { flex-direction: column; }
  .post-header-image { width: 100%; height: auto; aspect-ratio: 16/9; }
  .post-header-title { font-size: 1.8rem; }
  .post-navigation { flex-direction: column; }
  .post-nav-link { max-width: 100%; }
}

/* =========================================
   7. 深色模式 (Dark Mode)
   ========================================= */
html[data-theme="dark"], body[data-theme="dark"] {
  --primary-blue: #347df8;
  --bg-primary: #0D1117;
  --bg-secondary: #161b22;
  --bg-white: #0D1117;
  --bg-hover: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --text-white: #0D1117;
  --border-light: #30363d;
  --border-medium: #30363d;
  
  background-color: var(--bg-primary); color: var(--text-primary);
}

/* 深色模式特定覆盖 */
html[data-theme="dark"] .post-card,
html[data-theme="dark"] .blog-sidebar,
html[data-theme="dark"] .post-detail-wrapper,
html[data-theme="dark"] .post-detail-header,
html[data-theme="dark"] .mobile-header,
html[data-theme="dark"] .floating-btn,
html[data-theme="dark"] .post-nav-link {
  background-color: var(--bg-white); border-color: var(--border-light);
}

html[data-theme="dark"] .search-input,
html[data-theme="dark"] .aigc-link,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .original-image-toggle,
html[data-theme="dark"] .share-icon,
html[data-theme="dark"] .post-detail-article code,
html[data-theme="dark"] .post-detail-article pre,
html[data-theme="dark"] .post-detail-article blockquote {
  background-color: var(--bg-secondary); color: var(--text-primary); border-color: var(--border-medium);
}

html[data-theme="dark"] .post-card-date { border-right-color: var(--border-light); }
html[data-theme="dark"] .post-tag { background-color: var(--bg-hover); color: var(--text-secondary); }
html[data-theme="dark"] .toggle-slider { background-color: #30363d; }
html[data-theme="dark"] .toggle-switch input:checked + .toggle-slider { background-color: var(--primary-blue); }
html[data-theme="dark"] .post-detail-article a { color: var(--primary-blue-light); }
html[data-theme="dark"] .post-detail-article h1, 
html[data-theme="dark"] .post-detail-article h2 { border-bottom-color: var(--border-light); }
html[data-theme="dark"] .hamburger-line { background-color: var(--text-primary); }