/* 修復深色模式的文字顏色問題 */
/* 明亮模式 - 確保 html 背景為淺色 */
html[data-dark-theme="false"],
body[data-dark-theme="false"] {
  background-color: #FFFCEC !important;
  color: #3c3c3c;
}

/* 深色模式 - 確保 html 背景為黑色 */
html[data-dark-theme="true"],
body[data-dark-theme="true"] {
  background-color: #181a1b !important;
  color: #e8e8e8;
}

body[data-dark-theme="true"] .container[role=main] {
  color: #e8e8e8;
}

body[data-dark-theme="true"] p {
  color: #e8e8e8;
}

body[data-dark-theme="true"] li {
  color: #e8e8e8;
}

body[data-dark-theme="true"] .post-preview {
  color: #e8e8e8;
}

body[data-dark-theme="true"] .post-meta {
  color: #c0c0c0;
}

/* 確保深色模式下的連結顏色 */
body[data-dark-theme="true"] a {
  color: #809fff;
}

body[data-dark-theme="true"] a:hover {
  color: #a0b9ff;
}

/* 修正深色模式下的標題顏色 */
body[data-dark-theme="true"] h1,
body[data-dark-theme="true"] h2,
body[data-dark-theme="true"] h3,
body[data-dark-theme="true"] h4,
body[data-dark-theme="true"] h5,
body[data-dark-theme="true"] h6 {
  color: #f0f0f0;
}

body[data-dark-theme="true"] .post-title,
body[data-dark-theme="true"] .post-preview h1,
body[data-dark-theme="true"] .post-preview h2,
body[data-dark-theme="true"] .post-preview h3 {
  color: #f0f0f0;
}

/* 確保深色模式切換按鈕可見 */
#dark-mode-toggle {
  cursor: pointer;
}

/* 修復頁腳樣式 */
footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

footer .credits {
  margin: 5px 0;
  text-align: center;
}

/* 聯絡資訊區塊樣式 */
.contact-info {
  margin-top: 4rem;  /* 增加上方間距，避免與分頁導航重疊 */
  padding: 1rem;
  background-color: #f9f9f9;
  border-radius: 5px;
  text-align: center;
  clear: both;  /* 確保不會與浮動元素重疊 */
}

.contact-info hr {
  margin-bottom: 1rem;
  border-top: 1px solid #e0e0e0;
}

.contact-info p {
  font-size: 1rem;
  color: #555;
}

.contact-info a {
  color: #0066cc;
  text-decoration: none;
  transition: color 0.3s ease;
}

.contact-info a:hover {
  color: #004080;
  text-decoration: underline;
}

/* 分頁導航樣式修正 */
.pager {
  margin-bottom: 3rem;  /* 增加下方間距 */
  overflow: hidden;     /* 確保內容不會溢出 */
}

/* 深色模式下的聯絡資訊區塊 */
body[data-dark-theme="true"] .contact-info {
  background-color: #2d2d2d;
  border: 1px solid #3d3d3d;
}

body[data-dark-theme="true"] .contact-info p {
  color: #e0e0e0;
}

body[data-dark-theme="true"] .contact-info a {
  color: #809fff;
}

body[data-dark-theme="true"] .contact-info a:hover {
  color: #a0b9ff;
}

body[data-dark-theme="true"] .contact-info hr {
  border-top: 1px solid #3d3d3d;
}

/* 深色模式下的代碼塊 */
body[data-dark-theme="true"] pre {
  background-color: #2d2d2d;
  color: #f8f8f2;
}

body[data-dark-theme="true"] code {
  background-color: #2d2d2d;
  color: #f8f8f2;
}

/* 深色模式下的表格 */
body[data-dark-theme="true"] table {
  color: #e8e8e8;
}

body[data-dark-theme="true"] th {
  background-color: #2d2d2d;
}

body[data-dark-theme="true"] tr:nth-child(even) {
  background-color: #252525;
}

/* 深色模式下的引用 */
body[data-dark-theme="true"] blockquote {
  background-color: #252525;
  border-left: 4px solid #555;
}

/* 修正導航列 icon 大小,避免排擠文字 */
.nav-links .fa-lg {
  font-size: 1em;  /* 覆蓋預設的 1.33333em */
  vertical-align: middle;
  margin-right: 0.3em;  /* 增加與其他元素的間距 */
}

/* 確保導航列項目有足夠的間距 */
.nav-links li {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

/* 移除回到頂部按鈕的藍色外框 */
.backtop,
#backtotopButton {
  outline: none !important;
  text-decoration: none !important;
  border: none !important;
}

.backtop:focus,
#backtotopButton:focus {
  outline: none !important;
  box-shadow: none !important;
}

/* 確保 SVG icon 也沒有外框 */
.backtop svg {
  display: block;
  outline: none;
}

/* 修正首頁 L icon 樣式 */
.nav-logo img {
  width: 40px !important;  /* 稍微縮小尺寸 */
  height: 40px !important;
  border-radius: 50%;  /* 確保圓形 */
  transition: all 0.3s ease;  /* 平滑過渡效果 */
}

/* 深色模式下調整 logo 透明度,使其更融入背景 */
body[data-dark-theme="true"] .nav-logo img {
  opacity: 0.9;
  filter: brightness(0.95);
}

