/* 文章详情页特定样式 - 优化版 */
.article-detail {
  padding: 0;
}

.article-detail .article-header {
  padding: 0;
  border-bottom: none;
}

.article-cover-full {
  width: 100%;
  max-height: 400px;
  overflow: hidden;
  position: relative;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.article-cover-full img {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.article-cover-full:hover img {
  transform: scale(1.02);
}

/* 将标题和元信息移动到封面图片下方 */
.article-info {
  padding: 30px 30px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--article-bg);
  backdrop-filter: blur(10px);
  margin-top: -20px;
  position: relative;
  z-index: 2;
}

.article-detail .article-title {
  font-size: 2.2rem;
  margin-bottom: 15px;
  color: var(--text-color);
  line-height: 1.3;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.article-detail .article-meta {
  margin-bottom: 15px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  color: var(--text-light);
  font-size: 0.9rem;
}

.article-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.article-content-full {
  padding: 0 30px;
  font-size: 1.1rem;
  line-height: 1.8;
}

/* 阅读进度条 */
.reading-progress {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(var(--theme-primary-rgb), 0.2);
  z-index: 1000;
  display: none;
}

.reading-progress-bar {
  height: 100%;
  background: var(--theme-primary);
  width: 0%;
  transition: width 0.2s ease;
  box-shadow: 0 0 10px rgba(var(--theme-primary-rgb), 0.5);
}

/* 移动端目录悬浮按钮 */
.mobile-toc-toggle {
  display: none;
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--theme-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 997;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.3s ease;
}

.mobile-toc-toggle:hover {
  transform: scale(1.1);
}

/* Markdown内容样式优化 */
.article-content-full h1,
.article-content-full h2,
.article-content-full h3,
.article-content-full h4 {
  margin: 1.8em 0 0.8em;
  color: var(--text-color);
  position: relative;
  padding-bottom: 0.3em;
  border-bottom: 2px solid rgba(var(--theme-primary-rgb, 138, 124, 255), 0.2);
  scroll-margin-top: 100px; /* 为目录导航提供偏移 */
}

.article-content-full h1 {
  font-size: 1.8rem;
}

.article-content-full h2 {
  font-size: 1.6rem;
}

.article-content-full h3 {
  font-size: 1.4rem;
}

.article-content-full h4 {
  font-size: 1.2rem;
}

.article-content-full p {
  margin-bottom: 1.5em;
  text-align: justify;
  hyphens: auto; /* 自动断字改善排版 */
}

.article-content-full img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  margin: 1.5em auto;
  display: block;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  cursor: zoom-in;
}

.article-content-full img:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.article-content-full blockquote {
  border-left: 4px solid var(--theme-primary);
  padding: 1em 1.5em;
  margin: 1.5em 0;
  color: var(--text-light);
  background: rgba(var(--theme-primary-rgb, 255, 158, 203), 0.05);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  font-style: italic;
  position: relative;
}

.article-content-full blockquote:before {
  content: "\"";
  position: absolute;
  top: -10px;
  left: 10px;
  font-size: 3em;
  color: rgba(var(--theme-primary-rgb), 0.2);
  font-family: Georgia, serif;
}

.article-content-full blockquote p {
  margin-bottom: 0;
  position: relative;
  z-index: 1;
}

.article-content-full ul,
.article-content-full ol {
  margin: 1.5em 0;
  padding-left: 2em;
}

.article-content-full li {
  margin-bottom: 0.5em;
  position: relative;
}

.article-content-full li::before {
  content: "•";
  color: var(--theme-primary);
  font-weight: bold;
  display: inline-block;
  width: 1em;
  margin-left: -1em;
}

.article-content-full li ul,
.article-content-full li ol {
  margin: 0.5em 0;
}

.article-content-full code {
  background: rgba(var(--theme-primary-rgb, 138, 124, 255), 0.1);
  color: var(--theme-secondary);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
}

/* 改进的代码块样式 */
.article-content-full pre {
  background: #2d2d2d;
  border-radius: 8px;
  overflow: hidden;
  margin: 1.5em 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  transition: transform 0.3s ease;
}

.article-content-full pre:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.article-content-full pre code {
  background: none;
  color: #f8f8f2;
  padding: 0;
  font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  line-height: 1.6;
  display: block;
  overflow-x: auto;
}

/* 代码块容器 */
.code-block-wrapper {
  position: relative;
  margin: 1.5em 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.code-block-wrapper:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* 代码块头部 */
.code-block-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 8px 8px 0 0;
}

.code-block-title {
  color: #fff;
  font-size: 0.85em;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-block-title i {
  font-size: 1.1em;
}

.code-block-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-code-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.copy-code-btn.copied {
  background: rgba(46, 204, 113, 0.8);
}

.copy-code-btn.copied:hover {
  background: rgba(46, 204, 113, 0.9);
}

/* 代码内容区域 */
.code-block-content {
  background: #2d2d2d;
  position: relative;
  overflow: hidden;
}

/* 行号样式 */
.code-line-numbers {
  position: absolute;
  top: 0;
  left: 0;
  padding: 16px 0;
  background: rgba(0, 0, 0, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  color: #666;
  font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.85em;
  line-height: 1.6;
  text-align: right;
  user-select: none;
  z-index: 1;
  width: 50px;
}

.code-line-numbers .line-number {
  display: block;
  padding: 0 12px;
  transition: color 0.2s ease;
}

.code-line-numbers .line-number:hover {
  color: #999;
}

/* 代码内容 */
.code-content {
  padding: 16px 16px 16px 66px;
  color: #f8f8f2;
  font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}

/* 无行号的代码块 */
.code-block-wrapper.no-line-numbers .code-line-numbers {
  display: none;
}

.code-block-wrapper.no-line-numbers .code-content {
  padding-left: 16px;
}

/* 语言特定的头部颜色 */
.code-block-header.lang-javascript {
  background: linear-gradient(135deg, #f7df1e 0%, #f0d91a 100%);
  color: #333;
}

.code-block-header.lang-javascript .copy-code-btn {
  background: rgba(0, 0, 0, 0.1);
  color: #333;
}

.code-block-header.lang-javascript .copy-code-btn:hover {
  background: rgba(0, 0, 0, 0.2);
}

.code-block-header.lang-python {
  background: linear-gradient(135deg, #3776ab 0%, #4b8bbe 100%);
}

.code-block-header.lang-html {
  background: linear-gradient(135deg, #e34c26 0%, #f06529 100%);
}

.code-block-header.lang-css {
  background: linear-gradient(135deg, #1572b6 0%, #33a9dc 100%);
}

.code-block-header.lang-java {
  background: linear-gradient(135deg, #ed8b00 0%, #ff9500 100%);
}

.code-block-header.lang-cpp,
.code-block-header.lang-c {
  background: linear-gradient(135deg, #00599c 0%, #0076cc 100%);
}

/* 表格样式 */
.article-content-full table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  box-shadow: var(--shadow);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.article-content-full th,
.article-content-full td {
  padding: 0.75em 1em;
  text-align: left;
  border: 1px solid var(--border-light);
}

.article-content-full th {
  background: rgba(var(--theme-primary-rgb, 138, 124, 255), 0.1);
  font-weight: 600;
}

.article-content-full tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

.article-content-full hr {
  border: none;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--theme-primary), transparent);
  margin: 2em 0;
}

.article-content-full a {
  color: var(--theme-secondary);
  text-decoration: none;
  border-bottom: 1px dotted var(--theme-secondary);
  transition: all 0.3s;
  position: relative;
}

.article-content-full a:hover {
  color: var(--theme-primary);
  border-bottom: 1px solid var(--theme-primary);
  padding-left: 5px;
}

.article-content-full .image-caption {
  text-align: center;
  font-style: italic;
  color: var(--text-light);
  margin-top: -1em;
  margin-bottom: 1.5em;
  font-size: 0.9em;
}

.article-detail .article-footer {
  padding: 20px 30px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  background: var(--article-bg);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* 文章导航 - 上一篇和下一篇 */
.article-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.article-nav-item {
  display: flex;
  align-items: center;
  padding: 0;
  border-radius: var(--border-radius);
  background: var(--article-bg);
  transition: all 0.3s ease;
  border: 1px solid rgba(var(--theme-primary-rgb, 255, 107, 147), 0.1);
  position: relative;
  overflow: hidden;
  min-height: 140px;
}

.article-nav-item:hover {
  background: var(--article-bg);
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  border-color: rgba(var(--theme-primary-rgb, 255, 107, 147), 0.3);
}

.article-nav-prev {
  text-align: left;
}

.article-nav-next {
  text-align: right;
}

.article-nav-content {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  position: relative;
}

.article-nav-prev .article-nav-content {
  flex-direction: row;
}

.article-nav-next .article-nav-content {
  flex-direction: row-reverse;
}

.article-nav-thumb {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 1;
  overflow: hidden;
}

.article-nav-item:hover .article-nav-thumb img {
  transform: scale(1.05);
}

.article-nav-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.article-nav-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 15px;
  position: relative;
  z-index: 2;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
  color: #fff;
  height: 100%;
}

.article-nav-next .article-nav-info {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
  align-items: flex-end;
}

.article-nav-prev .article-nav-info {
  align-items: flex-start;
}

.article-nav-next .article-nav-info {
  align-items: flex-end;
}

.article-nav-label {
  font-size: 0.85rem;
  color: #fff;
  font-weight: 600;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.article-nav-prev .article-nav-label i {
  margin-right: 5px;
}

.article-nav-next .article-nav-label i {
  margin-left: 5px;
  order: 2;
}

.article-nav-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.3s ease;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.article-nav-item:hover .article-nav-title {
  color: var(--theme-primary);
}

/* 无导航项时的占位样式 */
.article-nav-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--article-bg);
}

.article-nav-item.disabled:hover {
  transform: none;
  background: var(--article-bg);
  border-color: rgba(0, 0, 0, 0.1);
}

.article-nav-item.disabled .article-nav-info {
  background: rgba(0, 0, 0, 0.5);
  width: 100%;
}

.article-nav-item.disabled .article-nav-title {
  color: #fff;
}

/* 图片灯箱样式 */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(10px);
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.lightbox.active .lightbox-content {
  transform: scale(1);
}

.lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  color: white;
  text-align: center;
  margin-top: 15px;
  font-size: 1.1rem;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.lightbox-close:hover {
  transform: rotate(90deg);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  transform: translateY(-50%);
}

.lightbox-prev,
.lightbox-next {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.5rem;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* 文章目录样式 */
.toc-container {
  max-height: 400px;
  overflow-y: auto;
  padding-right: 5px;
}

.toc-container::-webkit-scrollbar {
  width: 4px;
}

.toc-container::-webkit-scrollbar-track {
  background: rgba(var(--theme-primary-rgb, 138, 124, 255), 0.1);
  border-radius: 2px;
}

.toc-container::-webkit-scrollbar-thumb {
  background: rgba(var(--theme-primary-rgb, 138, 124, 255), 0.3);
  border-radius: 2px;
}

.toc-container::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--theme-primary-rgb, 138, 124, 255), 0.5);
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin-bottom: 8px;
  position: relative;
  padding-left: 20px;
  line-height: 1.4;
  transition: all 0.3s ease;
}

.toc-list li:hover {
  padding-left: 25px;
}

.toc-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: rgba(var(--theme-primary-rgb, 138, 124, 255), 0.2);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.toc-list li a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.95em;
  transition: color 0.3s ease;
  display: block;
}

.toc-list li a:hover {
  color: var(--theme-primary);
}

.toc-list .toc-item-h2 {
  font-weight: 600;
  padding-left: 20px;
}

.toc-list .toc-item-h3 {
  padding-left: 40px;
  font-size: 0.9em;
  color: var(--text-light);
}

.toc-list .toc-item-h4 {
  padding-left: 60px;
  font-size: 0.85em;
  color: var(--text-lighter);
}

.toc-placeholder {
  color: var(--text-light);
  font-style: italic;
  text-align: center;
  padding: 20px 0;
}

/* 移动端目录隐藏 */
@media (max-width: 1024px) {
  .left-container {
    display: none;
  }
  
  .mobile-toc-toggle {
    display: flex;
  }
}

/* 目录项激活状态 */
.toc-list li.active a {
  color: var(--theme-primary);
  font-weight: 600;
}

.toc-list li.active::before {
  background: var(--theme-primary);
  box-shadow: 0 0 5px rgba(var(--theme-primary-rgb), 0.5);
}

/* 移动端目录悬浮按钮 */
.mobile-toc-panel {
  position: fixed;
  top: 0;
  left: -300px;
  width: 280px;
  height: 100vh;
  background: var(--card-bg);
  z-index: 999;
  padding: 20px;
  overflow-y: auto;
  transition: left 0.3s ease;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.mobile-toc-panel.active {
  left: 0;
}

.mobile-toc-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
}

.mobile-toc-overlay.active {
  display: block;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .article-info {
    padding: 20px 15px 15px;
    margin-top: 0;
    border-radius: 0;
  }
  
  .article-detail .article-title {
    font-size: 1.8rem;
  }
  
  .article-content-full {
    padding: 0 15px;
    font-size: 1rem;
  }
  
  .article-detail .article-meta {
    flex-direction: column;
    gap: 8px;
  }
  
  .article-navigation {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .article-nav-item {
    min-height: 120px;
  }
  
  .article-detail .article-footer {
    padding: 15px;
    flex-direction: column;
    align-items: flex-start;
  }
  
  .toc-container {
    max-height: 300px;
  }
}

/* 打印样式 */
@media print {
  .article-cover-full,
  .article-navigation,
  .mobile-toc-toggle,
  .settings-button,
  .settings-menu,
  .back-to-top {
    display: none !important;
  }
  
  .article-content-full {
    padding: 0;
  }
  
  .article-info {
    border: none;
    padding: 0;
    margin: 0;
  }
  
  .article-detail .article-title {
    font-size: 1.8rem;
  }
  
  .article-content-full a {
    color: #000;
    text-decoration: underline;
  }
  
  .article-content-full pre {
    background: #f5f5f5 !important;
    color: #000 !important;
    border: 1px solid #ddd;
  }
}

/* 减少动画设置 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  .article-content-full {
    color: #000;
  }
  
  body.night-mode .article-content-full {
    color: #fff;
  }
  
  .article-content-full a {
    color: #0000ee;
    text-decoration: underline;
  }
  
  body.night-mode .article-content-full a {
    color: #99f;
  }
}

/* 深色模式优化 */
body.night-mode .article-content-full {
  color: #e0e0e0;
}

body.night-mode .article-content-full code {
  background: rgba(var(--theme-primary-rgb), 0.15);
}

body.night-mode .article-content-full blockquote {
  background: rgba(var(--theme-primary-rgb), 0.1);
  color: #ccc;
}

body.night-mode .article-content-full table {
  border-color: #444;
}

body.night-mode .article-content-full th {
  background: rgba(var(--theme-primary-rgb), 0.2);
}

body.night-mode .article-content-full tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

/* 焦点可见性 */
.article-content-full a:focus,
.copy-code-btn:focus,
.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
  outline: 2px solid var(--theme-primary);
  outline-offset: 2px;
}

/* 性能优化类 */
.will-change {
  will-change: transform, opacity;
}

/* 加载优化 */
.article-content-full img {
  content-visibility: auto;
}