/* ==========================================================================
   Highlights Layout — 成果展示（多分類列表）
   載入條件：com_content + view=categories + layout=highlights
   ========================================================================== */


/* ---- 文章頁面：隱藏 sidebar、主內容區全寬 ---- */
body.view-article.layout-cassiopeia_htsprouthighlights .container-sidebar-left,
body.view-article.layout-cassiopeia_htsprouthighlights .container-sidebar-right {
    display: none;
}

body.view-article.layout-cassiopeia_htsprouthighlights .container-component {
    grid-column: main-start / main-end;
}

/* ---- container-main-area 背景色與波浪裝飾（僅 view-categories） ---- */
body.view-categories.layout-cassiopeia_htsprouthighlights .container-main-area {
    position: relative;
    background: var(--htsprout-text-50);
    padding: 0 20px;
}

body.view-categories.layout-cassiopeia_htsprouthighlights .container-main-area::before {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    content: "";
    width: 100%;
    height: 137px;
    background: url(/images/template/container-top-b-shape-tablet.svg) no-repeat;
    background-size: 1440px auto;
    background-position: 50% 0%;
    transform: translateY(-100%);
}

body.view-categories.layout-cassiopeia_htsprouthighlights .container-component {
    position: relative;
    z-index: 2;
    max-width: 980px;
    margin: 0;
}

@media (min-width: 768px) and (max-width: 991.98px) {
    body.view-categories.layout-cassiopeia_htsprouthighlights .container-main-area::before {
        background-position: 32% 0%;
    }
}

@media (min-width: 992px) {
    body.view-categories.layout-cassiopeia_htsprouthighlights .container-main-area::before {
        background: url(/images/template/container-top-b-shape.svg) no-repeat;
        background-size: cover;
        height: 127px;
    }
}

.highlights {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 128px;
}

body.view-category.layout-cassiopeia_htsprouthighlights .highlights {
    padding: 0 20px;
}

body[class*="layout-cassiopeia_htsprouthighlights"] .container-main-area > .container-sidebar-left .sidebar-left {
    margin: 0;
}

/* ---- Sidebar card 殼去除 ---- */
body[class*="layout-cassiopeia_htsprouthighlights"] .sidebar-left.card {
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

body.view-category.layout-cassiopeia_htsprouthighlights .sidebar-left.card {
    padding: 0 20px;
}

body[class*="layout-cassiopeia_htsprouthighlights"] .sidebar-left.card .card-header {
    padding: 0;
    border-bottom: none;
    background: transparent;
    font-size: var(--htsprout-fs-20);
    font-weight: var(--htsprout-fw-medium);
    line-height: var(--htsprout-lh-150);
    color: var(--htsprout-text-900);
    margin-bottom: 24px;
}

body[class*="layout-cassiopeia_htsprouthighlights"] .sidebar-left.card .card-body {
    padding: 0;
    margin: 0 0 60px;
}

@media (min-width: 768px) {
    body[class*="layout-cassiopeia_htsprouthighlights"] .sidebar-left.card .card-body {
        margin: 0 0 150px;
    }
}

/* ---- Heading (當前分類名稱) ---- */
.highlights__heading {
    margin: 0;
    font-size: var(--htsprout-fs-16);
    font-weight: var(--htsprout-fw-medium);
    line-height: var(--htsprout-lh-150);
    color: var(--htsprout-text-600);
}

body.view-category.layout-cassiopeia_htsprouthighlights .highlights__heading{
    margin-bottom: 20px;
}

body.view-category.layout-cassiopeia_htsprouthighlights .news-item__title a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

/* ---- Grid Container ---- */
.highlights-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    margin-bottom: 28px;
}

/* ---- Card ---- */
.highlights-card {
    display: flex;
    flex-direction: column;
    background-color: #fff;
    padding: var(--htsprout-spacing-sm);
    box-shadow: 0 20px 20px rgba(62, 112, 115, 0.1);
    border-radius: var(--htsprout-radius-sm);
    text-decoration: none;
    color: inherit;
    transition: transform var(--htsprout-transition-base), box-shadow var(--htsprout-transition-base);
}

.highlights-card:hover,
.highlights-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 24px 28px rgba(62, 112, 115, 0.16);
}

