/* public/style.css */

/* --- 1. 全局及基本樣式 (General/Base Styles) --- */
:root {
    --primary-color: #ff0000; /* YouTube Red */
    --secondary-color: #ffffff;
    --background-color: #1a1a1a; /* Dark background */
    --card-background: #282828;
    --text-color: #ffffff;
    --light-text-color: #aaaaaa;
    --border-color: #3a3a3a;
    --button-bg-color: #4a4a4a;
    --button-hover-bg-color: #606060;
    --shorts-badge-bg: #cc0000;
}

body {
    font-family: 'Roboto', 'Noto Sans TC', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    overflow-x: hidden; /* Prevent horizontal scroll from layout issues */
}

#app-container {
    max-width: 1800px;
    margin: 20px auto;
    padding: 0 20px;
}

h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 30px;
}

h2 {
    color: var(--text-color);
    margin-top: 40px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

#loading-message, #error-message {
    text-align: center;
    padding: 20px;
    font-size: 1.2em;
}

#error-message {
    color: var(--primary-color);
    background-color: #330000;
    border: 1px solid var(--primary-color);
    border-radius: 5px;
}

/* --- 2. 類別區塊樣式 (Category Section Styles) --- */
.carousel-section {
    margin-bottom: 40px;
    position: relative; /* Make it a positioning context for absolute buttons */
    padding: 0 80px; /* 增加左右 padding，將按鈕推得更遠 */
}

.category-title {
    color: #f0f0f0;
    margin-left: 20px;
    font-size: 1.8em;
    margin-top: 30px;
    margin-bottom: 15px;
    font-weight: bold;
}


/* --- 3. 輪播容器及內容樣式 (Carousel Wrapper & Content Styles) --- */
.carousel-wrapper {
    display: flex; /* Make it a flex container for scrollable content */
    align-items: center; /* Vertically align items */
    overflow-x: hidden; /* Hide scrollbar for the wrapper itself */
    white-space: nowrap; /* Keep cards in one line */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: none; /* Hide scrollbar for Firefox */
}

/* Hide scrollbar for Chrome, Safari, Edge */
.carousel-content::-webkit-scrollbar {
    display: none;
}

.carousel-content {
    flex-grow: 1; /* Allow content to take available space */
    overflow-x: auto; /* Enable horizontal scrolling for video cards */
    white-space: nowrap; /* Keep video cards in a single line */
    padding: 10px 0; /* Add vertical padding for shadow/spacing */
    display: flex; /* Use flex for video cards inside */
    gap: 20px; /* Spacing between video cards */
}


/* --- 4. 影片卡片樣式 (Video Card Styles) --- */
.video-card {
    background-color: var(--card-background);
    border-radius: 8px;
    overflow: hidden;
    width: 320px; /* Increased width for larger cards */
    min-width: 320px; /* Ensure cards don't shrink */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    display: flex;
    flex-direction: column; /* Stack thumbnail, title, info vertically */
    flex-shrink: 0; /* Prevent shrinking in flex container */
    text-decoration: none; /* 移除連結下劃線 */
    color: inherit; /* 繼承文字顏色 */
    height: auto; /* 自動調整高度 */
}

.video-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}

.thumbnail-container { /* This is the div wrapping the img in script.js */
    position: relative;
    display: block;
    width: 100%;
    /* Ensure aspect ratio for thumbnails */
    padding-bottom: 56.25%; /* 16:9 aspect ratio for standard videos */
    overflow: hidden;
}

.thumbnail-container img { /* The actual img tag inside thumbnail-container */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cover the area, crop if necessary */
    border-bottom: 1px solid var(--border-color);
}

.play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: var(--secondary-color);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 2em;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.thumbnail-container:hover .play-button {
    opacity: 1;
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.8);
    color: var(--secondary-color);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: bold;
    z-index: 5;
}

.shorts-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background-color: var(--shorts-badge-bg);
    color: var(--secondary-color);
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.75em;
    font-weight: bold;
    z-index: 5;
}

.video-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.video-title {
    font-size: 1.05em;
    margin: 0 0 8px 0;
    line-height: 1.3;
    max-height: 2.6em; /* Show max 2 lines of title */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-word;
    color: var(--text-color);
}

.video-channel {
    font-size: 0.9em;
    color: var(--light-text-color);
    margin: 0 0 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-metadata {
    font-size: 0.8em;
    color: var(--light-text-color);
    margin-top: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- 5. 輪播導航按鈕樣式 (Carousel Navigation Buttons Styles) --- */
.carousel-button {
    background-color: var(--button-bg-color);
    color: var(--secondary-color);
    border: none;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5em;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute; /* Absolute position within .carousel-section */
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.carousel-button:hover {
    background-color: var(--button-hover-bg-color);
}

.carousel-button.left {
    left: 10px; /* 從 section 邊緣往內 10px (加上 section padding 就是整體往外移了) */
    display: none; /* Hidden by default, shown by JS */
}

.carousel-button.right {
    right: 10px; /* 從 section 邊緣往內 10px */
    display: none; /* Hidden by default, shown by JS */
}

/* --- 6. 響應式調整 (Responsive Adjustments) --- */
@media (max-width: 768px) {
    .video-card {
        width: 280px; /* Slightly smaller for tablets */
        min-width: 280px;
    }
    .carousel-button {
        width: 40px; /* Smaller buttons on tablets */
        height: 40px;
        font-size: 1.2em;
    }
    .carousel-section {
        padding: 0 45px; /* Adjust padding for smaller buttons */
    }
    .carousel-button.left {
        left: 0px;
    }
    .carousel-button.right {
        right: 0px;
    }
}

@media (max-width: 480px) {
    #app-container {
        padding: 0 10px;
    }
    .video-card {
        width: 100%; /* Full width cards on small screens */
    }
}