/* ========================================
   CSS 变量 - 配色方案
   ======================================== */
:root {
  --color-coral: #ff8370;
  --color-blue-green: #00b1b0;
  --color-freesia: #fec84d;
  --color-fuchsia: #e42256;

  --color-text: #333;
  --color-text-light: #666;
  --color-text-lighter: #999;
  --color-bg: #fff;
  --color-bg-light: #f8f9fa;
  --color-border: #e0e0e0;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: Consolas, Monaco, "Courier New", monospace;

  --max-width: 1200px;
  --content-width: 800px;
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  --border-radius: 4px;
  --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Dark Mode 配色 */
[data-theme="dark"] {
  --color-text: #e0e0e0;
  --color-text-light: #b0b0b0;
  --color-text-lighter: #7697a3;
  --color-bg: #000a14;
  --color-bg-light: #04333c;
  --color-border: #042627;

  --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Dark mode 下保持主题色不变，但稍微调整以适应深色背景 */
[data-theme="dark"] {
  --color-coral: #ff9580;
  --color-blue-green: #00c5c4;
  --color-freesia: #ffd966;
  --color-fuchsia: #ff4d7d;
}

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

html {
  font-size: 16px;
  line-height: 1.6;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* ========================================
   排版
   ======================================== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-top: var(--spacing-lg);
  margin-bottom: var(--spacing-sm);
  color: var(--color-text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: var(--spacing-sm);
}

a {
  color: var(--color-blue-green);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-coral);
}

/* 外链图标 */
a[target="_blank"]::after {
  content: "";
  display: inline-block;
  width: 0.92em;
  height: 0.92em;
  margin-left: 0.25em;
  background-color: currentColor;
  -webkit-mask-image: url('/images/external_link_icon_bold.svg');
  mask-image: url('/images/external_link_icon_bold.svg');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  vertical-align: middle;
  opacity: 0.6;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

a[target="_blank"]:hover::after {
  opacity: 1;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ========================================
   布局
   ======================================== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.content {
  max-width: var(--content-width);
  margin: 0 auto;
}

/* ========================================
   Header / 导航
   ======================================== */
.site-header {
  background-color: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
  padding: var(--spacing-md) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.site-title a {
  color: var(--color-text);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.site-title a:hover {
  color: var(--color-blue-green);
}

.site-logo {
  font-size: 1.75rem;
  line-height: 1;
}

.site-logo-img {
  height: 40px;
  width: auto;
  display: inline-block;
}

.site-name {
  line-height: 1.2;
}

.main-nav ul {
  list-style: none;
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  align-items: baseline;
}

.main-nav a {
  color: var(--color-text);
  font-weight: 500;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
}

.main-nav a:hover {
  background-color: var(--color-bg-light);
  color: var(--color-blue-green);
}

/* ========================================
   Main Content
   ======================================== */
.site-main {
  padding: var(--spacing-xl) 0;
  min-height: 70vh;
}

/* ========================================
   文章列表
   ======================================== */
.post-list {
  list-style: none;
}

.post-item {
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.post-item:last-child {
  border-bottom: none;
}

.post-title {
  font-size: 1.75rem;
  margin-top: 0;
  margin-bottom: var(--spacing-sm);
}

.post-title a {
  color: var(--color-text);
}

.post-title a:hover {
  color: var(--color-blue-green);
}

.post-meta {
  color: var(--color-text-light);
  font-size: 0.9rem;
  margin-bottom: var(--spacing-sm);
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  align-items: center;
}

.post-meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.post-summary {
  color: var(--color-text-light);
  line-height: 1.7;
}

.read-more {
  display: inline-block;
  margin-top: var(--spacing-sm);
  color: var(--color-blue-green);
  font-weight: 500;
}

.read-more:hover {
  color: var(--color-coral);
}

/* ========================================
   单篇文章
   ======================================== */
.post-single {
  max-width: var(--content-width);
  margin: 0 auto;
}

.post-header {
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  border-bottom: 2px solid var(--color-border);
}

.post-content {
  line-height: 1.8;
  font-size: 1.0625rem;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  position: relative;
  padding-left: var(--spacing-sm);
}

.post-content h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 1.2em;
  background: linear-gradient(to bottom, var(--color-coral), var(--color-blue-green));
  border-radius: 2px;
}

.post-content ul,
.post-content ol {
  margin-left: var(--spacing-lg);
  margin-bottom: var(--spacing-sm);
}

.post-content li {
  margin-bottom: var(--spacing-xs);
}

.post-content blockquote {
  border-left: 4px solid var(--color-blue-green);
  padding-left: var(--spacing-md);
  margin: var(--spacing-md) 0;
  color: var(--color-text-light);
  font-style: italic;
}

.post-content code {
  font-family: var(--font-mono);
  background-color: var(--color-bg-light);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

.post-content pre {
  background-color: #282c34;
  color: #abb2bf;
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  overflow-x: auto;
  margin: var(--spacing-md) 0;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ========================================
   标签和分类
   ======================================== */
.taxonomy-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  list-style: none;
  margin: var(--spacing-sm) 0;
  align-items: center;
}

.taxonomy-inline {
  gap: var(--spacing-md);
}

.taxonomy-inline strong {
  margin-right: var(--spacing-xs);
}

.taxonomy-item {
  display: inline-block;
}

.taxonomy-link {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background-color: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.875rem;
  color: var(--color-text);
  transition: all 0.2s ease;
}

.taxonomy-link:hover {
  background-color: var(--color-blue-green);
  border-color: var(--color-blue-green);
  color: white;
}

.tag-link {
  background-color: rgba(0, 177, 176, 0.1);
  border-color: var(--color-blue-green);
  color: var(--color-blue-green);
}

.tag-link:hover {
  background-color: var(--color-blue-green);
  color: white;
}

.category-link {
  background-color: rgba(255, 131, 112, 0.1);
  border-color: var(--color-coral);
  color: var(--color-coral);
}

.category-link:hover {
  background-color: var(--color-coral);
  color: white;
}

.topic-link {
  background-color: rgba(254, 200, 77, 0.1);
  border-color: var(--color-freesia);
  color: #b8860b;
}

.topic-link:hover {
  background-color: var(--color-freesia);
  color: #333;
}

/* ========================================
   内链板块 - 通用样式
   ======================================== */
.related-section {
  margin: var(--spacing-xl) 0;
  padding: var(--spacing-lg);
  background-color: var(--color-bg-light);
  border-radius: var(--border-radius);
  border-left: 4px solid var(--color-blue-green);
}

.related-section h3 {
  margin-top: 0;
  color: var(--color-blue-green);
  font-size: 1.25rem;
}

.related-posts {
  list-style: none;
}

.related-post-item {
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.related-post-item:last-child {
  border-bottom: none;
}

.related-post-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--spacing-sm);
  color: var(--color-text);
}

.related-post-link:hover {
  color: var(--color-blue-green);
}

.related-post-title {
  flex: 1;
}

.related-post-date {
  color: var(--color-text-lighter);
  font-size: 0.875rem;
  white-space: nowrap;
}

/* ========================================
   分页
   ======================================== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-sm);
  margin: var(--spacing-xl) 0;
  list-style: none;
}

.pagination a,
.pagination span {
  padding: var(--spacing-xs) var(--spacing-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  color: var(--color-text);
  transition: all 0.2s ease;
}

.pagination a:hover {
  background-color: var(--color-blue-green);
  border-color: var(--color-blue-green);
  color: white;
}

.pagination .active {
  background-color: var(--color-blue-green);
  border-color: var(--color-blue-green);
  color: white;
}

.pagination .disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   Footer
   ======================================== */
.site-footer {
  background-color: var(--color-bg-light);
  border-top: 2px solid var(--color-border);
  padding: var(--spacing-xl) 0 var(--spacing-lg);
  margin-top: var(--spacing-xl);
}

.footer-content {
  text-align: center;
  color: var(--color-text-light);
  font-size: 0.9rem;
}

/* ========================================
   响应式设计
   ======================================== */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  .site-header .container {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .main-nav ul {
    justify-content: center;
  }

  .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .related-post-link {
    flex-direction: column;
    align-items: flex-start;
  }

  .pagination {
    flex-wrap: wrap;
  }
}

/* ========================================
   辅助类
   ======================================== */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--color-text-light);
}

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* ========================================
   页面标题优化
   ======================================== */
.section-title,
.page-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 0;
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-md);
  border-bottom: 3px solid var(--color-blue-green);
  position: relative;
}

.section-title::after,
.page-header h1::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 80px;
  height: 3px;
  background: var(--color-coral);
}

.page-header {
  margin-bottom: var(--spacing-xl);
}

.page-header .text-muted {
  margin-top: var(--spacing-sm);
  font-size: 1rem;
}

/* ========================================
   Dark Mode 切换按钮
   ======================================== */
.theme-toggle {
  background: none;
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 0;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
}

.theme-toggle:hover {
  background-color: var(--color-bg-light);
  border-color: var(--color-blue-green);
  transform: rotate(20deg);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* ========================================
   语言切换按钮
   ======================================== */
.lang-toggle {
  background: none;
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 0;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
  color: var(--color-text);
}

.lang-toggle:hover {
  background-color: var(--color-bg-light);
  border-color: var(--color-fuchsia);
  color: var(--color-fuchsia);
}

.lang-toggle:active {
  transform: scale(0.95);
}

/* Dark mode 下的特殊样式 */
[data-theme="dark"] .site-header {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .topic-link:hover {
  color: #000;
}

/* ========================================
   图表和公式支持
   ======================================== */

/* Mermaid 图表 */
.mermaid {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md);
  background-color: var(--color-bg-light);
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
  overflow-x: auto;
  text-align: center;
}

/* PlantUML 图表 */
.plantuml-diagram {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md);
  background-color: var(--color-bg-light);
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
  text-align: center;
  overflow-x: auto;
}

.plantuml-diagram img {
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

/* KaTeX 数学公式 */
.katex-display {
  margin: var(--spacing-md) 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.katex {
  font-size: 1.1em;
}

/* Dark mode 下的图表样式 */
[data-theme="dark"] .mermaid,
[data-theme="dark"] .plantuml-diagram {
  background-color: var(--color-bg-light);
  border-color: var(--color-border);
}

/* ========================================
   拍立得边框样式
   ======================================== */
.polaroid-wrapper {
  display: block;
  background: white;
  padding: 10px;
  padding-bottom: 50px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 6px 20px rgba(0, 0, 0, 0.19);
  margin: 20px auto;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  width: 100%;
  max-width: 100%;
}

/* PC 端样式：93% 宽度居中 */
@media (min-width: 769px) {
  .polaroid-wrapper {
    width: 93%;
    max-width: 93%;
  }
}

.polaroid-wrapper:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.22);
}

.polaroid-image {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
}

.polaroid-image img {
  width: 100%;
  height: auto;
  display: block;
}

.polaroid-caption {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  text-align: center;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dark mode 下的拍立得样式 */
[data-theme="dark"] .polaroid-wrapper {
  background: #f5f5f5;
  box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1), 0 6px 20px rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .polaroid-wrapper:hover {
  box-shadow: 0 8px 16px rgba(255, 255, 255, 0.15), 0 12px 40px rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .polaroid-caption {
  color: #333;
}
