/* ==========================================================================
   有书阅读 · 个人知识库 —— 全站样式
   ========================================================================== */

:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #efeae0;
  --text: #2a2722;
  --text-muted: #6f6a60;
  --border: #e3ddd1;
  --accent: #2f6b5e;
  --accent-strong: #245247;
  --accent-soft: #e3efe9;
  --on-accent: #ffffff;
  --shadow: 0 12px 32px rgba(42, 39, 34, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
  --max: 1080px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "STSong", "SimSun", serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #14181a;
  --surface: #1c2124;
  --surface-2: #232a2e;
  --text: #e9e6de;
  --text-muted: #9b978d;
  --border: #2d353a;
  --accent: #7fc4ae;
  --accent-strong: #a5dcc9;
  --accent-soft: #1e332e;
  --on-accent: #10201b;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* 作者样式的 display 会覆盖 hidden 属性，这里显式兜底 */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 100;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

.container {
  width: min(100% - 40px, var(--max));
  margin-inline: auto;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-block: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-sub {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin-top: 3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav ul {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.nav a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}
.nav a[aria-current="page"] {
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 600;
}

.theme-toggle,
.nav-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.theme-toggle:hover,
.nav-toggle:hover { border-color: var(--accent); }

.nav-toggle {
  display: none;
  font-size: 1.15rem;
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
  padding: 76px 0 56px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 56px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-strong);
  font-weight: 600;
}

.hero h1 {
  margin: 0 0 20px;
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 4.6vw, 3.15rem);
  line-height: 1.22;
  letter-spacing: 0.015em;
  font-weight: 700;
}
.hero h1 em {
  font-style: normal;
  color: var(--accent-strong);
}

.lede {
  margin: 0 0 30px;
  color: var(--text-muted);
  font-size: 1.06rem;
  max-width: 36em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.hero-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 26px 18px;
  box-shadow: var(--shadow);
}

.panel-title {
  margin: 0 0 14px;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.panel-list li + li { border-top: 1px dashed var(--border); }
.panel-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  color: var(--text);
  text-decoration: none;
}
.panel-list a:hover {
  color: var(--accent-strong);
  text-decoration: none;
}
.panel-list .date {
  color: var(--text-muted);
  font-size: 0.8rem;
  flex: none;
}

/* --------------------------------------------------------------------------
   Sections & cards
   -------------------------------------------------------------------------- */

.section { padding: 36px 0 64px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 26px;
}
.section-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}
.section-head a {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.section-head a:hover { color: var(--accent-strong); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover {
  text-decoration: none;
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.card h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.4;
}
.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.card-meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.tag {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  width: fit-content;
}

.category-card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.category-icon { font-size: 1.15rem; }

/* --------------------------------------------------------------------------
   Notes list
   -------------------------------------------------------------------------- */

.note-list {
  display: grid;
  gap: 14px;
}

.note-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.note-row:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: var(--shadow);
}
.note-row h2 {
  margin: 6px 0;
  font-family: var(--font-serif);
  font-size: 1.18rem;
}
.note-row p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.93rem;
}
.note-row time {
  flex: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding-top: 6px;
}

.toolbar {
  display: grid;
  gap: 18px;
  margin-bottom: 26px;
}

.search {
  width: 100%;
  padding: 13px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}
.search::placeholder { color: var(--text-muted); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.chip {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 0;
}

/* --------------------------------------------------------------------------
   Article & prose
   -------------------------------------------------------------------------- */

.article {
  max-width: 760px;
  margin-inline: auto;
  padding: 56px 0 24px;
}

.article-head { margin-bottom: 34px; }

.article-head h1 {
  margin: 10px 0 14px;
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 3.6vw, 2.5rem);
  line-height: 1.35;
}

.article-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.prose { font-size: 1.02rem; }

.prose > p:first-of-type {
  font-size: 1.08rem;
  color: var(--text-muted);
}

.prose h2 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  margin: 2.1em 0 0.65em;
  line-height: 1.4;
}
.prose h3 {
  font-size: 1.1rem;
  margin: 1.7em 0 0.5em;
}
.prose p { margin: 0 0 1.15em; }
.prose ul,
.prose ol {
  padding-left: 1.4em;
  margin: 0 0 1.15em;
}
.prose li { margin-bottom: 0.4em; }

.prose blockquote {
  margin: 1.6em 0;
  padding: 14px 20px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 10px 10px 0;
  color: var(--text-muted);
}
.prose blockquote p { margin: 0; }

.prose pre {
  background: #1d2426;
  color: #e8e5dd;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 1.5em 0;
  font-size: 0.86rem;
  line-height: 1.65;
}

.prose code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
}
.prose pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.93rem;
}
.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 10px 13px;
  text-align: left;
  vertical-align: top;
}
.prose th {
  background: var(--surface-2);
  font-weight: 600;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.4em 0;
}

.prose a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-foot {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Page header & about
   -------------------------------------------------------------------------- */

.page-head { padding: 64px 0 34px; }
.page-head h1 {
  margin: 10px 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.3;
}
.page-head .lede { margin: 0; }

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 40px;
  padding-bottom: 64px;
  align-items: start;
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
}
.about-card + .about-card { margin-top: 16px; }
.about-card h2 {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: 1.15rem;
}
.about-card ul {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text-muted);
}
.about-card li { margin-bottom: 8px; }
.about-card p { margin: 0 0 10px; color: var(--text-muted); font-size: 0.94rem; }
.about-card p:last-child { margin-bottom: 0; }

.about-text p { margin: 0 0 1.1em; }
.about-text h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin: 1.8em 0 0.6em;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 56px;
  padding: 44px 0 26px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  padding-bottom: 30px;
}

.footer-title {
  margin: 0 0 12px;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.footer-note {
  margin: 12px 0 0;
  line-height: 1.8;
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--accent-strong); }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.84rem;
}
.footer-bottom p { margin: 0; }

.icp-slot a { color: var(--text-muted); }
.icp-slot a:hover { color: var(--accent-strong); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 52px 0 44px;
  }
  .about-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }

  .nav {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    display: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .nav.open { display: block; }
  .nav ul {
    flex-direction: column;
    gap: 2px;
    padding: 12px 20px 16px;
  }
  .nav a {
    display: block;
    padding: 10px 12px;
  }

  .header-actions { gap: 8px; }

  .note-row {
    flex-direction: column;
    gap: 8px;
  }
  .note-row time { padding-top: 0; }

  .section-head {
    flex-direction: column;
    gap: 6px;
  }

  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-bottom { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
