/**
 * Blog UI Enhancement V2.1
 * 现代极简主义设计 · 沉浸式阅读体验
 * 
 * 此文件包含博客系统的UI增强样式
 * 建议在 style.css 之后加载
 */

/* ===== 设计系统变量更新 ===== */
:root {
  /* 色彩系统 - 自然绿主题 */
  --color-primary-50: #f0f7f0;
  --color-primary-100: #dceddc;
  --color-primary-200: #c3e0c3;
  --color-primary-300: #9dcc9d;
  --color-primary-400: #7ab87a;
  --color-primary-500: #5a9d5a;
  --color-primary-600: #4a8a4a;
  --color-primary-700: #3d733d;
  --color-primary-800: #325e32;
  --color-primary-900: #2a4d2a;
  
  /* 中性色 - 温暖灰 */
  --color-neutral-50: #fafaf9;
  --color-neutral-100: #f5f5f4;
  --color-neutral-200: #e7e5e4;
  --color-neutral-300: #d6d3d1;
  --color-neutral-400: #a8a29e;
  --color-neutral-500: #78716c;
  --color-neutral-600: #57534e;
  --color-neutral-700: #44403c;
  --color-neutral-800: #292524;
  --color-neutral-900: #1c1917;
  
  /* 语义色 */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #3b82f6;
  
  /* 字体系统 */
  --font-serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 
                Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 
               'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-mono: 'Fira Code', 'JetBrains Mono', 'SF Mono', Consolas, 
               'Liberation Mono', monospace;
  
  /* 动效 */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

/* ===== 深色模式 ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --color-neutral-50: #1c1917;
    --color-neutral-100: #292524;
    --color-neutral-200: #44403c;
    --color-neutral-300: #57534e;
    --color-neutral-400: #78716c;
    --color-neutral-500: #a8a29e;
    --color-neutral-600: #d6d3d1;
    --color-neutral-700: #e7e5e4;
    --color-neutral-800: #f5f5f4;
    --color-neutral-900: #fafaf9;
    
    --color-primary-500: #7ab87a;
    --color-primary-600: #9dcc9d;
    
    --bg-primary: #1c1917;
    --bg-secondary: #292524;
    --text-primary: #fafaf9;
    --text-secondary: #d6d3d1;
    --text-tertiary: #a8a29e;
    
    --border-light: #44403c;
    --border-medium: #57534e;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  }
  
  body {
    background: var(--bg-primary);
    color: var(--text-primary);
  }
}

/* ===== 全局排版优化 ===== */
body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ===== 页面过渡动画 ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-content {
  animation: fadeInUp var(--duration-slow) var(--ease-out);
}

/* ===== 改进的卡片样式 ===== */
.post-card {
  background: var(--bg-primary, #fff);
  border-radius: 12px;
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.post-card__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-out);
}

.post-card:hover .post-card__image {
  transform: scale(1.05);
}

.post-card__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary, #1c1917);
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.post-card__excerpt {
  font-size: 1rem;
  color: var(--text-secondary, #57534e);
  line-height: 1.625;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== 文章详情页优化 ===== */
.article {
  max-width: 680px;
  margin: 0 auto;
  padding: 4rem 1.5rem;
}

.article__title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary, #1c1917);
  margin-bottom: 1.5rem;
}

.article__content {
  font-size: 1.125rem;
  line-height: 1.75;
  color: var(--text-primary, #1c1917);
}

.article__content h2 {
  font-family: var(--font-serif);
  font-size: 1.875rem;
  font-weight: 700;
  margin-top: 3rem;
  margin-bottom: 1.5rem;
}

.article__content p {
  margin-bottom: 1.5rem;
}

.article__content blockquote {
  border-left: 3px solid var(--color-primary-500, #5a9d5a);
  padding-left: 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--text-secondary, #57534e);
}

.article__content code {
  background: var(--bg-tertiary, #f5f5f4);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.article__content pre {
  background: var(--bg-tertiary, #f5f5f4);
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 2rem 0;
}

.article__content img {
  border-radius: 8px;
  margin: 2rem 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ===== 目录导航（TOC） ===== */
.toc {
  position: fixed;
  top: 100px;
  right: 40px;
  width: 240px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--bg-primary, #fff);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  font-size: 0.875rem;
}

.toc__title {
  font-weight: 600;
  color: var(--text-primary, #1c1917);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc__item {
  margin-bottom: 0.5rem;
}

.toc__link {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary, #57534e);
  border-radius: 6px;
  transition: all var(--duration-fast) var(--ease-out);
  text-decoration: none;
}

.toc__link:hover {
  background: var(--bg-tertiary, #f5f5f4);
  color: var(--text-primary, #1c1917);
}

.toc__link--active {
  background: var(--color-primary-50, #f0f7f0);
  color: var(--color-primary-700, #3d733d);
  font-weight: 500;
}

@media (max-width: 1280px) {
  .toc {
    display: none;
  }
}

/* ===== 阅读进度条 ===== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, 
    var(--color-primary-500, #5a9d5a), 
    var(--color-primary-400, #7ab87a)
  );
  width: 0%;
  transition: width var(--duration-fast) linear;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== 改进的按钮样式 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  border-radius: 8px;
  transition: all var(--duration-normal) var(--ease-out);
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.btn--primary {
  background: var(--color-primary-500, #5a9d5a);
  color: white;
}

.btn--primary:hover {
  background: var(--color-primary-600, #4a8a4a);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(90, 157, 90, 0.3);
}

.btn--primary:active {
  transform: translateY(0);
}

.btn--secondary {
  background: transparent;
  color: var(--text-primary, #1c1917);
  border: 1px solid var(--border-medium, #d6d3d1);
}

.btn--secondary:hover {
  background: var(--bg-tertiary, #f5f5f4);
  border-color: var(--border-strong, #a8a29e);
}

/* ===== 改进的表单样式 ===== */
.input, .textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-primary, #1c1917);
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-medium, #d6d3d1);
  border-radius: 8px;
  transition: all var(--duration-fast) var(--ease-out);
}

.input:hover, .textarea:hover {
  border-color: var(--border-strong, #a8a29e);
}

.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--color-primary-500, #5a9d5a);
  box-shadow: 0 0 0 3px var(--color-primary-100, #dceddc);
}

/* ===== 响应式优化 ===== */
@media (max-width: 768px) {
  .article {
    padding: 2rem 1rem;
  }
  
  .article__title {
    font-size: 2rem;
  }
  
  .article__content {
    font-size: 1rem;
  }
}

/* ===== 无障碍优化 ===== */
:focus-visible {
  outline: 2px solid var(--color-primary-500, #5a9d5a);
  outline-offset: 2px;
}

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

/* ===== 打印样式 ===== */
@media print {
  .toc, .reading-progress, .nav, .footer {
    display: none !important;
  }
  
  .article {
    max-width: 100%;
    padding: 0;
  }
  
  .article__content {
    font-size: 12pt;
    line-height: 1.5;
  }
}
