/* Dark-mode-first minimal blog theme */
:root {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --accent: #7ab3e4;
  --accent-hover: #a8d0f0;
  --border: #21262d;
  --code-bg: #161b22;
  --max-width: 800px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafafa;
    --bg-secondary: #f0f0f0;
    --text: #2c2c2c;
    --text-muted: #666;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #ddd;
    --code-bg: #f5f5f5;
  }
}

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

html { scroll-behavior: smooth; }

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

/* Navigation */
header { border-bottom: 1px solid var(--border); }

nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-home {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.3rem;
  line-height: 1;
}

.site-home:hover { color: var(--text); }

.nav-links { display: flex; gap: 1.5rem; }

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 300;
}

.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); font-weight: 500; }

/* Main content */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
  width: 100%;
}

/* Links */
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Author intro (home page) */
.author-intro {
  text-align: center;
  margin-bottom: 3rem;
}

.avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin-bottom: 1rem;
}

.author-intro h1 { font-size: 1.5rem; font-weight: 400; margin-bottom: 0.25rem; }
.author-intro p { color: var(--text-muted); font-weight: 300; }

/* Recent posts on home */
.recent-posts h2 { font-weight: 400; font-size: 1.2rem; margin-bottom: 0.75rem; }

/* Post list */
.post-list { list-style: none; }

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.post-list a { text-decoration: none; font-weight: 300; color: var(--text-muted); }
.post-list a:hover { color: var(--text); }
.post-list time { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; margin-left: 1rem; }

/* Posts index page */
.post-list-page { text-align: center; }
.post-list-page h1 { font-size: 2.5rem; font-weight: 300; margin-bottom: 2rem; }
.post-list-page .year-group { text-align: left; margin-bottom: 2rem; }
.post-list-page .year-group h2 { font-size: 1.3rem; font-weight: 400; margin-bottom: 0.25rem; }
.post-list-page .post-list li:first-child { border-top: 1px solid var(--border); }

/* Post / Page */
article header { border: none; margin-bottom: 2.5rem; }
article h1 { font-size: 1.6rem; font-weight: 400; line-height: 1.3; margin-bottom: 1.5rem; }

.page-content { line-height: 1.9; }
article time { color: var(--text-muted); font-size: 0.9rem; }

.post-content h2, .page-content h2 { font-size: 1.3rem; font-weight: 400; margin: 2.5rem 0 1rem; }
.post-content h3, .page-content h3 { font-size: 1.1rem; font-weight: 400; margin: 2rem 0 0.75rem; }
.post-content h4, .page-content h4 { font-size: 1rem; font-weight: 400; margin: 1.25rem 0 0.5rem; }

.post-content p, .page-content p { margin-bottom: 1.25rem; }

.post-content img, .page-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1rem 0;
}

.post-content ul, .post-content ol,
.page-content ul, .page-content ol {
  margin: 0.5rem 0 1rem 1.5rem;
}

.post-content li, .page-content li { margin-bottom: 0.25rem; }

/* Code blocks */
code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
  position: relative;
}

pre code { background: none; padding: 0; }

/* Copy button */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-family: inherit;
  opacity: 0;
  transition: opacity 0.15s;
}

pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--text-muted); }
.copy-btn.copied { color: #58a6ff; }

/* Table of contents */
.toc {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 2rem;
}

.toc summary {
  cursor: pointer;
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toc ul { list-style: none; margin: 0.5rem 0 0 0; }
.toc li { margin: 0.25rem 0; }
.toc a { text-decoration: none; font-size: 0.9rem; }
.toc .toc-h3 { padding-left: 1rem; }
.toc .toc-h4 { padding-left: 2rem; }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.social-links { margin-bottom: 0.5rem; display: flex; justify-content: center; gap: 1.5rem; }
.social-links a { color: var(--text-muted); text-decoration: none; }
.social-links a:hover { color: var(--text); }

/* Go to top */
.go-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  opacity: 0.6;
}

.go-to-top:hover { opacity: 1; color: var(--text); }

/* 404 */
.not-found { text-align: center; padding: 4rem 0; }
.not-found h1 { font-size: 4rem; font-weight: 300; color: var(--text-muted); }
.not-found p { margin: 1rem 0; color: var(--text-muted); }

/* Responsive */
@media (max-width: 600px) {
  .post-list li { flex-direction: column; gap: 0.25rem; }
  .post-list time { margin-left: 0; }
}
