/* =========================================================
   Phytoworld · 样式
   设计方向：Organic / Natural（有机自然·植物学编辑风）
   首页布局参考 idealclover.top：左侧个人资料 + 右侧堆叠卡片
   图标：内联 SVG（icons.js），无 emoji、无外部依赖
   ========================================================= */

/* ---------- 本地衬线标题字体（有机自然风） ---------- */
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-400i.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}

:root {
  --bg: #f6f7f6;
  --bg-soft: #eef1ef;
  --bg-card: #ffffff;
  --text: #1f2328;
  --text-soft: #5b6470;
  --text-faint: #8b949e;
  --border: #e6e9e6;
  --accent: #1f7a4d;
  --accent-strong: #15803d;
  --accent-soft: #e8f3ec;
  --accent-2: #2f9e6b;
  --code-bg: #0d1117;
  --code-text: #e6edf3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-hover: 0 4px 14px rgba(22, 163, 74, .12), 0 14px 34px rgba(16, 24, 40, .10);
  --radius: 18px;
  --radius-sm: 10px;
  --maxw: 1120px;
  --readw: 760px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-head: "Fraunces", "Noto Serif SC", "Songti SC", "Source Han Serif SC", serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg: #0e1110;
  --bg-soft: #161a18;
  --bg-card: #161a17;
  --text: #e6edf3;
  --text-soft: #aeb6b0;
  --text-faint: #76828a;
  --border: #262b27;
  --accent: #4ade80;
  --accent-strong: #22c55e;
  --accent-soft: #142719;
  --accent-2: #3fae74;
  --code-bg: #0b0e0c;
  --code-text: #e6edf3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-hover: 0 4px 16px rgba(74, 222, 128, .18), 0 14px 32px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

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

/* 通用图标尺寸 */
.icon { width: 1.2em; height: 1.2em; flex: none; }

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: var(--maxw); margin: 0 auto 0 60px;
  padding: 13px 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand {
  font-family: var(--font-head); font-weight: 700; font-size: 19px; color: var(--text);
  display: flex; align-items: center; gap: 10px; letter-spacing: -.3px;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 800; font-family: var(--font);
}
.nav-links { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav-links a {
  color: var(--text-soft); padding: 7px 13px;
  border-radius: 9px; font-size: 14px; font-weight: 500;
}
.nav-links a:hover { background: var(--bg-soft); text-decoration: none; color: var(--text); }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }
.theme-toggle {
  border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--text); width: 36px; height: 36px; border-radius: 9px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle:hover { border-color: var(--accent); }

/* ---------- 首页两栏布局 ---------- */
.home-layout {
  max-width: var(--maxw); margin: 0 auto 0 60px;
  padding: 32px 20px 80px;
  display: grid; grid-template-columns: 280px 1fr; gap: 24px;
  align-items: start;
}

/* ---------- 左侧个人资料卡 ---------- */
.profile-sidebar { position: sticky; top: 84px; }
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.profile-avatar {
  width: 96px; height: 96px; border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 18px;
  border: 2px solid var(--border);
  background: var(--bg-soft);
}
.profile-name {
  margin: 0; font-family: var(--font-head); font-size: 26px;
  letter-spacing: -.3px; font-weight: 700;
}
.profile-tagline { margin: 6px 0 0; color: var(--accent-strong); font-weight: 600; font-size: 14px; }
.profile-bio { margin: 12px 0 0; color: var(--text-soft); font-size: 13.5px; line-height: 1.65; }
.profile-links { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.profile-link {
  font-size: 13.5px; padding: 9px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-soft); font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .15s ease;
}
.profile-link:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; background: var(--accent-soft); }
.profile-link [data-icon] { display: inline-flex; }

/* ---------- 右侧内容卡片 ---------- */
.home-content { display: flex; flex-direction: column; gap: 24px; }
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px 26px;
  box-shadow: var(--shadow);
}
.panel-title {
  font-family: var(--font-head); font-size: 18px; font-weight: 700;
  color: var(--text); margin: 0 0 18px; display: flex; align-items: center; gap: 8px;
}
.panel-title .icon { width: 18px; height: 18px; color: var(--accent); }
.panel-footer { margin-top: 18px; display: flex; justify-content: flex-end; }

