/* Cards Component */

.site-card {
  display: flex;
  align-items: center;
  padding: 1rem;
  /* More generous padding */
  gap: 0.8rem;
  background-color: var(--site-card-bg-gradient-1);
  /* Solid color */
  border-radius: var(--radius-lg);
  /* Larger radius */
  text-decoration: none;
  color: var(--text-color);
  transition:
    transform var(--transition-normal),
    box-shadow var(--transition-normal),
    background-color var(--transition-normal);
  /* Spring transition */
  position: relative;
  overflow: hidden;
  border: 0.5px solid var(--border-color);
  /* Subtle separator */
  /* Remove hard shadow by default for cleaner look, only adding on hover or using very subtle depth */
}

.site-card:hover {
  transform: translateY(-2px) scale(1.01);
  /* Subtle scale */
  background-color: var(--site-card-hover-bg);
  box-shadow: 0 8px 20px var(--shadow-color);
  /* Deep soft shadow */
  z-index: 2;
  border-color: transparent;
  /* Merge with shadow */
}

/* 分类样式 */
.category {
  background: linear-gradient(145deg, var(--card-bg-gradient-1), var(--card-bg-gradient-2));
  border-radius: var(--radius-xl);
  padding: 1rem;
  margin: 0 auto 1.2rem auto;
  width: 100%;
  max-width: var(--page-max-width);
  position: relative;
  z-index: 1;
  opacity: 1;
  box-shadow: 0 4px 20px var(--shadow-color);
  border: 1px solid var(--border-color);
  transition:
    background var(--transition-normal),
    box-shadow var(--transition-normal);
}

/* 分类标题容器 */
.category-header {
  border-radius: var(--radius-md);
  padding: 0.4rem;
  margin: -0.4rem -0.4rem 0.8rem -0.4rem;
  transition: all var(--transition-normal);
}

/* 标题前图标固定宽度：避免不同图标宽度导致标题文本不对齐 */
.category-header [data-editable='category-name'] > i,
.group-header [data-editable='group-name'] > i {
  width: 1.25em;
  min-width: 1.25em;
  text-align: center;
  flex: 0 0 1.25em;
}

/* 分组标题容器：与分类保持一致的悬浮动效基础 */
.group-header {
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
}

/* 仅可折叠的标题显示交互态 */
.category-header[data-toggle='category'],
.group-header[data-toggle='group'] {
  cursor: pointer;
  user-select: none;
}

.category-header[data-toggle='category']:hover {
  transform: translateY(-2px);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
}

.group-header[data-toggle='group']:hover {
  transform: translateY(-2px);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
}

.category-header[data-toggle='category']:active {
  transform: translateY(0);
}

.group-header[data-toggle='group']:active {
  transform: translateY(0);
}

.category h2 {
  font-size: 1.2rem;
  margin-bottom: 0;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  letter-spacing: 0.3px;
  transition: color 0.3s ease;
}

.category h2 > i {
  color: var(--accent-color);
  font-size: 1.3rem;
  transition: all 0.3s ease;
}

.category-header[data-toggle='category']:hover h2 > i {
  transform: scale(1.1);
  color: var(--accent-hover);
}

/* 多层级嵌套样式 - 扁平化设计 */

/* 通用重置：移除所有嵌套层级的卡片背景和边框 */
.category-level-2,
.category-level-3,
.category-level-4,
.group-level-3,
.group-level-4 {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  width: 100%;
  margin: 0;
}

/* 嵌套层级指示线 (Hierarchy Indicator A) */
.category-level-2::before,
.category-level-3::before,
.group-level-3::before,
.category-level-4::before,
.group-level-4::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: var(--border-color);
  opacity: 0.6;
}

/* 层级2: 子分类 */
.category-level-2 {
  margin-top: 0;
  margin-bottom: 0;
  padding-left: 1rem;
  border-left: none;
  position: relative;
}

/* 层级2: 标题样式 */
.category-level-2 .category-header {
  margin: 0 -0.5rem 1rem -0.5rem;
  padding: 0.5rem;
  background: none;
  border-radius: var(--radius-md);
}

.category-level-2 .category-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.category-level-2 .category-header h3 > i {
  color: var(--accent-color);
  font-size: 1.2rem;
  opacity: 0.9;
}

