/* 文章页面样式 */

/* ========== 顶级栏目卡片网格 ========== */
.page.posts-page,
.posts-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 4rem 2rem;
  width: 100%;
  position: relative;
  min-height: calc(100vh - 300px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* 确保在 DoIt 主题的 main 容器中正确居中 */
main .page.posts-page,
main .posts-page {
  margin: auto;
}

.posts-page__header {
  text-align: center;
  margin-bottom: 4rem;
  width: 100%;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.posts-page__header .single-title,
.posts-page__header h1 {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 800;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.category-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  position: relative;
}

.category-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-2xl), var(--shadow-colored);
  border-color: var(--color-accent);
}

.category-card__link {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  text-decoration: none;
  color: inherit;
}

.category-card__icon {
  font-size: 3.5rem;
  line-height: 1;
  flex-shrink: 0;
  filter: grayscale(0.2);
  transition: all 0.3s ease;
}

.category-card:hover .category-card__icon {
  filter: grayscale(0);
  transform: scale(1.1) rotate(5deg);
}

.category-card__content {
  flex: 1;
  min-width: 0;
}

.category-card__title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.category-card__description {
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 1rem;
}

.category-card__meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--color-text-subtle);
}

.category-card__count,
.category-card__subs {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.category-card__arrow {
  font-size: 1.5rem;
  color: var(--color-text-muted);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.category-card:hover .category-card__arrow {
  color: var(--color-accent);
  transform: translateX(4px);
}

/* ========== 子分类页面（书签效果） ========== */
.section-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

.section-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-top: 4rem;
  margin-bottom: 3rem;
  padding-top: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

/* 确保 section-nav 在页面中有足够的顶部间距 */
.section-page .section-nav {
  margin-top: 2rem;
  padding-top: 2rem;
}

/* 如果 section-nav 在 posts-page 中 */
.posts-page .section-nav {
  margin-top: 4rem;
  padding-top: 2rem;
}

.section-nav__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.section-nav__btn:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-accent);
  color: var(--color-accent);
  transform: translateX(-4px);
}

.section-nav__icon {
  font-size: 1.25rem;
}

.section-nav__title {
  flex: 1;
}

.section-nav__title h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.bookmark-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-md);
  position: relative;
}

.bookmark-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--color-accent);
}

.bookmark-card__tab {
  position: absolute;
  top: 0;
  right: 2rem;
  width: 40px;
  height: 20px;
  background: var(--color-accent-gradient);
  border-radius: 0 0 8px 8px;
  box-shadow: var(--shadow-sm);
}

.bookmark-card__link {
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem 1.5rem;
  text-decoration: none;
  color: inherit;
  min-height: 140px;
}

.bookmark-card__title {
  font-size: 1.375rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.bookmark-card__description {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 1rem;
  flex: 1;
}

.bookmark-card__meta {
  font-size: 0.875rem;
  color: var(--color-text-subtle);
  margin-top: auto;
}

.bookmark-card__arrow {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  transition: all 0.3s ease;
}

.bookmark-card:hover .bookmark-card__arrow {
  color: var(--color-accent);
  transform: translateX(4px);
}

/* ========== 文章列表（长卡片） ========== */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.article-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-md);
}

.article-card:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-accent);
}

.article-card__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem;
  text-decoration: none;
  color: inherit;
}

.article-card__content {
  flex: 1;
  min-width: 0;
}

.article-card__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.article-card__description {
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 1rem;
}

.article-card__meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.875rem;
  color: var(--color-text-subtle);
}

.article-card__date {
  display: inline-flex;
  align-items: center;
}

.article-card__categories {
  display: inline-flex;
  align-items: center;
}

.article-card__arrow {
  font-size: 1.5rem;
  color: var(--color-text-muted);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.article-card:hover .article-card__arrow {
  color: var(--color-accent);
  transform: translateX(4px);
}

/* ========== 文章详情页 ========== */
/* ========== 文章返回按钮 - 高级设计 ========== */
.article-nav {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 2rem;
  position: relative;
  z-index: var(--z-modal);
  display: block;
  margin-top: 0;
  margin-bottom: 3rem; /* 增加与标题的间距 */
}

.article-nav__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 16px;
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  visibility: visible;
  opacity: 1;
  position: relative;
  z-index: calc(var(--z-modal) + 1);
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* 按钮背景渐变效果 */
.article-nav__btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(59, 130, 246, 0.08),
    transparent
  );
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: var(--z-base);
}

.article-nav__btn:hover::before {
  left: 100%;
}

/* 按钮内容层级 */
.article-nav__btn > * {
  position: relative;
  z-index: 1;
}

