/* ═══════════════════════════════════════════════════
   base.css — 布局与组件骨架（主题无关）
   主题令牌在各 theme-*.css 中定义：
   --bg --bg-soft --surface --ink --ink-soft --line
   --accent --accent-2 --font-display --font-body --font-mono
   --radius --shadow --sun
   ═══════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  transition: background .45s ease, color .45s ease;
  min-height: 100vh;
}

::selection { background: var(--accent); color: var(--bg); }

a { color: var(--accent); text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── 环境氛围层：默认隐藏，由主题开启 ─────────── */
.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.ambient > div { display: none; height: 100%; }

/* ── 顶栏 ─────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 28px;
  padding: 12px clamp(16px, 4vw, 48px);
  background: var(--topbar-bg, var(--bg));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  font-family: var(--font-display);
  font-size: 20px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-family: var(--font-display); font-size: 17px; font-weight: inherit; letter-spacing: .04em; }
.brand-text i { font-style: normal; font-size: 11px; color: var(--ink-soft); font-family: var(--font-mono); }

.main-nav { display: flex; gap: 4px; margin-left: 8px; }
.nav-link {
  padding: 6px 14px; color: var(--ink-soft);
  font-size: 15px; border-radius: var(--radius);
  transition: color .2s, background .2s;
}
.nav-link:hover { color: var(--ink); }
.nav-link.is-active { color: var(--accent); }

.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: var(--surface);
  transition: border-color .2s;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box input {
  border: 0; outline: 0; background: transparent;
  color: var(--ink); font-family: var(--font-body); font-size: 14px;
  width: 150px;
}
.search-box input::placeholder { color: var(--ink-soft); }
.search-box kbd {
  font-family: var(--font-mono); font-size: 11px;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 0 5px; color: var(--ink-soft);
}

.theme-switch { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.theme-btn {
  border: 0; background: transparent; color: var(--ink-soft);
  font-family: var(--font-body); font-size: 13px;
  padding: 7px 12px; cursor: pointer;
  transition: background .2s, color .2s;
}
.theme-btn + .theme-btn { border-left: 1px solid var(--line); }
.theme-btn:hover { color: var(--ink); }
.theme-btn.is-on { background: var(--accent); color: var(--accent-fg, var(--bg)); }

.mode-toggle {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); cursor: pointer;
  transition: border-color .2s;
}
.mode-toggle:hover { border-color: var(--accent); }
[data-mode="light"] .ic-moon { display: none; }
[data-mode="dark"] .ic-sun { display: none; }

/* ── HERO ─────────────────────────────────────── */
.hero { position: relative; z-index: 1; }
.hero-pane { display: none; position: relative; min-height: 380px; overflow: hidden; }
.hero-pane.is-active { display: block; }

.hero-copy { position: relative; z-index: 3; padding: clamp(36px, 6vw, 72px) clamp(16px, 6vw, 80px); max-width: 640px; }
.hero-eyebrow { font-family: var(--font-mono); font-size: 13px; letter-spacing: .22em; color: var(--accent); margin: 0 0 14px; }
.hero-title { font-family: var(--font-display); font-size: clamp(34px, 5vw, 58px); line-height: 1.15; margin: 0 0 16px; font-weight: inherit; }
.hero-tag { color: var(--ink-soft); font-size: 16px; margin: 0 0 22px; max-width: 46ch; }
.hero-stats { display: flex; align-items: center; gap: 18px; font-size: 14px; color: var(--ink-soft); }
.hero-stats b { color: var(--accent); font-size: 20px; }

/* ── 主体布局 ─────────────────────────────────── */
.layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(24px, 4vw, 56px);
  max-width: 1160px; margin: 0 auto;
  padding: 40px clamp(16px, 4vw, 48px) 64px;
}

.list-head { margin-bottom: 22px; }
.list-title { font-family: var(--font-display); font-size: 24px; margin: 0 0 14px; font-weight: inherit; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); border-radius: 999px;
  font-size: 13px; padding: 4px 13px; cursor: pointer;
  font-family: var(--font-body);
  transition: all .2s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg, var(--bg)); }

/* ── 文章卡片 ─────────────────────────────────── */
.article-list { display: flex; flex-direction: column; gap: 18px; }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px;
  cursor: pointer;
  box-shadow: var(--shadow, none);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card-eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; color: var(--accent); margin: 0 0 8px; }
.card-title { font-family: var(--font-display); font-size: 21px; margin: 0 0 8px; font-weight: inherit; line-height: 1.4; }
.card:hover .card-title { color: var(--accent); }
.card-summary { color: var(--ink-soft); font-size: 14.5px; margin: 0 0 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 12.5px; color: var(--ink-soft); font-family: var(--font-mono); }
.card-meta .c-tag::before { content: "#"; opacity: .6; }
.card-read { margin-left: auto; color: var(--accent); font-family: var(--font-mono); font-size: 12.5px; }

