/* ==========================================================================
   开源下载站 — 样式表
   设计目标：现代、清爽、精致；亮/暗双主题；完整响应式；保留无障碍焦点样式
   ========================================================================== */

/* ---------- 1. 设计变量 ---------- */
:root {
  --bg: #f8fafc;
  --bg-subtle: #f1f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: #eef2ff;
  --primary-text: #4338ca;
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --gradient-soft: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.12) 100%);

  --dot: rgba(100, 116, 139, 0.18);
  --header-bg: rgba(248, 250, 252, 0.82);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.05), 0 12px 32px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.10), 0 28px 60px rgba(15, 23, 42, 0.08);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-subtle: #111a2e;
  --surface: #131d33;
  --surface-soft: #17223b;
  --text: #f1f5f9;
  --text-secondary: #b0bdce;
  --text-muted: #7a8aa3;
  --border: #263451;
  --border-strong: #3b4c6b;

  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: rgba(129, 140, 248, 0.14);
  --primary-text: #c7d2fe;
  --gradient: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%);
  --gradient-soft: linear-gradient(135deg, rgba(129, 140, 248, 0.16) 0%, rgba(167, 139, 250, 0.16) 100%);

  --dot: rgba(148, 163, 184, 0.14);
  --header-bg: rgba(11, 17, 32, 0.82);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.24), 0 12px 32px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.32), 0 28px 60px rgba(0, 0, 0, 0.28);
}

/* ---------- 2. 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 88px; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
svg { display: block; width: 100%; height: 100%; }

img { max-width: 100%; height: auto; }

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}

.container { width: min(1200px, 100% - 48px); margin-inline: auto; }

/* ---------- 3. 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: 10px;
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 6px 14px -6px var(--primary);
}

.nav-actions { display: flex; align-items: center; gap: 8px; }

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.nav-link:hover { color: var(--text); background: var(--bg-subtle); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text); }

.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.nav-github {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.nav-github svg { width: 18px; height: 18px; }
.nav-github:hover { border-color: var(--primary); color: var(--primary-text); transform: translateY(-1px); }

/* ---------- 4. Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 84px 0 76px;
  background:
    radial-gradient(ellipse 60% 80% at 15% 0%, rgba(99, 102, 241, 0.14), transparent 70%),
    radial-gradient(ellipse 50% 70% at 85% 10%, rgba(139, 92, 246, 0.12), transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .hero {
  background:
    radial-gradient(ellipse 60% 80% at 15% 0%, rgba(99, 102, 241, 0.18), transparent 70%),
    radial-gradient(ellipse 50% 70% at 85% 10%, rgba(139, 92, 246, 0.16), transparent 70%),
    var(--bg);
}

/* 精致点阵背景 */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 90%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 90%);
  pointer-events: none;
}

.hero-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  pointer-events: none;
}
.hero-glow-1 { width: 320px; height: 320px; top: -160px; left: 8%; background: rgba(99, 102, 241, 0.30); }
.hero-glow-2 { width: 260px; height: 260px; top: -100px; right: 10%; background: rgba(167, 139, 250, 0.26); }

.hero-inner { position: relative; z-index: 1; text-align: center; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary-text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.hero-badge svg { width: 14px; height: 14px; color: var(--primary); }

.hero h1 {
  margin: 22px 0 18px;
  font-size: clamp(38px, 6vw, 62px);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.035em;
}

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-desc {
  max-width: 620px;
  margin-inline: auto;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.8;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 620px;
  margin: 32px auto 0;
  padding: 0 16px;
  height: 60px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow-md);
  transform: translateY(-2px);
}
.search-icon { width: 22px; height: 22px; flex: none; color: var(--text-muted); }
.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.search-kbd {
  flex: none;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin: 36px 0 0;
}
.stat { text-align: center; }
.stat dt { color: var(--text-muted); font-size: 12px; letter-spacing: 0.04em; }
.stat dd { margin: 2px 0 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat-divider { width: 1px; height: 28px; background: var(--border); }

/* ---------- 5. 软件库 ---------- */
.catalog { padding: 64px 0 72px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.section-head h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.section-subtitle { margin-top: 6px; color: var(--text-muted); font-size: 14px; }

.sort-control { display: flex; align-items: center; gap: 10px; flex: none; }
.sort-control label { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding: 9px 36px 9px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease;
}
.select-wrap select:hover { border-color: var(--primary); }
.select-wrap svg {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.filter-bar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 28px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary-text); transform: translateY(-1px); }
.filter-chip[aria-pressed="true"] {
  border-color: transparent;
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 6px 16px -6px var(--primary);
}
.filter-chip .chip-count {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
}
.filter-chip[aria-pressed="true"] .chip-count { background: rgba(255, 255, 255, 0.22); color: #fff; }

/* ---------- 6. 软件卡片 ---------- */
.software-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: cardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.app-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--cat-color, var(--gradient));
  opacity: 0;
  transition: opacity 0.25s ease;
}
.app-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.app-card:hover::before { opacity: 1; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.featured-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 11px;
  font-weight: 700;
}
.featured-badge svg { width: 11px; height: 11px; }

