<style>
.blog-search input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
}
.blog-search button {
  padding: 12px 18px;
  border: none;
  border-radius: 8px;
  background: #a600d8;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.blog-search button:hover {
  background: #8a00b8;
}

/* 卡片容器 */
.blog-articles {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
  gap: 20px !important;
  margin-top: 20px;
}

/* 卡片樣式 */
.article-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s;
  height: 320px; /* ✅ 固定卡片高度 */
}
.article-card:hover {
  transform: translateY(-5px);
}
.article-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

/* 內容區塊 */
.article-card__info {
  padding: 12px;
  flex: 1; /* ✅ 保持卡片撐滿 */
  display: flex;
  align-items: flex-start;
}

/* 標題固定行數（避免太長） */
.article-card__header h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;  /* ✅ 限制最多 2 行 */
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card__header h2 a {
  text-decoration: none;
  color: #222;
}
.article-card__header h2 a:hover {
  color: #a600d8;
}


/* 強制隱藏內文/摘要/作者 */
.article-card__excerpt,
.article-card__content,
.article-card p,
.article-card .article-card__footer {
  display: none !important;
}
</style>


<script>
function filterArticles() {
  var input = document.getElementById("searchInput").value.toLowerCase().trim();
  var articles = document.querySelectorAll("#articlesList .article-card");

  articles.forEach(function(article) {
    var title = article.querySelector("h2 a").innerText.toLowerCase();
    if (title.includes(input)) {
      article.style.display = "flex";
    } else {
      article.style.display = "none";
    }
  });
}

document.addEventListener("DOMContentLoaded", function() {
  var searchInput = document.getElementById("searchInput");
  if (searchInput) {
    searchInput.addEventListener("input", filterArticles);
  }
});
</script>
