/* ============================================================
   全站唯一样式表。纯 CSS、无外部字体/图标/CDN，配合 CSP style-src 'self'。
   结构：设计变量 -> 基础 -> 布局 -> 组件 -> 工具类 -> 响应式 -> 深色模式
   ============================================================ */

:root {
  color-scheme: light dark;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-soft: #f1eee6;
  --text: #24231f;
  --text-soft: #5d5a52;
  --text-muted: #8a857a;
  --line: #e4dfd4;
  --accent: #b4552d;
  --accent-soft: #f6e9e1;
  --accent-2: #2f6f5e;
  --focus: #1f6feb;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 22px rgba(40, 34, 24, 0.06);
  --max: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191a19;
    --surface: #222422;
    --surface-soft: #2b2e2b;
    --text: #f0eee8;
    --text-soft: #c2beb4;
    --text-muted: #928d83;
    --line: #373a36;
    --accent: #e39b73;
    --accent-soft: #3a2c25;
    --accent-2: #8ecbb4;
    --shadow: 0 6px 22px rgba(0, 0, 0, 0.22);
  }
}

/* ------------------------------ 基础 ------------------------------ */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 2.9rem); margin: 0 0 0.6em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.7rem); margin: 0 0 0.7em; }
h3 { font-size: 1.12rem; margin: 0 0 0.45em; }
p { margin: 0 0 1.1em; }
ul { padding-left: 1.3em; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface-soft);
  padding: 0.12em 0.4em;
  border-radius: 4px;
}

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

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

.muted { color: var(--text-muted); font-size: 0.9rem; }
.eyebrow {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 0.8em;
}
.lede { font-size: 1.08rem; color: var(--text-soft); max-width: 62ch; }
.note {
  color: var(--text-soft);
  background: var(--surface-soft);
  border-left: 3px solid var(--accent-2);
  padding: 0.8em 1em;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.94rem;
}
.note-block { margin: 2.5rem 0 0; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  padding: 0.7em 1.1em;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
}
.skip-link:focus { left: 12px; top: 12px; }

/* ------------------------------ 头部 / 导航 ------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }

.site-nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  color: var(--text-soft);
  padding: 8px 13px;
  border-radius: 8px;
  font-size: 0.94rem;
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface-soft); text-decoration: none; color: var(--text); }
.nav-link.is-active { color: var(--accent); background: var(--accent-soft); font-weight: 700; }

.nav-toggle {
  display: none;
  width: 42px;
  height: 38px;
  padding: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  margin: 4px 0;
  background: var(--text);
  border-radius: 2px;
}

/* ------------------------------ 主体 / 页脚 ------------------------------ */

main { flex: 1 0 auto; padding-top: 40px; padding-bottom: 72px; }
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  color: var(--text-soft);
  font-size: 0.9rem;
  background: var(--surface);
}
.site-footer p { margin: 0 0 0.35em; }

.section { margin-top: 64px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 24px;
}
.section-head h2 { margin: 0; }
.more-link { font-size: 0.9rem; font-weight: 600; white-space: nowrap; }

.page-head { padding: 18px 0 12px; }
.page-head .lede { margin-bottom: 0.5em; }
.not-found { text-align: center; padding: 90px 0; }

/* ------------------------------ 首页 Hero ------------------------------ */

.hero {
  padding: 36px 0 8px;
  border-bottom: 1px solid var(--line);
}
.hero h1 { font-size: clamp(2.6rem, 8vw, 4.2rem); margin-bottom: 0.25em; }
.hero-dot { color: var(--accent); }
.hero-tagline {
  font-size: clamp(1.1rem, 2.6vw, 1.45rem);
  color: var(--text-soft);
  max-width: 46ch;
  margin-bottom: 1.4em;
}
.hero-bio { max-width: 66ch; color: var(--text-soft); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 36px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); color: #fff; opacity: 0.9; }
.btn-small { padding: 7px 14px; font-size: 0.86rem; margin-top: 0.6em; }

