/* ================================================== */
/* ★★★ index.css - 首頁專屬柔和樣式 (Soft UI) ★★★ */
/* ================================================== */

/* --- 1. 核心變數 (與 view.css 保持色調一致) --- */
@import url('./assets/fonts/nunito.css');


:root {
    /* 背景與基底 */
    --bg-color: #f8f9fa;       /* 整體背景：極淡灰 */
    --card-bg: #ffffff;        /* 卡片背景：純白 */
    
    /* 文字顏色 */
    --text-primary: #2d3748;   /* 標題：深灰 */
    --text-secondary: #718096; /* 描述：中灰 */
    
    /* 品牌與互動 */
    --brand-color: #3b82f6;    /* 主色調：現代藍 */
    --brand-hover: #2563eb;    /* 懸停深藍 */
    
    /* 狀態色 */
    --tag-bg: #edf2f7;         /* 標籤背景 */
    --tag-text: #4a5568;       /* 標籤文字 */
    --tag-active-bg: #3b82f6;
    --tag-active-text: #ffffff;
    
    /* 狀態燈號 */
    --status-public-bg: #def7ec;
    --status-public-text: #03543f;
    --status-private-bg: #fde8e8;
    --status-private-text: #9b1c1c;

    /* 介面參數 */
    --radius-lg: 16px;         /* 卡片大圓角 */
    --radius-pill: 50px;       /* 按鈕膠囊狀圓角 */
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- 2. 全域設定 (修正：強制顯示捲軸，防止版面跳動) --- */
html {
    overflow-y: scroll; /* 關鍵：永遠預留捲軸空間 */
}

body {
    font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased; /* 讓文字在 Mac 上更細緻 */
}

*, *:before, *:after { box-sizing: border-box; }

/* --- 3. 頂部搜尋與標題區 --- */
.header-content {
    text-align: center;
    padding: 4rem 1.5rem 3rem; /* 增加頂部留白，讓視覺不壓迫 */
    max-width: 800px;
    margin: 0 auto;
}

.header-content h1 {
    font-size: clamp(2rem, 5vw, 2.75rem); /* 流體字體大小 */
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 2rem;
    letter-spacing: -0.02em;
}

/* 搜尋框容器 */
.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

/* 搜尋輸入框 - 膠囊狀設計 */
#search-box {
    width: 100%;
    padding: 1.2rem 3rem 1.2rem 2rem;
    border: 2px solid transparent; /* 預留邊框空間 */
    border-radius: var(--radius-pill);
    font-size: 1.1rem;
    background-color: var(--card-bg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08); /* 浮起陰影 */
    transition: var(--transition);
    color: var(--text-primary);
    outline: none;
}

#search-box:focus {
    box-shadow: 0 4px 25px rgba(59, 130, 246, 0.25);
    border-color: var(--brand-color);
}

#search-box::placeholder {
    color: #cbd5e0;
}

