/* ============================================================
   杂记 · 个人网站 样式表
   响应式适配：手机端（默认）/ 平板 / PC 宽屏
   断点：640px（手机→平板）、1080px（平板→PC 宽屏）
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #faf9f7;
  --card: #ffffff;
  --line: #e8e5df;
  --line-strong: #d6d2c9;
  --text: #2b2a26;
  --body-text: #3a3833;
  --sub: #6f6c64;
  --faint: #9c988e;
  --accent: #4a6b52;
  --accent-soft: #eef3ef;
  --footer-bg: #f5f3ef;
  --radius: 10px;
  --wrap: 760px;
  --gap: 14px;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  /* iPhone 刘海屏 / 底部横条安全区 */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

a { -webkit-tap-highlight-color: rgba(74, 107, 82, .12); }
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 18px;
}

/* ==================== 顶栏 ==================== */
.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(250, 249, 247, .93);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  padding-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex: none;
}
.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.brand-text em { font-style: normal; font-size: 11px; color: var(--faint); letter-spacing: .6px; }

/* 导航：手机端横向滚动，不换行不挤压 */
.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin: 0 -18px;
  padding: 0 18px;
  scroll-padding: 0 18px;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: none;
  text-decoration: none;
  color: var(--sub);
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--accent-soft); color: var(--accent); }
.nav a.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }

/* ==================== 主体 ==================== */
main { flex: 1; padding: 28px 0 48px; }
.loading { color: var(--faint); text-align: center; padding: 40px 0; }

