/* =============================================================================
   主页增强：Hero 导航、统计勋章、筛选、卡片层次、微交互
   ============================================================================= */

/* ---- Hero 轮换副标题 ---- */
.header-rotator {
  min-height: 2.4em;
  margin: 14px auto 0;
  max-width: 34em;
}

.header-rotator-line {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--w60);
  letter-spacing: 0.3px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.65rem;
}

.header-rotator-link {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #a5b4fc;
  text-decoration: none;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.28);
  transition: background 0.2s, transform 0.2s, color 0.2s;
}

.header-rotator-link:hover {
  color: #e0e7ff;
  background: rgba(99, 102, 241, 0.28);
  transform: translateY(-1px);
}

[data-theme="light"] .header-rotator-line {
  color: #475569;
}

[data-theme="light"] .header-rotator-link {
  color: #4338ca;
  background: rgba(99, 102, 241, 0.1);
}

.hero-sub-enter-active,
.hero-sub-leave-active {
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.hero-sub-enter-from {
  opacity: 0;
  transform: translateY(8px);
}

.hero-sub-leave-to {
  opacity: 0;
  transform: translateY(-6px);
}

@media (prefers-reduced-motion: reduce) {
  .hero-sub-enter-active,
  .hero-sub-leave-active {
    transition: none;
  }

  .home-index .home-orb {
    animation: none !important;
    transform: none !important;
    opacity: 0.28;
  }

  .home-index .stars span {
    animation: none !important;
    opacity: 0.35;
  }

  .home-index .stars span.star-drift {
    transform: none !important;
  }
}

@media (max-width: 767px) {
  .home-index .home-orb {
    filter: blur(56px);
    opacity: 0.3;
    animation-duration: 22s;
  }
}

/* ---- 统计勋章 ---- */
.header-stats-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 18px;
  padding-top: 14px;
  position: relative;
}

.header-stats-chips::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(120px, 28vw);
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--w15) 20%,
    var(--w20) 50%,
    var(--w15) 80%,
    transparent
  );
}

.header-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--w70);
  background: var(--w06);
  border: 1px solid var(--w12);
  backdrop-filter: blur(8px);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.header-stat-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--shadow-card);
}

.header-stat-chip-num {
  font-variant-numeric: tabular-nums;
  color: var(--w90);
}

.header-animate .header-stats-chips {
  animation: headerFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.36s both;
}

/* ---- 右上角统一工具胶囊（Teleport 到 body，始终固定视口） ---- */
body.home-index .home-top-bar {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  left: auto;
  bottom: auto;
  z-index: 10060;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: min(calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)), 480px);
  padding: 4px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--w20);
  background: var(--w05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px var(--shadow-card);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
}

.home-top-bar::-webkit-scrollbar {
  display: none;
}

.home-top-bar-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex-shrink: 0;
  padding: 0.38rem 0.62rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--w78);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.2px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.home-top-bar-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.home-top-bar-label {
  line-height: 1.2;
}

.home-top-bar-item:hover {
  background: var(--w08);
  color: var(--w90);
}

.home-top-bar-item:active {
  transform: scale(0.98);
}

.home-top-bar-item:focus {
  outline: none;
}

.home-top-bar-item:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.45);
  outline-offset: 1px;
}

.home-top-bar-divider {
  flex-shrink: 0;
  width: 1px;
  height: 22px;
  margin: 0 1px;
  background: var(--w15);
}

.home-top-bar-theme {
  padding: 0.38rem 0.55rem;
  font-size: 18px;
  line-height: 1;
}

[data-theme="light"] .home-top-bar {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(99, 102, 241, 0.16);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.08);
}

[data-theme="light"] .home-top-bar-item {
  color: #64748b;
}

[data-theme="light"] .home-top-bar-item:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #334155;
}

[data-theme="light"] .home-top-bar-divider {
  background: rgba(99, 102, 241, 0.18);
}

/* 顶栏工具组 / 搜索模式 */
.home-top-bar-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