/* 层级3: 分组 */
.group-level-3,
.category-level-3 {
  margin-top: 0;
  margin-bottom: 0;
  padding-left: 1rem;
  position: relative;
}

/* 层级3: 标题样式 */
.group-level-3 .group-header,
.category-level-3 .category-header {
  margin: 0 0 0.8rem 0;
  padding: 0.3rem 0;
  background: none;
}

.group-level-3 .group-header h4,
.category-level-3 .category-header h4 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.group-level-3 .group-header h4 i,
.category-level-3 .category-header h4 i {
  color: var(--text-muted);
  font-size: 1rem;
}

/* 层级4: 子分组 */
.group-level-4,
.category-level-4 {
  margin-top: 0;
  margin-bottom: 0;
  padding-left: 1rem;
  position: relative;
}

/* 嵌套层级间距：仅在同级相邻时增加间距，避免首项被额外下推 */
.subcategories-container > .category-level-2 + .category-level-2 {
  margin-top: 1rem;
}

.groups-container > .group-level-3 + .group-level-3,
.groups-container > .category-level-3 + .category-level-3 {
  margin-top: 0.8rem;
}

.subgroups-container > .group-level-4 + .group-level-4,
.subcategories-container > .category-level-4 + .category-level-4 {
  margin-top: 0.6rem;
}

/* 层级4: 标题样式 */
.group-level-4 .group-header,
.category-level-4 .category-header {
  margin: 0 0 0.6rem 0;
  padding: 0.2rem 0;
  background: none;
}