/* Hover 状态 - 高级交互效果 */
.article-nav__btn:hover {
  background: var(--color-surface-elevated);
  border-color: var(--color-accent);
  color: var(--color-accent);
  transform: translateX(-6px) translateY(-2px);
  box-shadow: var(--shadow-lg), 
              0 0 0 4px var(--color-accent-soft),
              0 8px 24px -4px rgba(59, 130, 246, 0.2);
}

/* Active 状态 */
.article-nav__btn:active {
  transform: translateX(-4px) translateY(0);
  box-shadow: var(--shadow-md);
}

/* Focus 状态 - 无障碍支持 */
.article-nav__btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
  border-radius: 16px;
}

/* 图标样式 - 高级动画 */
.article-nav__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
  flex-shrink: 0;
}

.article-nav__icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  transition: fill 0.3s ease;
}

/* 图标动画 - 向左滑动并轻微旋转 */
.article-nav__btn:hover .article-nav__icon {
  transform: translateX(-4px) rotate(-8deg);
}

/* 按钮文字样式 */
.article-nav__text {
  font-weight: 600;
  transition: color 0.3s ease;
  white-space: nowrap;
}

/* 暗色模式优化 */
html[data-theme="dark"] .article-nav__btn,
body[theme="dark"] .article-nav__btn {
  background: var(--color-surface-elevated);
  border-color: var(--color-border);
  box-shadow: var(--shadow-md);
}

html[data-theme="dark"] .article-nav__btn:hover,
body[theme="dark"] .article-nav__btn:hover {
  background: var(--color-surface);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-xl),
              0 0 0 4px var(--color-accent-soft),
              0 8px 24px -4px rgba(96, 165, 250, 0.3);
}

/* 响应式优化 */
@media (max-width: 768px) {
  .article-nav {
    padding: 0 1.5rem;
    margin-bottom: 2rem;
  }

  .article-nav__btn {
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
    gap: 0.625rem;
  }

  .article-nav__icon {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .article-nav__btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    border-radius: 12px;
  }

  .article-nav__icon {
    font-size: 1.125rem;
  }
}

/* 确保 DoIt 主题的样式正确应用 */
.page.single {
  /* DoIt 主题的样式会通过主题 CSS 自动应用 */
  padding-top: 5rem; /* 为返回按钮和标题留出空间，避开sticky header */
}


/* 文章内容区域样式增强 */
.page.single .content {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--color-text);
}

.page.single .content h2 {
  font-size: 2rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
}

.page.single .content h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2rem 0 1rem;
  color: var(--color-text);
}

.page.single .content h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  color: var(--color-text);
}

.page.single .content p {
  margin: 1rem 0;
  color: var(--color-text);
}

.page.single .content code:not(.chroma) {
  /* 内联代码整体一个连续背景，而不是每行一个方块 */
  display: inline;
  white-space: pre-wrap;
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: 4px;
  padding: 0.125rem 0.375rem;
  font-size: 0.9em;
  color: var(--color-accent);
}

.page.single .content pre {
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

/* 让主题自带的 .code-block 负责样式，避免重复边框 */
.page.single .content .code-block pre {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
}

/* 优化代码块整体卡片外观，只保留一层边框和背景 */
.page.single .content .code-block {
  border: 1px solid var(--color-code-border);
  border-radius: 8px;
  background: var(--color-code-bg);
}

.page.single .content .code-block > div.tw-flex.tw-flex-row.tw-flex-1.tw-justify-between.tw-w-full.tw-bg-bgColor-secondary {
  /* 去掉头部额外底色，让它融入整体卡片 */
  background: transparent;
  border-bottom: 1px solid var(--color-code-border);
  border-radius: 8px 8px 0 0;
}

.page.single .content blockquote {
  border-left: 4px solid var(--color-accent);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--color-text-muted);
  font-style: italic;
}

.page.single .content ul,
.page.single .content ol {
  margin: 1rem 0;
  padding-left: 2rem;
}

.page.single .content li {
  margin: 0.5rem 0;
  color: var(--color-text);
}

.page.single .content a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.page.single .content a:hover {
  color: var(--color-accent-hover);
  text-decoration: none;
}

.page.single .content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.page.single .content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.page.single .content table th,
.page.single .content table td {
  border: 1px solid var(--color-border);
  padding: 0.75rem;
  text-align: left;
}

.page.single .content table th {
  background: var(--color-surface-muted);
  font-weight: 600;
}