body.home-index .home-top-bar.is-search-expanded {
  width: var(--home-top-bar-locked-width, auto);
  min-width: var(--home-top-bar-locked-width, auto);
  max-width: var(--home-top-bar-locked-width, min(calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)), 480px));
  height: var(--home-top-bar-locked-height, auto);
  min-height: var(--home-top-bar-locked-height, auto);
  max-height: var(--home-top-bar-locked-height, auto);
  left: auto;
  padding: 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.home-top-bar-search-mode {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.home-top-bar-search-field {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 1;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0 0.38rem 0 0;
  cursor: text;
  box-sizing: border-box;
}

.home-top-bar-search-field .home-top-bar-icon {
  flex-shrink: 0;
  opacity: 0.85;
}

body.home-index .home-top-bar .home-search-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.2px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.home-search-close,
.home-top-bar-collapse,
.home-top-bar-expand {
  flex-shrink: 0;
  padding: 0.38rem 0.55rem;
  color: var(--w80);
}

.home-top-bar-arrow-icon {
  display: block;
  flex-shrink: 0;
  transition: transform 0.25s ease, color 0.2s ease;
}

.home-top-bar-arrow-icon--right {
  transform: rotate(90deg);
}

.home-top-bar-arrow-icon--left {
  transform: rotate(-90deg);
}

.home-top-bar-collapse:hover,
.home-search-close:hover,
.home-top-bar-expand:hover {
  color: #00d4ff;
}

.home-top-bar-item:hover .home-top-bar-arrow-icon--right {
  transform: rotate(90deg) translateX(1px);
}

.home-top-bar-item:hover .home-top-bar-arrow-icon--left {
  transform: rotate(-90deg) translateX(-1px);
}

@media (min-width: 1024px) {
  body.home-index .home-top-bar {
    top: 24px;
    right: 24px;
  }

  .home-top-bar-item {
    font-size: 13px;
    padding: 0.42rem 0.72rem;
  }
}

/* ---- 加载骨架屏 ---- */
.agents-grid-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  grid-column: 1 / -1;
  width: 100%;
}

.agent-card-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 24px;
  border-radius: 20px;
  border: 1px solid var(--w10);
  background: var(--w05);
  box-shadow: 0 8px 32px var(--shadow-card);
  min-height: 280px;
}

.skeleton {
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--w06) 0%,
    var(--w12) 45%,
    var(--w06) 90%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.35s ease-in-out infinite;
}

.skeleton-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-chip {
  width: 42%;
  height: 22px;
  border-radius: 999px;
}

.skeleton-title {
  width: 68%;
  height: 22px;
}

.skeleton-line {
  width: 100%;
  height: 14px;
}

.skeleton-line-short {
  width: 82%;
}

.skeleton-author {
  width: 48%;
  height: 14px;
  margin-top: 4px;
}

.skeleton-button {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  margin-top: auto;
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

[data-theme="light"] .agent-card-skeleton {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(99, 102, 241, 0.1);
}

[data-theme="light"] .skeleton {
  background: linear-gradient(
    90deg,
    rgba(99, 102, 241, 0.06) 0%,
    rgba(99, 102, 241, 0.12) 45%,
    rgba(99, 102, 241, 0.06) 90%
  );
  background-size: 200% 100%;
}

@media (max-width: 768px) {
  .agents-grid-skeleton {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .agent-card-skeleton {
    padding: 20px 16px;
    min-height: 260px;
  }
}

/* ---- Sticky 分组导航 ---- */
.home-group-nav-wrap {
  position: sticky;
  top: calc(8px + env(safe-area-inset-top));
  z-index: 10040;
  margin: -28px 0 28px;
  padding: 10px 0 0;
}

  .home-group-nav-row {
    position: relative;
    z-index: 2;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 20px 10px;
  }

.home-group-nav {
  display: flex;
  justify-content: flex-start;
  gap: 0.45rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
  min-width: 0;
}

.home-group-nav::-webkit-scrollbar {
  display: none;
}

.home-group-nav .home-filter-pill {
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  color: var(--w70);
  background: var(--w06);
  border: 1px solid var(--w12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.home-group-nav .home-filter-pill:hover {
  color: var(--w90);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--shadow-card);
}

.home-group-nav .home-filter-pill:focus {
  outline: none;
}

.home-group-nav .home-filter-pill:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.45);
  outline-offset: 2px;
}

.home-group-nav .home-filter-pill:active {
  transform: translateY(0);
}

.home-group-nav .home-filter-pill.is-active {
  color: var(--w90);
  background: var(--w10);
  border-color: rgba(102, 126, 234, 0.42);
  box-shadow: none;
}

[data-theme="light"] .home-group-nav .home-filter-pill {
  color: #64748b;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(99, 102, 241, 0.14);
}

[data-theme="light"] .home-group-nav .home-filter-pill:hover {
  color: #334155;
  background: rgba(255, 255, 255, 0.72);
}

[data-theme="light"] .home-group-nav .home-filter-pill.is-active {
  color: #4338ca;
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(99, 102, 241, 0.38);
  box-shadow: none;
}

[data-theme="light"] .home-search-wrap {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(99, 102, 241, 0.16);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.08);
}