.group-level-4 .group-header h5,
.category-level-4 .category-header h5 {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.group-level-4 .group-header h5 i,
.category-level-4 .category-header h5 i {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* 移除悬停时的缩放效果，保持简洁 */
.category-level-2 .category-header:hover h3 > i,
.group-level-3 .group-header:hover h4 i,
.category-level-3 .category-header:hover h4 i,
.group-level-4 .group-header:hover h5 i,
.category-level-4 .category-header:hover h5 i {
  transform: none;
}

/* 切换图标样式 */
.category-header .toggle-icon,
.group-header .toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.category-header .toggle-icon i,
.group-header .toggle-icon i {
  transition:
    transform 0.3s ease,
    color 0.3s ease;
  transform: rotate(0deg);
}

/* 展开态：图标旋转 180°（类似参考样式1） */
.category:not(.collapsed) > .category-header .toggle-icon i,
.group:not(.collapsed) > .group-header .toggle-icon i {
  transform: rotate(180deg);
  color: var(--text-bright);
}

.category-header[data-toggle='category']:hover .toggle-icon i,
.group-header[data-toggle='group']:hover .toggle-icon i {
  color: var(--accent-color);
}

/* 分类/分组折叠图标：桌面端默认隐藏，悬停/收起时显示，避免按钮过多 */
@media (hover: hover) and (pointer: fine) {
  .category-header .toggle-icon,
  .group-header .toggle-icon {
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .category-header[data-toggle='category']:hover .toggle-icon,
  .category.collapsed > .category-header .toggle-icon,
  .group-header[data-toggle='group']:hover .toggle-icon,
  .group.collapsed > .group-header .toggle-icon {
    opacity: 1;
  }
}

/* 展开/折叠动画 */
.category-content,
.group-content {
  overflow: visible;
  transition:
    max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 5000px;
  opacity: 1;
}

.category.collapsed .category-content,
.group.collapsed .group-content {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

/* 收起状态下调整header的下边距 */
.category.collapsed > .category-header {
  margin-bottom: -0.5rem;
}

.category-level-2.collapsed > .category-header {
  margin-bottom: 0;
  border-bottom: none;
}

.group-level-3.collapsed > .group-header,
.category-level-3.collapsed > .category-header {
  margin-bottom: 0;
}

.group-level-4.collapsed > .group-header,
.category-level-4.collapsed > .category-header {
  margin-bottom: 0;
}

/* 收起态默认向下，无需额外旋转（保持 0deg） */

/* 空内容提示 */
.empty-content {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
}

/* 子容器样式 */
.subcategories-container,
.groups-container {
  width: 100%;
}

/* 当分类同时包含子分类和站点时的样式优化 */
.category-content .subcategories-container + .sites-grid {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* 当分类同时包含分组和站点时的样式优化 */
.category-content .groups-container + .sites-grid {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* 子分类容器底部间距调整 */
.category-content .subcategories-container:not(:last-child),
.category-content .groups-container:not(:last-child) {
  margin-bottom: 0.6rem;
}

/* 确保嵌套的网站网格正确显示 */
.category-level-2 .sites-grid,
.group-level-3 .sites-grid,
.category-level-3 .sites-grid,
.group-level-4 .sites-grid,
.category-level-4 .sites-grid {
  margin-top: 0;
  gap: 0.75rem;
  /* 保持与顶层一致的网格布局 */
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* 响应式设计 - 嵌套结构 */
@media (max-width: 768px) {
  .category-level-2 {
    padding-left: 0.75rem;
  }

  .group-level-3,
  .category-level-3 {
    padding-left: 0.75rem;
  }

  .group-level-4,
  .category-level-4 {
    padding-left: 0.75rem;
  }

  .subcategories-container > .category-level-2 + .category-level-2 {
    margin-top: 0.8rem;
  }

  .groups-container > .group-level-3 + .group-level-3,
  .groups-container > .category-level-3 + .category-level-3 {
    margin-top: 0.7rem;
  }

  .subgroups-container > .group-level-4 + .group-level-4,
  .subcategories-container > .category-level-4 + .category-level-4 {
    margin-top: 0.55rem;
  }

  .category-level-2 .sites-grid,
  .group-level-3 .sites-grid,
  .category-level-3 .sites-grid,
  .group-level-4 .sites-grid,
  .category-level-4 .sites-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-sm);
  }
}

@media (max-width: 480px) {
  .category {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    padding: 1rem;
  }

  .category-level-2,
  .group-level-3,
  .category-level-3 {
    margin-left: 0;
    padding-left: 0.75rem;
    width: 100%;
  }

  .group-level-4,
  .category-level-4 {
    margin-left: 0;
    padding-left: 0.75rem;
    width: 100%;
  }

  .category-level-2 .sites-grid,
  .group-level-3 .sites-grid,
  .category-level-3 .sites-grid,
  .group-level-4 .sites-grid,
  .category-level-4 .sites-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }
}

/* 网站卡片网格 */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  position: relative;
  z-index: 1;
  width: 100%;
}

/* projects：GitHub 热力图（github-calendar.js，底部展示） */
.page-template-projects .gh-heatmap-category {
  /* 外层已复用一级分类卡片（.category），这里仅保留热力图内部布局/色阶 */
  --gh-text: var(--text-color);
  --gh-text-muted: var(--text-muted);
  --gh-level-0: rgba(255, 255, 255, 0.08);
  --gh-level-1: rgba(55, 178, 77, 0.35);
  --gh-level-2: rgba(55, 178, 77, 0.55);
  --gh-level-3: rgba(55, 178, 77, 0.75);
  --gh-level-4: rgba(55, 178, 77, 0.95);
  --gh-radius: 3px;

  margin: 0 auto 1.2rem auto;
}

.page-template-projects .gh-heatmap-wrapper {
  margin-top: 0;
}

/* 浅色主题：更接近 GitHub 原色阶 */
html.theme-preload .page-template-projects .gh-heatmap-category,
body.light-theme .page-template-projects .gh-heatmap-category {
  /* 浅色主题下，空格子需要比背景更明显一点 */
  --gh-level-0: #d8dee4;
  --gh-level-1: #9be9a8;
  --gh-level-2: #40c463;
  --gh-level-3: #30a14e;
  --gh-level-4: #216e39;
}

/* 标题中的用户名（@xxx）更弱化一点，像副标题 */
.page-template-projects .gh-heatmap-username {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.35rem;
}

/* 使用一级分类标题的排版节奏，略收紧热力图区域 */
.page-template-projects .gh-heatmap-category .category-header {
  margin-bottom: 0.8rem;
}

/* 标题行：左侧标题 + 右侧 legend（不占内容区高度） */
.page-template-projects .gh-heatmap-category .gh-heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.page-template-projects .gh-heatmap-category .gh-heatmap-header h2 {
  margin: 0;
}

/* 让 legend 与标题体系保持一致：放在标题区右侧 */
.page-template-projects .gh-heatmap-category .gh-legend {
  justify-content: flex-end;
  margin: 0;
}

.page-template-projects .gh-header {
  display: none;
}

.page-template-projects .gh-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--gh-text-muted);
  white-space: nowrap;
}

/* heatmap：移动端标题/legend 文本简写 */
.gh-text-mobile {
  display: none;
}

@media (max-width: 480px) {
  .gh-text-desktop {
    display: none;
  }

  .gh-text-mobile {
    display: inline;
  }

  .page-template-projects .gh-heatmap-category .gh-heatmap-header {
    flex-wrap: wrap;
  }

  .page-template-projects .gh-heatmap-category .gh-legend {
    gap: 2px;
    font-size: 0.7rem;
  }

  .page-template-projects .gh-legend-item {
    width: 8px;
    height: 8px;
  }
}

.page-template-projects .gh-legend-item {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.page-template-projects .gh-legend .level-0 {
  background-color: var(--gh-level-0);
}

.page-template-projects .gh-legend .level-1 {
  background-color: var(--gh-level-1);
}

.page-template-projects .gh-legend .level-2 {
  background-color: var(--gh-level-2);
}

.page-template-projects .gh-legend .level-3 {
  background-color: var(--gh-level-3);
}

.page-template-projects .gh-legend .level-4 {
  background-color: var(--gh-level-4);
}

/* github-calendar 注入的内容容器 */
.page-template-projects .gh-calendar {
  border: none !important;
  min-height: 0;
  width: 100%;
  /* 构建期注入：避免 flex 居中导致内容超宽“撑破卡片” */
  display: block;
}

/* 顶部统计标题：XXX contributions in the last year */
.page-template-projects .gh-calendar #js-contribution-activity-description {
  /* 注意：全局 .category h2 会把 h2 设为 flex，导致“看起来左对齐”。这里强制回退为 block。 */
  display: block;
  width: 100%;
  text-align: center;
  margin: 0 0 12px 0;
}

/* 外层包裹：强制占满卡片宽度，滚动发生在内部 */
.page-template-projects .gh-calendar .graph-before-activity-overview {
  width: 100%;
}

/* 允许移动端横向滚动查看（GitHub 风格） */
.page-template-projects .gh-calendar .js-calendar-graph {
  width: 100%;
  /* 构建期注入 GitHub 原生 table：滚动交给内层容器，避免裁剪 */
  display: block;
}

/* GitHub 原生 markup：通常在 .js-calendar-graph 内有一个 div 设置 overflow-x */
.page-template-projects .gh-calendar .js-calendar-graph > div {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  /* 由 table 的 margin:auto 来实现“可居中 + 可滚动时左对齐起始列” */
  display: block;
  padding-bottom: 10px;
}

.page-template-projects .gh-calendar .js-calendar-graph-svg {
  width: 100%;
  height: auto;
}

/* 覆盖每个方块的颜色（依赖 github-calendar 的 data-level） */
.page-template-projects .gh-calendar .day {
  rx: var(--gh-radius);
  ry: var(--gh-radius);
  outline: none;
}

.page-template-projects .gh-calendar .day[data-level='0'] {
  fill: var(--gh-level-0);
}

.page-template-projects .gh-calendar .day[data-level='1'] {
  fill: var(--gh-level-1);
}

.page-template-projects .gh-calendar .day[data-level='2'] {
  fill: var(--gh-level-2);
}

.page-template-projects .gh-calendar .day[data-level='3'] {
  fill: var(--gh-level-3);
}

.page-template-projects .gh-calendar .day[data-level='4'] {
  fill: var(--gh-level-4);
}

.page-template-projects .gh-calendar text {
  fill: var(--gh-text-muted);
  font-size: 10px;
}

/* 去掉库自带 footer（更简洁） */
.page-template-projects .gh-calendar .contrib-footer {
  display: none !important;
}

.page-template-projects .gh-calendar.gh-calendar-error {
  color: var(--gh-text-muted);
  font-size: 0.85rem;
}

/* github-calendar（HTML table 版）：适配 ContributionCalendar-* 类名 */
.page-template-projects .gh-calendar table {
  /* 让热力图在卡片内尽量铺满宽度；需要时仍可横向滚动 */
  /* 关键：避免 table 按列拉伸导致 day 变成长方形 */
  display: table;
  /* 不强制占满：保持自然宽度，并在容器内居中 */
  width: max-content;
  min-width: max-content;
  max-width: none;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 5px !important;
  /* table 未超宽时居中；超宽时 margin auto 会退化为 0（滚动起始列左对齐） */
  margin: 0 auto;
}

/* GitHub 原生 table：thead 行内写死 height:15px，需强制更高以避免月份 label 压到格子 */
.page-template-projects .gh-calendar table thead tr {
  height: 20px !important;
}

/* GitHub 原生 table 的月份 label 使用 absolute 定位，需要为 thead 行预留高度，避免与格子重叠 */
.page-template-projects .gh-calendar .ContributionCalendar-label {
  height: 16px;
  position: relative;
  padding-bottom: 4px;
  font-size: 10px;
  line-height: 10px;
  font-weight: 400;
  vertical-align: bottom;
}

@media (max-width: 600px) {
  /* 移动端：格子更紧凑，减少横向滚动压力 */
  .page-template-projects .gh-calendar table {
    border-spacing: 3px !important;
  }

  .page-template-projects .gh-calendar .ContributionCalendar-day {
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
  }

  .page-template-projects .gh-calendar #js-contribution-activity-description {
    font-size: 0.95rem;
  }
}

