/* 通用輪播系統樣式 */

/* 基礎容器 */
.news-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

/* 輪播視窗 */
.news-viewport {
    position: relative;
    width: 100%;
    overflow: hidden; /* 所有版本都隱藏溢出 */
}

/* 桌面版樣式 */
@media (min-width: 1025px) {
    .news-viewport {
        cursor: grab;
    }
    
    .news-viewport:active {
        cursor: grabbing;
    }
    
    /* 漸變提示系統 - 精確控制 */
    .news-viewport::before,
    .news-viewport::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 40px;
        z-index: 100;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    .news-viewport::before {
        left: 0;
        background: linear-gradient(to right, rgba(11, 15, 20, 0.9), transparent);
        opacity: 0; /* 預設隱藏左側提示 */
    }
    
    .news-viewport::after {
        right: 0;
        background: linear-gradient(to left, rgba(11, 15, 20, 0.9), transparent);
        opacity: 1; /* 預設顯示右側提示 */
    }
    
    /* 位置狀態控制 */
    
    /* 最左邊：顯示 1+1+1+0.5 */
    .news-viewport.at-start::before {
        opacity: 0; /* 左邊無提示 */
    }
    .news-viewport.at-start::after {
        opacity: 1; /* 右邊有提示 */
    }
    
    /* 中間：顯示 0.25+1+1+1+0.25 */
    .news-viewport.at-middle::before {
        opacity: 1; /* 左邊有提示 */
    }
    .news-viewport.at-middle::after {
        opacity: 1; /* 右邊有提示 */
    }
    
    /* 最右邊：顯示 0.5+1+1+1 */
    .news-viewport.at-end-position::before {
        opacity: 1; /* 左邊有提示 */
    }
    .news-viewport.at-end-position::after {
        opacity: 0; /* 右邊無提示 */
    }
    
    /* 軌道容器 */
    .news-track {
        display: flex;
        gap: 24px;
        align-items: stretch;
        transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        will-change: transform;
    }
    
    /* 卡片樣式 */
    .news-card {
        flex: 0 0 auto; /* 寬度由JS動態控制 */
        position: relative;
    }
}

/* 手機版樣式 */
@media (max-width: 1024px) {
    .news-viewport {
        overflow-x: auto;
        overflow-y: hidden;
        scroll-behavior: smooth;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        
        /* 隱藏滾動條 */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .news-viewport::-webkit-scrollbar {
        display: none;
    }
    
    .news-track {
        display: flex;
        gap: 16px;
        align-items: stretch;
        padding-bottom: 1rem;
    }
    
    .news-card {
        flex: 0 0 calc(85vw - 32px);
        min-width: 280px;
        max-width: 350px;
        scroll-snap-align: start;
    }
}

/* 導航按鈕 */
.news-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    gap: 1rem;
}

.news-prev,
.news-next {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.news-prev::before,
.news-next::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(255, 255, 255, 0.1), 
        rgba(255, 255, 255, 0.05)
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.news-prev:hover:not([disabled])::before,
.news-next:hover:not([disabled])::before {
    opacity: 1;
}

.news-prev:hover:not([disabled]),
.news-next:hover:not([disabled]) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.news-prev:active:not([disabled]),
.news-next:active:not([disabled]) {
    transform: translateY(0);
}

/* 禁用狀態 */
.news-prev[disabled],
.news-next[disabled],
.news-prev.disabled,
.news-next.disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    transform: none !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: none !important;
}

/* 確保禁用狀態不會被hover覆蓋 */
.news-prev[disabled]:hover,
.news-next[disabled]:hover,
.news-prev.disabled:hover,
.news-next.disabled:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    transform: none !important;
    opacity: 0.3 !important;
}

/* 按鈕圖標 */
.news-prev::after {
    content: '‹';
    font-size: 24px;
    line-height: 1;
}

.news-next::after {
    content: '›';
    font-size: 24px;
    line-height: 1;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .news-nav {
        margin-top: 1rem;
    }
    
    .news-prev,
    .news-next {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .news-prev::after,
    .news-next::after {
        font-size: 20px;
    }
}

/* 調試模式（開發時使用） */
.news-container[data-debug="true"]::before {
    content: "Cards: " attr(data-total) " | Current: " attr(data-current) " | Max: " attr(data-max);
    position: absolute;
    top: -25px;
    left: 0;
    font-size: 12px;
    color: #fff;
    background: rgba(0, 0, 0, 0.8);
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 1000;
    white-space: nowrap;
}

/* 平滑過渡效果 */
* {
    box-sizing: border-box;
}

/* 確保卡片內容不會被遮擋 */
.news-card {
    position: relative;
    z-index: 1;
}

/* 防止卡片被選中 */
.news-card,
.news-track {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
