/* ============================================
   Blog Listing & Article
   ============================================ */

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-xl);
  padding: var(--space-2xl) 0;
}

.blog-card {
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.blog-card-image {
  aspect-ratio: 16/9;
  overflow: hidden;
  background-color: var(--light-100);
}

.blog-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.blog-card-body {
  padding: var(--space-lg);
}

.blog-card-meta {
  font-size: var(--fs-xs);
  color: var(--gray-500);
  margin-bottom: var(--space-sm);
}

.blog-card-title {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  margin-bottom: var(--space-sm);
}

.blog-card-title a {
  color: var(--black);
}

.blog-card-excerpt {
  font-size: var(--fs-sm);
  color: var(--gray-600);
}

.blog-sidebar-filters {
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.blog-sidebar-filters h4 {
  font-family: var(--font-heading);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  margin-bottom: var(--space-md);
}

.blog-tag-chip {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  margin: 0 var(--space-xs) var(--space-xs) 0;
  color: var(--gray-600);
}

.blog-tag-chip:hover,
.blog-tag-chip.active {
  border-color: var(--black);
  color: var(--black);
  background-color: var(--light-50);
}

/* ---------- Article page ---------- */
.article-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-2xl);
  padding: var(--space-2xl) 0 var(--space-4xl);
}

.article-toc {
  position: sticky;
  top: 100px;
  /* Without this the grid stretches the box to the full height of the article
     beside it, leaving it no room to move — so it never stuck even once the
     body's overflow was sorted out. */
  align-self: start;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-size: var(--fs-sm);
  /* A long contents list on a short window gets its own scroll rather than
     running off the bottom of the screen. */
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.article-toc h4 {
  font-family: var(--font-heading);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}

.article-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.article-toc li a {
  display: block;
  padding: 4px 0;
  color: var(--gray-600);
}

.article-toc li.level-3 a {
  padding-left: var(--space-md);
}

/* These sit after every base .article-toc rule on purpose. They used to come
   before them, where the later base rule won on equal specificity and quietly
   undid position:static — so the mobile layout never actually changed. */
@media (max-width: 900px) {
  .article-layout {
    grid-template-columns: 1fr;
  }

  /* One column here, so the contents list sits above the article as a normal
     block. Sticky would pin it over the text the reader is trying to read, and
     the viewport-height cap would strand it mid-scroll. */
  .article-toc {
    position: static;
    max-height: none;
    overflow-y: visible;
    margin-bottom: var(--space-lg);
  }

  /* Two columns of links instead of one tall list, so the article is still
     reachable without scrolling past the whole contents on a phone. */
  .article-toc ul {
    columns: 2;
    column-gap: var(--space-lg);
  }

  .article-toc li {
    break-inside: avoid;
  }
}

@media (max-width: 480px) {
  /* Too narrow for two columns once the headings are more than a few words. */
  .article-toc ul {
    columns: 1;
  }
}

.article-header h1 {
  font-family: var(--font-heading);
  font-size: var(--fs-4xl);
  margin-bottom: var(--space-sm);
}

.article-meta {
  color: var(--gray-500);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-lg);
}

.article-featured-image {
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-xl);
}

.article-featured-image img {
  width: 100%;
  height: auto;
}

.article-body {
  font-size: var(--fs-base);
  line-height: 1.8;
  color: var(--gray-700, #333);
}

.article-body h2 {
  font-family: var(--font-heading);
  font-size: var(--fs-2xl);
  margin: var(--space-xl) 0 var(--space-md);
}

.article-body h3 {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  margin: var(--space-lg) 0 var(--space-sm);
}

.article-body p {
  margin-bottom: var(--space-md);
}

.article-cta {
  background-color: var(--black);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  margin: var(--space-2xl) 0;
}

.article-tags {
  margin: var(--space-lg) 0;
}

.article-share {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  margin: var(--space-lg) 0;
}