/* hover 效果優化 */
.nav-logo:hover img {
  opacity: 1;
  filter: brightness(1.1);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

/* 深色模式下確保頂部導航列背景為黑色 */
body[data-dark-theme="true"] .header,
body[data-dark-theme="true"] .navbar,
body[data-dark-theme="true"] .nav {
  background-color: #181a1b !important;
}

/* 深色模式下 read more 按鈕文字顏色 - 藍色主題 */
body[data-dark-theme="true"][data-theme="blue"] .post-read-more {
  color: #4a9eff !important;
}

body[data-dark-theme="true"][data-theme="blue"] a.post-read-more::after {
  background: #4a9eff !important;
}

/* 深色模式下 read more 按鈕文字顏色 - 綠色主題 */
body[data-dark-theme="true"][data-theme="green"] .post-read-more {
  color: #4ade80 !important;
}

body[data-dark-theme="true"][data-theme="green"] a.post-read-more::after {
  background: #4ade80 !important;
}

/* ========================================
   深色模式平滑過渡動畫優化
   ======================================== */

/* 全局過渡設定 - 覆蓋 theme-toggle.css 以提供更細緻的控制 */
/* 重要: html 和 body 必須有相同的過渡設定,確保背景色同步變化 */
html,
body {
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* 連結過渡效果 */
a {
  transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

a:hover {
  transition: color 0.2s ease, background-color 0.2s ease;
}

/* 代碼區塊過渡 */
pre,
code {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

/* 引用區塊過渡 */
blockquote {
  transition: background-color 0.4s ease, color 0.4s ease, border-left-color 0.4s ease;
}

/* 表格過渡 */
table,
th,
td,
tr {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

/* 按鈕和互動元素過渡 */
button,
.btn,
input[type="submit"],
input[type="button"] {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* 導航列過渡 */
.header,
.navbar,
.nav,
.nav-links li a {
  transition: background-color 0.4s ease, color 0.3s ease;
}

/* 文章預覽區塊過渡 */
.post-preview,
.post-meta,
.post-title {
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* 頁腳過渡 */
footer,
footer a {
  transition: background-color 0.4s ease, color 0.3s ease;
}

/* 搜尋相關元素過渡 */
#searchBox,
.searchResults,
.searchResultPage {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

/* 聯絡資訊區塊過渡 */
.contact-info {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

/* 確保圖片、影片不受過渡影響 */
img,
video,
iframe,
svg {
  transition: none !important;
}

/* 主題切換按鈕本身保持快速過渡 */
.theme-toggle-btn {
  transition: all 0.3s ease !important;
}

/* 避免文字選取時的過渡 */
::selection {
  transition: none !important;
}

::-moz-selection {
  transition: none !important;
}

/* ========================================
   相關文章推薦區塊樣式
   ======================================== */

.related-posts {
  margin: 3rem 0 2rem 0;
  padding: 1.5rem;
  background-color: #f8f9fa;
  border-left: 4px solid #007bff;
  border-radius: 4px;
}

.related-posts h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  color: #333;
}

.related-posts ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.related-posts li {
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #e0e0e0;
}

.related-posts li:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.related-posts li a {
  font-size: 1.1rem;
  color: #007bff;
  text-decoration: none;
  font-weight: 500;
}

.related-posts li a:hover {
  color: #0056b3;
  text-decoration: underline;
}

.related-posts .post-date {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.3rem;
}

/* 深色模式下的相關文章樣式 */
body[data-dark-theme="true"] .related-posts {
  background-color: #2a2a2a;
  border-left-color: #4a9eff;
}

body[data-dark-theme="true"] .related-posts h3 {
  color: #e8e8e8;
}

body[data-dark-theme="true"] .related-posts li {
  border-bottom-color: #444;
}

body[data-dark-theme="true"] .related-posts li a {
  color: #4a9eff;
}

body[data-dark-theme="true"] .related-posts li a:hover {
  color: #70b0ff;
}

body[data-dark-theme="true"] .related-posts .post-date {
  color: #aaa;
}

/* ========================================
   閱讀進度條
   ======================================== */

#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: transparent;
  z-index: 9999;
  pointer-events: none;
}

#reading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #007bff 0%, #0056b3 100%);
  transition: width 0.2s ease-out;
}

/* 深色模式下的進度條 */
body[data-dark-theme="true"] #reading-progress-fill {
  background: linear-gradient(90deg, #4a9eff 0%, #70b0ff 100%);
}

/* ========================================
   圖片燈箱優化
   ======================================== */

/* 文章內圖片添加游標提示 */
article.article img {
  cursor: zoom-in;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

article.article img:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

/* 深色模式下的燈箱背景 */
body[data-dark-theme="true"] .goverlay {
  background: rgba(0, 0, 0, 0.95);
}

/* 燈箱圖片說明文字 */
.gslide-description {
  background: rgba(0, 0, 0, 0.75);
  padding: 10px 15px;
  border-radius: 4px;
}

body[data-dark-theme="true"] .gslide-description {
  background: rgba(0, 0, 0, 0.85);
  color: #e8e8e8;
}