/* =====================================================================
   Joker · base.css
   设计基调：参照少数派（sspai）的清亮浅底 + 商务蓝强调色（#1e6fd9）
   变量 --accent / --bg 由 header.php 的 #joker-vars 内联覆盖（主题选项可调）
   ===================================================================== */

/* ── 设计令牌（浅色默认）── */
:root {
  --accent: #1e6fd9;
  --accent-2: #9dc3e6;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #1f2329;
  --text-2: #5b626b;
  --text-3: #8a9099;
  --border: #e8eaed;
  --border-2: #eef0f3;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 18px rgba(16,24,40,.05);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.12);
  --topbar-h: 60px;
  --maxw: 1180px;
  --content-w: 760px;
  --sidebar-w: 300px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* 跟随系统（未显式设 data-theme 时） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #1a1d23; --surface-2: #20242c;
    --text: #e7e9ec; --text-2: #a7adb5; --text-3: #6f757e;
    --border: #2a2f38; --border-2: #23272f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
  }
}
[data-theme="dark"] {
  --bg: #0f1115; --surface: #1a1d23; --surface-2: #20242c;
  --text: #e7e9ec; --text-2: #a7adb5; --text-3: #6f757e;
  --border: #2a2f38; --border-2: #23272f;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
}
[data-theme="light"] {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f7f8fa;
  --text: #1f2329; --text-2: #5b626b; --text-3: #8a9099;
  --border: #e8eaed; --border-2: #eef0f3;
}

/* ── 重置 ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); color: var(--text);
  background: var(--bg); line-height: 1.7; font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; transition: color .15s, background .15s; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }
h1,h2,h3,h4 { line-height: 1.3; font-weight: 700; color: var(--text); }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ── 顶栏 ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h); display: flex; align-items: center; gap: 18px;
  padding: 0 22px; background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; flex: none; }
.brand-logo { height: 30px; width: 30px; border-radius: 8px; object-fit: cover; }
.brand-initial {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800;
}
.brand-name { font-size: 17px; letter-spacing: .3px; }

.topnav { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: 14.5px; white-space: nowrap;
}
.topnav-link i { font-size: 14px; }
.topnav-link:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.topnav-link.active { color: var(--accent); font-weight: 600; }

.topnav-group { position: relative; }
.topnav-trigger { gap: 5px; }
.topnav-caret { font-size: 10px; opacity: .6; transition: transform .18s; }
.topnav-group.open .topnav-caret { transform: rotate(180deg); }
.topnav-panel {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 8px; display: none; z-index: 120;
  max-height: 70vh; overflow-y: auto;
}
.topnav-group.open .topnav-panel { display: block; animation: pop .14s ease; }
.topnav-panel-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px;
}
.topnav-panel-item i { width: 16px; text-align: center; color: var(--text-3); }
.topnav-panel-item:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); }
.topnav-panel-item.is-child { padding-left: 26px; font-size: 13.5px; }
.topnav-panel-item.active { color: var(--accent); font-weight: 600; }
.topnav-panel-tags .topnav-tagcloud { display: flex; flex-wrap: wrap; gap: 7px; padding: 6px; }
.nav-count { margin-left: auto; font-size: 12px; color: var(--text-3); background: var(--surface-2); padding: 1px 8px; border-radius: 20px; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar-search {
  display: flex; align-items: center; gap: 7px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 20px; padding: 7px 13px; min-width: 180px;
}
.topbar-search i { color: var(--text-3); font-size: 13px; }
.topbar-search input { border: none; background: none; outline: none; color: var(--text); width: 100%; }
.topbar-search input::placeholder { color: var(--text-3); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  color: var(--text-2); font-size: 16px;
}
.icon-btn:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

.hamburger { display: none; width: 40px; height: 40px; border-radius: 10px; place-items: center; font-size: 18px; color: var(--text-2); }
.hamburger:hover { color: var(--accent); }

/* ── 布局 ── */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 26px 22px; display: flex; gap: 26px; align-items: flex-start; }
.main { flex: 1; min-width: 0; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 26px 22px; }
.post-container { max-width: var(--maxw); }
.sidebar { width: var(--sidebar-w); flex: none; position: sticky; top: calc(var(--topbar-h) + 26px); }

