/* ============================================================
   Personal Blog — Clean & Modern
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --bg-elevated: #ffffff;
  --text: #1f2328;
  --text-soft: #57606a;
  --text-muted: #8b949e;
  --border: #e6e8eb;
  --border-strong: #d0d7de;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-ink: #3730a3;
  --code-bg: #f4f4f5;
  --quote-border: #c7d2fe;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.04);
  --radius: 14px;
  --radius-sm: 8px;
  --maxw: 720px;
  --maxw-wide: 1040px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #161a21;
  --bg-elevated: #1a1f27;
  --text: #e6e8eb;
  --text-soft: #b1bac4;
  --text-muted: #8b949e;
  --border: #262c36;
  --border-strong: #373e4a;
  --accent: #818cf8;
  --accent-soft: #1e1b4b;
  --accent-ink: #c7d2fe;
  --code-bg: #1a1f27;
  --quote-border: #4338ca;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  transition: background 0.25s ease, color 0.25s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--accent-ink);
}

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

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

/* ---------- Reading progress bar ---------- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  z-index: 100;
  transition: width 0.1s linear;
}

/* ---------- Navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover {
  color: var(--text);
}
.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-links a {
  color: var(--text-soft);
  font-size: 14.5px;
  padding: 7px 12px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--bg-soft);
}
.nav-links a.active {
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-weight: 600;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--border-strong);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Layout helpers ---------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}
.container-wide {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 72px 0;
}
.section-tight {
  padding: 48px 0;
}

/* ---------- Hero ---------- */
.hero {
  padding: 96px 0 72px;
  text-align: center;
}
.hero-eyebrow {
  display: inline-block;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(38px, 7vw, 60px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .tagline {
  font-size: clamp(16px, 2.4vw, 19px);
  color: var(--text-soft);
  max-width: 560px;
  margin: 0 auto 32px;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease,
    border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: var(--font-sans);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  color: #fff;
  background: var(--accent-ink);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-soft);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}
.btn svg { width: 16px; height: 16px; }

/* ---------- Section headings ---------- */
.section-head {
  margin-bottom: 32px;
}
.section-head .kicker {
  font-size: 12.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.section-head h2 {
  font-size: clamp(26px, 4vw, 34px);
  letter-spacing: -0.02em;
  margin: 8px 0 0;
  font-weight: 750;
}
.section-head p {
  color: var(--text-soft);
  margin: 10px 0 0;
  max-width: 540px;
}

/* ---------- Post grid ---------- */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}
.post-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  text-decoration: none;
  color: inherit;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  color: inherit;
}
.post-card .tag {
  align-self: flex-start;
}
.post-card h3 {
  font-size: 19px;
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--text);
  font-weight: 700;
}
.post-card .excerpt {
  color: var(--text-soft);
  font-size: 14.5px;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card .meta {
  margin-top: auto;
  padding-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.post-card .meta .sep { opacity: 0.5; }

/* ---------- Tag pills ---------- */
.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  letter-spacing: 0.01em;
}

/* ---------- Article list (archive) ---------- */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border);
}
.post-list li {
  border-bottom: 1px solid var(--border);
}
.post-list a {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 22px 4px;
  color: var(--text);
  transition: background 0.15s ease, padding-left 0.15s ease;
}
.post-list a:hover {
  background: var(--bg-soft);
  padding-left: 12px;
  color: var(--text);
}
.post-list .pl-date {
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-width: 92px;
}
.post-list .pl-title {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.post-list .pl-tag {
  margin-left: auto;
  align-self: center;
}

/* ---------- Article / prose ---------- */
.article-head {
  padding: 64px 0 32px;
}
.article-head .tag { margin-bottom: 16px; }
.article-head h1 {
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.18;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
  font-weight: 800;
}
.article-head .lede {
  font-size: 18px;
  color: var(--text-soft);
  margin: 0 0 18px;
}
.article-head .meta {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.article-head .meta .sep { opacity: 0.5; }

.article {
  padding: 8px 0 80px;
}
.prose {
  font-size: 16.5px;
  line-height: 1.8;
  color: var(--text);
}
.prose h2 {
  font-size: 26px;
  margin: 44px 0 14px;
  letter-spacing: -0.02em;
  font-weight: 750;
}
.prose h3 {
  font-size: 20px;
  margin: 32px 0 10px;
  font-weight: 700;
}
.prose p {
  margin: 0 0 18px;
}
.prose ul, .prose ol {
  margin: 0 0 18px;
  padding-left: 24px;
}
.prose li { margin-bottom: 8px; }
.prose blockquote {
  margin: 26px 0;
  padding: 6px 0 6px 20px;
  border-left: 3px solid var(--quote-border);
  color: var(--text-soft);
  font-style: italic;
}
.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--accent-ink);
}
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 20px 0;
}
.prose pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
  font-size: 14px;
}
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}
.prose img { margin: 20px 0; }

.article-footer {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.article-footer .back {
  font-size: 14.5px;
  font-weight: 600;
}

/* ---------- About page ---------- */
.about-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  padding: 64px 0 48px;
}
@media (min-width: 720px) {
  .about-hero { grid-template-columns: 140px 1fr; align-items: start; }
}
.avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-md);
}
.about-hero h1 {
  font-size: clamp(30px, 5vw, 40px);
  margin: 0 0 8px;
  letter-spacing: -0.025em;
  font-weight: 800;
}
.about-hero .role {
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 16px;
}
.about-hero .bio {
  color: var(--text-soft);
  font-size: 16.5px;
  margin: 0;
}

.socials {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.socials a {
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-soft);
  transition: all 0.15s ease;
}
.socials a:hover {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  margin-top: 48px;
  color: var(--text-muted);
  font-size: 14px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.footer a { color: var(--text-soft); }
.footer a:hover { color: var(--accent); }

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s, color 0.15s;
  z-index: 40;
}
.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover { color: var(--accent); }
.back-to-top svg { width: 20px; height: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .nav-links a { padding: 6px 9px; font-size: 13.5px; }
  .nav-inner { padding: 0 16px; }
  .container, .container-wide { padding: 0 18px; }
  .hero { padding: 64px 0 48px; }
  .section { padding: 52px 0; }
  .post-list a { flex-direction: column; align-items: flex-start; gap: 6px; }
  .post-list .pl-tag { margin-left: 0; }
}
