/* ============================================
   三栏布局样式 (Three Column Layout)
   ============================================
   参考 hugo-book 主题的三栏布局设计
============================================ */

/* ============================================
   三栏布局容器
============================================ */
.three-column-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-width);
  gap: 1.5rem;
  max-width: 80%;
  /* 原代码 */
  margin: 0 auto;
  padding: 5rem 2rem 2rem;
  min-height: 100vh;
}


/* ============================================
   左侧边栏
============================================ */
.left-sidebar {
  position: sticky;
  top: 5rem;
  height: fit-content;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.left-sidebar .sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* 个人名片 */
.profile-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: all 0.3s ease;
}

.profile-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.profile-link {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #e0f2fe;
  margin-bottom: 1rem;
}

.profile-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.profile-bio {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.back-home {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--primary);
}

/* 公告卡片 */
.announcement-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: #f97316;
}

.card-header h4 {
  font-size: 0.875rem;
  font-weight: 600;
}

.announcement-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.announcement-link {
  font-size: 0.875rem;
  color: var(--primary);
  transition: color 0.2s;
}

.announcement-link:hover {
  color: var(--primary-hover);
}

/* Archive链接 */
.archive-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  font-weight: 500;
  transition: all 0.3s ease;
}

.archive-link:hover {
  box-shadow: var(--shadow-md);
  color: var(--primary);
}

.archive-link .arrow {
  margin-left: auto;
  transition: transform 0.2s;
}

.archive-link:hover .arrow {
  transform: translateX(4px);
}