.hero-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 28px;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
}
.hero-meta div { min-width: 0; }
.hero-meta dt { color: var(--text-muted); font-size: 0.8rem; }
.hero-meta dd { margin: 2px 0 0; font-size: 1.1rem; font-weight: 700; }

/* ------------------------------ 卡片 / 网格 ------------------------------ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.card-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid-single { grid-template-columns: 1fr; gap: 12px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, border-color 160ms ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card-media { display: block; aspect-ratio: 3 / 2; overflow: hidden; background: var(--surface-soft); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 300ms ease; }
.card:hover .card-media img { transform: scale(1.04); }
.card-body { padding: 18px 20px 20px; }
.card-body h3 a { color: var(--text); }
.card-body h3 a:hover { color: var(--accent); }
.card-meta { color: var(--text-muted); font-size: 0.8rem; margin: 0 0 0.5em; }
.card-summary { color: var(--text-soft); font-size: 0.93rem; margin: 0; }
.card-text { box-shadow: none; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 14px 0 0; }
.tag {
  font-size: 0.76rem;
  color: var(--accent-2);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ------------------------------ 图文 / 文章 ------------------------------ */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.photo-tile { margin: 0; }
.photo-tile img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.photo-tile figcaption {
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.55;
}
.photo-set { margin-top: 48px; }
.photo-set-head { margin-bottom: 20px; }
.photo-set-head .lede { font-size: 1rem; }

.article, .tool-page { max-width: 760px; margin: 0 auto; }
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.article-head { margin-bottom: 30px; }
.article-head .lede { font-size: 1.15rem; }
.article-cover {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 32px;
}
.prose { font-size: 1.02rem; }
.prose h2 { margin-top: 2em; }
.prose h3 { margin-top: 1.6em; }
.prose figure { margin: 2em 0; }
.prose figure img { border-radius: var(--radius-sm); border: 1px solid var(--line); }
.prose figcaption { color: var(--text-muted); font-size: 0.86rem; margin-top: 8px; text-align: center; }
.prose blockquote {
  margin: 1.8em 0;
  padding: 0.6em 1.2em;
  border-left: 3px solid var(--accent);
  background: var(--surface-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text);
  font-size: 1.06rem;
}
.prose blockquote p { margin: 0; }
.prose li { margin-bottom: 0.4em; }
.article-foot { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }

/* ------------------------------ 工具演示 ------------------------------ */

.tool-root { margin: 28px 0 0; }
.tool-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.tool-label { display: block; font-weight: 700; margin-bottom: 8px; }
.tool-input {
  width: 100%;
  min-height: 132px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.98rem;
  line-height: 1.7;
  resize: vertical;
}
.tool-input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.tool-result {
  margin-top: 20px;
  padding: 18px 20px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  min-height: 64px;
}
.tool-result-title { display: block; font-size: 0.8rem; color: var(--text-soft); margin-bottom: 4px; }
.tool-result-value { font-size: 1.3rem; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.tool-hint { font-size: 0.84rem; color: var(--text-muted); margin: 12px 0 0; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.stat {
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-label { display: block; font-size: 0.8rem; color: var(--text-soft); margin-top: 4px; }

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 860px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 720px) {
  .container { padding: 0 18px; }
  main { padding-top: 26px; padding-bottom: 52px; }
  .section { margin-top: 48px; }
  .header-inner { min-height: 60px; flex-wrap: wrap; position: relative; }
  .nav-toggle { display: block; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px 18px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: flex; }
  .nav-link { padding: 11px 12px; font-size: 1rem; }
  .hero { padding-top: 20px; }
  .hero-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .card-grid, .card-grid-two, .photo-grid { grid-template-columns: 1fr; }
  .section-head { flex-wrap: wrap; gap: 4px; }
  .tool-panel { padding: 16px; }
  .article-head .lede { font-size: 1.05rem; }
}

@media (prefers-color-scheme: dark) {
  .btn-primary, .btn-primary:hover { color: #191a19; }
}

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