/* ===================================================================
   css/pages/articles-mobile-filter-20261203.css
   衛教總覽（articles.html）手機版：分類篩選 + 每區塊預設 3 篇
   建立日期：2026-12-03

   問題（依劉醫師手機版要求）：
     衛教總覽在手機上是 11 個 sub-section、46 篇文章連續排列，
     病人不是來逛全部文章，而是來找一個答案 → 需要篩選與折疊。

   實作：
   1. 頂部篩選列：5 大分類 + 全部（可橫向捲動）
   2. 每個 sub-section 手機預設顯示前 3 篇，其餘折疊（.is-collapsed）
      「看更多」按鈕展開剩餘篇數
   3. 桌機（>768px）完全不變：全部文章、沒有篩選列
   =================================================================== */

/* ---------- 篩選列（桌機隱藏） ---------- */
.art-filter {
  display: none;
}

@media (max-width: 768px) {
  .art-filter {
    display: block;
    margin: 0 0 1.25rem;
    padding: 0.75rem 0;
    background: #fff;
    border: 1px solid #e8eaf2;
    border-radius: 10px;
    position: sticky;
    top: 68px;                 /* 配合 sticky header */
    z-index: 40;
  }

  .art-filter-label {
    display: block;
    font-size: 0.75rem;
    color: #5a6a8a;
    font-weight: 600;
    padding: 0 0.85rem 0.5rem;
    letter-spacing: 0.05em;
  }

  .art-filter-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 0.85rem 0.25rem;
    scrollbar-width: none;
  }

  .art-filter-list::-webkit-scrollbar { display: none; }

  .art-filter-btn {
    flex: 0 0 auto;
    min-height: 40px;           /* 觸控目標 */
    padding: 0.5rem 0.9rem;
    border: 1px solid #d5dbe8;
    border-radius: 999px;
    background: #fff;
    color: #1B2952;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
  }

  .art-filter-btn[aria-pressed="true"] {
    background: #1B2952;
    color: #fff;
    border-color: #1B2952;
  }

  .art-filter-btn:focus-visible {
    outline: 3px solid #b8892a;
    outline-offset: 2px;
  }
}

/* ---------- 每區塊預設 3 篇 ---------- */
@media (max-width: 768px) {
  /* 被折疊的文章（不限 .sub-section，article-list 可能出現在其他容器） */
  .article-row.is-collapsed {
    display: none;
  }

  /* 「看更多」按鈕 */
  .art-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    min-height: 48px;           /* 觸控目標 */
    margin-top: 0.6rem;
    padding: 0.7rem 1rem;
    border: 1px solid #c5d4f0;
    border-radius: 8px;
    background: #f0f4ff;
    color: #1B2952;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    text-align: center;
  }

  .art-more-btn:focus-visible {
    outline: 3px solid #b8892a;
    outline-offset: 2px;
  }

  .art-more-btn[aria-expanded="true"] {
    background: #fff;
    color: #5a6a8a;
    border-color: #e8eaf2;
  }

  /* 展開後隱藏按鈕 */
  .art-more-btn[hidden] { display: none; }
}

/* 桌機：全部文章可見，不顯示「看更多」按鈕 */
@media (min-width: 769px) {
  .art-more-btn { display: none !important; }
}

/* ---------- 篩選生效時：隱藏不屬於該分類的整個 section ---------- */
@media (max-width: 768px) {
  .section.art-filtered-out { display: none; }

  /* 篩選後仍保留「看更多」的展開狀態 */
  .section.art-filtered-out .art-more-btn { display: none; }
}
