/* ============================================
   分类索引首页 — 一个类别一段，底下挂文章
   配套 scripts/category-index.cjs 与 source/index.md
   ============================================ */

.ci-root {
  display: flex;
  flex-direction: column;
  gap: 44px;
  margin: 8px 0 16px;
}

/* ---------- 一级分类 ---------- */

/* 盖掉 custom.css 给 #article-container h2 加的前缀图标和悬浮位移，
   分类标题不需要那个闪电图标 */
#article-container .ci-cat {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 18px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--hr-color, rgba(128, 128, 128, 0.2));
  font-size: 1.5rem;
  line-height: 1.3;
  transition: none;
}
#article-container .ci-cat:hover {
  padding-left: 0;
  color: inherit;
}
#article-container .ci-cat::before,
#article-container .ci-cat:hover::before {
  content: none;
}

.ci-cat > a,
.ci-cat > span {
  color: var(--text-highlight-color, #1f2d3d);
  font-weight: 700;
  text-decoration: none;
  border-bottom: none;
}
.ci-cat > a:hover {
  color: var(--theme-color, #49b1f5);
}

.ci-cat-count {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--meta-color, #858585);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ---------- 二级分类 ---------- */

.ci-sub {
  margin: 22px 0 0;
  padding-left: 16px;
  border-left: 2px solid var(--hr-color, rgba(128, 128, 128, 0.18));
}
.ci-sub:first-of-type {
  margin-top: 0;
}

.ci-sub-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--font-color, #4c4948);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: none;
}
.ci-sub-name:hover {
  color: var(--theme-color, #49b1f5);
}

.ci-sub-count {
  display: inline-block;
  min-width: 1.5em;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(var(--theme-color-rgb, 73, 177, 245), 0.12);
  color: var(--theme-color, #49b1f5);
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}

/* ---------- 文章行 ---------- */

#article-container .ci-posts {
  margin: 0;
  padding: 0;
  list-style: none;
}
#article-container .ci-posts > .ci-post {
  margin: 0;
  padding: 0;
  list-style: none;
}
#article-container .ci-posts > .ci-post::marker {
  content: none;
}

/* 只挂在一级分类下的文章，跟二级分类块对齐 */
.ci-posts-direct {
  padding-left: 18px !important;
}

.ci-post-link {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 10px 7px 8px;
  border-radius: 6px;
  border-bottom: none;
  color: var(--font-color, #4c4948);
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
/* 主题的 .container a:hover 会给容器内所有链接加下划线，
   目录式列表加下划线很脏，这里去掉 */
#article-container .ci-post-link:hover,
#article-container .ci-sub-name:hover,
#article-container .ci-cat > a:hover {
  text-decoration: none;
}

.ci-post-link:hover {
  background: rgba(var(--theme-color-rgb, 73, 177, 245), 0.08);
  color: var(--theme-color, #49b1f5);
  transform: translateX(3px);
}

.ci-post-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.ci-post-date {
  flex-shrink: 0;
  color: var(--meta-color, #858585);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- 边缘情况 ---------- */

.ci-empty {
  padding: 32px 0;
  color: var(--meta-color, #858585);
  text-align: center;
}

.ci-section-orphan .ci-cat > span {
  color: var(--meta-color, #858585);
  font-weight: 600;
}

/* ---------- 深色模式 ---------- */

[data-theme="dark"] .ci-cat > a,
[data-theme="dark"] .ci-cat > span {
  color: rgba(255, 255, 255, 0.9);
}
[data-theme="dark"] .ci-post-link:hover {
  background: rgba(var(--theme-color-rgb, 73, 177, 245), 0.16);
}

/* ---------- 窄屏 ---------- */

@media screen and (max-width: 768px) {
  .ci-root {
    gap: 32px;
  }
  #article-container .ci-cat {
    font-size: 1.25rem;
  }
  .ci-sub {
    padding-left: 12px;
  }
  .ci-post-link {
    padding: 8px 6px;
    gap: 8px;
  }
  .ci-post-date {
    font-size: 0.7rem;
  }
}

/* ---------- 头图打字机（配套 scripts/category-index.cjs 注入的 #ci-subtitle）---------- */

#ci-subtitle::after {
  content: "|";
  margin-left: 2px;
  font-weight: 300;
  animation: ciCaret 1.05s step-end infinite;
}
@keyframes ciCaret {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #ci-subtitle::after {
    animation: none;
  }
}

/* ---------- 注入的首页式头图定位 ---------- */

/* 主题只在 #page-header.full_page（真首页，100vh/380px）下给 #site-info 定 top，
   放进 .not-home-page 的 400px 页面头图里 top 会落回 auto，
   于是整块贴到 </nav> 后面的静态位置、被导航栏切掉。
   这里按头图高度重新居中：用 50% + translateY(-50%)，
   比主题给 #page-site-info 写死的 200px / 140px 更稳，窄屏头图变 280px 也不用改。
   选择器只命中「非首页头图里出现 #site-info」这一种情况，也就是本索引页。 */
/* 主题那条是 #page-header.full_page #site-info（只在真首页生效），
   所以这里必须把 position/left/width 一起补上——否则 #site-info 是 static，
   top 被忽略、translateY(-50%) 反而把整块推出头图。 */
#page-header.not-home-page #site-info {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  padding: 0 10px;
  transform: translateY(-50%);
  text-align: center;
}

/* 白色标题原本是靠 custom.css 那圈霓虹光晕才在亮画面上看得见的，
   霓虹按要求关掉之后白字没有任何轮廓，压在云层上会直接消失
   （头图只有 rgba(0,0,0,.3) 的遮罩，不够）。
   用一道克制的暗投影替代霓虹：给足对比，但不发光。 */
#page-header.not-home-page #site-info #site-title,
#page-header.not-home-page #site-info #site-subtitle {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.42), 0 2px 16px rgba(0, 0, 0, 0.32);
}
#page-header.not-home-page #site-info #site_social_icons .social-icon i {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}

/* ---------- DailyFlow：「查看全部」行 ---------- */

/* 架构设计有 197 篇，首页只列前 6 篇，其余走这一行进列表页 */
.ci-more .ci-post-link {
  padding-top: 10px;
}
.ci-more .ci-post-title {
  color: var(--theme-color, #49b1f5);
  font-size: 0.85rem;
  font-weight: 500;
}
.ci-more .ci-post-link:hover {
  transform: translateX(3px);
}

/* ---------- DailyFlow 二级主题列表页（/dailyflow/<主题>/）---------- */

#article-container .df-lead {
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hr-color, rgba(128, 128, 128, 0.2));
  color: var(--meta-color, #858585);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

#article-container .df-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
#article-container .df-list > .df-item {
  margin: 0;
  padding: 0;
  list-style: none;
}
#article-container .df-list > .df-item::marker {
  content: none;
}

.df-link {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 9px 10px 9px 8px;
  border-radius: 6px;
  border-bottom: none;
  color: var(--font-color, #4c4948);
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
#article-container .df-link:hover {
  background: rgba(var(--theme-color-rgb, 73, 177, 245), 0.08);
  color: var(--theme-color, #49b1f5);
  transform: translateX(3px);
  text-decoration: none;
}

.df-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}
.df-date {
  flex-shrink: 0;
  color: var(--meta-color, #858585);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] #article-container .df-link:hover {
  background: rgba(var(--theme-color-rgb, 73, 177, 245), 0.16);
}

@media screen and (max-width: 768px) {
  .df-link {
    padding: 8px 6px;
    gap: 8px;
  }
  .df-date {
    font-size: 0.7rem;
  }
}

/* ---------- 类型标签（原文 / 笔记 / 带读 / 精读）----------
   同一课时的原文和笔记 frontmatter title 完全相同，
   没有这个标签，列表里两行长得一模一样 */

.ci-kind,
.df-kind {
  flex-shrink: 0;
  min-width: 2.6em;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(133, 133, 133, 0.12);
  color: var(--meta-color, #858585);
  font-size: 0.68rem;
  line-height: 1.6;
  text-align: center;
  letter-spacing: 0.02em;
}
/* 原文是外部课程转录，压得更淡；笔记是自己写的，给主题色 */
.ci-post-link:hover .ci-kind,
#article-container .df-link:hover .df-kind {
  background: rgba(var(--theme-color-rgb, 73, 177, 245), 0.16);
  color: var(--theme-color, #49b1f5);
}

[data-theme="dark"] .ci-kind,
[data-theme="dark"] .df-kind {
  background: rgba(255, 255, 255, 0.1);
}

/* ---------- 首页侧栏瘦身 ----------
   首页本身就是一份完整的分类索引，侧栏的「最新文章 / 归档 / 知识图谱 /
   文件导航」做的是同一件事——导航。同一屏两套导航，右边那套还挤在 286px 里。
   首页只留：个人卡 + 公告栏 + 分类 + 网站资讯。
   文章页不受影响（选择器挂在 body.ci-page 下，只有索引首页有这个类）。 */

body.ci-page #aside-content .card-recent-post,
body.ci-page #aside-content .card-archives,
body.ci-page #aside-content #kg-sidebar-widget,
body.ci-page #aside-content #q-explorer-widget {
  display: none !important;
}

/* ---------- 二级主题网格 ----------
   首页只到二级主题为止。原来每个二级主题都列文章，高度随文章数线性增长；
   改成横向网格后，主题数翻倍也只多一行。 */

.ci-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.ci-chip {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--hr-color, rgba(128, 128, 128, 0.18));
  border-radius: 8px;
  border-bottom: 1px solid var(--hr-color, rgba(128, 128, 128, 0.18));
  color: var(--font-color, #4c4948);
  text-decoration: none;
  transition: border-color 0.2s ease, background-color 0.2s ease,
    transform 0.2s ease, color 0.2s ease;
}
#article-container .ci-chip:hover {
  background: rgba(var(--theme-color-rgb, 73, 177, 245), 0.06);
  border-color: rgba(var(--theme-color-rgb, 73, 177, 245), 0.4);
  color: var(--theme-color, #49b1f5);
  transform: translateY(-2px);
  text-decoration: none;
}

.ci-chip-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.4;
}

.ci-chip-count {
  flex-shrink: 0;
  color: var(--meta-color, #858585);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
.ci-chip:hover .ci-chip-count {
  color: var(--theme-color, #49b1f5);
}

/* ---------- 顶部「最近更新」 ---------- */

/* 它不是分类，标题不给计数，和下面的主题区拉开一点距离 */
.ci-recent {
  padding-bottom: 6px;
}

[data-theme="dark"] .ci-chip {
  border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] #article-container .ci-chip:hover {
  background: rgba(var(--theme-color-rgb, 73, 177, 245), 0.14);
}

@media screen and (max-width: 768px) {
  .ci-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
  }
  .ci-chip {
    padding: 11px 12px;
  }
  .ci-chip-name {
    font-size: 0.86rem;
  }
}
