/* ============================================
   組件：延伸閱讀（related-articles）
   Locofy 匯出轉寫；文章卡正常流 + RWD。全站載入。BEM 前綴：.related- / .article-card
   ============================================ */

.related-articles {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

/* 標題：棕色六角旗幟（heading-bg SVG）襯底 + 白色圓角膠囊，棕字置中 */
.related-articles__heading {
  display: flex;
  justify-content: center;
}
.related-articles__title {
  position: relative;
  margin: 0;
  min-width: 193px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 32px;
  margin-bottom: 8px;
  box-sizing: border-box;
  border-radius: 60px;
  background-color: #fff;
  border: 1px solid #ab7a44;
  font-size: 20px;
  font-weight: 500;
}
/* 六角旗幟襯底：左右尖角超出白膠囊兩側（設計稿） */
.related-articles__title::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: -1;
  transform: translateX(-50%);
  width: calc(100% + 56px);
  height: 48px;
  background: url("../../images/components/related-articles/related-articles__heading-bg-451-3342.svg")
    center / 100% 100% no-repeat;
  pointer-events: none;
}
.related-articles__empty {
  margin: 0;
  padding: 32px 0;
  font-size: 16px;
  color: #999;
}

/* 文章卡輪播：桌機一頁 3 篇／平板・手機 2 篇，可拖曳；分頁點由 JS 跟隨。
   捲動/拖曳機制已抽為共用（components/shared.css）；此處只保留 flex 排版與卡片尺寸。
   --gap 卡間距、--cols 每頁張數（卡寬與 JS 計算共用）。 */
.related-articles__list {
  --gap: 40px;
  --cols: 3;
  --pad-x: 20px;   /* 左右留白：卡片陰影不被容器邊緣裁切 */
  --pad-y: 28px;   /* 上下留白：容納卡片較大的下方陰影（0 14.9px 14.9px） */
  /* 內容寬維持 1220（外加左右 padding），卡片尺寸不變 */
  max-width: calc(1220px + var(--pad-x) * 2);
  display: flex;
  gap: var(--gap);
}
/* 每張寬＝(內容寬 − 每頁間距總和) ÷ 每頁張數（桌機精準填滿） */
.article-card {
  flex: 0 0
    calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
  min-width: 0;    /* 關鍵：允許收縮到 flex-basis；否則 nowrap 長標題會把第一張卡撐寬、圖片變大 */
}
.article-card__link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: #000;
}
/* 圖（上半，灰底佔位） */
.article-card__image {
  display: block;
  width: 100%;
  aspect-ratio: 380 / 236;
  background-color: #d9d9d9;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
/* 內文白卡（投影） */
.article-card__body {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 35px 29px;
  background-color: #fff;
  box-shadow: 0 14.9px 14.9px rgba(0, 0, 0, 0.15);
}
.article-card__meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.article-card__text {
  flex: 1 1 auto;
  min-width: 0; /* 允許縮小 → 單行標題以 … 截斷、不推擠右側日期 */
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.article-card__title {
  font-size: 20px;
  font-weight: 500;
  line-height: 1.4;
  /* 標題維持單行，過長以 … 截斷 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-card__excerpt {
  font-size: 16px;
  line-height: 1.6;
  color: #444;
  /* 摘要限制行數：電腦版 3 行，超過以 … 截斷（手機版覆寫為 2 行） */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.article-card__date {
  flex-shrink: 0;
  font-size: 14px;
  color: #888;
}
/* 查看更多（描邊膠囊） */
.article-card__more {
  align-self: center;
  width: 100%;
  max-width: 245px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 60px;
  border: 1px solid #5a3b1f;
  font-size: 16px;
  color: #5a3b1f;
}
/* 標題 hover 與「查看更多」hover 各自獨立：只在滑到該元素本身時觸發，
   不再因整張卡（.article-card__link）hover 而一起變化 */
.article-card__title {
  transition: color 0.2s ease;
}
.article-card__title:hover {
  color: #5a3b1f;
}
.article-card__more {
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}
.article-card__more:hover {
  background-color: #5a3b1f;
  color: #fff;
}

/* 更多文章（棕色實心鈕） */
.more-articles__button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 6px 29px;
  box-sizing: border-box;
  background-color: #5a3b1f;
  color: #fff;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-decoration: none;
}
.more-articles__button:hover {
  background-color: #6f4926;
  color: #fff;
}
.more-articles__arrow {
  width: 25px;
  height: 2px;
  flex-shrink: 0;
  background: currentColor;
  position: relative;
}
.more-articles__arrow::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
}

/* ===== RWD ===== */
/* 平板：一頁 2 篇 */
@media (max-width: 1024px) {
  .related-articles__list {
    --cols: 2;
    --gap: 28px;
  }
}
@media (max-width: 640px) {
  /* 延伸閱讀：一頁 2 篇（兩欄）、13px、六角標題與按鈕縮小 */
  .related-articles {
    gap: 28px;
  }
  .related-articles__title {
    min-width: 150px;
    min-height: 40px;
    padding: 6px 24px;
    font-size: 15px;
  }
  .related-articles__title::before {
    height: 42px;
    width: calc(100% + 44px);
  }
  .related-articles__list {
    --gap: 24px;   /* 手機卡片間距加大（12 → 24），三輪播統一 */
  }
  /* 卡寬依 --cols 填滿螢幕（每頁 2 張），非固定寬（沿用基礎 calc） */
  .article-card {
    flex: 0 0 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
  }
  .article-card__body {
    gap: 12px;
    padding: 14px;
  }
  /* 標題與日期維持同一列（不上下堆疊）；標題過長以 … 截斷、日期靠右不換行 */
  .article-card__meta {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }
  .article-card__text {
    gap: 8px;
  }
  .article-card__title {
    font-size: 14px;
  }
  .article-card__excerpt {
    font-size: 13px;
    line-height: 22px;
    -webkit-line-clamp: 2; /* 手機版摘要限制 2 行 */
    line-clamp: 2;
  }
  .article-card__date {
    white-space: nowrap; /* 日期不換行，穩定佔右側 */
  }
  .article-card__date {
    font-size: 12px;
  }
  .article-card__more {
    height: 36px;
    font-size: 13px;
  }
  /* 更多文章鈕：字縮、滿寬置中 */
  .more-articles__button {
    height: 42px;
    padding: 6px 24px;
    font-size: 16px;
  }
}