/* 清除按鈕 */
.clear-search {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: #e2e8f0;
    border: none;
    color: #718096;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: none; /* JS 控制顯示 */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}
.clear-search:hover { background: #cbd5e0; color: #4a5568; }
.search-container.has-text .clear-search { display: flex; }

/* 標籤雲 */
.tag-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 2rem;
}

.tag-button {
    background-color: var(--tag-bg);
    color: var(--tag-text);
    border: 1px solid transparent;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-pill);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.tag-button:hover {
    background-color: #e2e8f0;
    transform: translateY(-2px);
}

/* 當標籤被搜尋選中時的樣式 (可搭配 JS 優化，目前僅做 hover 示意) */
.tag-button.active {
    background-color: var(--tag-active-bg);
    color: var(--tag-active-text);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* --- 4. 影片卡片網格 (最終修正：Grid 佈局 + 頂部對齊) --- */
/* 使用 Grid 徹底解決「重疊」問題，這是最穩定的排版 */
.card-container {
    display: grid;
    /* 自動計算欄位：最小寬度 280px，剩下的空間平分 */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    
    width: 95%;
    max-width: 1400px;
    margin: 0 auto 2rem;
    padding: 0 1rem;
    
    /* ★★★ 核心關鍵：靠上對齊 ★★★ */
    /* 這行能確保當隔壁抽屜變長時，自己不會被強制拉長，也不會重疊 */
    align-items: start; 
}

.card-link {
    text-decoration: none;
    display: block;
    height: 100%;
}

/* 卡片與抽屜基礎設定 */
.card, .drawer-wrapper {
    width: 100%;
    margin-bottom: 0;
    /* 移除所有可能導致重疊的 Masonry 屬性 */
    break-inside: auto; 
    page-break-inside: auto;
}

/* --- ★★★ 抽屜配色與交互 (您喜歡的風格) ★★★ --- */

/* 1. 抽屜標題 (未展開) */
.drawer-header {
    background: #fff;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    transition: all 0.2s ease;
    border-radius: var(--radius-lg);
}

/* 2. 抽屜標題 (展開時：變身為藍色高對比) */
.drawer-wrapper.open .drawer-header {
    background-color: var(--brand-color); /* 變藍色 */
    border-color: var(--brand-color);
    color: white; /* 文字變白 */
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
    
    /* 展開時，讓下方圓角變直，與內容區接合 */
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* 強制改變展開後的內部元素顏色 */
.drawer-wrapper.open .drawer-title h2 { color: white !important; }
.drawer-wrapper.open .drawer-count { color: rgba(255, 255, 255, 0.8); }
.drawer-wrapper.open .drawer-icon {
    color: white;
    transform: rotate(180deg);
}

/* 3. 抽屜內容區 (白色底，藍色邊框) */
.drawer-content {
    display: none;
    background: #fff; /* 內容區維持白底，閱讀性最佳 */
    border: 2px solid var(--brand-color); /* 藍色邊框呼應標題 */
    border-top: none; /* 去掉頂部邊框，看起來像一體的 */
    
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
    
    /* 底部圓角 */
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    
    animation: slideDown 0.3s ease-out;
}

.drawer-wrapper.open .drawer-content {
    display: flex;
}

/* 子卡片 (在抽屜裡的影片) */
.child-card {
    box-shadow: none;
    border: 1px solid #e2e8f0;
    background: #f8fafc; /* 淺灰底區分層次 */
    padding: 1rem;
    border-radius: 8px;
}
.child-card:hover {
    transform: translateX(5px);
    border-color: var(--brand-color);
    background: #fff;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- RWD 手機版調整 --- */
@media (max-width: 768px) {
    .card-container {
        grid-template-columns: 1fr; /* 手機版強制單欄 */
        gap: 1rem;
    }
    
    .header-content {
        padding: 3rem 1rem 2rem;
    }
    
    .card h2 {
        font-size: 1.1rem;
    }
}

/* --- 分區標題與分隔線 --- */
.section-header {
    width: 95%;
    max-width: 1400px;
    margin: 2rem auto 1rem;
    padding: 0 1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.section-divider {
    width: 90%;
    max-width: 1200px;
    height: 1px;
    background: repeating-linear-gradient(to right, #e2e8f0, #e2e8f0 10px, transparent 10px, transparent 20px);
    margin: 3rem auto;
}

/* 懸停效果：上浮 + 加深陰影 */
.card:hover { transform: translateY(-8px); box-shadow: var(--shadow-hover); border-color: rgba(59, 130, 246, 0.1); }
.card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--brand-color), #60a5fa); opacity: 0; transition: var(--transition); }
.card:hover::before { opacity: 1; }

.card h2 {
    font-size: 1.25rem; /* 電腦版標題大小 */
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* 標題最多兩行 */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 狀態標籤 */
.page-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 600;
    width: fit-content;
}

.page-status.public {
    background-color: var(--status-public-bg);
    color: var(--status-public-text);
}

.page-status.private {
    background-color: var(--status-private-bg);
    color: var(--status-private-text);
}

/* 狀態圖示微調 */
.page-status i { font-size: 0.9em; }

/* 提示訊息 (無資料時) */
.message-box {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    background: #fff;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    box-shadow: var(--shadow-soft);
}

.message-box a.button {
    background: var(--brand-color);
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-pill);
    text-decoration: none;
    display: inline-block;
    margin-top: 1rem;
    transition: var(--transition);
}
.message-box a.button:hover { background: var(--brand-hover); }



/* --- 高對比抽屜樣式修正 --- */

/* 1. 抽屜標題卡片 (未展開時) */
.drawer-header {
    background: #fff;
    border: 2px solid #e2e8f0; /* 預設淺灰邊框 */
    cursor: pointer;
    display: flex; /* 修正：確保內容對齊 */
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    transition: all 0.2s ease;
    border-radius: var(--radius-lg); /* 確保有圓角 */
}

/* 2. 抽屜被展開時 (High Contrast Mode) */
/* 當抽屜被加上 .open class 時，改變標題顏色 */
.drawer-wrapper.open .drawer-header {
    background-color: var(--brand-color); /* 使用品牌藍底 (或改成 #2d3748 深灰底) */
    border-color: var(--brand-color);
    color: white; /* 強制白字 */
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4); /* 加上藍色暈光 */
}

/* 修正展開後的內部文字顏色 */
.drawer-wrapper.open .drawer-title h2 {
    color: white !important; /* 強制標題變白 */
}

.drawer-wrapper.open .drawer-count {
    color: rgba(255, 255, 255, 0.8); /* 次要文字變半透明白 */
}

.drawer-wrapper.open .drawer-icon {
    color: white; /* 箭頭變白 */
    transform: rotate(180deg);
}

/* 3. 抽屜內容區 (左側線條顏色也跟著變) */
.drawer-content {
    display: none;
    padding-left: 1.5rem;
    border-left: 3px solid var(--brand-color); /* 線條加粗並變色 */
    margin-left: 1rem;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem; /* 增加與標題的距離 */
    animation: slideDown 0.3s ease-out;
}

.drawer-wrapper.open .drawer-content {
    display: flex;
}
/* 子卡片樣式微調 */
.child-card {
    box-shadow: none;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}
.child-card:hover {
    transform: translateX(5px); /* 子卡片懸停向右移 */
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* RWD: 手機版調整 */
@media (max-width: 768px) {
    .drawer-wrapper.open {
        grid-column: 1 / -1; /* 手機版展開時佔滿整行 */
    }
    .drawer-content {
        padding-left: 0.5rem;
        margin-left: 0.5rem;
    }
}

/* --- 分區標題與分隔線 --- */

/* 讓每個 card-container 的底部間距變小，由分隔線來控制距離 */
.card-container {
    margin-bottom: 1rem;
}

/* 區塊標題 */
.section-header {
    width: 95%;
    max-width: 1400px;
    margin: 2rem auto 1rem; /* 上留白多一點 */
    padding: 0 1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid #e2e8f0; /* 標題下方加上細線 */
    padding-bottom: 0.5rem;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.section-header i {
    color: var(--brand-color);
}

/* 兩個區塊中間的分隔線 (如果不想用標題，這個也會有區隔效果) */
.section-divider {
    width: 90%;
    max-width: 1200px;
    height: 1px;
    background: repeating-linear-gradient(
        to right,
        #e2e8f0,
        #e2e8f0 10px,
        transparent 10px,
        transparent 20px
    ); /* 虛線效果 */
    margin: 3rem auto; /* 上下拉開距離 */
}