/* ==========================================================================
   Collection Page Styles
   Collection 頁面與作品集網格樣式
   ========================================================================== */

#collection-page {
    flex-direction: row;
}

.collection-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

.collection-sidebar {
    position: absolute;
    bottom: 120px; /* 剛好在左下角橫排標題 (bottom 30px) 的上方 */
    left: 42px;    /* 往右調整 12px，對齊底部導覽選單 */
    width: auto;
    
    padding: 0;
    display: none; /* 預設隱藏，只在 Collection 頁面顯示 */
    flex-direction: column;
    align-items: flex-start;
    gap: 15px; /* 增加各選項間的留白 */
    z-index: 100; /* 確保在 gradient 之上 */
}

body.state-collection .collection-sidebar {
    display: flex;
}

.sidebar-title {
    font-family: "Saira", sans-serif;
    font-optical-sizing: auto;
    font-weight: 300;
    font-style: normal;
    font-size: 1.5em;
    color: #cccccc;
    margin-bottom: 15px; /* 配合 gap 15px，總共與第一顆按鈕距離 30px */
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

body.dark-mode .sidebar-title {
    color: #666666;
}

@media (max-width: 1000px) {
    .sidebar-title {
        display: none;
    }
}

.collection-sidebar .tab-button {
    background: none;
    border: none;
    padding: 0;
    text-align: left;
    font-size: 1.2em; /* 稍微縮小字體 */
    font-family: inherit;
    cursor: pointer;
    color: #999999;
    border-bottom: none;
    transition: color 0.3s ease;
}

.collection-sidebar .tab-button:hover {
    color: #666666;
    background-color: transparent;
}

.collection-sidebar .tab-button.active-tab {
    background: none;
    font-weight: bold;
    color: #111111;
}

.collection-content {
    flex-grow: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: transparent;
    padding-left: 22vw; /* 等比縮放的左側留白，不強制抓特定標題位置 */
    padding-top: 0; /* 上下 padding 移交給 content-area 避免 Safari 裁切 bug */
    padding-bottom: 0;
    /* 隱藏原生滑動條 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.collection-content::-webkit-scrollbar {
    display: none;
}

.tab-content {
    height: auto;
    display: none;
}

.tab-content.active-content {
    display: block;
}

/* Collection 頁面內容區樣式 (覆寫 base.css) */
.collection-content .content-area {
    width: calc(100vw - 22vw - 60px) !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 100px 0 140px 0 !important; /* 原本在 collection-content 的上下留白移至此處 */
    height: auto !important;
    overflow: visible !important; /* 確保 sticky 可以對照到 collection-content 捲動 */
}

/* 項目網格樣式 (固定兩列方格，採用 Project 結構) */
.item-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    padding-top: 20px;
    width: 100%;
}

/* 複用 .project-item 結構的 collection 專用覆蓋 */
.collection-item {
    aspect-ratio: 1 / 1;
    height: auto; /* 取代固定的高度 */
    text-decoration: none;
    color: inherit;
    padding: 0;
}

/* 音樂卡片專屬：改為 16:9 比例 (寬度維持，高度減小) */
#content-music .collection-item {
    aspect-ratio: 16 / 9;
}

.collection-item .item-visual {
    opacity: 1 !important; /* 確保圖片不被半透明處理 */
}

.collection-item .item-visual img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

/* 音樂卡片使用 cover 來裁切掉 YouTube 預設縮圖(hqdefault)上下的黑邊，完美填滿 16:9 */
#content-music .collection-item .item-visual img {
    object-fit: cover;
}

/* 將內容區疊加在圖片上方並置底 */
.collection-item .item-content {
    position: relative;
    z-index: 2;
    padding: 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-sizing: border-box;
    pointer-events: none; /* 讓整個卡片都可以點擊跳轉 */
}

.collection-item .item-title {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 16px;
    border-radius: 6px;
    backdrop-filter: blur(8px);
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: fit-content;
    gap: 12px;
    pointer-events: auto;
    font-weight: 600;
    font-size: 0.95em; /* 稍微調大一點 */
}

.collection-item .item-title-text {
    display: flex;
    flex-direction: column;
}

.collection-item .item-author {
    font-size: 0.8em; /* 配合主標題稍微調大 */
    color: #666;
    margin-top: 2px;
    font-weight: 400;
}

body.dark-mode .collection-item .item-title {
    background: rgba(20, 20, 20, 0.9);
    color: #ffffff;
}

body.dark-mode .collection-item .item-author {
    color: #aaa;
}




/* Accordion Styles */
.accordion-group {
    width: 100%;
    margin-bottom: 24px;
    border-bottom: 1px solid #eaeaea;
}

body.dark-mode .accordion-group {
    border-bottom: 1px solid #333;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s;
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #ffffff;
}

body.dark-mode .accordion-header {
    background-color: #111111;
}

.accordion-header:hover {
    opacity: 0.7;
}

.accordion-header h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    font-family: "Space Mono", "Noto Sans TC", sans-serif;
    letter-spacing: -0.02em;
}

.accordion-icon {
    width: 24px;
    height: 24px;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-icon::before,
.accordion-icon::after {
    content: '';
    position: absolute;
    background-color: #000;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: background-color 0.3s;
}

body.dark-mode .accordion-icon::before,
body.dark-mode .accordion-icon::after {
    background-color: #fff;
}

.accordion-icon::before {
    width: 12px;
    height: 2px;
}

.accordion-icon::after {
    width: 2px;
    height: 12px;
}

.accordion-group.open .accordion-icon {
    transform: rotate(45deg);
}

.accordion-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.accordion-group.open .accordion-content {
    grid-template-rows: 1fr;
}

.accordion-inner {
    min-height: 0; /* Necessary for grid animation */
    overflow: hidden;
}

/* 當螢幕寬度小於 1000px（手機與平板）：標準安全區對齊與單欄精緻排版 */
@media (max-width: 1000px) {
    .collection-content {
        padding-left: var(--mobile-gutter, 16px);
        padding-right: var(--mobile-gutter, 16px);
    }
    .collection-content .content-area {
        width: 100% !important;
        padding-top: calc(105px + env(safe-area-inset-top, 0px)) !important;
        padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
    }
    .item-grid {
        grid-template-columns: 1fr; /* 改成單欄直列 */
        gap: 14px;
        padding-top: 10px;
    }
    .collection-item .item-content {
        padding: 14px;
    }
    .collection-item .item-title {
        font-size: 0.85em;
        padding: 4px 8px;
        gap: 6px;
        border-radius: 4px;
    }
    .collection-item .item-author {
        font-size: 0.7em;
    }
    .collection-item .item-arrow {
        font-size: 0.9em;
    }
    
    .accordion-header {
        top: calc(92px + env(safe-area-inset-top, 0px)); /* 精準避開頂部 global-title 與分類橫條 */
    }
}
