/**
 * Cassiopeia HTSprout - 單一文章頁面樣式
 *
 * 包含：
 * - 文章頁面側邊欄隱藏
 * - 附件下載區塊
 * - Gallery 輪播
 * - Lightbox
 *
 * @package     Joomla.Site
 * @subpackage  Templates.cassiopeia_htsprout
 * @copyright   Copyright (C) 2026 HTSprout. All rights reserved.
 * @license     GNU General Public License version 2 or later
 */

/* ============================================
   14. 單一文章頁面隱藏側邊欄
   ============================================ */

/* 隱藏左右側邊欄 */
body.view-article.layout-cassiopeia_htsproutnews .container-sidebar-left,
body.view-article.layout-cassiopeia_htsproutnews .container-sidebar-right {
  display: none;
}

/* 主內容區擴展至全寬 */
body.view-article.layout-cassiopeia_htsproutnews .container-component {
  grid-column: main-start / main-end;
}

/* 標籤名稱連結關閉時，標籤為非互動元素 */
.tags-no-link .tags span.btn {
  min-height: auto;
  min-width: auto;
  cursor: default;
}

/* ============================================
   文章附件下載
   ============================================ */
.article-attachments__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.article-attachments__list li {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  width: 100%;
}

.article-attachments__name {
  font-weight: 500;
  margin-right: auto;
}

/* ============================================
   文章圖片 Gallery 輪播
   ============================================ */
:root {
  --gallery-cols: 6;
}

.article-gallery {
  margin-top: var(--htsprout-spacing-md);
}

/* 標題列：標題 + 箭頭同一排 */
.article-gallery__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--htsprout-spacing-xs);
}

.article-gallery__header h2 {
  margin: 0;
}

.article-gallery__arrows {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* 滾動軌道：gap 自動計算使首張靠左、末張靠右 */
.article-gallery__track {
  display: flex;
  gap: max(0px, calc((100% - var(--gallery-cols) * 150px) / (var(--gallery-cols) - 1)));
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  height: 120px;
  /* 隱藏捲軸 */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.article-gallery__track::-webkit-scrollbar {
  display: none;
}

/* 單一項目：固定 150×120 */
.article-gallery__item {
  flex: 0 0 150px;
  scroll-snap-align: start;
}

.article-gallery__item img {
  display: block;
  width: 150px;
  height: 120px;
  object-fit: cover;
}

/* 箭頭按鈕 */
.article-gallery__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: var(--htsprout-gray-light);
  border: 1px solid var(--htsprout-border);
  border-radius: var(--htsprout-radius-sm);
  cursor: pointer;
  color: var(--htsprout-secondary);
  font-size: 1rem;
  transition: background-color var(--htsprout-transition-base), color var(--htsprout-transition-base);
}

.article-gallery__arrow:hover:not(:disabled) {
  background: var(--htsprout-primary);
  border-color: var(--htsprout-primary);
  color: var(--htsprout-text-50);
}

.article-gallery__arrow:focus {
  outline: 3px solid var(--focus-color);
  outline-offset: 2px;
}

.article-gallery__arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

/* 響應式：平板 4 筆 */
@media (max-width: 991.98px) {
  :root {
    --gallery-cols: 4;
  }
}

/* 響應式：手機 2 筆 */
@media (max-width: 768px) {
  :root {
    --gallery-cols: 2;
  }

  .article-gallery__arrow {
    width: 44px;
    height: 44px;
  }
}

/* 縮圖可點擊提示 */
.article-gallery__item img {
  cursor: pointer;
  transition: opacity var(--htsprout-transition-base);
}

.article-gallery__item img:hover {
  opacity: 0.8;
}

.article-gallery__item img:focus {
  outline: 3px solid var(--focus-color);
  outline-offset: 2px;
}

/* ============================================
   Gallery Lightbox
   ============================================ */
.gallery-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.85);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox.is-active {
  display: flex;
}

.gallery-lightbox__close {
  position: absolute;
  top: var(--htsprout-spacing-sm);
  right: var(--htsprout-spacing-sm);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--htsprout-radius-sm);
  color: var(--htsprout-text-50);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--htsprout-transition-base), background-color var(--htsprout-transition-base);
}

.gallery-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--htsprout-text-50);
}

.gallery-lightbox__close:focus {
  outline: 3px solid var(--focus-color);
  outline-offset: 2px;
}

.gallery-lightbox__img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
}

.gallery-lightbox__caption {
  color: var(--htsprout-text-50);
  text-align: center;
  margin: 1rem 0 0;
  padding: 0 var(--htsprout-spacing-md);
  font-size: 0.9375rem;
}

/* Lightbox 減少動畫 */
@media (prefers-reduced-motion: reduce) {
  .gallery-lightbox,
  .gallery-lightbox__close,
  .article-gallery__item img {
    transition: none !important;
  }
}