[data-theme="light"] .home-search-close,
[data-theme="light"] .home-top-bar-collapse,
[data-theme="light"] .home-top-bar-expand {
  color: #64748b;
}

[data-theme="light"] .home-search-close:hover,
[data-theme="light"] .home-top-bar-collapse:hover,
[data-theme="light"] .home-top-bar-expand:hover {
  color: #0284c7;
}

body.home-index .home-top-bar.is-collapsed {
  overflow: hidden;
  width: 46px;
  height: 46px;
  min-width: 46px;
  max-width: 46px;
  min-height: 46px;
  max-height: 46px;
  padding: 0;
  gap: 0;
  border-radius: 50%;
  justify-content: center;
  align-items: center;
}

body.home-index .home-top-bar.is-collapsed .home-top-bar-expand {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
}

/* ---- 分组标题 ---- */
.agents-group-head {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.agents-group-head.is-visible {
  opacity: 1;
  transform: none;
}

.agents-group-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* ---- 卡片角标 ---- */
.agent-card-badge {
  position: absolute;
  z-index: 2;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-radius: 999px;
  pointer-events: none;
  line-height: 1.3;
}

/* ---- 外链应用卡片 ---- */
.agent-card-external {
  border-color: rgba(139, 92, 246, 0.38);
  background: linear-gradient(155deg, rgba(99, 102, 241, 0.1) 0%, var(--w05) 52%);
}

.agent-card-external:hover {
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: 0 18px 48px rgba(99, 102, 241, 0.22);
}

/* ---- 筹备中 / 孵化 ---- */
.coming-soon-toggle strong {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.coming-soon-card {
  opacity: 0.78;
  border-style: dashed;
  border-color: rgba(148, 163, 184, 0.35);
}

.coming-soon-card .agent-card-badge-incubate {
  top: 14px;
  left: 14px;
  color: #64748b;
  background: rgba(248, 250, 252, 0.9);
  border: 1px dashed rgba(148, 163, 184, 0.5);
  animation: incubatePulse 2.4s ease-in-out infinite;
}

@keyframes incubatePulse {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

.coming-soon-card .enter-button.disabled {
  background: rgba(100, 116, 139, 0.25);
  color: var(--w55);
}

/* ---- 微交互：头像弹跳、点赞数字 ---- */
.agent-card:hover:not(.disabled) .agent-avatar {
  animation: avatarBounce 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes avatarBounce {
  0% { transform: scale(1) rotate(0); }
  35% { transform: scale(1.12) rotate(-4deg); }
  65% { transform: scale(1.06) rotate(2deg); }
  100% { transform: scale(1.08) rotate(-3deg); }
}

.like-count-bump {
  animation: likeCountBump 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes likeCountBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.35); color: #ff5252; }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .agent-card:hover:not(.disabled) .agent-avatar {
    animation: none;
    transform: scale(1.05);
  }

  .coming-soon-card .agent-card-badge-incubate {
    animation: none;
  }

  .agents-group-head {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .home-index .agent-card.show {
    opacity: 1;
    transform: none;
    animation: none !important;
  }

  .skeleton {
    animation: none;
    background: var(--w08);
  }
}

/* =============================================================================
   移动端适配（≤768px）
   ============================================================================= */
@media (max-width: 768px) {
  body.home-index {
    --home-chrome-top: calc(8px + env(safe-area-inset-top));
    --home-chrome-height: 52px;
  }

  body.home-index .container {
    padding: 12px;
    padding-top: calc(var(--home-chrome-height) + var(--home-chrome-top) + 16px);
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  body.home-index .header {
    margin-bottom: 22px;
    padding: 8px 44px 12px;
  }

  body.home-index .header h1 {
    font-size: 26px;
    gap: 10px;
    margin-bottom: 12px;
  }

  body.home-index .header-title-text {
    font-size: 1.32em;
    letter-spacing: 1px;
  }

  body.home-index .header-tagline {
    font-size: 17px;
    letter-spacing: 1px;
  }

  body.home-index .home-top-bar {
    top: var(--home-chrome-top);
    right: calc(8px + env(safe-area-inset-right));
    max-width: calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  body.home-index .home-top-bar.is-search-expanded {
    max-width: var(--home-top-bar-locked-width, calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }

  body.home-index .home-top-bar .home-search-input {
    font-size: 16px;
  }

  .home-top-bar-item {
    min-height: 44px;
    padding: 0.45rem 0.65rem;
    font-size: 12px;
  }

  .home-top-bar-theme {
    min-width: 44px;
  }

  .header-stats-chips {
    gap: 0.45rem;
    margin-top: 14px;
    padding-top: 12px;
  }

  .header-stat-chip {
    font-size: 12px;
    padding: 0.38rem 0.75rem;
  }

  .header-rotator {
    min-height: auto;
    margin-top: 10px;
    padding: 0 4px;
  }

  .header-rotator-line {
    font-size: 14px;
    line-height: 1.55;
  }

  .header-rotator-link {
    font-size: 13px;
    padding: 0.35rem 0.75rem;
    min-height: 36px;
  }

  .home-group-nav-wrap {
    top: calc(var(--home-chrome-height) + var(--home-chrome-top) + 4px);
    margin: -12px 0 18px;
    padding: 6px 0 0;
  }

  .home-group-nav-row {
    padding: 0 12px 8px;
  }

  .home-group-nav .home-filter-pill {
    min-height: 40px;
    padding: 0.5rem 1rem;
    font-size: 13px;
  }

  body.home-index .enter-button {
    min-height: 44px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  body.home-index .agent-card:hover:not(.disabled) {
    transform: none;
    box-shadow: 0 8px 32px var(--shadow-card);
  }

  body.home-index .agent-card:active:not(.disabled) {
    transform: scale(0.985);
  }

  body.home-index .back-to-top {
    width: 48px;
    height: 48px;
    bottom: calc(16px + env(safe-area-inset-bottom));
  }

  body.home-index .home-top-bar.is-collapsed {
    width: 48px;
    height: 48px;
    min-width: 48px;
    max-width: 48px;
    min-height: 48px;
    max-height: 48px;
  }
}

@media (max-width: 480px) {
  .home-top-bar-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  body.home-index .home-top-bar {
    max-width: calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  .home-top-bar-item:not(.home-top-bar-theme) {
    min-width: 44px;
    padding: 0.5rem;
  }

  .header-stat-chip {
    flex: 1 1 calc(50% - 0.45rem);
    justify-content: center;
    min-width: calc(50% - 0.45rem);
  }

  body.home-index .header {
    padding-left: 36px;
    padding-right: 36px;
  }

  body.home-index .header h1 {
    font-size: 24px;
  }
}

/* ---- 底部关注我们 ---- */
.home-follow {
  margin-top: 56px;
  padding: 36px 0 calc(48px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--w10);
}

.home-follow-inner {
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
}

.home-follow-title {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--w80);
}

.home-follow-desc {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--w55);
}

.home-follow-qr {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--w12);
  background: var(--w05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px var(--shadow-card);
}

.home-follow-qr img {
  display: block;
  width: 168px;
  height: 168px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
}

.home-follow-account {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--w70);
}

[data-theme="light"] .home-follow-qr {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(99, 102, 241, 0.14);
}

[data-theme="light"] .home-follow-desc {
  color: #64748b;
}

[data-theme="light"] .home-follow-account {
  color: #4338ca;
}

@media (max-width: 768px) {
  .home-follow {
    margin-top: 40px;
    padding-top: 28px;
    padding-bottom: calc(36px + env(safe-area-inset-bottom));
  }

  .home-follow-title {
    font-size: 18px;
  }

  .home-follow-desc {
    padding: 0 8px;
    font-size: 13px;
  }
}
