/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #ffffff;
  --surface:  #f8f8f8;
  --border:   #e5e5e5;
  --text:     #1a1a1a;
  --muted:    #6b7280;
  --accent:   #2563eb;
  --accent-h: #1d4ed8;
  --code-bg:  #1e1e2e;
  --radius:   6px;
  --max-w:    720px;
  --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono:     'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0f0f0f;
    --surface: #1a1a1a;
    --border:  #2e2e2e;
    --text:    #e5e5e5;
    --muted:   #9ca3af;
  }
}

html { font-size: 17px; }

body {
  font-family: var(--font);
  background:  var(--bg);
  color:       var(--text);
  line-height: 1.65;
  min-height:  100vh;
  display:     flex;
  flex-direction: column;
}

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

img { max-width: 100%; height: auto; display: block; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: calc(var(--max-w) + 2rem);
  margin: 0 auto;
  padding: 0 1rem;
}

main.container { flex: 1; padding-top: 2.5rem; padding-bottom: 4rem; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.site-header nav { display: flex; gap: 1.25rem; }
.site-header nav a { color: var(--muted); font-size: 0.9rem; }
.site-header nav a:hover { color: var(--text); text-decoration: none; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 2.5rem; }
.page-header h1 { font-size: 1.75rem; }
.site-desc { color: var(--muted); margin-top: 0.4rem; }
.tag-highlight { color: var(--accent); }

/* ── Post list ───────────────────────────────────────────────────────────── */
.post-list { display: flex; flex-direction: column; gap: 2.5rem; }

.post-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.post-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }

.post-card .post-cover img {
  width: 100%; height: 220px; object-fit: cover;
}

.post-card-body { padding: 1.25rem 1.5rem 1.5rem; }

/* ── Post meta & tags ────────────────────────────────────────────────────── */
.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.tag {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1em 0.65em;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
}
.tag:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.post-card h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--accent); text-decoration: none; }
.excerpt { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.75rem; }
.read-more { font-size: 0.9rem; font-weight: 500; }

.empty { color: var(--muted); }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ── Single post ─────────────────────────────────────────────────────────── */
.post-header { margin-bottom: 2rem; }
.post-header h1 { font-size: 2rem; line-height: 1.25; margin: 0.4rem 0 1rem; }
.post-cover-full {
  width: 100%; border-radius: var(--radius);
  max-height: 420px; object-fit: cover;
}

/* ── Post body (rendered markdown) ──────────────────────────────────────── */
.post-body { max-width: var(--max-w); }

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  margin: 2rem 0 0.75rem;
  line-height: 1.3;
}
.post-body h1 { font-size: 1.7rem; }
.post-body h2 { font-size: 1.35rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.post-body h3 { font-size: 1.1rem; }

.post-body p  { margin: 1rem 0; }
.post-body ul,
.post-body ol { margin: 1rem 0; padding-left: 1.75rem; }
.post-body li { margin: 0.25rem 0; }

.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1.25rem 0;
  color: var(--muted);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.post-body a { color: var(--accent); }

.post-body img {
  border-radius: var(--radius);
  margin: 1.5rem auto;
}

/* Inline code */
.post-body code:not([class]) {
  font-family: var(--mono);
  font-size: 0.87em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.15em 0.4em;
}

/* Code blocks */
.post-body pre {
  background: var(--code-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.88rem;
  line-height: 1.6;
}
.post-body pre code {
  font-family: var(--mono);
  background: none;
  border: none;
  padding: 0;
  color: #cdd6f4;
}

.post-body table {
  width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.93rem;
}
.post-body th,
.post-body td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; }
.post-body th { background: var(--surface); font-weight: 600; }

.post-body hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ── Post footer ─────────────────────────────────────────────────────────── */
.post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.back-link { font-size: 0.9rem; }
.post-tags { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Error page ──────────────────────────────────────────────────────────── */
.error-page { text-align: center; padding: 4rem 0; }
.error-page h1 { font-size: 5rem; color: var(--border); margin-bottom: 1rem; }
.error-page p  { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  html { font-size: 16px; }
  .post-header h1 { font-size: 1.6rem; }
  .post-card-body { padding: 1rem; }
}
