/* Yitian's AIDD Blog - main stylesheet (light/dark aware sidebar layout) */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-code: #f2f4f7;
  --text: #1b1f24;
  --text-soft: #5b6472;
  --text-faint: #8b94a3;
  --border: #e6e8ec;
  --border-strong: #d5d9e0;
  --accent: #1f7a6d;
  --accent-soft: rgba(31, 122, 109, 0.1);
  --radius: 10px;
  --sidebar-w: 288px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --bg-soft: #1a1e24; --bg-code: #1f242c;
    --text: #dfe4ea; --text-soft: #a5aebc; --text-faint: #7b8494;
    --border: #262c35; --border-strong: #333b46;
    --accent: #58c4b3; --accent-soft: rgba(88, 196, 179, 0.12);
  }
}

:root[data-theme="dark"] {
  --bg: #14171c; --bg-soft: #1a1e24; --bg-code: #1f242c;
  --text: #dfe4ea; --text-soft: #a5aebc; --text-faint: #7b8494;
  --border: #262c35; --border-strong: #333b46;
  --accent: #58c4b3; --accent-soft: rgba(88, 196, 179, 0.12);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }

/* sidebar */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  overflow-y: auto; padding: 36px 26px 28px;
  background: var(--bg-soft); border-right: 1px solid var(--border);
}
.profile { text-align: center; }
.profile img.avatar {
  width: 112px; height: 112px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border-strong); background: var(--bg);
}
.profile .name { margin: 16px 0 4px; font-size: 21px; font-weight: 650; letter-spacing: -0.01em; }
.profile .tagline { margin: 0 auto; max-width: 220px; font-size: 14px; line-height: 1.6; color: var(--text-soft); }
.social { display: flex; justify-content: center; gap: 12px; margin: 20px 0 4px; }
.social a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; color: var(--text-soft);
  border: 1px solid transparent;
}
.social a:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--border); text-decoration: none; }
.social svg { width: 18px; height: 18px; }

.sidebar nav {
  margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar nav a { padding: 6px 8px; border-radius: 7px; font-size: 14.5px; color: var(--text-soft); }
.sidebar nav a:hover, .sidebar nav a.active { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.recent { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.recent h2 {
  margin: 0 0 10px; font-size: 12px; font-weight: 650;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-faint);
}
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { margin-bottom: 11px; }
.recent li a { display: block; font-size: 14px; line-height: 1.45; color: var(--text); }
.recent li a:hover { color: var(--accent); text-decoration: none; }
.recent li time { display: block; margin-top: 2px; font-size: 12px; color: var(--text-faint); }

.sidebar-foot {
  margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 12px; line-height: 1.6; color: var(--text-faint);
}
.theme-toggle {
  margin-top: 14px; width: 100%; padding: 7px 10px;
  font: inherit; font-size: 13px; color: var(--text-soft);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* main column */
.main { margin-left: var(--sidebar-w); padding: 56px 40px 96px; }
.wrap { max-width: 768px; }
.page-head { margin-bottom: 40px; }
.page-head h1 { margin: 0 0 10px; font-size: 32px; line-height: 1.25; letter-spacing: -0.02em; }
.page-head .lede { margin: 0; font-size: 16.5px; color: var(--text-soft); }

/* post list */
.post-list { display: flex; flex-direction: column; }
.post-item { padding: 22px 0; border-top: 1px solid var(--border); display: flex; gap: 22px; align-items: flex-start; }
.post-item:first-child { border-top: 0; padding-top: 4px; }
.post-item h2 { margin: 0 0 6px; font-size: 21px; font-weight: 620; line-height: 1.35; letter-spacing: -0.01em; }
.post-item h2 a { color: var(--text); }
.post-item h2 a:hover { color: var(--accent); text-decoration: none; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; color: var(--text-faint); }
.meta .dot, .post-meta .dot { color: var(--border-strong); }
.post-item p.summary { margin: 8px 0 0; font-size: 15.5px; color: var(--text-soft); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block; padding: 2px 9px; font-size: 12px; line-height: 1.6;
  color: var(--text-soft); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px;
}
a.tag:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); text-decoration: none; }

/* article */
article.post .post-title { margin: 0 0 12px; font-size: 33px; line-height: 1.25; letter-spacing: -0.02em; }
article.post .post-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding-bottom: 20px; margin-bottom: 28px; border-bottom: 1px solid var(--border);
  font-size: 13.5px; color: var(--text-faint);
}
.post-body { font-size: 17px; }
.post-body p { margin: 0 0 1.15em; }
.post-body h2 { margin: 2.1em 0 0.7em; font-size: 24px; line-height: 1.3; letter-spacing: -0.01em; }
.post-body h3 { margin: 1.8em 0 0.6em; font-size: 19.5px; }
.post-body ul, .post-body ol { margin: 0 0 1.15em; padding-left: 1.4em; }
.post-body li { margin-bottom: 0.4em; }
.post-body blockquote {
  margin: 1.4em 0; padding: 2px 0 2px 18px;
  border-left: 3px solid var(--border-strong); color: var(--text-soft); font-style: italic;
}
.post-body blockquote p:last-child { margin-bottom: 0; }
.post-body code {
  padding: 0.15em 0.38em; font-family: var(--mono); font-size: 0.88em;
  background: var(--bg-code); border-radius: 5px;
}
.post-body pre {
  margin: 1.4em 0; padding: 16px 18px; overflow-x: auto;
  background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; line-height: 1.65;
}
.post-body pre code { padding: 0; background: none; font-size: inherit; }
.post-body hr { margin: 2.4em 0; border: 0; border-top: 1px solid var(--border); }

