/**
 * Cassiopeia HTSprout - 新聞列表樣式
 *
 * 包含：
 * - 新聞列表佈局（容器、項目、卡片、Accordion）
 * - 月份篩選提示
 * - 分頁導航
 * - 新聞列表響應式
 *
 * @package     Joomla.Site
 * @subpackage  Templates.cassiopeia_htsprout
 * @copyright   Copyright (C) 2026 HTSprout. All rights reserved.
 * @license     GNU General Public License version 2 or later
 */

/* ============================================
   10. 新聞列表佈局 (News Layout)
   ============================================ */

/* 新聞列表容器 */
.com-content-category-news {
  max-width: var(--htsprout-container-max-width);
  margin: 0 auto;
}

.news-category-title {
  color: var(--htsprout-secondary);
  margin-bottom: var(--htsprout-spacing-md);
  padding-bottom: var(--htsprout-spacing-sm);
  border-bottom: 2px solid var(--htsprout-primary);
}

/* 新聞列表 */
.news-list {
  display: flex;
  flex-direction: column;
  gap: var(--htsprout-spacing-sm);
}

/* 格狀排列 — mobile-first */
.news-layout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--htsprout-spacing-md);
}

.news-layout-grid .news-item {
  flex-direction: column;
}

.news-layout-grid .news-item__date--badge {
  width: 100%;
  min-width: auto;
  flex-direction: row;
  gap: var(--htsprout-spacing-xs);
  justify-content: flex-start;
}

.news-layout-grid .news-item__image a {
  display: block;
  width: 100%;
}

.news-layout-grid .news-item__image a img {
  width: 100%;
  height: 130px;
  object-fit: cover;
}

.news-layout-grid .news-month-heading {
  grid-column: 1 / -1;
}

@media (min-width: 768px) {
  .news-layout-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .news-layout-grid {
    grid-template-columns: repeat(var(--news-grid-columns, 3), 1fr);
  }
}

/* 月份標題 */
.news-month-heading {
  margin: var(--htsprout-spacing-md) 0 var(--htsprout-spacing-xs);
  padding-bottom: var(--htsprout-spacing-xs);
  font-size: var(--htsprout-fs-18);
  font-weight: 600;
  color: var(--htsprout-primary);
  border-bottom: 2px solid var(--htsprout-primary);
}

.news-month-heading:first-child {
  margin-top: 0;
}

/* 新聞項目 - 標準列表樣式 */
.news-item {
  display: flex;
  gap: var(--htsprout-spacing-sm);
  padding: var(--htsprout-spacing-sm);
  background: var(--htsprout-text-50);
  border: 1px solid var(--htsprout-border);
  border-radius: var(--htsprout-radius-sm);
  transition: box-shadow var(--htsprout-transition-base), border-color var(--htsprout-transition-base), background-color var(--htsprout-transition-base);
}

.news-item--card-link:hover {
  border-color: var(--htsprout-primary);
  box-shadow: var(--htsprout-shadow-sm);
  background: var(--htsprout-text-100);
}

/* 整卡可點擊：stretched-link */
.news-item--card-link {
  position: relative;
  cursor: pointer;
}

.news-item__stretched-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* 標籤、分類、檔案下載等連結需在 stretched-link 之上 */
.news-item--card-link .news-item__meta a,
.news-item--card-link .news-item__file-btn,
.news-item--card-link .news-item__icons,
.news-item--card-link .news-item__readmore a {
  position: relative;
  z-index: 2;
}

.news-item:focus-within {
  outline: 2px dotted var(--focus-color);
}

/* 日期標籤樣式 */
.news-item__date--badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  padding: var(--htsprout-spacing-xs);
  background: var(--htsprout-primary);
  color: var(--htsprout-text-50);
  border-radius: var(--htsprout-radius-sm);
  text-align: center;
  flex-shrink: 0;
}

.news-item__date-day {
  font-size: var(--htsprout-fs-24);
  font-weight: 700;
  line-height: 1;
}

.news-item__date-month {
  font-size: var(--htsprout-fs-12);
  margin-top: 2px;
}