.card-top { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }

.app-icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  overflow: hidden;
  background-color: var(--icon-color, #6366f1);
  background-image: linear-gradient(145deg, rgba(255, 255, 255, 0.28), rgba(0, 0, 0, 0.22));
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  box-shadow: 0 8px 18px -8px var(--icon-color, #6366f1);
}
.app-icon img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: contain; padding: 8px; background: #fff; }
.app-icon span { position: relative; z-index: 1; }

.card-title-wrap { min-width: 0; padding-right: 44px; }
.app-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.version-tag {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
}
.category-tag { font-size: 12px; font-weight: 600; color: var(--cat-color, var(--primary)); }

.app-desc {
  flex: 1;
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.75;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 16px; }
.app-tag {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
}

.platform-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}
.platform-badge svg { width: 11px; height: 11px; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.card-links { display: flex; align-items: center; gap: 4px; min-width: 0; }
.mini-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s ease;
}
.mini-btn:hover { border-color: var(--border); background: var(--bg-subtle); color: var(--primary-text); }
.star-info { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.star-info svg { width: 13px; height: 13px; color: #f59e0b; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 6px 16px -8px var(--primary); }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 10px 22px -8px var(--primary); }

/* ---------- 7. 空状态 ---------- */
.empty-state { padding: 80px 20px; text-align: center; }
.empty-state[hidden] { display: none; }
.empty-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  padding: 18px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
}
.empty-state h3 { font-size: 20px; font-weight: 700; }
.empty-state p { margin: 8px 0 22px; color: var(--text-muted); }

/* ---------- 8. 安全提示卡 ---------- */
.notice-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--gradient-soft);
}
.notice-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  padding: 11px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.notice-text h3 { font-size: 15px; font-weight: 700; }
.notice-text p { margin-top: 4px; color: var(--text-secondary); font-size: 13px; }

/* ---------- 9. 页脚 ---------- */
.site-footer { margin-top: 72px; border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 30px 0; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand strong { font-size: 14px; }
.footer-brand p { margin-top: 2px; color: var(--text-muted); font-size: 12px; }
.footer-copy { color: var(--text-muted); font-size: 12px; }

/* ---------- 10. 轻提示 Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 100;
  padding: 12px 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 11. 响应式 ---------- */
@media (max-width: 820px) {
  .section-head { align-items: flex-start; flex-direction: column; }
  .software-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 640px) {
  .container { width: min(100% - 32px, 1200px); }
  html { scroll-padding-top: 76px; }
  .nav { height: 60px; }
  .nav-link { display: none; }
  .nav-github span { display: none; }
  .nav-github { padding: 9px; }
  .hero { padding: 60px 0 56px; }
  .hero h1 { font-size: 38px; }
  .hero-desc { font-size: 14px; }
  .desktop-only { display: none; }
  .search-box { height: 54px; margin-top: 26px; }
  .search-kbd { display: none; }
  .hero-stats { gap: 18px; margin-top: 30px; }
  .stat dd { font-size: 20px; }
  .catalog { padding: 48px 0 56px; }
  .section-head h2 { font-size: 24px; }
  .sort-control label { display: none; }
  .software-grid { grid-template-columns: 1fr; }
  .notice-card { align-items: flex-start; padding: 18px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .site-footer { margin-top: 56px; }
}

/* ---------- 12. 尊重减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
