/* ===================================================
   ?? 黑夜模式變數定義控制中心
   =================================================== */
:root {
  /* ?? 白天模式色彩 */
  --bg-page: #fcfcfc;
  --bg-card: #ffffff;
  --text-main: #222222;       /* 白天大標題、主文字：深灰接近黑 */
  --text-muted: #555555;      /* 白天內文、摘要：優雅中灰 */
  --text-light: #999999;
  --border-color: #e0e0e0;
  --input-bg: #ffffff;
  --blockquote-bg: #f8f9fa;
  --blockquote-border: #cccccc;
}

[data-theme="dark"] {
  /* ?? 黑夜模式色彩 */
  --bg-page: #121212;         /* 背景保持極致深黑 */
  --bg-card: #1e1e1e;         /* 卡片為石墨黑 */
  --text-main: #ffffff;       /* ?? 關鍵修正：黑夜模式主標題直接拉到純白，絕對清晰！ */
  --text-muted: #e1e1e6;      /* ?? 關鍵修正：黑夜模式文章內文調亮為亮灰色，大幅提升閱讀舒適度 */
  --text-light: #8e8e93;
  --border-color: #333333;
  --input-bg: #2c2c2e;
  --blockquote-bg: #2c2c2e;
  --blockquote-border: #555555;
}


/* 全域平滑套用色彩轉換 */
body, .article-item, input, .category-btn, .page-btn, .sort-btn, blockquote {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ?? 右上角黑夜開關按鈕樣式 */
.theme-toggle-container {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.theme-btn {
  background: none;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
  box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.theme-btn:hover {
  border-color: #0066cc;
}

/* ?箇??Ｚ身? */

body {
  background-color: var(--bg-page); /* ?? 改用變數 */
  margin: 0;
  padding: 40px 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

/* 銝剖亢銝餃捆?剁?撌血? */
.main-container {
  max-width: 800px;
  margin: 0 auto;
}

/* ?Ｗ之?憿?*/
.page-title {
  font-size: 1.8rem;
  color: var(--text-main); /* ?? 改用變數 */
  margin-bottom: 32px;
  font-weight: 700;
}

/* ===================================================
   ??獢璅撘?
   =================================================== */
.search-container {
  position: relative;
  margin-bottom: 20px;
  width: 100%;
}

.search-container input {
  width: 100%;
  padding: 14px 45px 14px 16px;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--input-bg); /* ?? 改用變數 */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.01);
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.search-container input:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.08);
}

.clear-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #999999;
  cursor: pointer;
  padding: 4px;
}

.clear-btn:hover { color: #333333; }

.no-results {
  text-align: center;
  padding: 40px;
  color: #888888;
  font-size: 1.1rem;
}

/* ===================================================
   ??????璅??
   =================================================== */
.categories-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 32px;
}

.category-btn {
  border: 1px solid var(--border-color); /* ?? 改用變數 */
 
	background-color: var(--bg-card);
    color: var(--text-muted);
  border: 1px solid #e0e0e0;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.category-btn:hover {
  background-color: #f5f5f5;
  color: #0066cc;
  border-color: #0066cc;
}

.category-btn.active {
  background-color: #0066cc;
  color: #ffffff;
  border-color: #0066cc;
  font-weight: 600;
}

/* ===================================================
   ???銵?∠?璅??
   =================================================== */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.article-item {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  background-color: var(--bg-card);
  text-decoration: none;
  color: inherit;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.article-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.06);
}

.article-img {
  width: 200px;
  height: 130px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
}

.article-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.article-item:hover .article-img img { transform: scale(1.04); }

.article-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ?∠??抒?撠?蝐?*/
.article-tag, .post-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

.article-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main); /* 讀取純白變數 */
  margin: 0;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.article-item:hover .article-title { color: #0066cc; }

.article-excerpt {
  font-size: 0.95rem;
  color: var(--text-muted); /* 讀取亮灰變數 */
  margin: 0;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-date {
  font-size: 0.85rem;
   color: var(--text-light); /* ?? 改用變數 */
  margin-top: 4px;
}

/* ===================================================
   ????璅??
   =================================================== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
}

.page-btn {
 border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main); /* ?? 改用變數 */
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.page-btn:hover:not(:disabled) {
  background-color: #f0f0f0;
  color: #0066cc;
}

.page-btn.active {
  background-color: #0066cc;
  border-color: #0066cc;
  color: #ffffff;
  cursor: default;
}

.page-btn:disabled {
  background-color: #f5f5f5;
  border-color: #e0e0e0;
  color: #cccccc;
  cursor: not-allowed;
}

/* ? RWD ???????望帖霈 */
@media (max-width: 600px) {
  .article-item { flex-direction: column; gap: 16px; }
  .article-img { width: 100%; height: 160px; }
}

/* ===================================================
   ?? 排序按鈕樣式
   =================================================== */
.sort-container {
  display: flex;
  gap: 16px;
  margin-bottom: 16px; /* 與下方分類按鈕的間距 */
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 8px;
}

.sort-btn {
  background: none;
  border: none;
  color: #86868b;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 4px 8px;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
  user-select: none;
}

.sort-btn:hover {
  color: #0066cc;
}

/* 經典 Apple 風格底線效果 */
.sort-btn.active {
  color: #0066cc;
  font-weight: 600;
}

.sort-btn.active::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: #0066cc;
}