.news-item__date-full {
  font-size: var(--htsprout-fs-14);
  font-weight: 600;
}

/* 一般文字日期樣式 */
.news-item__date--text {
  font-size: var(--htsprout-fs-14);
  color: var(--htsprout-text-muted);
}
.news-layout-grid .news-item__date--text {
  margin-left: auto;
}

/* 摘要圖片 */
.news-item__image {
  margin-bottom: 12px;
}

/* 內容區 */
.news-item__content {
  flex: 1;
  min-width: 0; /* 防止 flex 子項目溢出 */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* 元資訊區塊（日期、分類、標籤） */
.news-item__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--htsprout-spacing-xs);
}

/* 分類標籤 */
.news-item__category {
  display: inline-block;
  padding: 2px 8px;
  background: var(--htsprout-secondary);
  color: var(--htsprout-text-50);
  font-size: var(--htsprout-fs-12);
  font-weight: 600;
  border-radius: var(--htsprout-radius-sm);
}

/* 文章標籤 */
.news-item__tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--htsprout-blue-100);
  color: var(--htsprout-green-900);
  font-size: var(--htsprout-fs-12);
  font-weight: 500;
  border-radius: var(--htsprout-radius-sm);
}

/* 文章標籤連結樣式 */
a.news-item__tag {
  min-height: auto;
  text-decoration: none;
  transition: background-color var(--htsprout-transition-base), opacity var(--htsprout-transition-base);
}

a.news-item__tag:hover {
  text-decoration: none;
  color: var(--htsprout-text-50);
  opacity: 0.85;
}

/* 標題 */
.news-item__title {
  margin: 0 0 var(--htsprout-spacing-xs);
  font-size: var(--htsprout-fs-18);
  font-weight: 600;
  line-height: 1.4;
}

.news-item__title a {
  color: var(--htsprout-secondary);
  text-decoration: none;
}

.news-item__title a:hover {
  color: var(--htsprout-primary);
  text-decoration: underline;
}

/* 摘要 */
.news-item__intro {
  margin: 0;
  color: var(--htsprout-text-light);
  font-size: var(--htsprout-fs-14);
  line-height: 1.5;
}

/* 自訂欄位 */
.news-item__fields {
  margin-top: var(--htsprout-spacing-xs);
  font-size: var(--htsprout-fs-14);
}

.news-item__fields .fields-container {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--htsprout-spacing-xs);
}

.news-item__fields .field-entry {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25em;
  color: var(--htsprout-text-light);
}

.news-item__fields .field-label {
  font-weight: 600;
  color: var(--htsprout-text);
}

.news-item__fields .field-value {
  color: var(--htsprout-text-light);
}

/* 檔案下載按鈕列表 */
.news-item__file-list {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--htsprout-spacing-xs);
  flex-shrink: 0;
}

.news-item__file-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  min-height: auto;
  font-size: var(--htsprout-fs-16);
  font-weight: var(--htsprout-fw-regular);
  color: var(--htsprout-text-1000);
  background-color: var(--htsprout-text-50);
  border: 1px solid rgba(43, 114, 152, 0.3);
  border-radius: 0;
  text-decoration: none;
  line-height: 26px;
  transition: border-color var(--htsprout-transition-base), opacity var(--htsprout-transition-base);
}

.news-item__file-btn:hover {
  color: var(--htsprout-text-1000);
  background-color: var(--htsprout-text-50);
  border-color: rgba(43, 114, 152, 0.6);
  text-decoration: none;
  opacity: 1;
}

.news-item__file-btn:focus {
  outline: 2px dotted var(--focus-color);
}

.news-item__file-btn img {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* 閱讀更多 */
.news-item__readmore {
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
}

.readmore-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--htsprout-primary);
  font-size: var(--htsprout-fs-14);
  font-weight: 600;
  text-decoration: none;
}

.readmore-link:hover {
  text-decoration: underline;
}

/* 緊湊樣式 */
.news-style-compact .news-item {
  padding: var(--htsprout-spacing-xs);
  gap: var(--htsprout-spacing-xs);
}

.news-style-compact .news-item__date--badge {
  min-width: 50px;
  padding: 4px;
}

