/**
 * 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: 1.125rem;
  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);
}

.news-item:hover {
  border-color: var(--htsprout-primary);
  box-shadow: var(--htsprout-shadow-sm);
}

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

/* 日期標籤樣式 */
.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: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.news-item__date-month {
  font-size: 0.75rem;
  margin-top: 2px;
}

.news-item__date-full {
  font-size: 0.875rem;
  font-weight: 600;
}

/* 一般文字日期樣式 */
.news-item__date--text {
  font-size: 0.875rem;
  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: 0.75rem;
  font-weight: 600;
  border-radius: var(--htsprout-radius-sm);
}

/* 文章標籤 */
.news-item__tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--htsprout-secondary);
  color: var(--htsprout-text-50);
  font-size: 0.75rem;
  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: 1.125rem;
  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: 0.875rem;
  line-height: 1.5;
}

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

.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: 0.25em;
  padding: 0.375rem 0.75rem;
  min-height: 44px;
  font-size: 0.8125rem;
  font-weight: normal;
  color: var(--htsprout-text-50);
  background-color: var(--htsprout-primary);
  border: none;
  border-radius: 0;
  text-decoration: none;
  transition: background-color var(--htsprout-transition-base), opacity var(--htsprout-transition-base);
}

.news-item__file-btn:hover {
  color: var(--htsprout-text-50);
  background-color: var(--htsprout-secondary);
  text-decoration: none;
  opacity: 0.9;
}

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

.news-item__file-btn .icon-download {
  font-size: 0.875em;
}

/* 閱讀更多 */
.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: 0.875rem;
  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: 1.25rem;
}

.news-style-compact .news-item__title {
  font-size: 1rem;
  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;
  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: 3px solid var(--focus-color);
  outline-offset: 2px;
}

/* 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;
}

/* 響應式 */
@media (max-width: 767.98px) {
  .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: 1.25rem;
  }

  .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: 0.875rem;
  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: 3px solid var(--focus-color, #0d6efd);
  outline-offset: 2px;
}

/* ============================================
   文章列表分頁置中
   ============================================ */
.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;
}
