/* ============================================================
   探索文章（前台文章列表，依設計稿）
   左為主要內容（主視覺、文章分類、文章列表），
   右為篩選條件與推薦文章。
   色彩一律沿用 article.css 的變數。
   ============================================================ */
.article-explore {
  /* main 為 flex 容器，撐滿剩餘高度讓底色延伸至頁尾 */
  flex: 1;
  background: #f6f8fb;
  padding: 26px 0 60px;
}

.ex-shell {
  /* 與頁首選單（.header-inner）同寬 */
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

.ex-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 306px;
  align-items: start;
  gap: 22px;
}

.ex-main {
  min-width: 0;
}

/* ---------------------------------------------
   主視覺：標題、說明、搜尋與熱門關鍵字
   --------------------------------------------- */
.ex-hero {
  display: grid;
  grid-template-columns: minmax(0, 460px) minmax(0, 1fr);
  align-items: stretch;
  margin-bottom: 30px;
  border: 1px solid var(--article-card-border);
  border-radius: 10px;
  background: var(--article-surface);
  overflow: hidden;
}

.ex-hero-text {
  padding: 34px 30px 30px;
}

.ex-hero-lead {
  display: block;
  margin-bottom: 8px;
  color: #111827;
  font-size: clamp(32px, 2.6vw, 42px);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.ex-hero-eyebrow {
  display: block;
  margin-bottom: 10px;
  color: var(--article-primary);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.ex-hero-title {
  margin: 0;
  color: #111827;
  font-size: clamp(20px, 1.6vw, 24px);
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.ex-hero-desc {
  margin: 14px 0 0;
  color: var(--article-muted);
  font-size: 18px;
  line-height: 1.85;
}

.ex-hero-search {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 22px;
}

.ex-hero-search input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--article-card-border);
  border-radius: 7px;
  background: var(--article-surface-2);
  color: var(--article-ink);
  font-size: 18px;
  transition: border-color 0.2s, background 0.2s;
}

.ex-hero-search input::placeholder {
  color: #94a3b8;
}

.ex-hero-search input:focus {
  outline: none;
  border-color: var(--article-primary);
  background: #fff;
}

.ex-hero-search button {
  flex: none;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 7px;
  background: var(--article-primary);
  color: #fff;
  font-size: 19px;
  transition: background 0.2s;
}

.ex-hero-search button:hover {
  background: var(--article-primary-dark);
}

.ex-hot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.ex-hot-label {
  color: var(--article-muted);
  font-size: 17px;
}

.ex-hot-tag {
  padding: 4px 12px;
  border: 1px solid var(--article-card-border);
  border-radius: 999px;
  background: var(--article-surface);
  color: var(--article-muted);
  font-size: 17px;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.ex-hot-tag:hover,
.ex-hot-tag.active {
  border-color: var(--article-primary);
  background: var(--article-primary);
  color: #fff;
}

.ex-hero-image {
  position: relative;
  min-height: 260px;
}

.ex-hero-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------------------------------------------
   區塊標題（文章分類／文章列表）
   --------------------------------------------- */
.ex-section + .ex-section {
  margin-top: 30px;
}

.ex-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.ex-section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  color: #111827;
  font-size: 23px;
  font-weight: 800;
}

.ex-section-count {
  color: var(--article-muted);
  font-size: 17px;
  font-weight: 500;
}

/* 排序下拉 */
.ex-sort select,
.ex-filter-form select {
  height: 40px;
  padding: 0 34px 0 14px;
  border: 1px solid var(--article-card-border);
  border-radius: 7px;
  background-color: var(--article-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236b7280'%3E%3Cpath d='M8 11.2 3.6 6.8l1-1L8 9.2l3.4-3.4 1 1z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  color: var(--article-ink);
  font-size: 18px;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.ex-sort select:hover,
.ex-sort select:focus,
.ex-filter-form select:hover,
.ex-filter-form select:focus {
  border-color: var(--article-primary);
  outline: none;
}

.ex-sort-submit {
  margin-left: 8px;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  background: var(--article-primary);
  color: #fff;
  font-size: 18px;
}

/* ---------------------------------------------
   文章分類：圖示方塊
   --------------------------------------------- */
.ex-cat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ex-cat {
  flex: 1 1 96px;
  max-width: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  border: 1px solid var(--article-card-border);
  border-radius: 8px;
  background: var(--article-surface);
  color: var(--article-ink);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.2s;
}

.ex-cat:hover {
  border-color: var(--article-primary);
  color: var(--article-primary);
  transform: translateY(-2px);
}

.ex-cat.active {
  border-color: var(--article-primary);
  background: #e6ecf9;
  color: var(--article-primary);
}

.ex-cat-icon {
  font-size: 23px;
  color: var(--article-muted);
  transition: color 0.2s;
}

.ex-cat:hover .ex-cat-icon,
.ex-cat.active .ex-cat-icon {
  color: var(--article-primary);
}

.ex-cat-name {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ---------------------------------------------
   文章卡片
   --------------------------------------------- */
.ex-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.ex-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--article-card-border);
  border-radius: 10px;
  background: var(--article-surface);
  overflow: hidden;
  transition: box-shadow 0.25s, transform 0.25s;
}

.ex-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--article-shadow);
}