.news-style-compact .news-item__date-day {
  font-size: var(--htsprout-fs-20);
}

.news-style-compact .news-item__title {
  font-size: var(--htsprout-fs-16);
  margin-bottom: 0;
}

.news-style-compact .news-item__intro {
  display: none;
}

/* 卡片樣式 */
.news-style-card .news-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--htsprout-spacing-md);
}

.news-style-card .news-item {
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.news-style-card .news-item__date--badge {
  width: 100%;
  min-width: auto;
  padding: var(--htsprout-spacing-sm);
  border-radius: 0;
}

.news-style-card .news-item__content {
  padding: var(--htsprout-spacing-sm);
}

/* ---- 摺疊式排列 (Accordion) ---- */

.news-layout-accordion.news-list {
  gap: 20px;
  padding: 0 20px;
}

.news-layout-accordion .news-item--accordion {
  flex-wrap: wrap;
  border: none;
  border-radius: var(--htsprout-radius-btn);
  padding: 20px;
  cursor: pointer;
  gap: 0 16px;
  box-shadow: 0 4px 12px rgba(71, 195, 178, 0.12);
}

.news-layout-accordion .news-item--accordion:hover {
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(71, 195, 178, 0.2);
}

.news-layout-accordion .news-item--accordion.news-item--expanded {
  gap: 20px 16px;
}

/* 標題行：分類/標籤 + 標題 同一行 */
.news-item__header-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.news-item__header-row .news-item__meta {
  margin-bottom: 0;
  flex-shrink: 0;
}

.news-item__header-row .news-item__title {
  margin-bottom: 0;
}

.news-layout-accordion .news-item__header-row .news-item__title {
  flex: 1 0 0;
  font-size: var(--htsprout-fs-18);
  font-weight: var(--htsprout-fw-medium);
  color: var(--htsprout-text-1000);
}

/* Chevron toggle 按鈕 */
.news-item__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
  padding: 0;
}

.news-item__toggle:hover {
  background: var(--htsprout-gray-light);
}

.news-item__toggle:focus {
  outline: 2px dotted var(--focus-color);
}

/* Chevron 旋轉動畫 */
.news-item__toggle .icon-chevron-down {
  transition: transform 0.3s ease;
}

.news-item--expanded .news-item__toggle .icon-chevron-down {
  transform: rotate(180deg);
}

/* 分類 badge — 膠囊形 */
.news-layout-accordion .news-item__category {
  padding: 10px 12px;
  border-radius: 50px;
  font-size: var(--htsprout-fs-14);
  font-weight: var(--htsprout-fw-regular);
  color: var(--htsprout-text-1000);
  line-height: calc(20 / 14);
  height: 30px;
  display: flex;
  align-items: center;
}

