:root {
  --article-width: 720px;
}

/* Blog layout */
.blog-main {
  padding: 140px 0 80px;
}

.blog-header {
  text-align: center;
  margin-bottom: 48px;
}

.blog-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  margin: 0 0 12px;
  line-height: 1.1;
}

.blog-header p {
  color: var(--muted);
  max-width: 560px;
  margin: 0 auto;
}

/* Tag filter */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 40px;
}

.tag-filter button {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}

.tag-filter button:hover,
.tag-filter button.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

/* Post cards on listing */
.posts-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.post-card .post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.post-card time {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.post-card h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0;
  line-height: 1.25;
}

.post-card h2 a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.post-card p {
  color: var(--muted);
  margin: 0;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Post detail */
.post-detail {
  padding: 140px 0 80px;
}

.post-detail .container {
  max-width: var(--article-width);
}

.post-detail header {
  margin-bottom: 48px;
}

.post-detail .post-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.post-detail h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
  margin: 0 0 18px;
}

.post-detail .excerpt {
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.6;
}

.article-body {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.75;
}

.article-body h2,
.article-body h3,
.article-body h4 {
  font-family: var(--font-display);
  margin-top: 2.2em;
  margin-bottom: 0.7em;
  line-height: 1.2;
}

.article-body h2 { font-size: 1.6rem; }
.article-body h3 { font-size: 1.3rem; }
.article-body h4 { font-size: 1.1rem; }

.article-body p {
  margin: 0 0 1.4em;
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.4em;
  padding-left: 1.4em;
}

.article-body li {
  margin-bottom: 0.5em;
}

.article-body blockquote {
  margin: 1.8em 0;
  padding: 18px 24px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
  font-style: italic;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(45,212,191,0.1);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 6px;
}

.article-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin: 0 0 1.6em;
}

.article-body pre code {
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

.article-body img {
  max-width: 100%;
  border-radius: var(--radius);
}

/* Related posts */
.related-posts {
  margin-top: 72px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}

.related-posts h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: 20px;
}

/* Empty / error states */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
}

.empty-state a {
  color: var(--accent);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .post-card,
  .article-body * {
    transition: none !important;
  }
}

/* Responsive */
@media (max-width: 640px) {
  .blog-main,
  .post-detail {
    padding-top: 120px;
  }
}
