/* 站点功能导览（site_guide）前台样式 — sg- 前缀隔离；颜色/圆角/阴影全走 CSS 变量，
   深浅主题自动跟随（禁止硬编码色值） */

/* ==================== 导览页 ==================== */

.sg-page {
  display: grid;
  gap: 16px;
  --sg-hdr: 0px; /* 吸顶导航实际高度（JS 写入，未注入时按 0 处理） */
}

/* ---------- Hero：一眼确认「这是功能导览」 ---------- */

.sg-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding: 26px 24px 24px;
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--ac-soft), var(--card) 62%);
}

/* 右上装饰光晕：纯 CSS 变量取色，不做位图资源 */
.sg-hero::after {
  content: "";
  position: absolute;
  right: -46px;
  top: -74px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ac) 0%, transparent 68%);
  opacity: 0.14;
  pointer-events: none;
}

.sg-hero-body {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 10px;
}

.sg-hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-self: start;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--bd);
  color: var(--ac-2);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.sg-hero-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.sg-hero-desc {
  margin: 0;
  color: var(--tx-2);
  font-size: 14px;
  line-height: 1.7;
  max-width: 62ch;
}

.sg-hero-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.sg-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 12.5px;
  color: var(--tx-3);
}

.sg-stat b {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ac-2);
}

.sg-stat-sep {
  width: 1px;
  height: 14px;
  background: var(--bd-2);
}

.sg-back {
  position: relative;
  z-index: 1;
  margin-left: auto;
  flex: none;
}

/* ---------- 吸顶目录条：板块跳转 + 搜索 ---------- */

.sg-toc {
  position: sticky;
  top: var(--sg-hdr, 0px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 2px 10px rgba(25, 24, 23, 0.04);
}

.sg-toc-list {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 1px;
}

.sg-toc-list::-webkit-scrollbar {
  display: none;
}

.sg-toc-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--tx-2);
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sg-toc-link:hover {
  border-color: var(--bd);
  color: var(--tx);
}

/* 筛选后无条目的板块：目录项同步隐藏（.sg-toc-link 自带 display，需显式盖住 UA 的 [hidden]） */
.sg-toc-link[hidden] {
  display: none;
}

.sg-toc-link.is-on {
  background: var(--ac);
  border-color: var(--ac);
  color: #fff;
}

.sg-toc-icon {
  display: inline-flex;
  align-items: center;
  flex: none;
  opacity: 0.9;
}

.sg-toc-n {
  min-width: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--tx-3);
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}

.sg-toc-link.is-on .sg-toc-n {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* 搜索框：与目录同排，窄屏整体换行到下方 */
.sg-search {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--bd);
  border-radius: 999px;
  background: var(--soft-2);
  color: var(--tx-3);
  transition: border-color 0.15s ease;
}

.sg-search:focus-within {
  border-color: var(--ac);
}

.sg-search-input {
  width: 170px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--tx);
  font-family: inherit;
  font-size: 12.5px;
  padding: 1px 0;
}

.sg-search-input::placeholder {
  color: var(--tx-3);
}

/* ---------- 分区区块 ---------- */

.sg-section {
  padding: 18px;
  scroll-margin-top: calc(var(--sg-hdr, 0px) + 74px); /* 吸顶导航 + 目录条高度，锚点不被压住 */
}

.sg-section[hidden] {
  display: none;
}

.sg-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bd);
}

/* 序号：衬线大数字，导览章节感 */
.sg-section-idx {
  flex: none;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: var(--ac);
  opacity: 0.55;
}

.sg-section-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-s);
  background: var(--ac-soft);
  color: var(--ac-2);
}

.sg-section-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  min-width: 0;
}

.sg-count {
  margin-left: auto;
  flex: none;
  font-size: 12px;
  color: var(--tx-3);
}

/* 条目卡片栅格（minmax(0,1fr) 防长文撑爆；auto-fill 自适应列数） */
.sg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.sg-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--bd);
  border-radius: var(--radius-s);
  background: var(--card);
  text-decoration: none;
  color: inherit;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.sg-item[hidden] {
  display: none;
}

a.sg-item:hover {
  border-color: var(--ac);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.sg-item-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-s);
  background: var(--ac-soft);
  color: var(--ac-2);
}

.sg-item-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.sg-item-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.45;
}

.sg-item-desc {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--tx-2);
  /* 说明过长时两行截断，栅格行高整齐 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sg-item-go {
  margin-left: auto;
  flex: none;
  align-self: center;
  color: var(--tx-3);
  transition: color 0.15s ease, transform 0.15s ease;
}

a.sg-item:hover .sg-item-go {
  color: var(--ac);
  transform: translateX(2px);
}

/* 搜索无结果 */
.sg-noresult {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 36px 16px;
  border: 1px dashed var(--bd-2);
  border-radius: var(--radius);
  color: var(--tx-3);
  text-align: center;
}

.sg-noresult[hidden] {
  display: none;
}

.sg-noresult p {
  margin: 0;
  font-size: 13.5px;
}

.sg-empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--tx-3);
  font-size: 14px;
}

/* ==================== 首页引导块 ==================== */

.sg-home {
  overflow: hidden;
  background: linear-gradient(135deg, var(--ac-soft), var(--card) 70%);
}

.sg-home-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}

.sg-home-link:hover .sg-home-title {
  color: var(--ac);
}

.sg-home-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-s);
  background: var(--card);
  border: 1px solid var(--bd);
  color: var(--ac-2);
}

.sg-home-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sg-home-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  transition: color 0.15s ease;
}

.sg-home-sub {
  font-size: 12.5px;
  color: var(--tx-3);
}

/* 右侧 CTA 胶囊：与站点主色一致，明确「点进去看」 */
.sg-home-cta {
  margin-left: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--ac);
  color: var(--ac-2);
  font-size: 12.5px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.sg-home-link:hover .sg-home-cta {
  background: var(--ac);
  color: #fff;
}

/* ==================== 移动端 ==================== */

@media (max-width: 640px) {
  .sg-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .sg-hero {
    padding: 20px 16px 18px;
  }

  .sg-hero-title {
    font-size: 23px;
  }

  .sg-hero-desc {
    font-size: 13.5px;
  }

  .sg-back {
    position: absolute;
    right: 14px;
    top: 14px;
    padding: 4px 10px;
    font-size: 12px;
  }

  /* 目录条：底部换行，搜索框独占一行 */
  .sg-toc {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
  }

  .sg-search {
    flex: 1 1 100%;
  }

  .sg-search-input {
    width: 100%;
  }

  .sg-section {
    padding: 14px;
  }

  .sg-section-idx {
    font-size: 20px;
  }

  .sg-home-cta span {
    display: none; /* 窄屏只留箭头，省横向空间 */
  }

  .sg-home-cta {
    padding: 5px 8px;
  }
}