/* ── 卡片网格（首页/归档共用）── */
.post-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.post-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: transform .18s, box-shadow .18s, border-color .18s;
}
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.pc-cover { aspect-ratio: 16/9; overflow: hidden; background: var(--surface-2); }
.pc-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.post-card:hover .pc-cover img { transform: scale(1.04); }
.pc-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.pc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--accent); font-weight: 600; }
.pc-top a:hover { text-decoration: underline; }
.pc-taxo { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); padding: 2px 8px; border-radius: 6px; }
.pc-title { margin: 0; font-size: 17px; line-height: 1.4; }
.pc-title a:hover { color: var(--accent); }
.pc-excerpt { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc-meta { display: flex; align-items: center; gap: 14px; margin-top: auto; font-size: 12.5px; color: var(--text-3); }
.pc-meta span { display: inline-flex; align-items: center; gap: 4px; }
.pc-author { color: var(--text-2); }

/* ── 分页 ── */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 30px; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px; padding: 0 12px; display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font-size: 14px;
}
.pagination a:hover { color: var(--accent); border-color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── 页脚 ── */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 40px; }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 30px 22px 14px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-logo { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800; }
.footer-site { font-weight: 700; }
.footer-desc { color: var(--text-3); font-size: 13px; }
.footer-social { display: flex; gap: 6px; }
.footer-social-link { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: var(--text-2); background: var(--surface-2); }
.footer-social-link:hover { color: #fff; background: var(--accent); }
.footer-meta { max-width: var(--maxw); margin: 0 auto; padding: 12px 22px 26px; display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-3); font-size: 12.5px; border-top: 1px solid var(--border-2); }

.back-to-top {
  position: fixed; right: 24px; bottom: 24px; width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 16px;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; z-index: 90;
}
.back-to-top.show { opacity: 1; transform: none; pointer-events: auto; }

/* ── 移动端抽屉 ── */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; visibility: hidden; transition: .25s; z-index: 200; }
.drawer-mask.show { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 300px; max-width: 84vw;
  background: var(--surface); box-shadow: var(--shadow-lg); z-index: 210;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-title { font-weight: 700; }
.drawer-body { padding: 10px 14px 30px; overflow-y: auto; flex: 1; }
.drawer-link { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 15px; }
.drawer-link i { width: 18px; color: var(--text-3); }
.drawer-link:hover, .drawer-link.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.nav-group { margin-top: 8px; }
.nav-group-title { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; font-size: 12px; font-weight: 700; letter-spacing: .5px; color: var(--text-3); text-transform: uppercase; }
.section-toggle-btn { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--text-3); }
.section-toggle-btn:hover { color: var(--accent); background: var(--surface-2); }
.section-list { padding: 0 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 14.5px; }
.nav-item i { width: 18px; color: var(--text-3); }
.nav-item:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.cat-tree, .menu-tree { list-style: none; margin: 0; padding: 0; }
.cat-group { border-radius: var(--radius-sm); }
.cat-row { display: flex; align-items: center; }
.cat-parent { flex: 1; }
.cat-toggle { width: 30px; height: 34px; display: grid; place-items: center; color: var(--text-3); border-radius: 7px; flex: none; }
.cat-toggle:hover { color: var(--accent); background: var(--surface-2); }
.cat-children { list-style: none; margin: 0; padding: 0 0 4px 28px; }
.cat-child-wrap .nav-item { font-size: 13.5px; padding: 8px 12px; }
.drawer-search { display: flex; align-items: center; gap: 8px; margin-top: 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
.drawer-search i { color: var(--text-3); }
.drawer-search input { border: none; background: none; outline: none; color: var(--text); width: 100%; }

/* ── 通用标签 ── */
.sidebar-tag { display: inline-flex; align-items: center; gap: 3px; padding: 4px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; color: var(--text-2); font-size: 12.5px; }
.sidebar-tag:hover { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ── 404 ── */
.error-404 { max-width: 520px; margin: 60px auto; text-align: center; }
.error-code { font-size: 84px; font-weight: 800; color: var(--accent); line-height: 1; }
.error-title { margin: 10px 0; }
.error-desc { color: var(--text-2); }
.error-back { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; padding: 10px 20px; background: var(--accent); color: #fff; border-radius: 10px; }

/* ── 响应式 ── */
@media (max-width: 920px) {
  .topnav, .topbar-search, .topbar-right .icon-btn[title=""] { display: none; }
  .topbar-search { display: none; }
  .hamburger { display: grid; }
  .topbar { gap: 8px; }
  .brand-name { display: none; }
  .wrap { flex-direction: column; padding: 18px 14px; }
  .sidebar { width: 100%; position: static; }
  .post-grid { grid-template-columns: 1fr; gap: 14px; }
  .container { padding: 18px 14px; }
}
@media (max-width: 560px) {
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