/* ---- Card Image ---- */
.highlights-card__image {
    width: 100%;
    height: 130px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.highlights-card__image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ---- Card Title ---- */
.highlights-card__title {
    margin: 12px 0 0;
    font-size: var(--htsprout-fs-20);
    font-weight: var(--htsprout-fw-medium);
    line-height: var(--htsprout-lh-150);
    color: var(--htsprout-green-500);
}

/* ---- Responsive: Tablet (2 欄) ---- */
@media (min-width: 768px) {
    .highlights-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    body.view-category.layout-cassiopeia_htsprouthighlights .highlights {
        padding: 0;
    }

    body.view-category.layout-cassiopeia_htsprouthighlights .sidebar-left.card {
        padding: 0;
    }

    /* 成果展示：平板版開始分左右兩欄（覆寫 page.css 的 display:block） */
    body.view-categories[class*="layout-cassiopeia_htsprouthighlights"] .container-main-area {
        display: flex;
        align-items: flex-start;
        padding: 0 40px;
        gap: 20px;
    }

    body[class*="layout-cassiopeia_htsprouthighlights"] .container-main-area > .container-sidebar-left {
        max-width: 225px;
        flex-shrink: 0;
        margin: 0;
    }

    /* view-category：取消 subgrid，改用 flex（由 news.css 控制） */
    body.view-category.layout-cassiopeia_htsprouthighlights .container-main-area.container-main-area {
        display: flex;
        grid-template-columns: initial;
        grid-template-areas: initial;
        align-items: flex-start;
        gap: 20px;
        padding: 0 40px;
    }

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

    /* ---- 裝飾圖片：content 區域右下方（平板+電腦） ---- */
    body:not(.view-article).layout-cassiopeia_htsprouthighlights .container-component {
        position: relative;
        height: 100%;
    }

    body:not(.view-article).layout-cassiopeia_htsprouthighlights .container-component::after {
        content: '';
        position: absolute;
        right: -136px;
        bottom: -16px;
        width: 314px;
        height: 314px;
        background: url('/images/template/banner-deco-user-form.png') no-repeat;
        background-size: contain;
        z-index: 0;
        pointer-events: none;
    }
}

/* ==========================================================================
   Page Header — 手機版（預設）
   ========================================================================== */

body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header-columns {
    padding: 20px 20px 0;
}

body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__left {
    gap: 40px;
}

body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__left .page-header h1,
body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__left .page-header h2 {
    text-align: center;
}

body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__right {
    margin: 0 -20px;
}

body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__right .item-image {
    width: 460px;
    margin: 0 auto;
}

/* ==========================================================================
   Page Header — 平板版（768px–991px）
   ========================================================================== */
@media (min-width: 768px) and (max-width: 991.98px) {
    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header-columns.grid-child {
        position: relative;
        padding: 36px 60px 213px;
    }

    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__left {
        gap: 31px;
        z-index: 3;
    }

    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__left .page-header h1,
    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__left .page-header h2 {
        text-align: left;
        text-shadow: rgb(240, 248, 253) 3px 0px 0px, rgb(240, 248, 253) 2.83487px 0.981584px 0px, rgb(240, 248, 253) 2.35766px 1.85511px 0px, rgb(240, 248, 253) 1.62091px 2.52441px 0px, rgb(240, 248, 253) 0.705713px 2.91581px 0px, rgb(240, 248, 253) -0.287171px 2.98622px 0px, rgb(240, 248, 253) -1.24844px 2.72789px 0px, rgb(240, 248, 253) -2.07227px 2.16926px 0px, rgb(240, 248, 253) -2.66798px 1.37182px 0px, rgb(240, 248, 253) -2.96998px 0.42336px 0px, rgb(240, 248, 253) -2.94502px -0.571704px 0px, rgb(240, 248, 253) -2.59586px -1.50383px 0px, rgb(240, 248, 253) -1.96093px -2.27041px 0px, rgb(240, 248, 253) -1.11013px -2.78704px 0px, rgb(240, 248, 253) -0.137119px -2.99686px 0px, rgb(240, 248, 253) 0.850987px -2.87677px 0px, rgb(240, 248, 253) 1.74541px -2.43999px 0px, rgb(240, 248, 253) 2.44769px -1.73459px 0px, rgb(240, 248, 253) 2.88051px -0.838247px 0px;
    }

    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__right {
        position: absolute;
        top: 22px;
        right: 34px;
        width: 500px;
        overflow: visible;
        margin: 0;
    }

    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__right .item-image {
        width: 100%;
    }
}

/* ==========================================================================
   Page Header — 電腦版（≥992px）
   ========================================================================== */
@media (min-width: 992px) {
    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .container-page-header {
        padding: 0;
    }

    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header-columns {
        position: relative;
        max-width: 1144px;
        padding: 48px 20px 161px;
    }

    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__left {
        gap: 31px;
    }

    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__left .page-header h1,
    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__left .page-header h2 {
        text-align: left;
    }

    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__right {
        position: absolute;
        top: 0;
        right: -200px;
        width: 702px;
        overflow: visible;
        margin: 0;
        z-index: 1;
    }

    body:not(.view-article)[class*="layout-cassiopeia_htsprouthighlights"] .page-header__right .item-image {
        width: 100%;
    }
}

/* ---- Responsive: Desktop (3 欄) ---- */
@media (min-width: 992px) {
    .highlights-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    body[class*="layout-cassiopeia_htsprouthighlights"] .container-main-area > .container-sidebar-left {
        width: 225px;
        flex-shrink: 0;
        margin: 0;
    }

    body.view-categories[class*="layout-cassiopeia_htsprouthighlights"] .container-main-area {
        padding: 0 20px;
        gap: 60px;
        justify-content: center;
    }

    body.view-category.layout-cassiopeia_htsprouthighlights .container-main-area.container-main-area {
        gap: 60px;
        padding: 0 20px;
    }

    body.view-article.layout-cassiopeia_htsprouthighlights .com-content-article {
        margin: 0 auto 108px;
    }

}

/* ==========================================================================
   Sidebar 分類搜尋
   ========================================================================== */

.highlights-categories-wrapper {
    position: relative;
}

/* ---- 搜尋列（輸入框 + 送出鈕） ---- */
.highlights-categories__search {
    margin-bottom: 16px;
}

.highlights-categories__search-bar {
    display: flex;
    align-items: center;
    height: 40px;
    border: 1px solid var(--htsprout-blue-100);
    border-radius: var(--htsprout-radius-sm);
    transition: border-color var(--htsprout-transition-base),
        background-color var(--htsprout-transition-base);
}

.highlights-categories__search-bar:focus-within {
    border-color: var(--htsprout-blue-500);
    background-color: var(--focus-bg-color);
}

.highlights-categories__search-bar:focus-within .highlights-categories__search-input::placeholder {
    color: var(--htsprout-text-1000);
}

.highlights-categories__search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--htsprout-radius-sm) 0 0 var(--htsprout-radius-sm);
    font-size: var(--htsprout-fs-14);
    font-family: inherit;
    outline: none;
}

