/* ============================================================================
   首页样式
   ============================================================================ */

/* ---------- Hero ---------- */
.hero {
  max-width: var(--content-max);
  margin: 28px auto 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(234, 111, 90, 0.08), rgba(234, 111, 90, 0.02));
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}
.hero:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

[data-theme="dark"] .hero {
  background: linear-gradient(135deg, rgba(234, 111, 90, 0.12), rgba(234, 111, 90, 0.04));
}

/* 让整块 hero 可点击跳转到关于页 */
.hero-link {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 32px 24px;
  color: inherit;
  text-decoration: none;
  position: relative;
}
.hero-link > .hero-arrow {
  align-self: center;
}

/* 头像占位：默认正方形，实际边长由 home.js 按 .hero-info 高度写入，避免 WebView 下宽度塌成 0 叠字 */
.hero-avatar-wrap {
  flex: 0 0 auto;
  align-self: center;
  width: 72px;
  height: 72px;
  min-width: 48px;
  min-height: 48px;
  box-sizing: border-box;
  display: block;
  overflow: hidden;
}
.hero-avatar {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-soft);
  border: 3px solid var(--bg);
  box-shadow: var(--shadow);
}
.hero-arrow {
  flex-shrink: 0;
  font-size: 28px;
  line-height: 1;
  color: var(--text-tertiary);
  transition: transform 0.2s, color 0.2s;
}
.hero:hover .hero-arrow { color: var(--primary); transform: translateX(4px); }

.hero-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px;
  text-align: left;
}
.hero-subtitle {
  font-size: 18px;
  font-weight: 700;
  color: #614e4e;
  line-height: 1.5;
  margin: 0;
  min-width: 0;
  white-space: nowrap;
  overflow: visible;
}
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}
.hero-stats .stat {
  flex: 0 0 auto;
  white-space: nowrap;
}
.hero-stats .stat strong { font-size: 16px; color: var(--text-main); margin-right: 4px; }

@media (max-width: 720px) {
  .hero {
    margin: 8px 12px 0;
    border-radius: 14px;
    background:
      radial-gradient(circle at 12% 8%, rgba(234, 111, 90, 0.12), transparent 34%),
      linear-gradient(135deg, rgba(234, 111, 90, 0.07), rgba(255, 255, 255, 0.55));
    border: 1px solid color-mix(in srgb, var(--primary), var(--border) 76%);
    box-shadow: 0 8px 22px rgba(234, 111, 90, 0.07);
  }
  .hero-link {
    align-items: center;
    padding: 9px 12px 9px;
    gap: 10px;
  }
  .hero-info {
    gap: 5px;
    padding-right: 22px;
  }
  .hero-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    opacity: 0.72;
  }
  .hero:hover .hero-arrow { transform: translateY(-50%) translateX(3px); }
  .hero-avatar {
    border-width: 2px;
  }
  .hero-subtitle {
    font-size: 15.5px;
    font-weight: 700;
    color: #614e4e;
    line-height: 1.45;
    margin: 0;
    padding-right: 0;
    min-width: 0;
    white-space: nowrap;
    overflow: visible;
  }
  .hero-stats {
    row-gap: 5px;
    column-gap: 5px;
    font-size: 11px;
    line-height: 1;
    padding-right: 0;
  }
  .hero-stats .stat {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-elev), var(--primary) 5%);
    border: 1px solid color-mix(in srgb, var(--border), var(--primary) 18%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  }
  .hero-stats .stat.saobby-slot-stat {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.08);
    padding: 2px 7px 2px 5px;
    gap: 0;
  }
  .hero-stats .stat.saobby-slot-stat .saobby-counter {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }
  .hero-stats .stat strong {
    font-size: 12px;
    line-height: 1;
    margin-right: 3px;
  }
}

[data-mode="dark"] .hero-stats .stat.saobby-slot-stat {
  background: #ececec;
  border-color: rgba(0, 0, 0, 0.18);
}
[data-mode="dark"] .hero-stats .stat.saobby-slot-stat .saobby-label {
  color: #555;
}
[data-mode="dark"] .hero-stats .stat.saobby-slot-stat .saobby-counter {
  filter: none;
}