/* ---------- 按钮 ---------- */
.btn-more {
  font-size: 13px; padding: 8px 18px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-soft); color: var(--text-soft); font-weight: 500;
  transition: all .15s ease;
}
.btn-more:hover { background: var(--accent); border-color: var(--accent); color: #fff; text-decoration: none; }

/* ---------- 文章筛选 chips ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  font-family: var(--font); font-size: 12.5px; padding: 5px 13px;
  border: 1px solid transparent; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-soft); font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  transition: all .15s ease;
}
.chip:hover { background: var(--border); color: var(--text); }
.chip.active { background: var(--accent); color: #fff; }
.chip .count { font-size: 11px; opacity: .65; }
.chip.active .count { opacity: .85; }

/* ---------- 文章列表（行式） ---------- */
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 16px; border-radius: var(--radius-sm);
  background: var(--bg-soft); color: inherit;
  transition: background .15s ease, transform .15s ease;
}
.post-row:hover {
  background: var(--accent-soft); transform: translateX(3px); text-decoration: none;
}
.post-row h3 {
  margin: 0; font-size: 15px; font-weight: 600; color: var(--text);
  line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.post-row .date {
  flex: none; font-size: 12px; color: var(--text-faint); font-family: var(--mono);
}

/* ---------- 标签 ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-size: 12.5px; padding: 3px 11px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-soft); font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
a.tag:hover { background: var(--accent); color: #fff; text-decoration: none; }

/* ---------- 项目展示（横向滚动卡片） ---------- */
.project-grid {
  display: flex; gap: 14px; overflow-x: auto;
  scroll-snap-type: x mandatory; padding-bottom: 6px;
  scrollbar-width: thin;
}
.project-grid::-webkit-scrollbar { height: 6px; }
.project-grid::-webkit-scrollbar-track { background: transparent; }
.project-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.project-card {
  flex: none; width: 260px; height: 170px; border-radius: var(--radius-sm);
  position: relative; overflow: hidden; scroll-snap-align: start;
  background-size: cover; background-position: center;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 16px;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.35);
  transition: transform .18s ease, box-shadow .18s ease;
}
.project-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); text-decoration: none; }
.project-card.blank {
  background: var(--bg-soft);
  border: 2px dashed var(--border);
  pointer-events: none;
}
.project-card.blank::after { display: none; }
.project-card.blank:hover { transform: none; box-shadow: none; }
.project-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.68) 0%, rgba(0,0,0,.22) 45%, rgba(0,0,0,.06) 100%);
  pointer-events: none;
}
.project-card > * { position: relative; z-index: 1; }
.project-card .name {
  font-family: var(--font-head); font-size: 16px; font-weight: 700;
  margin: 0; line-height: 1.3;
}
.project-card .desc {
  margin: 5px 0 0; font-size: 12.5px; line-height: 1.5; opacity: .92;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.project-card .metric {
  margin-top: 9px; font-size: 11px; font-family: var(--mono); opacity: .9;
  display: inline-flex; align-self: flex-start;
  background: rgba(255,255,255,.18); backdrop-filter: blur(4px);
  padding: 3px 8px; border-radius: 6px;
}

/* ---------- 文章详情 ---------- */
.article { max-width: var(--readw); margin: 0 auto; }
.article-header { margin-bottom: 28px; }
.article-header h1 { font-family: var(--font-head); font-size: 30px; margin: 0 0 10px; line-height: 1.28; letter-spacing: -.5px; font-weight: 700; }
.article-header .meta { color: var(--text-faint); font-size: 13.5px; font-family: var(--mono); }
.article-header .tags { margin-top: 14px; }
.back-link { display: inline-block; margin-bottom: 20px; font-size: 14px; color: var(--text-soft); }
.back-link:hover { color: var(--accent); }

/* ---------- Markdown 正文排版 ---------- */
.markdown { font-size: 16px; color: var(--text); }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  font-family: var(--font-head); margin: 1.7em 0 .6em; line-height: 1.3; font-weight: 700;
}
.markdown h2 { font-size: 23px; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 19px; }
.markdown p { margin: .9em 0; }
.markdown ul, .markdown ol { padding-left: 1.5em; margin: .8em 0; }
.markdown li { margin: .35em 0; }
.markdown blockquote {
  margin: 1.2em 0; padding: .6em 1.1em;
  border-left: 4px solid var(--accent);
  background: var(--bg-soft); color: var(--text-soft); border-radius: 0 8px 8px 0;
}
.markdown code {
  font-family: var(--mono); font-size: .88em;
  background: var(--bg-soft); padding: .15em .4em;
  border-radius: 5px; border: 1px solid var(--border);
}
.markdown pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px; overflow: auto;
  margin: 1.2em 0; line-height: 1.55;
}
.markdown pre code {
  background: none; border: none; padding: 0; font-size: 13.5px; color: var(--code-text);
}
.markdown img { max-width: 100%; border-radius: 10px; }
.markdown table { border-collapse: collapse; width: 100%; margin: 1.2em 0; font-size: 14.5px; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.markdown th { background: var(--bg-soft); }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

/* ---------- 标签分类页 ---------- */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 30px; }
.tag-cloud .tag { font-size: 14px; padding: 7px 15px; cursor: pointer; }
.tag-cloud .tag .count { opacity: .6; margin-left: 5px; font-size: 12px; }
.tag-cloud .tag.active { background: var(--accent); color: #fff; }
.tag-section-title { font-size: 15px; color: var(--text-faint); margin: 0 0 14px; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--border); color: var(--text-faint);
  font-size: 13px; text-align: center; padding: 30px 20px;
}
.site-footer a { color: var(--text-soft); }

/* ---------- 加载/错误状态 ---------- */
.status-box { text-align: center; padding: 60px 20px; color: var(--text-soft); }
.status-box code {
  background: var(--bg-soft); padding: 2px 8px; border-radius: 6px;
  font-family: var(--mono); border: 1px solid var(--border);
}

/* ---------- 入场动效（错落上浮） ---------- */
.card-anim { animation: riseIn .5s ease both; }
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card-anim { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- 复制反馈提示 ---------- */
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 10000;
  pointer-events: none;
  white-space: nowrap;
}
.copy-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .home-layout { grid-template-columns: 1fr; padding: 24px 16px 60px; }
  .profile-sidebar { position: static; }
  .profile-card { padding: 24px 20px; }
  .profile-avatar { width: 78px; height: 78px; }
  .panel { padding: 20px 18px 22px; }
  .post-row { padding: 12px 14px; }
  .post-row h3 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .post-row .date { display: none; }
  .project-card { width: 230px; height: 150px; }
}