.highlights-categories__search-input::placeholder {
    color: var(--htsprout-text-400);
}

.highlights-categories__search-input:focus-visible {
    box-shadow: none;
}

.highlights-categories__search-btn {
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 0 var(--htsprout-radius-sm) var(--htsprout-radius-sm) 0;
    padding: 0 12px;
    color: var(--htsprout-text-1000);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
}

.highlights-categories__search-btn:hover {
    background: transparent;
    color: var(--htsprout-blue-500);
    box-shadow: none;
}

.highlights-categories__search-btn:focus-visible {
    background: transparent;
    color: var(--htsprout-text-1000);
    box-shadow: none;
}

/* ---- 搜尋結果 Popup ---- */
.highlights-categories__search-popup {
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9;
    background: #fff;
    border: 1px solid var(--htsprout-blue-100);
    border-radius: var(--htsprout-radius-sm);
    box-shadow: var(--htsprout-shadow-md);
    overflow-y: auto;
    /* 高度由 JS 或 bottom:0 相對於 wrapper 撐滿 */
    min-height: 200px;
}

/* ---- Popup 標題列 ---- */
.highlights-categories__search-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 7px;
    border-bottom: 1px solid var(--htsprout-blue-100);
    position: sticky;
    top: 0;
    background-color: var(--htsprout-green-100);
    z-index: 1;
}

.highlights-categories__search-popup-title {
    font-size: var(--htsprout-fs-18);
    font-weight: var(--htsprout-fw-medium);
    line-height: var(--htsprout-lh-150);
    color: var(--htsprout-blue-500);
}

.highlights-categories__search-close {
    background: none;
    border: none;
    font-size: var(--htsprout-fs-20);
    line-height: 1;
    color: var(--htsprout-text-600);
    cursor: pointer;
    padding: 0 4px;
}

.highlights-categories__search-close:hover {
    color: var(--htsprout-text-900);
}