/* badge 分類顏色 */
.news-item__category.members        { background: #e7d3f4; }
.news-item__category.implementation { background: var(--htsprout-blue-100); }
.news-item__category.works           { background: #FDF2C7; }
.news-item__category.eligibility     { background: var(--htsprout-green-100); }

/* 全文面板 - grid-template-rows 動畫 */
.news-item__panel-wrap {
  width: 100%;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease, border-color 0.3s ease;
  border-top: 1px solid transparent;
}

.news-item--expanded .news-item__panel-wrap {
  grid-template-rows: 1fr;
  border-top-color: var(--htsprout-border);
}

.news-item__panel {
  overflow: hidden;
  padding: 0 var(--htsprout-spacing-md);
  transition: padding 0.3s ease;
}

.news-item--expanded .news-item__panel {
  padding: 20px 0 0;
}

/* 展開面板內容文字 */
.news-layout-accordion .news-item__panel {
  font-size: var(--htsprout-fs-16);
  font-weight: var(--htsprout-fw-regular);
  color: var(--htsprout-text-1000);
  line-height: var(--htsprout-lh-150);
}

.news-layout-accordion .news-item__panel p:last-child {
  margin-bottom: 0;
}

/* 減少動畫 */
@media (prefers-reduced-motion: reduce) {
  .news-item__toggle .icon-chevron-down,
  .news-item__panel-wrap,
  .news-item__panel {
    transition: none;
  }
}

/* 未發布文章樣式 */
.news-item.system-unpublished {
  opacity: 0.6;
  border-style: dashed;
}

/* ============================================
   平板版（768px–991px）— sidebar + content 並排
   ============================================ */
@media (min-width: 768px) and (max-width: 991.98px) {
  body.page-news .container-main-area,
  body.page-office .container-main-area {
    display: flex;
    align-items: flex-start;
    padding: 0 40px;
    gap: 0;
  }

  body.view-category[class*="cassiopeia_htsprouthighlights"] .container-main-area {
    display: flex;
    align-items: flex-start;
    padding: 0 40px;
    gap: 60px;
  }

  body.page-news .container-main-area > [class^="container-"],
  body.page-news .container-main-area > [class*=" container-"],
  body.page-office .container-main-area > [class^="container-"],
  body.page-office .container-main-area > [class*=" container-"] {
    width: auto;
  }

  body.page-news .container-main-area > .container-sidebar-left,
  body.page-office .container-main-area > .container-sidebar-left {
    width: 160px;
    flex-shrink: 0;
  }

  body.page-news .container-main-area > .container-component,
  body.page-office .container-main-area > .container-component,
  body.view-category[class*="cassiopeia_htsprouthighlights"] .container-main-area > .container-component {
    flex: 1;
    min-width: 0;
  }
}

/* ============================================
   電腦版（≥ 992px）— sidebar + content 並排
   ============================================ */
@media (min-width: 992px) {
  body.page-news .container-main-area,
  body.page-office .container-main-area,
  body.view-category[class*="cassiopeia_htsprouthighlights"] .container-main-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin: 0 auto;
    gap: 60px;
    padding: 0 20px;
  }

  body.page-news .container-main-area > [class^="container-"],
  body.page-news .container-main-area > [class*=" container-"],
  body.page-office .container-main-area > [class^="container-"],
  body.page-office .container-main-area > [class*=" container-"] {
    width: auto;
    margin: 0;
  }

  body.page-news .container-main-area > .container-sidebar-left,
  body.page-office .container-main-area > .container-sidebar-left {
    width: 160px;
    flex-shrink: 0;
  }

  body.page-news .container-main-area > .container-component,
  body.page-office .container-main-area > .container-component,
  body.view-category[class*="cassiopeia_htsprouthighlights"] .container-main-area > .container-component {
    flex: 1;
    min-width: 0;
    max-width: 980px;
    margin: 0;
  }

  /* --- 裝飾背景圖片 --- */
  body.page-news .container-main-area,
  body.page-office .container-main-area,
  body.view-category[class*="cassiopeia_htsprouthighlights"] .container-main-area {
    position: relative;
  }

  body.page-news .container-component,
  body.page-office .container-component,
  body.view-category[class*="cassiopeia_htsprouthighlights"] .container-component {
    position: relative;
    z-index: 1;
  }

  body.page-news .container-main-area::after,
  body.page-office .container-main-area::after,
  body.view-category[class*="cassiopeia_htsprouthighlights"] .container-main-area::after {
    content: '';
    position: absolute;
    left: -103px;
    top: 520px;
    width: 314px;
    height: 314px;
    background: url('../../../../../images/template/banner-deco-user-form.png') no-repeat;
    background-size: contain;
    z-index: 0;
    pointer-events: none;
  }
}

/* ============================================
   新聞頁元件樣式 — 全斷點
   ============================================ */

/* 新聞列表間距 */
body.page-news .news-list,
body.page-office .news-list,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-list {
  margin-bottom: 24px;
  gap: 20px;
}

/* 月份標題：文字 + 延伸線 */
body.page-news .news-month-heading,
body.page-office .news-month-heading,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-month-heading {
  display: flex;
  align-items: center;
  gap: 25px;
  margin: 0;
  padding-bottom: 0;
  border-bottom: none;
  font-size: var(--htsprout-fs-20);
  font-weight: var(--htsprout-fw-medium);
  color: var(--htsprout-green-500);
}

body.page-news .news-month-heading::after,
body.page-office .news-month-heading::after,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-month-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--htsprout-green-300);
}