/* ---------- 首页轮播 ---------- */
.home-carousel {
  max-width: var(--content-max);
  margin: 18px auto 0;
  padding: 0 24px;
}

.carousel-viewport {
  position: relative;
  height: 260px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-soft);
  box-shadow: var(--shadow);
  /* 纵向手势仍滚动页面，横向手势交给 JS 切换轮播；同时禁用拖蓝 / 长按图片菜单 */
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.carousel-viewport.is-swiping .carousel-slide,
.carousel-viewport.is-swiping img {
  cursor: grabbing;
}

.carousel-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
  color: #fff;
}
.carousel-slide.active {
  opacity: 1;
  pointer-events: auto;
}
.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.carousel-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.18) 58%, rgba(0, 0, 0, 0.08));
}
.carousel-content {
  position: absolute;
  left: 34px;
  right: 88px;
  bottom: 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.carousel-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(234, 111, 90, 0.92);
  font-size: 12px;
  font-weight: 500;
}
.carousel-content strong {
  max-width: 680px;
  font-size: 26px;
  line-height: 1.35;
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.32);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.carousel-content em {
  max-width: 560px;
  font-style: normal;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.86);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 46px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.carousel-btn:hover { background: rgba(0, 0, 0, 0.42); }
.carousel-btn.prev { left: 16px; }
.carousel-btn.next { right: 16px; }
.carousel-dots {
  position: absolute;
  right: 26px;
  bottom: 24px;
  display: flex;
  gap: 7px;
}
.carousel-dots button {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.52);
  transition: width 0.2s, background 0.2s;
}
.carousel-dots button.active {
  width: 22px;
  background: #fff;
}

@media (max-width: 720px) {
  .home-carousel {
    margin: 12px auto 0;
    padding: 0 14px;
  }
  .carousel-viewport {
    height: 180px;
    border-radius: 12px;
  }
  .carousel-shade {
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0.1) 68%);
  }
  .carousel-content {
    left: 16px;
    right: 16px;
    bottom: 18px;
    gap: 6px;
  }
  .carousel-badge {
    height: 22px;
    padding: 0 8px;
    font-size: 11px;
  }
  .carousel-content strong {
    font-size: 18px;
    line-height: 1.35;
  }
  .carousel-content em { display: none; }
  .carousel-btn {
    display: none;
  }
  .carousel-dots {
    right: 14px;
    bottom: 12px;
    gap: 5px;
  }
  .carousel-dots button {
    width: 6px;
    height: 6px;
  }
  .carousel-dots button.active {
    width: 18px;
  }
}

/* ---------- 主体布局 ---------- */
.layout {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 36px;
}
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
@media (max-width: 720px) {
  .layout { padding: 0 14px; }
  .tabs { padding-top: 12px; gap: 0; }
  .tab { padding: 10px 12px; font-size: 13.5px; }
  .tab.active::after { left: 12px; right: 12px; }
}

/* ---------- tab ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding-top: 18px;
  margin-bottom: 8px;
}

.tab {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}

.tab.active { color: var(--text-main); font-weight: 600; }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 16px;
  right: 16px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}
.tab:hover { color: var(--primary); }

/* ---------- 文章卡片 ---------- */
.post-list { list-style: none; }

/* ---------- 列表懒加载哨兵 / 到底提示 ---------- */
.load-more-sentinel,
.load-more-end {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 4px;
  color: var(--text-tertiary);
  font-size: 13px;
}
.load-more-sentinel:hover { background: none; padding-left: 4px; padding-right: 4px; }
.load-more-end::before,
.load-more-end::after {
  content: "";
  flex: 0 0 28px;
  height: 1px;
  background: var(--border);
}
.load-more-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: lm-spin 0.8s linear infinite;
}
@keyframes lm-spin { to { transform: rotate(360deg); } }