/* ---- 搜尋結果列表 ---- */
.highlights-categories__search-results {
    list-style: none;
    margin: 0;
    padding: 16px 20px;
}

.highlights-categories__search-item {
    padding: 4px 12px;
    font-size: var(--htsprout-fs-14);
    line-height: var(--htsprout-lh-150);
}

.highlights-categories__search-item a {
    text-decoration: none;
    color: var(--htsprout-text-600);
}

.highlights-categories__search-item.is-match a {
    color: var(--htsprout-blue-500);
    font-weight: var(--htsprout-fw-medium);
}

.highlights-categories__search-item a:hover {
    text-decoration: underline;
}

.highlights-categories__search-empty {
    padding: 8px 12px;
    font-size: var(--htsprout-fs-14);
    color: var(--htsprout-text-400);
}

/* ==========================================================================
   Sidebar 分類手風琴
   ========================================================================== */

.highlights-categories {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---- 第一層群組（<details>） ---- */
.highlights-categories__group {
    border: none;
}

/* ---- 展開收合按鈕（<summary>） ---- */
.highlights-categories__toggle {
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    list-style: none;
    font-size: var(--htsprout-fs-18);
    font-weight: var(--htsprout-fw-medium);
    line-height: var(--htsprout-lh-150);
    color: var(--htsprout-text-600);
    padding: 5px 0;
}

/* 移除 Safari 的預設三角形 */
.highlights-categories__toggle::-webkit-details-marker {
    display: none;
}

/* active 狀態：子元素 __link 有 .active 時套用相同樣式 */
.highlights-categories__toggle:has(.highlights-categories__link.active) {
    color: var(--htsprout-green-500);
    background-color: var(--htsprout-green-100);
}

/* ---- 連結（在 summary 內） ---- */
.highlights-categories__link {
    text-decoration: none;
    color: inherit;
    padding: 5px 7px;
}

.highlights-categories__link:hover {
    text-decoration: underline;
}

.highlights-categories__group--leaf .highlights-categories__link.active {
    color: var(--htsprout-green-500);
    background-color: var(--htsprout-green-100);
}

/* ---- Chevron 圖示 ---- */
.highlights-categories__chevron {
    width: 30px;
    height: 16px;
    margin-left: auto;
    padding: 0 7px;
    flex-shrink: 0;
    transition: transform var(--htsprout-transition-base);
}

/* 收合：chevron 朝下（預設） */
/* 展開：chevron 朝上（旋轉 180deg） */
details[open] > .highlights-categories__toggle .highlights-categories__chevron {
    transform: rotate(180deg);
}

/* ---- 子分類容器 ---- */
.highlights-categories__children {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-left: 20px;
    margin-top: 16px;
}

/* 第三層子分類容器（更深的縮排） */
.highlights-categories__children .highlights-categories__children {
    padding-left: 20px;
    margin-top: 0;
    gap: 10px;
}

/* ---- 子層連結項目 ---- */
.highlights-categories__item {
    display: block;
    padding: 0 7px;
    font-size: var(--htsprout-fs-14);
    font-weight: var(--htsprout-fw-medium);
    line-height: var(--htsprout-lh-150);
    color: var(--htsprout-green-500);
    text-decoration: none;
    min-height: 24px;
}

.highlights-categories__item:hover {
    text-decoration: underline;
}

.highlights-categories__item.active {
    font-weight: var(--htsprout-fw-bold);
    background-color: var(--htsprout-green-100);
}

/* ---- 文章數 ---- */
.highlights-categories__count {
    margin-left: 2px;
}

/* ---- 無子分類的第一層項目（leaf） ---- */
.highlights-categories__group--leaf .highlights-categories__link.active {
    color: var(--htsprout-green-500);
}

/* ---- 成果展示：平板版 .site-grid 提前分欄 ---- */
/* 需要 @supports 才能覆寫父主題 template.css 的同層規則 */
@supports (display: grid) {
    @media (min-width: 768px) {
        body[class*="layout-cassiopeia_htsprouthighlights"] .site-grid {
            grid-template-areas:
                ". banner banner banner banner ."
                ". top-a top-a top-a top-a ."
                ". top-b top-b top-b top-b ."
                "page-header page-header page-header page-header page-header page-header"
                "main-area main-area main-area main-area main-area main-area"
                ". bot-a bot-a bot-a bot-a ."
                ". bot-b bot-b bot-b bot-b .";
        }
    }
}
