/* =====================================================
   components.css — 搜索框 / 分类 / 卡片 / 工具栏 / 回顶按钮
   ===================================================== */

/* ---------- 搜索框 ---------- */
.search-box {
  max-width: 680px;
  margin: 36px auto 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 14px 14px 16px;
  transition: background .3s, border-color .3s, box-shadow .3s;
}
.search-box:focus-within {
  border-color: rgba(99, 102, 241, .5);
  box-shadow: 0 8px 36px rgba(99, 102, 241, .18);
}

.engine-tabs {
  display: flex;
  gap: 6px;
  padding-bottom: 12px;
}
.engine-tab {
  padding: 5px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--text-2);
  transition: all .2s;
}
.engine-tab:hover { color: var(--primary); }
.engine-tab.active {
  background: var(--primary-grad);
  color: #fff;
  font-weight: 600;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.search-icon { width: 22px; height: 22px; color: var(--text-3); flex-shrink: 0; }

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  height: 44px;
}
.search-input::placeholder { color: var(--text-3); }

.search-btn {
  height: 44px;
  padding: 0 30px;
  border-radius: 12px;
  background: var(--primary-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .1em;
  transition: transform .15s, box-shadow .2s;
}
.search-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(99, 102, 241, .35); }
.search-btn:active { transform: translateY(0); }

@media (max-width: 520px) {
  .search-box { padding: 12px 12px 14px; }
  .search-btn { padding: 0 20px; letter-spacing: 0; }
  .search-input { height: 40px; }
  .search-btn { height: 40px; }
}

/* ---------- 工具栏（快速筛选） ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0 28px;
}
.quick-filter {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 44px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.quick-filter:focus-within {
  border-color: rgba(99, 102, 241, .5);
  box-shadow: 0 4px 16px rgba(99, 102, 241, .15);
}
.quick-filter svg { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; }
.quick-filter input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14.5px;
  color: var(--text);
}
.quick-filter input::placeholder { color: var(--text-3); }

.filter-tip { font-size: 13.5px; color: var(--text-3); }
.filter-tip em { font-style: normal; color: var(--primary); font-weight: 600; }

/* ---------- 分类区块 ---------- */
.category { margin-bottom: 48px; scroll-margin-top: 90px; }

.category-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.category-head h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cat-icon {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  color: #fff;
  flex-shrink: 0;
}
.cat-icon svg { width: 19px; height: 19px; }

.c-red    { background: linear-gradient(135deg, #f87171, #ef4444); }
.c-purple { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }
.c-blue   { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.c-teal   { background: linear-gradient(135deg, #2dd4bf, #14b8a6); }
.c-pink   { background: linear-gradient(135deg, #f472b6, #ec4899); }
.c-orange { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.c-green  { background: linear-gradient(135deg, #4ade80, #22c55e); }
.c-yellow { background: linear-gradient(135deg, #facc15, #eab308); }

.cat-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--card-border), transparent);
}

/* ---------- 站点卡片 ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.site-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s, background .3s;
  animation: cardIn .45s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.site-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--hover-shadow);
  border-color: rgba(99, 102, 241, .35);
}
.site-card.hidden { display: none; }

/* 字母/文字头像（渐变） */
.avatar {
  position: relative;
  width: 46px; height: 46px;
  border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
/* 站点真实 logo：覆盖在渐变首字上，加载失败会自动移除露出首字 */
.card-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 7px;
  background: #ffffff;
  border-radius: 11px;
  box-sizing: border-box;
}
.g-blue   { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.g-sky    { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.g-red    { background: linear-gradient(135deg, #fb7185, #e11d48); }
.g-orange { background: linear-gradient(135deg, #fbbf24, #ea580c); }
.g-green  { background: linear-gradient(135deg, #4ade80, #16a34a); }
.g-purple { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.g-pink   { background: linear-gradient(135deg, #f472b6, #db2777); }
.g-teal   { background: linear-gradient(135deg, #2dd4bf, #0d9488); }
.g-dark   { background: linear-gradient(135deg, #64748b, #1e293b); }

.card-info { min-width: 0; display: flex; flex-direction: column; }
.card-info b {
  font-size: 15.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-info i {
  font-style: normal;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ---------- 回到顶部 ---------- */
.back-top {
  position: fixed;
  right: 28px;
  bottom: 32px;
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--primary-grad);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(99, 102, 241, .4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all .3s ease;
  z-index: 90;
}
.back-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-top:hover { transform: translateY(-3px); }
.back-top svg { width: 20px; height: 20px; }

/* ---------- 响应式微调 ---------- */
@media (max-width: 768px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
  .site-card { padding: 13px; gap: 11px; }
  .avatar { width: 40px; height: 40px; font-size: 16px; }
  .card-info b { font-size: 14.5px; }
  .category-head h2 { font-size: 18px; }
  .cat-icon { width: 33px; height: 33px; }
  .toolbar { flex-wrap: wrap; }
  .back-top { right: 16px; bottom: 20px; }
}

@media (max-width: 420px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .card-info i { display: none; }
}
