/* === CSS Variables / Theme ============================================= */

:root {
  --bg: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #555;
  --text-muted: #888;
  --border: #e2e2e8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --code-bg: #f5f5f7;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 12px;
  --max-width: 760px;
  --header-height: 60px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #161b22;
  --text: #e6edf3;
  --text-secondary: #9da7b3;
  --text-muted: #6e7681;
  --border: #30363d;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --code-bg: #1c2128;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.4);
}

/* === Reset =============================================================== */

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

img { max-width: 100%; height: auto; border-radius: 8px; }

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

/* === Header ============================================================== */

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

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
}

.logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.logo:hover { color: var(--accent); }

.site-header nav {
  display: flex;
  gap: 24px;
  align-items: center;
}

.site-header nav a {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  position: relative;
}
.site-header nav a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width var(--transition);
}
.site-header nav a:hover { color: var(--accent); }
.site-header nav a:hover::after { width: 100%; }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* === Main ================================================================ */

main {
  flex: 1;
  padding: 48px 0;
}

/* Hero */
.hero {
  text-align: center;
  margin-bottom: 56px;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}
.hero .subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
}

/* Post list */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  transition: all var(--transition);
}
.post-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.post-card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--accent); }
.post-card .excerpt {
  color: var(--text-secondary);
  margin: 12px 0 16px;
  font-size: 0.95rem;
}
.read-more {
  font-size: 0.9rem;
  font-weight: 600;
}

/* Post meta */
.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.post-meta time { font-weight: 500; }
.tag {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* === Single post ========================================================= */

.post-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.post-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
  line-height: 1.3;
}

.post-body {
  font-size: 1.05rem;
  line-height: 1.85;
}
.post-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5em;
  margin-bottom: 0.6em;
  letter-spacing: -0.02em;
}
.post-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2em;
  margin-bottom: 0.5em;
}
.post-body p { margin-bottom: 1.2em; }
.post-body ul, .post-body ol {
  margin-bottom: 1.2em;
  padding-left: 1.5em;
}
.post-body li { margin-bottom: 0.5em; }
.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 0 8px 20px;
  margin: 1.5em 0;
  color: var(--text-secondary);
  font-style: italic;
}
.post-body code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
}
.post-body pre {
  background: var(--code-bg);
  padding: 20px 24px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5em 0;
  border: 1px solid var(--border);
}
.post-body pre code {
  background: none;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.6;
}
.post-body img {
  margin: 1.5em 0;
  box-shadow: var(--shadow);
}
.post-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.post-body a:hover { text-decoration-color: var(--accent); }
.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}
.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95rem;
}
.post-body th, .post-body td {
  border: 1px solid var(--border);
  padding: 8px 14px;
  text-align: left;
}
.post-body th { background: var(--bg-secondary); font-weight: 600; }

/* Post nav */
.post-nav {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.post-nav a {
  font-size: 0.9rem;
  font-weight: 600;
}

/* === Generic page ======================================================== */

.page h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}
.page h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 2em;
  margin-bottom: 0.6em;
}
.page p { margin-bottom: 1em; color: var(--text-secondary); }
.page ul { padding-left: 1.5em; margin-bottom: 1em; }
.page li { margin-bottom: 0.4em; color: var(--text-secondary); }
.page code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
}

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

/* === Footer ============================================================== */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* === Responsive ========================================================== */

@media (max-width: 640px) {
  .hero h1 { font-size: 1.8rem; }
  .hero .subtitle { font-size: 1rem; }
  .post-card { padding: 20px; }
  .post-header h1 { font-size: 1.5rem; }
  .post-body { font-size: 1rem; }
  .site-header nav { gap: 14px; }
  .site-header nav a { font-size: 0.85rem; }
  .container { padding: 0 16px; }
}

/* === Scrollbar =========================================================== */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Selection =========================================================== */

::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