/* ── 空状态 ───────────────────────────────────── */
.empty-state { text-align: center; padding: 64px 0; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-main { font-family: var(--font-display); font-size: 20px; margin: 0 0 6px; }
.empty-sub { color: var(--ink-soft); margin: 0; font-size: 14px; }

/* ── 分页 ─────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 34px; flex-wrap: wrap; }
.page-btn {
  min-width: 38px; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-soft);
  font-family: var(--font-mono); font-size: 13.5px; cursor: pointer;
  transition: all .2s;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg, var(--bg)); }
.page-btn:disabled { opacity: .38; cursor: not-allowed; }
.page-info { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); margin-left: 12px; }

/* ── 侧栏 ─────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 22px; }
.widget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow, none); }
.widget-title { font-family: var(--font-display); font-size: 16.5px; margin: 0 0 14px; font-weight: inherit; }
.widget[data-widget] { display: none; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud .chip { cursor: pointer; }
.arch-list { list-style: none; margin: 0; padding: 0; }
.arch-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.arch-list li:last-child { border-bottom: 0; }
.arch-list .cnt { color: var(--ink-soft); font-family: var(--font-mono); font-size: 12.5px; }

/* ── 页脚 ─────────────────────────────────────── */
.footer {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 26px clamp(16px, 4vw, 48px);
  border-top: 1px solid var(--line);
  color: var(--ink-soft); font-size: 13px;
}
#footer-motto { font-family: var(--font-display); }

/* ── 阅读器 ───────────────────────────────────── */
.reader, .sheet { position: fixed; inset: 0; z-index: 100; }
.reader-mask { position: absolute; inset: 0; background: rgba(10, 10, 12, .55); backdrop-filter: blur(3px); }
.reader-panel, .sheet-panel {
  position: relative; z-index: 1;
  max-width: 780px; margin: 4vh auto;
  max-height: 92vh; overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: clamp(28px, 5vw, 56px);
  animation: reader-in .3s ease;
}
@keyframes reader-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.reader-close {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; font-size: 14px;
}
.reader-close:hover { border-color: var(--accent); color: var(--accent); }
.reader-eyebrow { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .14em; color: var(--accent); margin: 0 0 10px; }
.reader-head h1 { font-family: var(--font-display); font-size: clamp(26px, 4vw, 36px); line-height: 1.3; margin: 0 0 10px; font-weight: inherit; }
.reader-meta { font-family: var(--font-mono); font-size: 13px; color: var(--ink-soft); margin: 0 0 28px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.reader-pager { display: flex; justify-content: space-between; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 14px; }
.rp-link.is-disabled { opacity: .35; pointer-events: none; }

/* ── Markdown 排版 ────────────────────────────── */
.md { font-size: 16px; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--font-display); font-weight: inherit; line-height: 1.4; margin: 1.6em 0 .6em; }
.md h2 { font-size: 24px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 19px; }
.md p { margin: .9em 0; }
.md a { text-decoration: underline; text-underline-offset: 3px; }
.md blockquote {
  margin: 1.2em 0; padding: 4px 18px;
  border-left: 3px solid var(--accent);
  color: var(--ink-soft); background: var(--bg-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.md code { font-family: var(--font-mono); font-size: .88em; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.md pre { background: var(--code-bg, #171a21); border-radius: var(--radius); padding: 18px 20px; overflow-x: auto; border: 1px solid var(--line); }
.md pre code { background: transparent; border: 0; padding: 0; color: var(--code-fg, #e6e9ee); font-size: 13.5px; line-height: 1.7; }
.md ul, .md ol { padding-left: 1.5em; }
.md li { margin: .3em 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.md img { max-width: 100%; border-radius: var(--radius); }
.md table { border-collapse: collapse; width: 100%; margin: 1.2em 0; font-size: 14.5px; }
.md th, .md td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.md th { background: var(--bg-soft); }

/* ── 归档/关于 弹层 ───────────────────────────── */
.sheet-panel h2 { font-family: var(--font-display); margin-top: 0; font-weight: inherit; }
.arch-group h3 { font-family: var(--font-mono); font-size: 13px; color: var(--accent); letter-spacing: .1em; margin: 22px 0 8px; }
.arch-row { display: flex; gap: 14px; padding: 7px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.arch-row:hover .arch-row-title { color: var(--accent); }
.arch-row time { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); flex: 0 0 86px; }
.arch-row-title { transition: color .2s; }

/* ── 响应式 ───────────────────────────────────── */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .sidebar .widget { flex: 1 1 260px; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .topbar-tools { width: 100%; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }
}
@media (max-width: 560px) {
  .main-nav { order: 3; width: 100%; }
  .hero-pane { min-height: 320px; }
}

/* ── 动效降级 ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
