/* 全局样式 */
:root {
  --bg-color: #ffffff;
  --text-color: #333333;
  --link-color: #3498db;
  --link-hover-color: #2980b9;
  --border-color: #e0e0e0;
  --header-bg: #ffffff;
  --header-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  --code-bg: #f5f5f5;
  --code-color: #333333;
  --footer-bg: #f8f8f8;
  --max-width: 720px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Noto Serif", "Noto Serif SC", Georgia, serif;
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --link-color: #4da6ff;
    --link-hover-color: #66b3ff;
    --border-color: #333333;
    --header-bg: #1a1a1a;
    --header-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    --code-bg: #2d2d2d;
    --code-color: #e0e0e0;
    --footer-bg: #2d2d2d;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-serif);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.7;
  font-size: 16px;
  transition: background-color 0.3s, color 0.3s;
}

/* 容器 */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* 头部导航 */
header {
  background-color: var(--header-bg);
  box-shadow: var(--header-shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s, box-shadow 0.3s;
}

nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}

.logo {
  font-size: 1.2rem;
  font-weight: bold;
  text-decoration: none;
  color: var(--text-color);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 20px;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-color);
  font-size: 0.9rem;
  transition: color 0.3s;
}

.nav-links a:hover {
  color: var(--link-color);
}

/* 主内容 */
main {
  padding: 40px 0;
  min-height: calc(100vh - 120px);
}

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

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

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

.post-title {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.post-title a {
  text-decoration: none;
  color: var(--text-color);
  transition: color 0.3s;
}

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

.post-meta {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 15px;
}

.post-excerpt {
  margin-bottom: 20px;
}

/* 文章详情 */
.post-header {
  margin-bottom: 40px;
}

.post-content {
  margin-bottom: 40px;
}

.post-content h2 {
  margin: 30px 0 20px;
  font-size: 1.3rem;
}

.post-content h3 {
  margin: 25px 0 15px;
  font-size: 1.1rem;
}

.post-content p {
  margin-bottom: 20px;
}

.post-content ul,
.post-content ol {
  margin-bottom: 20px;
  padding-left: 20px;
}

.post-content li {
  margin-bottom: 10px;
}

.post-content a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.3s;
}

.post-content a:hover {
  color: var(--link-hover-color);
  text-decoration: underline;
}

/* 代码块 */
pre {
  background-color: var(--code-bg);
  border-radius: 4px;
  padding: 20px;
  overflow-x: auto;
  margin-bottom: 20px;
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

code {
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.9rem;
  background-color: var(--code-bg);
  padding: 2px 4px;
  border-radius: 3px;
}

/* 页脚 */
footer {
  background-color: var(--footer-bg);
  padding: 30px 0;
  text-align: center;
  font-size: 0.85rem;
  color: #666;
  transition: background-color 0.3s;
}

.footer-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.footer-links {
  margin: 15px 0;
}

.footer-links a {
  color: #666;
  text-decoration: none;
  margin: 0 10px;
  transition: color 0.3s;
}

.footer-links a:hover {
  color: var(--link-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
  nav {
    flex-direction: column;
    height: auto;
    padding: 15px 20px;
  }

  .logo {
    margin-bottom: 10px;
  }

  .nav-links {
    gap: 15px;
  }

  .post-title {
    font-size: 1.3rem;
  }

  main {
    padding: 30px 0;
  }
}

/* 404 页面 */
.not-found {
  text-align: center;
  padding: 60px 0;
}

.not-found h1 {
  font-size: 3rem;
  margin-bottom: 20px;
}

.not-found p {
  font-size: 1.2rem;
  margin-bottom: 30px;
}

/* 分类和标签页面 */
.taxonomy-term {
  margin-bottom: 40px;
}

.taxonomy-term h2 {
  margin-bottom: 20px;
}

/* 广告位 */
.adsense {
  margin: 30px 0;
  text-align: center;
}

/* 首页介绍文章 */
.intro-article {
  margin: 40px 0;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: 8px;
  transition: background-color 0.3s;
}

@media (prefers-color-scheme: dark) {
  .intro-article {
    background-color: rgba(255, 255, 255, 0.05);
  }
}

.intro-article h2 {
  margin-bottom: 20px;
  font-size: 1.5rem;
}

.intro-article p {
  margin-bottom: 15px;
  line-height: 1.7;
}

/* 特色内容区域 */
.featured-section {
  margin: 40px 0;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.01);
  border-radius: 8px;
  transition: background-color 0.3s;
}

@media (prefers-color-scheme: dark) {
  .featured-section {
    background-color: rgba(255, 255, 255, 0.03);
  }
}

.featured-section h3 {
  margin-bottom: 15px;
  font-size: 1.2rem;
}

.featured-section p {
  margin-bottom: 20px;
}

.featured-links {
  list-style: none;
  padding: 0;
}

.featured-links li {
  margin-bottom: 10px;
  padding-left: 20px;
  position: relative;
}

.featured-links li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: #666;
}