.post-item {
  display: flex;
  gap: 22px;
  padding: 20px 4px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  border-radius: 8px;
}

.post-item:hover { background: var(--bg-soft); padding-left: 12px; padding-right: 12px; }

.post-content { flex: 1; min-width: 0; }

.post-author-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.post-author-row .avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-soft);
  background-size: cover;
}

.post-pin {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
}

.post-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

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

.post-summary {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  margin-bottom: 10px;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.post-meta .meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.post-views {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-tertiary);
}
.post-views::before {
  content: "";
  width: 1px;
  height: 12px;
  background: var(--border);
  margin-right: 2px;
}
.post-views .pvapi-num {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.tag {
  background: var(--bg-soft);
  color: var(--text-secondary);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.tag:hover, .tag.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.tag.tag-colored {
  background: var(--tag-bg);
  color: var(--tag-text);
  border-color: var(--tag-border);
}
[data-mode="dark"] .tag.tag-colored,
[data-theme="dark"] .tag.tag-colored {
  background: var(--tag-dark-bg);
  color: var(--tag-dark-text);
  border-color: var(--tag-dark-border);
}
.tag.tag-colored:hover,
.tag.tag-colored.active {
  background: var(--tag-text);
  color: #fff;
  border-color: var(--tag-text);
}
[data-mode="dark"] .tag.tag-colored:hover,
[data-mode="dark"] .tag.tag-colored.active,
[data-theme="dark"] .tag.tag-colored:hover,
[data-theme="dark"] .tag.tag-colored.active {
  background: var(--tag-dark-text);
  color: #151515;
  border-color: var(--tag-dark-text);
}

.post-thumbnail {
  width: 160px;
  aspect-ratio: 16 / 10;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.post-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.25s ease;
}
.post-item:hover .post-thumbnail img { transform: scale(1.03); }

@media (max-width: 720px) {
  .post-thumbnail { width: 96px; aspect-ratio: 4 / 3; border-radius: 8px; }
  .post-title { font-size: 15.5px; line-height: 1.45; margin-bottom: 6px; -webkit-line-clamp: 3; line-clamp: 3; }
  .post-summary { -webkit-line-clamp: 2; line-clamp: 2; font-size: 12.5px; margin-bottom: 8px; }
  .post-item { gap: 12px; padding: 14px 4px; }
  .post-item:hover { padding: 14px 4px; background: transparent; }
  .post-author-row { font-size: 11px; gap: 6px; margin-bottom: 6px; }
  .post-author-row .avatar { width: 16px; height: 16px; }
  .post-meta { font-size: 11px; gap: 8px; }
  .tag { padding: 1px 7px; font-size: 11px; }
}

@media (max-width: 420px) {
  .post-thumbnail { width: 84px; }
}

/* ---------- 侧栏 ---------- */
.sidebar { padding-top: 18px; }

.sidebar-card {
  padding: 18px;
  background: var(--bg-soft);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.sidebar-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-author { display: flex; align-items: center; gap: 12px; }
.sidebar-author .avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bg);
  background-size: cover;
}
.sidebar-author .name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.sidebar-author .desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }

.recent-list { list-style: none; }
.recent-list li {
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recent-list a:hover { color: var(--primary); }

/* ---------- 加载更多 ---------- */
.load-more {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.load-more:hover { color: var(--primary); }

/* ---------- 首页「随笔」Tab：仅 giscus ---------- */
.post-list.post-list--giscus {
  list-style: none;
}
.post-list.post-list--giscus .home-giscus-only {
  list-style: none;
  width: 100%;
  padding: 0;
  border: none;
}
.home-notes-lead {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 0 0 16px;
}
.home-notes-lead a { color: var(--primary); font-weight: 600; }
.home-notes-lead code {
  font-size: 12px;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: 4px;
}
.home-notes-giscus {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg-secondary);
  min-height: 100px;
}
.post-list.post-list--giscus .empty a { color: var(--primary); }
