/* ============================================================
   技术笔记 · 样式表
   设计：工程期刊感 · 克制、清晰、专业；支持亮/暗主题
   ============================================================ */

:root {
  --bg: #f4f6f8;
  --bg-accent: #e8eef2;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #dce3ea;
  --accent: #0e7490;
  --accent-hover: #0f5f75;
  --accent-soft: #e0f2f7;
  --accent-glow: rgba(14, 116, 144, 0.12);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.05), 0 6px 16px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 4px 8px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 920px;
  --font: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #0b1117;
  --bg-accent: #121a22;
  --surface: #121a22;
  --surface-2: #1a2430;
  --text: #e8eef4;
  --text-muted: #8b9aab;
  --border: #243040;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: #132a2e;
  --accent-glow: rgba(45, 212, 191, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.25), 0 14px 36px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, var(--accent-glow), transparent 55%),
    radial-gradient(ellipse 60% 40% at -5% 30%, var(--bg-accent), transparent 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.35s ease, color 0.35s ease;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent-hover); }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand:hover { color: var(--accent); text-decoration: none; }
.brand svg { width: 26px; height: 26px; flex-shrink: 0; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}
.nav-links a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav-right { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: color-mix(in srgb, var(--text-muted) 40%, var(--border));
}
.icon-btn svg { width: 16px; height: 16px; }
.menu-toggle { display: none; }

/* ---------- 主区域 ---------- */
main { padding: 48px 0 80px; min-height: 60vh; }

.page-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: var(--text);
}
.page-sub {
  color: var(--text-muted);
  margin: 0 0 36px;
  font-size: 15px;
  line-height: 1.65;
  max-width: 36em;
}

/* ---------- 首页 Hero ---------- */
.hero {
  position: relative;
  padding: 56px 0 8px;
  margin-bottom: 48px;
  overflow: visible;
  animation: fadeUp 0.7s var(--ease) both;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 16px;
}
.hero-eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -0.035em;
  line-height: 1.2;
  max-width: 14em;
}
.hero p {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 16px;
  line-height: 1.7;
  max-width: 34em;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s var(--ease), box-shadow 0.15s ease, color 0.15s ease;
}
.btn:hover {
  background: var(--accent-hover);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
  font-weight: 500;
}
.btn.ghost:hover {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--text-muted) 35%, var(--border));
  color: var(--text);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 48px 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  animation: fadeUp 0.6s var(--ease) both;
  animation-delay: 0.08s;
}
.section-head h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.section-head a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s ease;
}
.section-head a:hover { color: var(--accent); text-decoration: none; }

/* ---------- 卡片网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
  animation: fadeUp 0.65s var(--ease) both;
  animation-delay: 0.14s;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s var(--ease), border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.2s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: var(--shadow);
}
.card:hover::before { background: var(--accent); }
.card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.4;
}
.card h3 a { color: var(--text); }
.card h3 a:hover { color: var(--accent); text-decoration: none; }
.card p {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 14px;
  flex: 1;
  line-height: 1.65;
}
.card .meta {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: -0.01em;
}
.card .card-tags { margin-top: 10px; }
.article .card-tags { margin-top: 28px; }
.chip {
  display: inline-block;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-muted);
  margin: 0 5px 4px 0;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.chip.tag-btn {
  cursor: pointer;
  border: 1px solid transparent;
}
.chip.tag-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--accent-soft);
}
.chip.tag-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
}

/* ---------- 文章详情 ---------- */
.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 48px;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.55s var(--ease) both;
}
.article h1 {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.03em;
  line-height: 1.3;
}
.article .article-meta {
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--mono);
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.article .content { font-size: 15.5px; line-height: 1.85; }
.article .content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 36px 0 12px;
  letter-spacing: -0.02em;
}
.article .content h3 { font-size: 17px; font-weight: 600; margin: 28px 0 10px; }
.article .content p { margin: 14px 0; color: var(--text); }
.article .content ul, .article .content ol { padding-left: 22px; }
.article .content li { margin: 8px 0; }
.article .content code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.86em;
  color: var(--accent-hover);
}
[data-theme="dark"] .article .content code { color: var(--accent); }

.back-link {
  margin-bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s ease;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ---------- 关于页 ---------- */
.prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 48px;
  box-shadow: var(--shadow-sm);
  line-height: 1.85;
  animation: fadeUp 0.55s var(--ease) both;
}
.prose h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 32px 0 12px;
  letter-spacing: -0.02em;
}
.prose h2:first-child { margin-top: 0; }
.prose p { color: var(--text); margin: 12px 0; }
.prose ul { padding-left: 22px; }
.prose li { margin: 8px 0; color: var(--text); }
.notice {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 16px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 22px 0;
  font-size: 14px;
  line-height: 1.7;
}

/* ---------- 演示区 ---------- */
.demo-section { margin-top: 40px; }
.demo-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-top: 12px;
}
.demo-box label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin: 14px 0 6px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.demo-box label:first-child { margin-top: 0; }
.demo-box textarea, .demo-box input {
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.demo-box textarea:focus, .demo-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.demo-box textarea { min-height: 120px; resize: vertical; }
.preview {
  margin-top: 8px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  min-height: 80px;
  line-height: 1.7;
}
.preview h1, .preview h2, .preview h3 { margin: 8px 0; }
.preview code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
}
.swatch-row { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.swatch {
  width: 52px; height: 52px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 8px;
  box-shadow: var(--shadow-sm);
}
.result { margin-top: 14px; font-size: 14px; line-height: 1.7; }
.result b { color: var(--accent); font-family: var(--mono); font-weight: 500; }
canvas { display: block; max-width: 100%; }

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 64px;
  padding: 36px 0 28px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}
.footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}
.footer-brand svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.footer-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.3;
}
.footer-brand-text strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.footer-brand-text span {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}
.footer-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.footer-nav a {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s ease, background 0.15s ease;
}
.footer-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}
.footer-note {
  margin: 22px 0 0;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: -0.01em;
}
.footer-icp {
  color: var(--text-muted);
  transition: color 0.15s ease;
}
.footer-icp:hover { color: var(--accent); text-decoration: none; }

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

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .container { padding: 0 18px; }
  main { padding: 32px 0 56px; }
  .menu-toggle { display: inline-flex; }
  .nav-links {
    position: absolute;
    top: 56px; left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 14px;
    display: none;
    box-shadow: var(--shadow-lg);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 11px 14px; border-radius: var(--radius-sm); }
  .hero { padding: 36px 0 4px; margin-bottom: 36px; }
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 15px; }
  .article, .prose { padding: 26px 20px; }
  .article h1 { font-size: 22px; }
  .page-title { font-size: 24px; }
  .grid { grid-template-columns: 1fr; }
  .section-head { margin: 36px 0 14px; }
  .footer-top { align-items: flex-start; flex-direction: column; gap: 16px; }
  .footer-nav { margin-left: -11px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }
}
