/* ═══════════════════════════════════════════════════════════
   home.css — 首页新布局样式（分类横向滚动卡片）
═══════════════════════════════════════════════════════════ */

/* ── 首页视图容器 ──────────────────────────────────────── */
.home-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── 首页顶部栏 ──────────────────────────────────────── */
.home-topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.home-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* "+" 添加按钮 */
.home-add-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.home-add-btn:hover {
  background: var(--accent);
  color: #fff;
  transform: scale(1.05);
}

/* 欢迎语 */
.home-welcome {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* 诗经名句文字（PC端同问候语大小，iOS端单独覆盖） */
.home-poem-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* 诗经名句 */
.home-poem-line {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
  line-height: 1.4;
}

/* 配置按钮 */
.home-config-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
  transition: all .15s;
  font-family: var(--font-sans);
}
.home-config-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-hover);
}
.home-config-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: rgba(232,145,106,.3);
}

/* ── 配置气泡菜单 ──────────────────────────────────────── */
.config-popover {
  position: absolute;
  top: 54px;
  right: 28px;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  z-index: 100;
  animation: popoverIn .15s ease;
}

@keyframes popoverIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.config-popover-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.config-popover-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.config-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
}

.config-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: grab;
  transition: background .12s;
  user-select: none;
}

.config-item:hover {
  background: rgba(128,128,128,.08);
}

.config-item.dragging {
  opacity: .5;
  background: var(--accent-bg);
}

.config-item.drag-over {
  border-top: 2px solid var(--accent);
}

/* 拖拽手柄 */
.config-drag-handle {
  color: var(--text-muted);
  font-size: 14px;
  cursor: grab;
  flex-shrink: 0;
  padding: 0 2px;
  line-height: 1;
}

/* 复选框 */
.config-checkbox {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-hover);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all .12s;
}

.config-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.config-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.config-item-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  flex: 1;
}

.config-item-label.unchecked {
  color: var(--text-muted);
  text-decoration: line-through;
  opacity: .6;
}

/* ── 分类区块 ──────────────────────────────────────── */
.home-sections {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 40px;
}

.home-sections::-webkit-scrollbar {
  width: 5px;
}
.home-sections::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}

.home-section {
  margin-bottom: 28px;
}

/* 区块标题栏 */
.home-section-header {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}

.home-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}

.home-section-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.home-section-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-left: 2px;
}

.home-section-count {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(128,128,128,.08);
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: auto;
  margin-right: 4px;
}

/* 横向滚动按钮 */
.home-section-scroll-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all .12s;
  flex-shrink: 0;
}
.home-section-scroll-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* 更多选项按钮 */
.home-section-more-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all .12s;
  flex-shrink: 0;
}
.home-section-more-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

/* ── 横向滚动容器 ──────────────────────────────────────── */
.home-section-cards {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  /* 性能优化：开启GPU合成层，消除滚动卡顿 */
  will-change: scroll-position;
  transform: translateZ(0);
  /* scroll-snap：让卡片滚动时对齐，减少半截卡片 */
  scroll-snap-type: x proximity;
}

.home-section-cards::-webkit-scrollbar {
  display: none;
}
.home-section-cards {
  scrollbar-width: none; /* Firefox */
}

/* ── 首页卡片（参考图样式）─────────────────────────────── */
.home-card {
  flex-shrink: 0;
  width: 200px;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex;
  flex-direction: column;
}

.home-card {
  /* 提前开启合成层，hover时不触发重排 */
  will-change: transform;
}
.home-card:hover {
  transform: translate3d(0, -3px, 0);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  border-color: var(--border-hover);
}

/* 封面图 */
.home-card-cover {
  width: 100%;
  height: 130px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.home-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s;
}

.home-card:hover .home-card-cover img {
  transform: scale(1.04);
}

/* 无封面占位 */
.home-card-placeholder {
  width: 100%;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

/* 渐变占位背景 */
.home-card-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(232,145,106,.12) 0%, rgba(155,127,245,.12) 50%, rgba(74,158,255,.12) 100%);
}

.home-card-placeholder-icon {
  position: relative;
  z-index: 1;
  font-size: 32px;
  opacity: .3;
}

/* 阅读进度条（卡片顶部） */
.home-card-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0,0,0,.3);
  z-index: 2;
}

.home-card-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  transition: width .3s;
}

/* 卡片内容区 */
.home-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-height: 0;
}

/* 来源信息 */
.home-card-source {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.home-card-source-favicon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--bg-input);
}

/* 标题 */
.home-card-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* 底部元数据 */
.home-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 2px;
}

.home-card-domain {
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

.home-card-meta-right {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.home-card-read-icon {
  font-size: 11px;
  color: var(--green);
}

/* 已读标记 */
.home-card-is-read {
  color: var(--green);
  font-size: 11px;
}

/* 收藏标记 */
.home-card-is-starred {
  color: var(--yellow);
  font-size: 10px;
}

/* ── 空区块 ──────────────────────────────────────── */
.home-section-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 12px;
  opacity: .6;
}

/* ── 收件箱视图容器 ──────────────────────────────────────── */
.inbox-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── 移动端适配 ──────────────────────────────────────── */
@media (max-width: 768px) {
  .home-topbar {
    padding: 0 14px;
    height: 52px;
  }
  .home-topbar-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .home-welcome {
    font-size: 14px;
  }
  .home-poem-text {
    font-size: 7px;
  }
  .home-sections {
    padding: 14px 14px 40px;
  }
  .home-section {
    margin-bottom: 20px;
  }
  .home-card {
    width: 160px;
  }
  .home-card-cover,
  .home-card-placeholder {
    height: 100px;
  }
  .home-card-title {
    font-size: 11.5px;
  }
  .config-popover {
    right: 10px;
    left: 10px;
    width: auto;
  }
  .home-section-scroll-btn {
    display: none;
  }
}

/* ── 板块拖动滚动条 ────────────────────────────────────── */
.section-scrollbar-wrap {
  position: relative;
  height: 4px;
  margin: 4px 4px 8px;
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
  cursor: pointer;
  overflow: hidden;
}
.section-scrollbar-thumb {
  position: absolute;
  top: 0;
  height: 100%;
  min-width: 32px;
  background: rgba(255,255,255,0.22);
  border-radius: 2px;
  cursor: grab;
  /* 只过渡background，left/width由JS直接设置不走transition避免延迟 */
  transition: background 0.15s;
  will-change: left, width;
  /* GPU合成层，拖动更顺滑 */
  transform: translateZ(0);
}
.section-scrollbar-thumb:hover {
  background: rgba(255,165,0,0.5);
}
.section-scrollbar-thumb.dragging {
  background: rgba(255,165,0,0.75);
  cursor: grabbing;
}
.section-nav-row {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
}

/* ── 底部控制栏（箭头 + 滚动条）─────────────────────────── */
.section-bottom-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 2px 2px;
}
.section-bottom-bar .home-section-scroll-btn {
  flex-shrink: 0;
}
/* 覆盖旧的独立滚动条样式，使其在底部栏内自适应 */
.section-bottom-bar .section-scrollbar-wrap {
  flex: 1;
  margin: 0;           /* 覆盖旧 margin */
  overflow: visible;   /* thumb 不裁切 */
}