.ex-card-cover {
  position: relative;
  display: block;
  overflow: hidden;
}

.ex-card-cover img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  transition: transform 0.5s;
}

.ex-card:hover .ex-card-cover img {
  transform: scale(1.05);
}

/* 底部資訊列：難度徽章與主題分類（原位於封面，已移至原閱讀時間的位置） */
.ex-card-level,
.ex-card-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
}

.ex-card-level {
  border: 1px solid var(--article-line);
  background: var(--article-surface-2);
  color: var(--article-ink);
}

.ex-card-type {
  background: var(--article-surface-3);
  color: var(--article-ink);
  font-weight: 600;
}

/* 閱讀狀態：卡片右上角的小圓標（僅「已閱讀完成」「已完成測驗」時才輸出，故一律為完成色） */
.ex-card-state {
  position: absolute;
  right: 12px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ex-card-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--article-warm);
  color: #fff;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.14);
}

/* 難度徽章的圖示以等級色區分 */
.ex-card-level-icon-4 {
  color: var(--level-4);
}

.ex-card-level-icon-3 {
  color: var(--level-3);
}

.ex-card-level-icon-2 {
  color: var(--level-2);
}

.ex-card-level-icon-1 {
  color: var(--level-1);
}

.ex-card-body {
  flex: 1;
  padding: 16px 16px 6px;
}

.ex-card-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.5;
}

.ex-card-title a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1.5em * 2);
  color: #111827;
  text-decoration: none;
  transition: color 0.2s;
}

.ex-card-title a:hover {
  color: var(--article-primary);
}

.ex-card-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 10px 0 0;
  color: var(--article-muted);
  font-size: 18px;
  line-height: 1.75;
}

.ex-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 6px 12px 10px;
}

.ex-card-info {
  display: inline-flex;
  align-items: center;
  color: var(--article-muted);
  font-size: 17px;
}

.ex-card-info i {
  margin-right: 7px;
  color: #94a3b8;
}

/* 喜歡人數（唯讀統計，列表不提供喜歡切換） */
.ex-card-like i {
  color: var(--article-danger);
}

.ex-card-act {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
}

/* ---------------------------------------------
   右側欄：篩選條件與推薦文章
   --------------------------------------------- */
.ex-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 86px;
}

.ex-side-block {
  padding: 18px 18px 20px;
  border: 1px solid var(--article-card-border);
  border-radius: 10px;
  background: var(--article-surface);
}

.ex-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.ex-side-title {
  margin: 0;
  color: #111827;
  font-size: 20px;
  font-weight: 800;
}

.ex-side-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--article-primary);
  font-size: 17px;
  text-decoration: none;
  transition: color 0.2s;
}

.ex-side-more:hover {
  color: var(--article-primary-dark);
}

.ex-filter-group + .ex-filter-group {
  margin-top: 18px;
}

.ex-filter-label {
  margin-bottom: 10px;
  color: var(--article-ink);
  font-size: 18px;
  font-weight: 700;
}

.ex-filter-form select {
  width: 100%;
}

/* 難度等級：2×2 方塊 */
.ex-level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ex-level-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 11px 6px;
  border: 1px solid var(--article-card-border);
  border-radius: 7px;
  background: var(--article-surface-2);
  color: var(--article-ink);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.ex-level-box:hover {
  border-color: var(--article-primary);
  color: var(--article-primary);
}

.ex-level-box.active {
  border-color: var(--article-primary);
  background: #e6ecf9;
  color: var(--article-primary);
}

.ex-level-box-name {
  font-size: 18px;
  font-weight: 700;
}

.ex-level-box-note {
  color: var(--article-muted);
  font-size: 16px;
}