/* ============================================
   中间内容区
============================================ */
.main-content {
  min-width: 0;
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* 页面头部 */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.page-description {
  color: var(--text-secondary);
}

/* 文章列表 */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-entry {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

.post-entry:hover {
  box-shadow: var(--shadow-md);
  border-color: #dbeafe;
  transform: translateY(-2px);
}

.entry-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.entry-title a {
  color: var(--text-primary);
  transition: color 0.2s;
}

.entry-title a:hover {
  color: var(--primary);
}

.entry-content {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.entry-content p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.entry-footer span {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.entry-footer svg {
  width: 14px;
  height: 14px;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.pagination a {
  color: var(--primary);
  font-weight: 500;
  transition: color 0.2s;
}

.pagination a:hover {
  color: var(--primary-hover);
}

.page-number {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* 单篇文章 */
.post-single {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.post-single .post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.post-single .post-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  text-align: center;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  justify-content: center;
  margin-bottom: 0.75rem;
}

.post-meta span {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.post-meta a {
  color: var(--primary);
}

.post-meta a:hover {
  text-decoration: underline;
}

.post-content {
  color: var(--text-secondary);
  line-height: 1.8;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  color: var(--text-primary);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.post-content h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.post-content p {
  margin-bottom: 1rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content code {
  background: var(--bg-code);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.875em;
}

.post-content pre {
  background: var(--bg-code);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.post-tags {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.post-tags .tag {
  padding: 0.375rem 0.75rem;
  background: #f3f4f6;
  border-radius: 9999px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.post-tags .tag:hover {
  background: #eff6ff;
  color: var(--primary);
}

/* 文章头部标签样式 */
.post-tags-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.post-tags-header .tag {
  padding: 0.375rem 0.75rem;
  background: #f3f4f6;
  border-radius: 9999px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.post-tags-header .tag:hover {
  background: #eff6ff;
  color: var(--primary);
}

/* 返回按钮样式 */
.post-tags-header .tag-back {
  background: #e5e7eb;
  color: var(--text-secondary);
}

.post-tags-header .tag-back:hover {
  background: #d1d5db;
  color: var(--text-primary);
}

/* 目录层级标签样式 */
.post-tags-header .tag-folder {
  background: #f3f4f6;
  color: var(--text-secondary);
}

.post-tags-header .tag-folder:hover {
  background: #eff6ff;
  color: var(--primary);
}

/* 标签图标样式 */
.post-tags-header .tag-icon {
  display: inline-flex;
  align-items: center;
  margin-right: -0.25rem;
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.post-nav a {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
  transition: all 0.2s;
}

.post-nav a:hover {
  background: #eff6ff;
}

.post-nav .next {
  text-align: right;
  grid-column: 2;
}

.nav-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.nav-title {
  font-weight: 500;
  color: var(--text-primary);
}

/* Archive页面 */
.archive-header {
  margin-bottom: 2rem;
}

.archive-header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.archive-count {
  color: var(--text-secondary);
}

.archive-count strong {
  color: var(--primary);
}

.archive-year {
  margin-bottom: 2.5rem;
}

.year-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}

.year-posts {
  list-style: none;
}

.post-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.625rem 0.5rem;
  border-radius: 6px;
  transition: background 0.2s;
}

.post-item:hover {
  background: #f9fafb;
}

.post-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-color);
  flex-shrink: 0;
}

.post-item:hover .post-bullet {
  background: var(--primary);
}

.post-title {
  flex: 1;
  color: var(--text-primary);
  font-size: 0.9375rem;
}

.post-item:hover .post-title {
  color: var(--primary);
}

.post-date {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* About页面 */
.about-page {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.about-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}

.about-avatar a {
  display: block;
  transition: transform 0.3s;
}

.about-avatar a:hover {
  transform: scale(1.05);
}

.about-avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: var(--shadow-md);
}

.about-content h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.about-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.about-content p {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 1rem;
}

.about-content ul {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.about-content li {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.about-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* ============================================
   右侧边栏
============================================ */
.right-sidebar {
  position: sticky;
  top: 5rem;
  height: fit-content;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.right-sidebar .sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* 搜索框 */
.search-box {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input-wrapper input {
  width: 100%;
  padding: 0.625rem 0.75rem 0.625rem 2.5rem;
  background: #f9fafb;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: all 0.2s;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.search-input-wrapper input::placeholder {
  color: var(--text-muted);
}

.search-results {
  display: none;
  /* 新增：默认彻底隐藏，杜绝占位闪烁 */
  margin-left: 1rem;
  /* 新增：整体向右偏移一点 */
  width: calc(100% - 1rem);
  /* 新增：减去偏移量，防止右侧超出面板 */
  margin-top: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

/* TOC */

.toc-wrapper {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  /* 增加与其他卡片相同的统一内边距 */
  box-shadow: var(--shadow-sm);
}

.toc-wrapper .section-header {
  color: var(--primary);
  /* 让标题图标呈现网站主色调（蓝色），以区分其他卡片的绿/橙色 */
}

.toc-content {
  max-height: 300px;
  overflow-y: auto;
  /* 移除了原本的 padding，因为外层 wrapper 已经统一设置了 */
}

.toc-content ul {
  list-style: none;
}

.toc-content li {
  margin-bottom: 0.1rem;
}

.toc-content a {
  display: block;
  padding: 0.2rem 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.2s;
}

.toc-content a:hover {
  background: #eff6ff;
  color: var(--primary);
}

/* 新增：让多级目录的父容器统一缩进，1.2rem 大致等同于 4 个空格的视觉宽度 */
.toc-content ul ul {
  padding-left: 1.2rem;
}

.toc-content ul ul a {
  padding-left: 0.5rem;
  /* 去掉以前写死的左缩进，让外层 ul 去负责缩进 */
  font-size: 0.8125rem;
}

/* 广告位 */
.ad-space {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.ad-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.ad-content {
  background: linear-gradient(135deg, #eff6ff 0%, #f3e8ff 100%);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
}

.ad-content p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.ad-contact {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* 友情链接 */
.friend-links {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: #22c55e;
}

.section-header h4 {
  font-size: 0.875rem;
  font-weight: 600;
}

.links-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.friend-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.friend-link:hover {
  color: var(--primary);
}

/* 网站资讯 */
.site-info {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.site-info .section-header {
  color: #f97316;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.info-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ============================================
   响应式
============================================ */
@media (max-width: 1200px) {
  .three-column-layout {
    grid-template-columns: 240px 1fr 240px;
    gap: 1.5rem;
  }
}

@media (max-width: 1024px) {
  .three-column-layout {
    grid-template-columns: 1fr;
    padding-top: 4rem;
  }

  .left-sidebar,
  .right-sidebar {
    display: none;
  }

  .main-content {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .three-column-layout {
    padding: 1rem;
  }

  .post-single {
    padding: 1.5rem;
  }

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

  .post-nav {
    grid-template-columns: 1fr;
  }

  .post-nav .next {
    grid-column: 1;
  }
}

/* ============================================
   轮换面板样式 (友情链接 & 网站资讯)
============================================ */
.widget-carousel {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.carousel-tabs {
  display: flex;
  justify-content: center;
  /* 新增：让两个标签在面板中水平居中对齐 */
  gap: 2.5rem;
  /* 修改：把间距稍微调大一点，视觉上更平衡对称 */
  margin-bottom: 1rem;
  border-bottom: 2px solid #f3f4f6;
  padding-bottom: 0.5rem;
}

.carousel-tab {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color 0.3s;
}

.carousel-tab:hover {
  color: var(--primary);
}

.carousel-tab.active {
  color: var(--primary);
}

/* 当前激活标签底部的蓝线 */
.carousel-tab.active::after {
  content: '';
  position: absolute;
  bottom: -0.6rem;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

.carousel-pane {
  display: none;
  animation: fadeIn 0.4s ease;
  /* 切换时的淡入动画 */
}

.carousel-pane.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ============================================
   左侧边栏 - 笔记目录 (.nav-menu)
============================================ */
.nav-menu {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.menu-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: var(--primary);
  /* 与右侧边栏统一蓝色主色调 */
}

.menu-header span {
  font-size: 0.875rem;
  font-weight: 600;
}

.menu-content {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  /* 从 0.25rem 缩小：拉近文件夹/文件之间的整体行距 */
}

/* 文件夹层级 */
.menu-folder {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.1rem 0.5rem;
  /* 从 0.4rem 缩小：减小文件夹上下内边距，使其与右侧目录行高一致 */
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: background 0.2s;
  list-style: none;
  user-select: none;
}

.menu-folder::-webkit-details-marker {
  display: none;
}

/* 兼容 Safari */

.menu-folder:hover {
  background: #f3f4f6;
}

/* 自定义翻页小三角 */
.folder-toggle-icon {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--text-muted);
  transition: transform 0.2s ease;
}

details[open]>.menu-folder .folder-toggle-icon {
  transform: rotate(90deg);
  /* 展开时箭头朝下 */
}

.folder-name {
  flex: 1;
}

/* 文件夹里的文章数量标签 */
.folder-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #e5e7eb;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
}

/* 子文件列表 */
.folder-children {
  padding-left: 1.7rem;
  margin-top: 0.1rem;
  /* 从 0.25rem 缩小：让子文件更贴近其父文件夹 */
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.menu-item {
  display: block;
  padding: 0.1rem 0.5rem;
  /* 从 0.3rem 缩小：减小文章链接的上下内边距 */
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.2s;
  text-decoration: none;
}

.menu-item:hover,
.menu-item.active {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 500;
}

/* ============================================
   左侧边栏 - 热门标签 (.tags-widget)
============================================ */
.tags-widget {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.widget-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  /* 稍微缩小标题和标签堆的距离 */
  color: #8b5cf6;
}

.widget-header span {
  font-size: 0.875rem;
  font-weight: 600;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  /* 前面是上下间距，后面是左右间距，调小让排列更紧密 */
  gap: 0.35rem 0.4rem;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  /* 缩小文字和数字的间距 */
  padding: 0.15rem 0.5rem;
  /* 极大缩小上下内边距，显得小巧 */
  background: #f3f4f6;
  /* 用淡灰底色代替硬边框，看起来更柔和 */
  border: 1px solid transparent;
  border-radius: 9999px;
  /* 绝对圆角，呈现经典的胶囊/药丸形状 */
  font-size: 0.75rem;
  /* 保持较小的字号 */
  color: var(--text-secondary);
  transition: all 0.2s ease;
  text-decoration: none;
}

.tag-badge:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  /* 鼠标放上去加一点轻微的浮动阴影 */
}

.tag-num {
  font-size: 0.65rem;
  /* 数字进一步缩小 */
  background: rgba(0, 0, 0, 0.06);
  padding: 0.05rem 0.3rem;
  /* 减少数字背景块的厚度 */
  border-radius: 9999px;
  /* 数字的背景也变成圆角胶囊 */
}

.tag-badge:hover .tag-num {
  background: rgba(255, 255, 255, 0.25);
}