/* 新聞卡片 */
body.page-news .news-item,
body.page-office .news-item,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-item {
  padding: 16px;
  border: 1px solid var(--htsprout-blue-100);
  box-shadow: 0 20px 20px rgba(62, 112, 115, 0.1);
}

/* 卡片內容 */
body.page-news .news-item__content,
body.page-office .news-item__content,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-item__content {
  gap: 12px;
  justify-content: flex-start;
}

/* 標籤：膠囊形 */
body.page-news .news-item__tag,
body.page-office .news-item__tag,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-item__tag {
  font-size: var(--htsprout-fs-14);
  font-weight: var(--htsprout-fw-regular);
  padding: 4px 12px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 35px;
  background: var(--htsprout-blue-100);
}

/* Meta 列 */
body.page-news .news-item__meta,
body.page-office .news-item__meta,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-item__meta {
  gap: 12px;
  margin-bottom: 0;
}

/* 日期文字 */
body.page-news .news-item__date--text,
body.page-office .news-item__date--text,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-item__date--text {
  font-size: var(--htsprout-fs-16);
  color: var(--htsprout-text-800);
}

/* 標題 */
body.page-news .news-item__title,
body.page-office .news-item__title,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-item__title {
  font-weight: var(--htsprout-fw-medium);
  line-height: var(--htsprout-lh-150);
  margin-bottom: 0;
}

body.page-news .news-item__title a,
body.page-office .news-item__title a,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-item__title a {
  color: var(--htsprout-text-800);
}

/* 摘要 */
body.page-news .news-item__intro,
body.page-office .news-item__intro,
body.view-category[class*="cassiopeia_htsprouthighlights"] .news-item__intro {
  font-size: var(--htsprout-fs-16);
  color: var(--htsprout-text-700);
}

body.page-news .com-content-category-news,
body.page-office .com-content-category-news,
body.view-category[class*="cassiopeia_htsprouthighlights"] .com-content-category-news {
  margin: 0 auto 128px;
}

/* ============================================
   響應式：行動版（< 992px）— 容器間距
   ============================================ */
/* 響應式 */
@media (max-width: 767.98px) {
  body.page-news .com-content-category-news,
  body.page-office .com-content-category-news,
  body.view-category[class*="cassiopeia_htsprouthighlights"] .com-content-category-news {
    padding: 0 20px;
  }

  .news-item {
    flex-direction: column;
  }

  .news-item__date--badge {
    flex-direction: row;
    width: 100%;
    min-width: auto;
    gap: var(--htsprout-spacing-xs);
    justify-content: flex-start;
  }

  .news-item__date-day {
    font-size: var(--htsprout-fs-20);
  }

  .news-item__date-month {
    margin-top: 0;
    margin-left: 4px;
  }

  .news-style-card .news-list {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   月份篩選提示
   ============================================ */
.news-filter-info {
  display: flex;
  align-items: center;
  gap: var(--htsprout-spacing-sm);
  margin-bottom: var(--htsprout-spacing-md);
  padding: var(--htsprout-spacing-sm) var(--htsprout-spacing-md);
  border-radius: var(--htsprout-radius-md);
}

.news-filter-clear {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  padding: 0.25rem 0.75rem;
  background: var(--htsprout-text-50);
  border: 1px solid currentColor;
  border-radius: var(--htsprout-radius-sm);
  color: inherit;
  text-decoration: none;
  font-size: var(--htsprout-fs-14);
  transition: background-color 0.2s ease;
}

.news-filter-clear:hover {
  background: var(--cassiopeia-color-primary, #132f53);
  border-color: var(--cassiopeia-color-primary, #132f53);
  color: var(--htsprout-text-50);
  text-decoration: none;
}

.news-filter-clear:focus {
  outline: 2px dotted var(--focus-color);
}

/* ============================================
   文章列表分頁置中
   ============================================ */
.com-content-category-news__navigation {
  text-align: center;
}

.com-content-category-news__pagination {
  display: flex;
  justify-content: center;
}

.com-content-category-news__counter {
  float: none !important;
}
