/* ==========================================================================
   个人技术博客 - 自定义样式
   基于 Bootstrap 5 的简洁风格
   ========================================================================== */

/* ==========================================================================
   全局变量
   ========================================================================== */
:root {
  /* 颜色系统 */
  --primary-color: #0d6efd;
  --secondary-color: #6c757d;
  --success-color: #198754;
  --info-color: #0dcaf0;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  
  /* 背景色 */
  --bg-light: #f8f9fa;
  --bg-white: #ffffff;
  --bg-dark: #212529;
  
  /* 文字颜色 */
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #6c757d;
  --text-light: #ffffff;
  
  /* 字体 */
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  
  /* 间距 */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 3rem;
  
  /* 圆角 */
  --border-radius: 0.375rem;
  --border-radius-lg: 0.5rem;
  --border-radius-sm: 0.25rem;
  
  /* 阴影 */
  --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --box-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
  
  /* 过渡动画 */
  --transition-base: all 0.2s ease-in-out;
  --transition-fade: opacity 0.15s linear;
}

/* ==========================================================================
   基础样式重置
   ========================================================================== */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family-base);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 链接样式 */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition-base);
}

a:hover {
  color: #0b5ed7;
  text-decoration: underline;
}

/* 图片样式 */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ==========================================================================
   布局组件
   ========================================================================== */

/* Site Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: var(--box-shadow);
}

.site-main {
  min-height: calc(100vh - 300px);
  padding: var(--spacing-xl) 0;
}

.site-footer {
  margin-top: auto;
  border-top: 1px solid #e9ecef;
}

/* Container */
.container {
  max-width: 1140px;
}

/* ==========================================================================
   文章样式
   ========================================================================== */

/* Article Card */
.article-card {
  transition: var(--transition-base);
}

.article-card:hover {
  transform: translateY(-2px);
}

.article-title {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--spacing-sm);
}

.article-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.article-title a:hover {
  color: var(--primary-color);
}

.article-meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.article-meta a {
  color: var(--text-secondary);
}

.article-meta a:hover {
  color: var(--primary-color);
}

.article-excerpt {
  color: var(--text-secondary);
  line-height: 1.7;
}

.article-cover {
  overflow: hidden;
  border-radius: var(--border-radius-lg);
}

.article-cover img {
  transition: transform 0.3s ease;
}

.article-card:hover .article-cover img {
  transform: scale(1.05);
}

/* Article Divider */
.article-divider {
  margin: var(--spacing-xl) 0;
  border: 0;
  border-top: 1px solid #e9ecef;
}

/* ==========================================================================
   侧边栏组件
   ========================================================================== */

/* Sidebar Widget */
.sidebar-widget {
  background: var(--bg-white);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  box-shadow: var(--box-shadow);
}

.widget-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--primary-color);
}

/* Tag Cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
}

.tag-cloud .badge {
  font-size: 0.875rem;
  font-weight: 400;
  padding: 0.35em 0.65em;
  transition: var(--transition-base);
}

.tag-cloud .badge:hover {
  background-color: var(--primary-color) !important;
  color: var(--text-light) !important;
  transform: translateY(-1px);
}

/* Article Tags */
.article-tags .badge {
  transition: var(--transition-base);
}

.article-tags .badge:hover {
  background-color: var(--primary-color) !important;
  color: var(--text-light) !important;
}

/* ==========================================================================
   Markdown 内容样式
   ========================================================================== */

/* Markdown Content */
.markdown-content {
  line-height: 1.8;
  color: var(--text-primary);
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
  font-weight: 600;
  line-height: 1.3;
}

.markdown-content h1 {
  font-size: 2rem;
  border-bottom: 2px solid #e9ecef;
  padding-bottom: var(--spacing-sm);
}

.markdown-content h2 {
  font-size: 1.75rem;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: var(--spacing-xs);
}

.markdown-content h3 {
  font-size: 1.5rem;
}

.markdown-content h4 {
  font-size: 1.25rem;
}

.markdown-content h5 {
  font-size: 1.125rem;
}

.markdown-content h6 {
  font-size: 1rem;
}

/* Paragraphs */
.markdown-content p {
  margin-bottom: var(--spacing-md);
  white-space: pre-wrap;  /* 保留空白符和换行 */
  word-wrap: break-word;  /* 长单词换行 */
}

