/* =========================================================
   1547 实验室 · 项目展示站
   现代卡片流 + 详情文章页，支持深色模式与响应式布局
   ========================================================= */

:root {
  --bg: #f6f7fb;
  --bg-soft: #eef0f8;
  --surface: #ffffff;
  --surface-2: #f1f2f9;
  --text: #17182b;
  --text-2: #4b4f68;
  --muted: #7c809c;
  --border: rgba(23, 24, 43, 0.08);
  --border-strong: rgba(23, 24, 43, 0.14);
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --accent: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(23, 24, 43, 0.04), 0 4px 16px rgba(23, 24, 43, 0.05);
  --shadow-md: 0 6px 24px rgba(23, 24, 43, 0.08), 0 20px 50px rgba(23, 24, 43, 0.1);
  --shadow-lg: 0 12px 40px rgba(79, 70, 229, 0.22);
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
  --grad-soft: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(219, 39, 119, 0.1));
  --radius: 18px;
  --radius-sm: 12px;
  --header-h: 68px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html.dark {
  --bg: #0b0c16;
  --bg-soft: #111222;
  --surface: #151627;
  --surface-2: #1c1e32;
  --text: #e9eaf4;
  --text-2: #b8bacd;
  --muted: #8b8ea6;
  --border: rgba(233, 234, 244, 0.08);
  --border-strong: rgba(233, 234, 244, 0.16);
  --primary-soft: rgba(129, 140, 248, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.4), 0 20px 50px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(79, 70, 229, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.3s ease, color 0.3s ease;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; background: var(--primary-soft); color: var(--primary); padding: 2px 6px; border-radius: 6px; }

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

/* ---------- 无障碍 ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 0 0 12px 0;
}
.skip-link:focus { left: 0; }

/* ---------- 头部 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-badge {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
  box-shadow: var(--shadow-lg);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 17px; letter-spacing: 0.3px; }
.brand-text small { color: var(--muted); font-size: 12px; }

.site-nav { display: flex; align-items: center; gap: 6px; }
.nav-link { padding: 8px 14px; border-radius: 999px; color: var(--text-2); font-size: 14px; font-weight: 500; transition: all 0.2s; }
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--primary); background: var(--primary-soft); }

.theme-toggle {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: all 0.2s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
html:not(.dark) .icon-moon { display: none; }
html.dark .icon-sun { display: none; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: 88px 0 72px; background: var(--grad-soft); }
.hero::before {
  content: ""; position: absolute; inset: -20% -10%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 50% at 15% 20%, rgba(79, 70, 229, 0.18), transparent 60%),
    radial-gradient(35% 45% at 85% 25%, rgba(219, 39, 119, 0.14), transparent 60%),
    radial-gradient(30% 40% at 60% 90%, rgba(245, 158, 11, 0.12), transparent 60%);
  filter: blur(10px);
}
.hero-inner { position: relative; z-index: 1; }
.hero-eyebrow, .section-eyebrow {
  margin: 0 0 14px; font-size: 12px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase; color: var(--primary);
}
.hero h1 { margin: 0 0 20px; font-size: clamp(34px, 5vw, 56px); line-height: 1.15; letter-spacing: -1px; }
.grad-text {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-desc { max-width: 640px; margin: 0 0 32px; color: var(--text-2); font-size: 17px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 44px; }

.hero-stats { display: flex; flex-wrap: wrap; gap: 40px; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 30px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-label { color: var(--muted); font-size: 13px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: 13px; font-size: 15px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all 0.22s ease;
}
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-lg); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 46px rgba(79, 70, 229, 0.32); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }
.btn-lg { padding: 15px 32px; font-size: 16px; border-radius: 15px; }

/* ---------- 项目列表 ---------- */
.projects-section { padding: 72px 0 32px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head h2, .about-inner h2 { margin: 0; font-size: clamp(24px, 3vw, 32px); letter-spacing: -0.5px; }

.search-box {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); min-width: 240px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-box input { border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; width: 100%; }
.search-box input::placeholder { color: var(--muted); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 32px; }
.chip {
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.chip.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-lg); }

/* ---------- 卡片 ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 26px; }
.card {
  display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.card-cover { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
.card-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform 0.5s cubic-bezier(0.2, 0.6, 0.2, 1); }
.card:hover .card-cover img { transform: scale(1.06); }
.card-cover::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(10, 10, 20, 0.35));
  pointer-events: none;
}
.card-badge {
  position: absolute; left: 14px; bottom: 12px; z-index: 2; padding: 5px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.92); color: #17182b; font-size: 12px; font-weight: 700;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

.card-body { display: flex; flex-direction: column; gap: 8px; padding: 20px 20px 18px; flex: 1; }
.card-title { margin: 0; font-size: 19px; letter-spacing: -0.2px; }
.card-title a:hover { color: var(--primary); }
.card-tagline { margin: 0; color: var(--primary); font-size: 13.5px; font-weight: 600; }
.card-intro {
  margin: 0; color: var(--text-2); font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 4px 10px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.card-more { color: var(--primary); font-weight: 600; }
.card-more:hover { text-decoration: underline; }

.empty-tip { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- 关于 ---------- */
.about-section { padding: 48px 0 72px; }
.about-inner { padding: 36px 40px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.about-inner p { color: var(--text-2); max-width: 760px; margin: 14px 0 0; }
.about-inner p:first-of-type { margin-top: 18px; }

/* ---------- 详情页 ---------- */
.detail-main { padding: 30px 0 64px; }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13.5px; margin-bottom: 26px; }
.breadcrumb a:hover { color: var(--primary); }

.detail { display: flex; flex-direction: column; gap: 34px; }

.detail-head {
  display: grid; grid-template-columns: 1.05fr 1.3fr; gap: 36px; align-items: center;
  padding: 34px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.detail-badge {
  display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--primary-soft);
  color: var(--primary); font-size: 13px; font-weight: 700; margin-bottom: 16px;
}
.detail-head h1 { margin: 0 0 10px; font-size: clamp(28px, 4vw, 40px); letter-spacing: -1px; }
.detail-tagline { margin: 0 0 18px; color: var(--primary); font-size: 17px; font-weight: 600; }
.detail-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
.detail-tags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.detail-cover { margin: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-md); background: var(--surface-2); }
.detail-cover img { width: 100%; height: auto; }