/* ========== 浮动 TOC ========== */
.floating-toc {
  position: fixed;
  top: 50%;
  right: 2rem;
  transform: translateY(-50%);
  width: 280px;
  max-height: 70vh;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  z-index: var(--z-modal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
  visibility: visible;
  opacity: 1;
}

/* 确保默认 collapsed 状态 */
.floating-toc:not(.expanded) {
  width: 50px;
  min-width: 50px;
  min-height: 50px;
}

.floating-toc:not(.expanded) .floating-toc__content {
  display: none !important;
}

.floating-toc:not(.expanded) .floating-toc__title {
  display: none;
}

.floating-toc:not(.expanded) .floating-toc__header {
  padding: 0.75rem;
  justify-content: center;
  border-bottom: none;
}

.floating-toc:not(.expanded) .floating-toc__toggle {
  width: 100%;
  height: 100%;
  font-size: 1.5rem;
}

/* 隐藏 DoIt 主题的默认固定 TOC（使用浮动 TOC 替代） */
#toc-auto {
  display: none !important;
}

.floating-toc.collapsed {
  width: 50px;
  min-width: 50px;
  height: auto;
  min-height: 50px;
}

.floating-toc.collapsed .floating-toc__content {
  display: none !important;
}

.floating-toc.collapsed .floating-toc__title {
  display: none;
}

.floating-toc.collapsed .floating-toc__header {
  padding: 0.75rem;
  justify-content: center;
  border-bottom: none;
}

.floating-toc.collapsed .floating-toc__toggle {
  width: 100%;
  height: 100%;
  font-size: 1.5rem;
}

.floating-toc__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.floating-toc__title {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text);
  margin: 0;
}

.floating-toc__toggle {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.floating-toc.collapsed .floating-toc__toggle {
  width: 100%;
  font-size: 1.5rem;
}

.floating-toc__toggle:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.floating-toc__content {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.floating-toc__content::-webkit-scrollbar {
  width: 6px;
}

.floating-toc__content::-webkit-scrollbar-track {
  background: transparent;
}

.floating-toc__content::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.floating-toc__content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.floating-toc__content li {
  margin: 0.5rem 0;
}

.floating-toc__content a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.6;
  display: block;
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.floating-toc__content a:hover {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

.floating-toc__content a.active {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  font-weight: 600;
}

.floating-toc__content li.active > a {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

/* TOC 层级缩进 - 支持 h1, h2, h3 */
.floating-toc__content ul ul {
  margin-left: 1rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--color-border);
  margin-top: 0.25rem;
}

.floating-toc__content ul ul ul {
  margin-left: 1rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--color-border);
  margin-top: 0.25rem;
}

/* h1 标题样式 */
.floating-toc__content > ul > li > a {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
}

/* h2 标题样式 */
.floating-toc__content > ul > li > ul > li > a {
  font-weight: 500;
  font-size: 0.85rem;
}

/* h3 标题样式 */
.floating-toc__content > ul > li > ul > li > ul > li > a {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--color-text-subtle);
}

/* ========== 文章导航 ========== */
.article-navigation {
  display: none !important; /* 隐藏上一篇/下一篇导航 - 用户反馈是多余的 */
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.article-navigation__link {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--color-text);
  transition: all 0.3s ease;
}

.article-navigation__link:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.article-navigation__link--prev {
  text-align: left;
}

.article-navigation__link--next {
  text-align: right;
}

.article-navigation__label {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.article-navigation__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-text-muted);
}

/* ========== 响应式设计 ========== */
@media (max-width: 1024px) {
  .floating-toc {
    right: 1rem;
    width: 240px;
    max-width: calc(100vw - 2rem);
  }
  
  .floating-toc.collapsed {
    width: 50px;
  }
}

@media (max-width: 768px) {
  .floating-toc {
    display: none; /* 移动端隐藏 TOC */
  }
}

@media (max-width: 768px) {
  .page.posts-page,
  .posts-page {
    padding: 3rem 1.5rem;
    min-height: calc(100vh - 150px);
  }

  .posts-page__header {
    margin-bottom: 3rem;
  }

  .section-page,
  .article-single {
    padding: 2rem 1.5rem 3rem;
  }

  .category-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .category-card__link {
    flex-direction: column;
    text-align: center;
    padding: 2rem 1.5rem;
  }

  .category-card__icon {
    font-size: 3rem;
  }

  .bookmark-grid {
    grid-template-columns: 1fr;
  }

  .section-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .article-navigation {
    grid-template-columns: 1fr;
  }

  .article-navigation__link--next {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .posts-page__header h1,
  .section-nav__title h1 {
    font-size: 2rem;
  }

  .category-card__title,
  .bookmark-card__title {
    font-size: 1.25rem;
  }

  .article-card__title {
    font-size: 1.25rem;
  }
}