/* Links */
.markdown-content a {
  color: var(--primary-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.markdown-content a:hover {
  color: #0b5ed7;
  text-decoration-thickness: 2px;
}

/* Lists - Complete isolation to prevent style conflicts */
.article-body.markdown-content ul,
.article-excerpt ul {
  margin-bottom: var(--spacing-md) !important;
  padding-left: var(--spacing-lg) !important;
  list-style: disc outside !important;
  /* Reset counter to prevent interference from ol */
  counter-reset: none !important;
}

.article-body.markdown-content ol,
.article-excerpt ol {
  margin-bottom: var(--spacing-md) !important;
  padding-left: var(--spacing-lg) !important;
  list-style: decimal outside !important;
  counter-reset: list-item !important;
}

/* Completely isolate li elements */
.article-body.markdown-content ul li,
.article-excerpt ul li {
  margin-bottom: var(--spacing-xs) !important;
  display: list-item !important;
  /* Force disc for ul children - use all to override any inheritance */
  list-style: disc outside !important;
  /* Ensure no counter is used */
  counter-increment: none !important;
}

.article-body.markdown-content ol li,
.article-excerpt ol li {
  margin-bottom: var(--spacing-xs) !important;
  display: list-item !important;
  /* Force decimal for ol children - use all to override any inheritance */
  list-style: decimal outside !important;
  /* Ensure counter is used */
  counter-increment: list-item !important;
}

/* Blockquotes */
.markdown-content blockquote {
  border-left: 4px solid var(--primary-color);
  padding: var(--spacing-md) var(--spacing-lg);
  margin: var(--spacing-lg) 0;
  background-color: var(--bg-light);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  font-style: italic;
  color: var(--text-secondary);
}

.markdown-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Code */
.markdown-content code {
  font-family: var(--font-family-mono);
  font-size: 0.875em;
  background-color: var(--bg-light);
  padding: 0.2em 0.4em;
  border-radius: var(--border-radius-sm);
  color: #e83e8c;
}

.markdown-content pre {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
  margin: var(--spacing-lg) 0;
  overflow-x: auto;
}

.markdown-content pre code {
  background-color: transparent;
  padding: 0;
  color: inherit;
}

/* Tables */
.markdown-content table {
  width: 100%;
  margin-bottom: var(--spacing-lg);
  border-collapse: collapse;
  border: 1px solid #dee2e6;
}

.markdown-content th,
.markdown-content td {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid #dee2e6;
  text-align: left;
}

.markdown-content th {
  background-color: var(--bg-light);
  font-weight: 600;
}

.markdown-content tr:nth-child(even) {
  background-color: #f8f9fa;
}

/* Images */
.markdown-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  margin: var(--spacing-md) 0;
}

/* Horizontal Rule */
.markdown-content hr {
  margin: var(--spacing-xl) 0;
  border: 0;
  border-top: 1px solid #e9ecef;
}

/* ==========================================================================
   文字样式 (支持 Markdown 编辑器中的自定义样式)
   ========================================================================== */

/* 文字颜色 - 使用 !important 确保优先级 */
.markdown-content .text-red { color: #dc3545 !important; }
.markdown-content .text-blue { color: #0d6efd !important; }
.markdown-content .text-green { color: #198754 !important; }
.markdown-content .text-orange { color: #fd7e14 !important; }
.markdown-content .text-purple { color: #6f42c1 !important; }
.markdown-content .text-yellow { color: #ffc107 !important; }
.markdown-content .text-cyan { color: #0dcaf0 !important; }
.markdown-content .text-pink { color: #d63384 !important; }

/* 文字大小 - 使用 !important 确保优先级 */
.markdown-content .text-xs { font-size: 0.75rem !important; }
.markdown-content .text-sm { font-size: 0.875rem !important; }
.markdown-content .text-lg { font-size: 1.25rem !important; }
.markdown-content .text-xl { font-size: 1.5rem !important; }
.markdown-content .text-2xl { font-size: 2rem !important; }

/* 字体 - 使用 !important 确保优先级 */
.markdown-content .font-song { font-family: "SimSun", "宋体", serif !important; }
.markdown-content .font-kai { font-family: "KaiTi", "楷体", serif !important; }
.markdown-content .font-yahei { font-family: "Microsoft YaHei", "微软雅黑", sans-serif !important; }
.markdown-content .font-hei { font-family: "SimHei", "黑体", sans-serif !important; }

/* ==========================================================================
   代码高亮样式 (Monokai 主题)
   ========================================================================== */

.markdown-content .highlight {
  background: #272822;
  color: #f8f8f2;
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
  margin: var(--spacing-lg) 0;
  overflow-x: auto;
}

.markdown-content .highlight pre {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
}

/* 代码高亮颜色 */
.markdown-content .highlight .hll { background-color: #49483e; }
.markdown-content .highlight .c { color: #75715e; } /* Comment */
.markdown-content .highlight .err { color: #960050; background-color: #1e0010; } /* Error */
.markdown-content .highlight .k { color: #66d9ef; } /* Keyword */
.markdown-content .highlight .l { color: #ae81ff; } /* Literal */
.markdown-content .highlight .n { color: #f8f8f2; } /* Name */
.markdown-content .highlight .o { color: #f92672; } /* Operator */
.markdown-content .highlight .p { color: #f8f8f2; } /* Punctuation */
.markdown-content .highlight .cm { color: #75715e; } /* Comment.Multiline */
.markdown-content .highlight .cp { color: #75715e; } /* Comment.Preproc */
.markdown-content .highlight .c1 { color: #75715e; } /* Comment.Single */
.markdown-content .highlight .cs { color: #75715e; } /* Comment.Special */
.markdown-content .highlight .ge { font-style: italic; } /* Generic.Emph */
.markdown-content .highlight .gs { font-weight: bold; } /* Generic.Strong */
.markdown-content .highlight .kc { color: #66d9ef; } /* Keyword.Constant */
.markdown-content .highlight .kd { color: #66d9ef; } /* Keyword.Declaration */
.markdown-content .highlight .kn { color: #f92672; } /* Keyword.Namespace */
.markdown-content .highlight .kp { color: #66d9ef; } /* Keyword.Pseudo */
.markdown-content .highlight .kr { color: #66d9ef; } /* Keyword.Reserved */
.markdown-content .highlight .kt { color: #66d9ef; } /* Keyword.Type */
.markdown-content .highlight .ld { color: #e6db74; } /* Literal.Date */
.markdown-content .highlight .m { color: #ae81ff; } /* Literal.Number */
.markdown-content .highlight .s { color: #e6db74; } /* Literal.String */
.markdown-content .highlight .na { color: #a6e22e; } /* Name.Attribute */
.markdown-content .highlight .nb { color: #f8f8f2; } /* Name.Builtin */
.markdown-content .highlight .nc { color: #a6e22e; } /* Name.Class */
.markdown-content .highlight .no { color: #66d9ef; } /* Name.Constant */
.markdown-content .highlight .nd { color: #a6e22e; } /* Name.Decorator */
.markdown-content .highlight .ni { color: #f8f8f2; } /* Name.Entity */
.markdown-content .highlight .ne { color: #a6e22e; } /* Name.Exception */
.markdown-content .highlight .nf { color: #a6e22e; } /* Name.Function */
.markdown-content .highlight .nl { color: #f8f8f2; } /* Name.Label */
.markdown-content .highlight .nn { color: #f8f8f2; } /* Name.Namespace */
.markdown-content .highlight .nx { color: #a6e22e; } /* Name.Other */
.markdown-content .highlight .py { color: #f8f8f2; } /* Name.Property */
.markdown-content .highlight .nt { color: #f92672; } /* Name.Tag */
.markdown-content .highlight .nv { color: #f8f8f2; } /* Name.Variable */
.markdown-content .highlight .ow { color: #f92672; } /* Operator.Word */
.markdown-content .highlight .w { color: #f8f8f2; } /* Text.Whitespace */
.markdown-content .highlight .mf { color: #ae81ff; } /* Literal.Number.Float */
.markdown-content .highlight .mh { color: #ae81ff; } /* Literal.Number.Hex */
.markdown-content .highlight .mi { color: #ae81ff; } /* Literal.Number.Integer */
.markdown-content .highlight .mo { color: #ae81ff; } /* Literal.Number.Oct */
.markdown-content .highlight .sb { color: #e6db74; } /* Literal.String.Backtick */
.markdown-content .highlight .sc { color: #e6db74; } /* Literal.String.Char */
.markdown-content .highlight .sd { color: #e6db74; } /* Literal.String.Doc */
.markdown-content .highlight .s2 { color: #e6db74; } /* Literal.String.Double */
.markdown-content .highlight .se { color: #ae81ff; } /* Literal.String.Escape */
.markdown-content .highlight .sh { color: #e6db74; } /* Literal.String.Heredoc */
.markdown-content .highlight .si { color: #e6db74; } /* Literal.String.Interpol */
.markdown-content .highlight .sx { color: #e6db74; } /* Literal.String.Other */
.markdown-content .highlight .sr { color: #e6db74; } /* Literal.String.Regex */
.markdown-content .highlight .s1 { color: #e6db74; } /* Literal.String.Single */
.markdown-content .highlight .ss { color: #e6db74; } /* Literal.String.Symbol */
.markdown-content .highlight .bp { color: #f8f8f2; } /* Name.Builtin.Pseudo */
.markdown-content .highlight .vc { color: #f8f8f2; } /* Name.Variable.Class */
.markdown-content .highlight .vg { color: #f8f8f2; } /* Name.Variable.Global */
.markdown-content .highlight .vi { color: #f8f8f2; } /* Name.Variable.Instance */
.markdown-content .highlight .il { color: #ae81ff; } /* Literal.Number.Integer.Long */

/* ==========================================================================
   响应式设计
   ========================================================================== */

/* 平板设备 (768px 及以上) */
@media (min-width: 768px) {
  .article-title {
    font-size: 1.5rem;
  }
  
  .markdown-content h1 {
    font-size: 2.25rem;
  }
  
  .markdown-content h2 {
    font-size: 2rem;
  }
  
  .markdown-content h3 {
    font-size: 1.75rem;
  }
}

/* 桌面设备 (992px 及以上) */
@media (min-width: 992px) {
  .site-main {
    padding: var(--spacing-xl) 0;
  }
  
  .article-title {
    font-size: 1.75rem;
  }
}

/* 大屏幕 (1200px 及以上) */
@media (min-width: 1200px) {
  .container {
    max-width: 1140px;
  }
}

/* ==========================================================================
   动画效果
   ========================================================================== */

/* 淡入动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.6s ease-out;
}

/* 加载动画 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