.detail-section { padding: 32px 34px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.detail-section h2, .detail-cta h2 {
  position: relative; margin: 0 0 18px; font-size: 21px; letter-spacing: -0.3px; padding-left: 16px;
}
.detail-section h2::before, .detail-cta h2::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 5px; height: 22px; border-radius: 3px; background: var(--grad);
}
.intro-lead { margin: 0; font-size: 17px; color: var(--text-2); line-height: 1.8; }
.detail-desc p { margin: 0 0 14px; color: var(--text-2); font-size: 15.5px; }
.detail-desc p:last-child { margin-bottom: 0; }

.highlights { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.highlights li {
  position: relative; padding: 14px 16px 14px 40px; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 14.5px; color: var(--text-2);
}
.highlights li::before {
  content: "✓"; position: absolute; left: 14px; top: 14px; width: 20px; height: 20px;
  display: grid; place-items: center; border-radius: 50%; background: var(--grad); color: #fff; font-size: 12px; font-weight: 700;
}

.screenshots { display: flex; flex-direction: column; gap: 18px; }
.screenshot-item { margin: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--surface-2); transition: box-shadow 0.25s; }
.screenshot-item:hover { box-shadow: var(--shadow-md); }
.screenshot-item img { width: 100%; height: auto; }

.detail-cta {
  text-align: center; padding: 44px 34px; border-radius: var(--radius);
  background: var(--grad); color: #fff; box-shadow: var(--shadow-lg);
}
.detail-cta h2 { color: #fff; }
.detail-cta h2::before { background: rgba(255, 255, 255, 0.9); }
.detail-url { color: rgba(255, 255, 255, 0.85); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; margin: 0 0 22px; word-break: break-all; }
.detail-cta .btn-primary { background: #fff; color: var(--primary); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); }
.detail-cta .btn-primary:hover { box-shadow: 0 14px 36px rgba(0, 0, 0, 0.25); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pager-item {
  display: flex; flex-direction: column; gap: 4px; padding: 20px 22px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: all 0.22s;
}
.pager-item:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.pager-item small { color: var(--muted); font-size: 12.5px; }
.pager-item strong { font-size: 16px; }
.pager-item.next { text-align: right; }
.pager-item.disabled { visibility: hidden; }

.not-found { text-align: center; padding: 80px 0; }
.not-found h1 { margin: 0 0 12px; font-size: 32px; }
.not-found p { color: var(--text-2); margin: 0 0 28px; }

/* ---------- 页脚 ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 26px 0; color: var(--muted); font-size: 13.5px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.back-top { color: var(--primary); font-weight: 600; }
.back-top:hover { text-decoration: underline; }
.footer-meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.icp { color: var(--muted); }
.icp:hover { color: var(--primary); }

/* ---------- 动画与响应式 ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.card, .detail-section, .detail-head, .detail-cta, .pager-item { animation: fadeUp 0.5s ease both; }
.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.16s; }
.card:nth-child(6) { animation-delay: 0.2s; }
.card:nth-child(7) { animation-delay: 0.24s; }
.card:nth-child(8) { animation-delay: 0.28s; }
.card:nth-child(9) { animation-delay: 0.32s; }
.card:nth-child(10) { animation-delay: 0.36s; }

@media (max-width: 860px) {
  .detail-head { grid-template-columns: 1fr; gap: 24px; padding: 24px; }
  .detail-section, .about-inner { padding: 24px; }
  .hero { padding: 60px 0 52px; }
  .hero-stats { gap: 28px; }
  .section-head { flex-direction: column; align-items: stretch; }
  .search-box { min-width: 0; }
}

@media (max-width: 560px) {
  .container { width: calc(100% - 32px); }
  .brand-text small { display: none; }
  .site-nav .nav-link { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager-item.next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
  html { scroll-behavior: auto; }
}