/* GitHub 原生 footer：保留“Learn how we count contributions”，隐藏右侧自带 legend（避免与自定义 legend 重复） */
.page-template-projects .gh-calendar .float-right.color-fg-muted.d-flex.flex-items-center {
  display: none !important;
}

/* 按需求：去除 “Learn how we count contributions” */
.page-template-projects .gh-calendar .float-left {
  display: none !important;
}

/* Link--muted 目前不展示（float-left 已隐藏）；保留基础链接色由下方 a 规则兜底 */

.page-template-projects .gh-calendar .ContributionCalendar-day {
  /* 固定正方形，防止被 table 列宽拉伸 */
  width: 15px;
  height: 15px;
  min-width: 15px;
  min-height: 15px;
  aspect-ratio: 1 / 1;
  border-radius: var(--gh-radius);
  background-color: var(--gh-level-0);
}

.page-template-projects .gh-calendar .ContributionCalendar-day[data-level='0'] {
  background-color: var(--gh-level-0) !important;
}

.page-template-projects .gh-calendar .ContributionCalendar-day[data-level='1'] {
  background-color: var(--gh-level-1) !important;
}

.page-template-projects .gh-calendar .ContributionCalendar-day[data-level='2'] {
  background-color: var(--gh-level-2) !important;
}