/* ---------- 首屏 ---------- */
.hero { padding-bottom: 26px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.hero h1 { font-size: clamp(24px, 6vw, 30px); font-weight: 600; letter-spacing: 1px; line-height: 1.3; }
.hero-sub { color: var(--accent); font-size: 13px; letter-spacing: 3px; margin-top: 6px; }
.hero-desc { color: var(--sub); margin-top: 14px; font-size: 15px; }
.hero-sm { padding-bottom: 20px; margin-bottom: 22px; }
.hero-sm h1 { font-size: clamp(21px, 5vw, 24px); }

/* ---------- 分类卡 ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  margin-bottom: 34px;
}
.cat-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  min-height: 44px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.cat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(30, 28, 20, .06);
}
.cat-card h3 { font-size: 16px; font-weight: 600; color: var(--accent); }
.cat-card p { font-size: 13px; color: var(--sub); margin-top: 6px; line-height: 1.65; padding-right: 46px; }
.cat-count { position: absolute; top: 16px; right: 18px; font-size: 12px; color: var(--faint); }

.section-title { font-size: 15px; font-weight: 600; color: var(--faint); letter-spacing: 1px; margin-bottom: 14px; }

/* ---------- 文章列表 ---------- */
.list { display: flex; flex-direction: column; gap: var(--gap); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: var(--line-strong); box-shadow: 0 2px 10px rgba(30, 28, 20, .05); }
.card-link { text-decoration: none; color: inherit; }
.card-title { font-size: 17px; font-weight: 600; line-height: 1.5; }
.card-link:hover .card-title { color: var(--accent); }
.card-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--faint); flex-wrap: wrap; }
.tag { padding: 2px 9px; border-radius: 999px; font-size: 11px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag-code { background: #eef2f7; color: #46617f; }
.tag-note { background: #f2f0e9; color: #7a6a3d; }
.tag-tool { background: #eef4f1; color: #3f6b58; }
.tag-shushu { background: #f3f0e6; color: #6f6335; }
.tag-life { background: #f4eef1; color: #7a4a5c; }
.card-summary { color: var(--sub); font-size: 14px; margin-top: 10px; }
.card-more {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 0;
}
.card-more:hover { text-decoration: underline; }

/* ---------- 文章详情 ---------- */
.post {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px 22px;
}
.post-crumb { font-size: 13px; color: var(--faint); margin-bottom: 14px; }
.post-crumb a { color: var(--sub); text-decoration: none; padding: 4px 0; }
.post-crumb a:hover { color: var(--accent); }
.post-title { font-size: clamp(21px, 5.5vw, 26px); font-weight: 600; line-height: 1.45; }
.post-meta { font-size: 13px; color: var(--faint); margin-top: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.post-body { margin-top: 18px; }
.post-body p { margin-bottom: 15px; color: var(--body-text); }
.post-body a { color: var(--accent); }
.post-body h2 { font-size: 17px; font-weight: 600; margin: 26px 0 12px; }
.post-back { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; }
.post-back a { color: var(--accent); text-decoration: none; display: inline-block; padding: 4px 0; }
.post-back a:hover { text-decoration: underline; }

.empty { text-align: center; color: var(--sub); padding: 50px 0; }
.empty a { color: var(--accent); }

/* ==================== 页脚 ==================== */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--footer-bg);
  padding: 22px 0 calc(26px + env(safe-area-inset-bottom));
}
.footer-inner { font-size: 12.5px; color: var(--faint); line-height: 1.9; }
.footer-line { word-break: break-word; }
.footer-line a { color: var(--sub); text-decoration: none; }
.footer-line a:hover { color: var(--accent); text-decoration: underline; }
.footer-note { margin-top: 8px; font-size: 11.5px; color: #a8a49a; }

/* ============================================================
   平板及以上（≥640px）
   ============================================================ */
@media (min-width: 640px) {
  :root { --wrap: 720px; --gap: 16px; }

  .wrap { padding: 0 24px; }
  .header-inner { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; padding-top: 0; padding-bottom: 0; min-height: 64px; }
  .nav { margin: 0; padding: 0; overflow: visible; flex-wrap: wrap; }

  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 20px 22px; }
  .card-title { font-size: 18px; }
  .post { padding: 30px 32px 26px; }
  main { padding: 36px 0 56px; }
}

/* ============================================================
   PC 宽屏（≥1080px）—— 更宽的版心 + 双列文章卡
   ============================================================ */
@media (min-width: 1080px) {
  :root { --wrap: 1000px; --gap: 18px; }

  .wrap { padding: 0 32px; }
  .header-inner { min-height: 68px; }
  .brand-mark { width: 36px; height: 36px; font-size: 18px; }
  .brand-text strong { font-size: 18px; }
  .nav a { font-size: 14.5px; padding: 8px 13px; }

  main { padding: 44px 0 64px; }

  .hero { padding-bottom: 30px; margin-bottom: 30px; }
  .hero h1 { font-size: 32px; }
  .hero-desc { max-width: 720px; }

  .cat-grid { grid-template-columns: repeat(3, 1fr); margin-bottom: 40px; }

  /* 文章列表改为双列，阅读型页面仍保持单列窄版心 */
  .list { display: grid; grid-template-columns: repeat(2, 1fr); align-items: start; }
  .card { height: 100%; display: flex; flex-direction: column; }
  .card-more { margin-top: auto; padding-top: 12px; }

  .post { max-width: 780px; margin: 0 auto; padding: 36px 40px 30px; }
  .post-body p { font-size: 16.5px; }

  .footer-inner { font-size: 13px; }
}

/* ============================================================
   超宽屏（≥1440px）
   ============================================================ */
@media (min-width: 1440px) {
  :root { --wrap: 1120px; }
}

/* ============================================================
   触屏设备优化（无 hover 能力时去掉悬停位移）
   ============================================================ */
@media (hover: none) {
  .cat-card:hover { transform: none; box-shadow: none; border-color: var(--line); }
  .card:hover { box-shadow: none; border-color: var(--line); }
  .cat-card:active { border-color: var(--accent); background: var(--accent-soft); }
  .card:active { border-color: var(--accent); }
}

/* ============================================================
   打印
   ============================================================ */
@media print {
  .site-header, .site-footer, .card-more, .post-back { display: none; }
  body { background: #fff; }
  .post { border: 0; padding: 0; max-width: none; }
  .card { break-inside: avoid; }
}

/* ============================================================
   减少动效偏好
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
