/* ============================================================
 * 码上搜 · 布局层
 * 只管排版结构与页面级区块，颜色/组件见 theme.css / components.css。
 * ============================================================ */

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 400 var(--text-md)/1.65 var(--font-sans);
  /* 坐标纸：极淡网格铺满页面底，纸/墨主题通用 */
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- 头部（排印双细线） ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 3px double var(--line-strong);
}
.brand {
  font: 700 24px/1.2 var(--font-display);
  letter-spacing: 1px;
}
.brand-accent { color: var(--accent); }
.tagline {
  color: var(--text-2);
  font: 400 var(--text-xs)/1.6 var(--font-mono);
  letter-spacing: 1px;
}
.search-wrap { margin-left: auto; width: min(320px, 40vw); }

/* ---------- 大类导航（一级） ---------- */
.group-nav {
  display: flex;
  gap: 24px;
  padding: 8px 24px 0;
  background: var(--surface);
  overflow-x: auto;
}
.group-nav a {
  font: 600 15px/1.6 var(--font-sans);
  color: var(--text-2);
  padding: 6px 2px 10px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.group-nav a:hover { color: var(--text); }
.group-nav a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.group-nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- 分类导航（二级） ---------- */
.cat-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.container { max-width: 1080px; margin: 0 auto; padding: 24px; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 56px 0 8px; }
.hero h1 {
  font: 700 var(--text-hero)/1.35 var(--font-display);
  margin: 0 0 10px;
  letter-spacing: 1px;
}
.hero h1 em {
  font-style: normal;
  color: var(--accent-text);
  border-bottom: 3px solid var(--accent);
  padding-bottom: 2px;
}
/* 终端光标：品牌记忆点 */
.cursor {
  display: inline-block;
  width: 0.45em;
  height: 0.85em;
  margin-left: 10px;
  background: var(--accent);
  vertical-align: -0.08em;
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.hero p {
  color: var(--text-2);
  font: 400 var(--text-sm)/1.6 var(--font-mono);
  letter-spacing: 3px;
  margin: 0 0 22px;
}
.hero-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* ---------- 分类区块 ---------- */
.cat-section { margin-top: 44px; }
.cat-section h1, .cat-section h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font: 700 var(--text-xl)/1.4 var(--font-display);
  margin: 0 0 4px;
}
/* 标题后延伸的发丝线：编辑排印的分节符 */
.cat-section h1::after, .cat-section h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.cat-section h2 small {
  color: var(--text-2);
  font: 400 var(--text-xs)/1.6 var(--font-mono);
  font-weight: 400;
  margin-left: 0;
}
/* 等宽序号：分类编号，替代图标 */
.cat-no {
  font: 400 var(--text-sm)/1.6 var(--font-mono);
  color: var(--accent-text);
  margin-right: 10px;
  letter-spacing: 1px;
}

/* ---------- 大类章节头（首页） ---------- */
.group-chapter { margin-top: 52px; }
.chapter-title a {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font: 700 clamp(20px, 2.6vw, 26px)/1.4 var(--font-display);
  letter-spacing: 1px;
}
.chapter-title a::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.chapter-title a:hover { color: var(--accent-text); }
.chapter-title small {
  color: var(--text-2);
  font: 400 var(--text-xs)/1.6 var(--font-mono);
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* 大类页的分类卡 */
.cat-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow);
  transition: border-color 0.12s ease;
}
.cat-card:hover { border-color: var(--accent); }

.cat-desc {
  color: var(--text-2);
  font-size: var(--text-sm);
  margin: 0 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

/* ---------- 详情页 ---------- */
.tool-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
.tool-detail h1 {
  font: 700 28px/1.4 var(--font-display);
  margin: 0 0 12px;
  letter-spacing: 0.5px;
}
.tool-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.tool-block { margin: 24px 0; }
.tool-block h2 {
  font: 700 var(--text-lg)/1.5 var(--font-display);
  margin: 0 0 8px;
}
.comment-block p {
  margin: 0;
  padding: 14px 16px;
  background: var(--note-bg);
  border-left: 2px solid var(--note-line);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--text-md);
}
.comment-block .note-mark { color: var(--note-line); font-weight: 700; margin-right: 4px; }
.tool-actions { margin: 28px 0 8px; }
.dead-note { color: var(--danger); font-size: var(--text-sm); }

.related { margin-top: 44px; }
.related h2 { font: 700 var(--text-lg)/1.5 var(--font-display); }

/* ---------- 页脚（与页眉呼应的双细线） ---------- */
.site-footer {
  margin-top: 56px;
  padding: 24px;
  text-align: center;
  color: var(--text-2);
  font: 400 var(--text-xs)/1.8 var(--font-mono);
  border-top: 3px double var(--line-strong);
}
.site-footer a { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }
.site-footer a:hover { color: var(--accent-text); }

/* ---------- 首屏加载级联（一次性，克制） ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero, .hero-cats a, .cat-section .card {
    animation: rise 0.45s ease backwards;
  }
  .hero-cats a:nth-child(1) { animation-delay: 0.05s; }
  .hero-cats a:nth-child(2) { animation-delay: 0.1s; }
  .hero-cats a:nth-child(3) { animation-delay: 0.15s; }
  .hero-cats a:nth-child(4) { animation-delay: 0.2s; }
  .hero-cats a:nth-child(5) { animation-delay: 0.25s; }
  .hero-cats a:nth-child(6) { animation-delay: 0.3s; }
  .hero-cats a:nth-child(7) { animation-delay: 0.35s; }
  .hero-cats a:nth-child(8) { animation-delay: 0.4s; }
  .cat-section .card:nth-child(1) { animation-delay: 0.08s; }
  .cat-section .card:nth-child(2) { animation-delay: 0.12s; }
  .cat-section .card:nth-child(3) { animation-delay: 0.16s; }
  .cat-section .card:nth-child(4) { animation-delay: 0.2s; }
  .cat-section .card:nth-child(5) { animation-delay: 0.24s; }
  .cat-section .card:nth-child(6) { animation-delay: 0.28s; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .site-header { flex-wrap: wrap; gap: 10px; }
  .search-wrap { width: 100%; margin-left: 0; }
  .tagline { display: none; }
  .container { padding: 16px; }
  .tool-detail { padding: 20px; }
  .hero { padding-top: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