.popular-articles {
  margin-top: 40px;
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: 8px;
}

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

.article-links li {
  margin-bottom: 12px;
  padding-left: 20px;
  position: relative;
}

.article-links li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #666;
  font-weight: bold;
}

.article-links a {
  color: #333;
  text-decoration: none;
  transition: color 0.3s ease;
}

.article-links a:hover {
  color: #555;
  text-decoration: underline;
}

.featured-links a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.3s;
}

.featured-links a:hover {
  color: var(--link-hover-color);
  text-decoration: underline;
}

/* 商品样式 */
.product {
  margin: 40px 0;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: 8px;
  transition: background-color 0.3s;
}

@media (prefers-color-scheme: dark) {
  .product {
    background-color: rgba(255, 255, 255, 0.05);
  }
}

.product-image {
  text-align: center;
  margin-bottom: 20px;
}

.product-image img {
  max-width: 200px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.product-price {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 15px 0;
  color: var(--link-color);
}

.product-description {
  margin: 20px 0;
}

.product-description ul {
  margin: 15px 0;
  padding-left: 20px;
}

.product-description li {
  margin-bottom: 8px;
}

.purchase-section {
  margin: 30px 0;
  padding: 15px;
  background-color: rgba(0, 0, 0, 0.01);
  border-radius: 4px;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .purchase-section {
    background-color: rgba(255, 255, 255, 0.03);
  }
  
  .popular-articles {
    background-color: #2a2a2a;
  }
  
  .article-links li::before {
    color: #999;
  }
  
  .article-links a {
    color: #ddd;
  }
  
  .article-links a:hover {
    color: #fff;
  }
}

.purchase-button {
  display: inline-block;
  padding: 10px 20px;
  background-color: var(--link-color);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  transition: background-color 0.3s;
  margin-top: 10px;
}

.purchase-button:hover {
  background-color: var(--link-hover-color);
  color: white;
  text-decoration: none;
}

/* PayPal 按钮容器 */
#paypal-button-container {
  margin: 20px auto;
  max-width: 300px;
  min-height: 45px;
}

.purchase-note {
  font-size: 0.85rem;
  color: #666;
  margin-top: 15px;
  line-height: 1.5;
}

/* 深色模式切换按钮 */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  font-size: 1rem;
  padding: 5px;
  transition: color 0.3s;
}

.theme-toggle:hover {
  color: var(--link-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
  body {
    font-size: 15px;
  }
  
  .container {
    padding: 0 15px;
  }
  
  nav {
    padding: 0 15px;
  }
  
  .nav-links {
    gap: 15px;
  }
  
  .nav-links a {
    font-size: 0.85rem;
  }
  
  h1 {
    font-size: 1.8rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  h3 {
    font-size: 1.3rem;
  }
  
  .featured-section,
  .popular-articles {
    padding: 15px;
  }
  
  .product {
    padding: 15px;
  }
  
  .product-image img {
    max-width: 180px;
  }
  
  #paypal-button-container {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
  
  .nav-links {
    gap: 10px;
  }
  
  .nav-links a {
    font-size: 0.8rem;
  }
  
  h1 {
    font-size: 1.6rem;
  }
  
  h2 {
    font-size: 1.3rem;
  }
  
  h3 {
    font-size: 1.1rem;
  }
  
  .featured-section,
  .popular-articles {
    padding: 12px;
  }
  
  .product {
    padding: 12px;
  }
  
  .product-image img {
    max-width: 160px;
  }
}

/* 预加载字体和关键资源 */
@font-face {
  font-family: 'Noto Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/notoserif/v25/P5sMzZCDf9_T_10ZxPsyW-.woff2) format('woff2');
}

/* 优化图片加载 */
img {
  max-width: 100%;
  height: auto;
  display: block;
}
