/* ===== 主题变量 ===== */
:root {
  --bg: #f0f2f5;
  --bg-card: rgba(255, 255, 255, 0.68);
  --bg-card-solid: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #8e8e93;
  --border: rgba(0, 0, 0, 0.07);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 18px 40px rgba(0, 0, 0, 0.12);
  --radius: 20px;
  --max-width: 1200px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1d1f;
    --bg-card: rgba(44, 44, 46, 0.72);
    --bg-card-solid: #2c2c2e;
    --text: #f5f5f7;
    --text-secondary: #aeaeb2;
    --text-tertiary: #8e8e93;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #2997ff;
    --accent-soft: rgba(41, 151, 255, 0.18);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 18px 40px rgba(0, 0, 0, 0.55);
  }
}

/* ===== 基础重置 ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  color: var(--text);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  position: relative;
}

/* 背景样式已模块化到 src/themes/*.css，通过 body 上的 theme-* class 控制 */

a {
  color: inherit;
  text-decoration: none;
}
code {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.9em;
}

/* ===== Hero ===== */
.hero {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 96px 24px 48px;
}
.hero-title {
  font-family: "Ma Shan Zheng", "PingFang SC", "Microsoft YaHei", cursive;
  font-size: clamp(56px, 9vw, 96px);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.15;
  background: linear-gradient(
    180deg,
    var(--text) 0%,
    var(--text-secondary) 120%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: fadeUp 0.8s ease both;
}
.hero-subtitle {
  margin-top: 16px;
  font-family: "Ma Shan Zheng", "PingFang SC", "Microsoft YaHei", cursive;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 400;
  letter-spacing: 0.25em;
  color: var(--text-secondary);
  animation: fadeUp 0.8s ease 0.1s both;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 主容器 ===== */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 80px;
  flex: 1;
}

/* ===== 卡片网格 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
@media (max-width: 1023px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 767px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 560px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* ===== 卡片 ===== */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow);
  transition:
    transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.35s ease,
    border-color 0.35s ease;
  animation: cardIn 0.6s ease both;
  overflow: hidden;
  isolation: isolate;
}
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent-soft);
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at var(--mx, 50%) var(--my, 0%),
    var(--accent-soft) 0%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: -1;
}
.card:hover::after {
  opacity: 1;
}

.card-icon {
  font-size: 40px;
  line-height: 1;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  transition: transform 0.35s ease;
}
.card:hover .card-icon {
  transform: scale(1.08) rotate(-3deg);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 4px;
}

.badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-beta {
  background: rgba(255, 159, 10, 0.15);
  color: #ff9f0a;
}
.badge-archived {
  background: rgba(142, 142, 147, 0.18);
  color: var(--text-tertiary);
}

.card-desc {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
  flex: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.tag {
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--border);
  padding: 3px 10px;
  border-radius: 999px;
}

.card-arrow {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  transition: gap 0.3s ease;
}
.card:hover .card-arrow {
  gap: 12px;
}
.card-arrow svg {
  width: 16px;
  height: 16px;
}

/* ===== 骨架 ===== */
.skeleton {
  height: 200px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

/* ===== 状态块 ===== */
.state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
}
.state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.state p {
  font-size: 15px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-retry {
  margin-top: 16px;
  padding: 8px 20px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}
.btn-retry:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

/* ===== 页脚 ===== */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 28px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ===== 可访问性 ===== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== 滚动条美化（Apple 风格细条） ===== */

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 120, 128, 0.35) transparent;
}

/* WebKit / Chromium / Safari */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 128, 0.3);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition:
    background 0.25s ease,
    width 0.25s ease;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 120, 128, 0.5);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active {
  background: rgba(120, 120, 128, 0.65);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* 暗色模式：滑块变浅 */
@media (prefers-color-scheme: dark) {
  * {
    scrollbar-color: rgba(200, 200, 205, 0.3) transparent;
  }
  ::-webkit-scrollbar-thumb {
    background: rgba(200, 200, 205, 0.25);
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: rgba(200, 200, 205, 0.45);
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:active {
    background: rgba(200, 200, 205, 0.6);
    background-clip: padding-box;
  }
}