figure { margin: 1.9em 0; text-align: center; }
figure img { display: block; margin: 0 auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft); }
figcaption { margin-top: 10px; font-size: 13.5px; line-height: 1.6; color: var(--text-faint); }

.table-scroll { overflow-x: auto; }
.post-body table { width: 100%; margin: 1.6em 0; border-collapse: collapse; font-size: 14.5px; }
.post-body th, .post-body td { padding: 9px 12px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.post-body thead th { background: var(--bg-soft); font-weight: 620; }

.toc {
  margin: 0 0 32px; padding: 16px 20px; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 14.5px;
}
.toc h2 { margin: 0 0 8px; font-size: 12px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-faint); }
.toc ol { margin: 0; padding-left: 1.25em; }
.toc li { margin-bottom: 3px; }
.toc a { color: var(--text-soft); }
.toc a:hover { color: var(--accent); }

.post-foot { margin-top: 46px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-soft); }
.post-foot .source { margin: 0 0 6px; padding: 12px 15px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); }
.post-nav { display: flex; justify-content: space-between; gap: 18px; margin-top: 30px; font-size: 14.5px; }
.post-nav span { color: var(--text-faint); }

.site-foot { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--text-faint); }

@media (max-width: 960px) {
  .sidebar { position: static; width: auto; height: auto; padding: 28px 22px 24px; border-right: 0; border-bottom: 1px solid var(--border); }
  .profile img.avatar { width: 88px; height: 88px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .main { margin-left: 0; padding: 36px 22px 72px; }
  article.post .post-title { font-size: 27px; }
  .page-head h1 { font-size: 26px; }
  .post-body { font-size: 16.5px; }
}

@media (max-width: 520px) {
  .main { padding: 28px 18px 64px; }
  .post-body h2 { font-size: 21px; }
  .post-nav { flex-direction: column; gap: 8px; }
}

@media print {
  .sidebar, .toc, .post-nav, .site-foot { display: none; }
  .main { margin: 0; padding: 0; }
  a { color: inherit; }
}

/* ---------- profile page ---------- */

.profile-hero { margin: -6px 0 0; }
.profile-hero-img {
  width: 100%; height: 268px; object-fit: cover; object-position: center 46%;
  border-radius: var(--radius); border: 1px solid var(--border); display: block;
}
.profile-head { display: flex; gap: 22px; align-items: center; margin-top: 26px; padding: 0 4px; }
.profile-photo {
  width: 132px; height: 132px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--bg); box-shadow: 0 2px 14px rgba(16, 24, 40, 0.16); background: var(--bg); flex: none;
}
.profile-head h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -0.02em; }
.profile-sub { margin: 0 0 6px; font-size: 15px; color: var(--text-soft); }
.profile-links { margin: 0; font-size: 14px; color: var(--text-faint); }
.profile-lede { margin: 24px 0 4px; font-size: 17px; }
.profile-note { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-soft); }

.timeline { list-style: none; margin: 0 0 10px; padding: 0; }
.timeline > li {
  display: grid; grid-template-columns: 138px 1fr; gap: 18px;
  padding: 15px 0; border-top: 1px solid var(--border);
}
.timeline > li:first-child { border-top: 0; }
.tl-when { font-size: 13px; color: var(--text-faint); padding-top: 3px; }
.tl-what { font-size: 15.5px; }
.tl-what .tl-role { color: var(--text-soft); }
.tl-what .tl-where { color: var(--text-faint); font-size: 13.5px; }
.tl-what ul { margin: 8px 0 0; padding-left: 1.1em; }
.tl-what li { margin-bottom: 5px; }

.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.pub { margin: 0 0 14px; font-size: 15px; }
.pub .pub-meta { color: var(--text-faint); font-size: 13.5px; }

@media (max-width: 640px) {
  .profile-hero-img { height: 190px; }
  .profile-head { flex-direction: column; align-items: flex-start; gap: 14px; margin-top: 20px; padding: 0 4px; }
  .profile-photo { width: 104px; height: 104px; }
  .timeline > li { grid-template-columns: 1fr; gap: 4px; }
}

/* list covers (WeChat-style, right of each entry) */
.post-text { flex: 1 1 auto; min-width: 0; }
.post-cover { flex: none; display: block; }
.post-cover img {
  width: 132px; height: 132px; object-fit: cover; display: block;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.post-cover:hover img { transform: translateY(-2px); border-color: var(--accent); }

@media (max-width: 560px) {
  .post-item { gap: 14px; }
  .post-cover img { width: 96px; height: 96px; border-radius: 8px; }
}