.page-template-projects .gh-calendar .ContributionCalendar-day[data-level='3'] {
  background-color: var(--gh-level-3) !important;
}

.page-template-projects .gh-calendar .ContributionCalendar-day[data-level='4'] {
  background-color: var(--gh-level-4) !important;
}

/* a11y 跳转链接：视觉隐藏（保留可访问性） */
.page-template-projects .gh-calendar a[href^='#year-list'],
.page-template-projects .gh-calendar a[href*='year-list'],
.page-template-projects .gh-calendar a[href*='contributions-year'],
/* GitHub 注入的 "Skip to contributions year list"（常见为 show-on-focus） */
.page-template-projects .gh-calendar a.show-on-focus {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 隐藏库自带 footer/legend，避免与自定义 legend 重复 */
.page-template-projects .gh-calendar .ContributionCalendar-footer,
.page-template-projects .gh-calendar .contrib-footer,
.page-template-projects .gh-calendar .legend,
/* GitHub 原生 legend 容器（float-right + flex） */
.page-template-projects .gh-calendar .float-right.color-fg-muted.d-flex.flex-items-center {
  display: none !important;
}

/* 修复星期/月份 label 的意外高亮（如 Wed 蓝底） */
.page-template-projects .gh-calendar .ContributionCalendar-label {
  background: transparent !important;
  background-color: transparent !important;
  color: var(--gh-text-muted) !important;
}

/* 组件内链接样式：去掉默认紫色 */
.page-template-projects .gh-calendar a {
  color: var(--gh-text-muted);
  text-decoration: none;
}

.page-template-projects .gh-calendar a:hover {
  color: var(--gh-text);
  text-decoration: underline;
}

/* Mobile text toggling for Heatmap Header：已在上方 heatmap 区域定义，避免重复 */

/* projects：旧版 GitHub 热力图（ghchart 图片）已弃用，改用 github-calendar.js */

.page-template-projects .sites-grid {
  /* projects：桌面端固定 3 列（避免 auto-fill 在中等宽度下退化为 2 列） */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

@media (max-width: 1024px) {
  .page-template-projects .sites-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 600px) {
  .page-template-projects .sites-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* projects：代码仓库风卡片 */
.site-card.site-card-repo {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 1.1rem 1.1rem 1rem;
  gap: 0;
}

.site-card.site-card-repo:hover {
  transform: translateY(-4px);
}

.site-card.site-card-repo .repo-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 12px;
  min-width: 0;
}

.site-card.site-card-repo .repo-icon {
  font-size: 1.15rem;
  color: var(--nav-item-color);
  opacity: 0.85;
  transition:
    color 0.3s ease,
    opacity 0.3s ease;
  flex: 0 0 auto;
}

.site-card.site-card-repo:hover .repo-icon {
  color: var(--accent-color);
  opacity: 1;
}

.site-card.site-card-repo .repo-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-card.site-card-repo .repo-desc {
  font-size: 0.9rem;
  color: var(--nav-item-color);
  opacity: 0.85;
  line-height: 1.5;
  flex-grow: 1;
  margin: 0 0 16px 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
  /* Ensure tooltip positioning context */
}

.site-card.site-card-repo .repo-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
  color: var(--nav-item-color);
  opacity: 0.85;
}

.site-card.site-card-repo .stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.site-card.site-card-repo .lang-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

@media (max-width: 600px) {
  .welcome-section-with-side {
    align-items: flex-start;
  }

  .welcome-section-with-side .welcome-section-side {
    width: 100%;
  }

  /* 旧版 heatmap-container/heatmap-img 已弃用 */
}

/* 网站卡片样式 */
.site-card {
  background: linear-gradient(
    145deg,
    var(--site-card-bg-gradient-1),
    var(--site-card-bg-gradient-2)
  );
  border-radius: var(--radius-lg);
  padding: 0.75rem 0.9rem;
  text-decoration: none;
  color: inherit;
  transition:
    background var(--transition-normal),
    transform var(--transition-normal),
    box-shadow var(--transition-normal),
    border-color var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  backface-visibility: hidden;
  transform: translateZ(0);
  will-change: transform;
  max-width: 100%;
  position: relative;
  box-shadow: 0 4px 16px var(--shadow-color);
  border: 1px solid var(--border-color);
  z-index: 2;
  overflow: hidden;
}

/* 网站卡片变体：projects 大卡片 */
.site-card.site-card-large {
  padding: 1.1rem 1.2rem;
  gap: 0.9rem;
}

.site-card.site-card-large .site-card-icon {
  width: 3.1rem;
  height: 3.1rem;
}

.site-card.site-card-large h3 {
  font-size: 1rem;
  font-weight: 600;
}

.site-card.site-card-large p {
  font-size: 0.9rem;
}

/* Phase 2：articles 页面隐藏“扩展写回结构”，避免与文章条目渲染混淆 */
.menav-extension-shadow {
  display: none;
}

/* articles：文章元信息（日期 + 来源） */
.site-card[data-type='article'] .site-card-meta {
  margin: 0 0 8px 0;
  font-size: 0.75rem;
  color: var(--nav-item-color);
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.site-card[data-type='article'] .site-card-meta-sep {
  opacity: 0.8;
}

/* articles：文章卡片布局（首行：图标+标题；下方：时间/来源 + 简介 全宽对齐） */
.site-card[data-type='article'] {
  display: block;
  padding: 1rem 1.1rem;
}

.site-card[data-type='article'] .article-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.site-card[data-type='article'] .article-card-title {
  min-width: 0;
}

.site-card[data-type='article'] .article-card-body {
  margin-top: 0.55rem;
}

.site-card[data-type='article'] h3 {
  margin: 0;
}

.site-card[data-type='article'] p {
  margin: 0;
}

/* articles：桌面端网格固定 3 列（避免 auto-fill 在大屏上过多列导致阅读密度过高） */
.page-template-articles .sites-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1024px) {
  .page-template-articles .sites-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 480px) {
  .page-template-articles .sites-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

/* articles：标题/描述允许两行显示（更适合多列宽卡片，也适用于搜索结果页） */
.site-card[data-type='article'] h3 {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.site-card[data-type='article'] p {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.site-card:hover {
  transform: translateY(-3px);
  background: var(--site-card-hover-bg);
  border-color: var(--border-color);
}

.site-card-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: rgba(var(--card-bg-rgb), 0.35);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.3s ease,
    background-color 0.3s ease;
}

.site-card .site-icon {
  font-size: 1.4rem;
  color: var(--accent-color);
  transition: color 0.3s ease;
}

.site-card:hover .site-card-icon {
  transform: scale(1.06);
}

.site-card:hover .site-icon {
  color: var(--accent-hover);
}

/* 网站卡片 favicon 图片样式，与图标尺寸保持一致 */
.site-card .favicon-icon {
  display: inline-block;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: var(--radius-sm);
  object-fit: cover;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.site-card .icon-placeholder,
.site-card .icon-fallback {
  display: inline-block;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  vertical-align: middle;
  text-align: center;
  line-height: 1.8rem;
  font-size: 1.5rem;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
  color: var(--accent-color);
}

/* 确保图标容器在加载过程中保持固定尺寸 */
.site-card .icon-container {
  display: inline-block;
  width: 1.8rem;
  height: 1.8rem;
  position: relative;
  vertical-align: middle;
}

.site-card .icon-container .favicon-icon,
.site-card .icon-container .icon-placeholder,
.site-card .icon-container .icon-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin-bottom: 0;
}

/* 优化图标切换动画 */
.site-card .icon-container .favicon-icon {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.site-card .icon-container .favicon-icon.loaded {
  opacity: 1;
}

.site-card .icon-container .favicon-icon.error {
  display: none;
}

.site-card .icon-container .icon-placeholder {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.site-card .icon-container .icon-placeholder.hidden {
  opacity: 0;
  pointer-events: none;
}

.site-card .icon-container .icon-fallback {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.site-card .icon-container .icon-fallback.visible {
  opacity: 1;
}

.site-card:hover .icon-placeholder,
.site-card:hover .icon-fallback {
  color: var(--accent-hover);
}

.site-card-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.site-card h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--text-bright);
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: color 0.3s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.site-card p {
  font-size: 0.9rem;
  color: var(--nav-item-color);
  margin: 0;
  line-height: 1.4;
  transition: color 0.3s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  position: relative;
  /* Ensure tooltip positioning context */
}

/* Tooltip styles */
/* Tooltip styles */
.site-card p[data-tooltip],
.site-card .repo-desc[data-tooltip] {
  cursor: default;
  /* Indicate interactivity */
}

.custom-tooltip {
  position: fixed;
  background: rgba(47, 48, 53, 0.95);
  /* Fallback dark */
  background: rgba(var(--card-bg-rgb), 0.95);
  color: var(--text-bright);
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px var(--shadow-color);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  white-space: normal;
  line-height: 1.4;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease-out;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  max-width: 300px;
  word-break: break-word;
}

.custom-tooltip.visible {
  opacity: 1;
}

/* 添加编辑按钮 */
.edit-buttons {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.site-card:hover .edit-buttons {
  opacity: 1;
}

.edit-btn,
.delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.edit-btn:hover,
.delete-btn:hover {
  color: var(--text-bright);
  background-color: var(--secondary-bg);
}

/* 添加网站按钮 */
.add-site-btn {
  background: linear-gradient(
    145deg,
    var(--site-card-bg-gradient-1),
    var(--site-card-bg-gradient-2)
  );
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-normal);
  transition-timing-function: var(--transition-bounce);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  box-shadow: 0 4px 16px var(--shadow-color);
}

.add-site-btn:hover {
  background: linear-gradient(145deg, var(--secondary-bg), var(--site-card-bg-gradient-1));
  border-color: var(--accent-color);
  color: var(--text-bright);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow-color);
}

.add-site-btn i {
  font-size: 2.2rem;
  margin-bottom: 0.8rem;
  transition: transform 0.3s ease;
}

.add-site-btn:hover i {
  transform: scale(1.1);
}