.ex-level-box:hover .ex-level-box-note,
.ex-level-box.active .ex-level-box-note {
  color: inherit;
}

/* 閱讀時間與顯示範圍：兩欄按鈕（與難度等級的排列呼應） */
.ex-chip-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ex-chip {
  text-align: center;
  padding: 8px 10px;
  border: 1px solid var(--article-card-border);
  border-radius: 6px;
  background: var(--article-surface-2);
  color: var(--article-muted);
  font-size: 17px;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.ex-chip:hover {
  border-color: var(--article-primary);
  color: var(--article-primary);
}

.ex-chip.active {
  border-color: var(--article-primary);
  background: var(--article-primary);
  color: #fff;
  font-weight: 600;
}

/* 推薦文章 */
.ex-rec-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ex-rec-item {
  display: flex;
  gap: 12px;
}

.ex-rec-item + .ex-rec-item {
  padding-top: 16px;
  border-top: 1px solid var(--article-line);
}

.ex-rec-cover {
  flex: none;
  width: 66px;
  height: 66px;
  border-radius: 7px;
  overflow: hidden;
}

.ex-rec-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ex-rec-body {
  flex: 1;
  min-width: 0;
}

.ex-rec-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--article-muted);
  font-size: 16px;
}

.ex-rec-meta > * + *::before {
  content: '·';
  margin-right: 6px;
}

.ex-rec-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
  color: var(--article-ink);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
  transition: color 0.2s;
}

.ex-rec-title:hover {
  color: var(--article-primary);
}

.ex-rec-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  color: var(--article-muted);
  font-size: 16px;
}

/* ---------------------------------------------
   Google 廣告：文章列表與頁碼之後（共用樣式在 style.css 的「Google 廣告」區塊，此處只調整間距）
   --------------------------------------------- */
.ex-ad.is-filled,
.ex-ad.site-ad-preview {
  margin-top: 24px;
}

/* ---------------------------------------------
   查無資料
   --------------------------------------------- */
.ex-empty {
  padding: 40px 20px 50px;
  border: 1px solid var(--article-card-border);
  border-radius: 10px;
  background: var(--article-surface);
  text-align: center;
}

.ex-empty img {
  width: 170px;
  max-width: 55%;
  opacity: 0.32;
}

.ex-empty-text {
  margin-top: 14px;
  color: var(--article-muted);
  font-size: 19px;
}

.ex-empty-btn {
  display: inline-block;
  margin-top: 16px;
  padding: 9px 20px;
  border-radius: 7px;
  background: var(--article-primary);
  color: #fff;
  font-size: 18px;
  text-decoration: none;
  transition: background 0.2s;
}

.ex-empty-btn:hover {
  background: var(--article-primary-dark);
  color: #fff;
}

/* ---------------------------------------------
   響應式調整
   --------------------------------------------- */
@media (max-width: 1279.98px) {
  /* 右側欄移至內容下方，篩選條件與推薦文章並排 */
  .ex-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .ex-side {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }
}

@media (max-width: 991.98px) {
  .ex-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .ex-hero-image {
    order: -1;
    min-height: 200px;
  }

  .ex-hero-text {
    padding: 26px 22px 24px;
  }

  .ex-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* 「篩選條件」改排在「文章分類」與文章列表之間。
     純 CSS 無法把巢狀的子元素移出父層，故讓 .ex-main 與 .ex-side 不生成自己的框，
     其子元素因此成為 .ex-layout 的直接項目，才能以 order 交錯排序（慣例同 video.css 的 .vd-left）。 */
  .ex-main,
  .ex-side {
    display: contents;
  }

  .ex-hero,
  .ex-section,
  .ex-side-block {
    min-width: 0;
  }

  /* 區塊間距一律交給 .ex-layout 的 gap，避免與原本的區塊間距疊加 */
  .ex-hero {
    margin-bottom: 0;
    order: 1;
  }

  .ex-section + .ex-section {
    margin-top: 0;
  }

  .ex-section-cat {
    order: 2;
  }

  .ex-side-filter {
    order: 3;
  }

  .ex-section-list {
    order: 4;
  }

  .ex-side-rec {
    order: 5;
  }
}

@media (max-width: 575.98px) {
  .ex-shell {
    padding: 0 12px;
  }

  .ex-hero-desc br {
    display: none;
  }

  .ex-cat {
    flex-basis: 78px;
    padding: 12px 6px;
  }

  .ex-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .ex-section-head {
    flex-wrap: wrap;
  }

  .ex-sort select {
    width: 100%;
  }
}
