/* 統一的影片預覽樣式 */

/* 共通預覽容器樣式 */
.gallery-video-player,
.preview-player,
.item__cover[data-preview] {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    background: #000;
    transition: transform 0.2s ease;
}

/* 懸停效果（桌面版） */
@media (hover: hover) and (pointer: fine) {
    .gallery-video-player:hover,
    .preview-player:hover,
    .item__cover[data-preview]:hover {
        transform: scale(1.02);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
        z-index: 10;
    }
}

/* 預覽圖片樣式 */
.gallery-preview-img,
.preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    transition: opacity 0.3s ease;
}

/* 播放器容器 */
.gallery-player-container,
.shaka-player-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    pointer-events: none;
}

/* 預覽影片樣式 */
.preview-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

/* 播放圖示 */
.item__play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(249, 171, 0, 0.9);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    pointer-events: none;
}

.item__play i {
    font-size: 24px;
}

/* 手機版播放圖示較小 */
@media (max-width: 767px) {
    .item__play {
        width: 48px;
        height: 48px;
    }
    
    .item__play i {
        font-size: 20px;
    }
}

/* 正在播放時隱藏播放圖示 */
.gallery-video-player:has(.preview-video),
.preview-player:has(.preview-video),
.item__cover[data-preview]:has(.preview-video) {
    .item__play {
        opacity: 0;
    }
}

/* 評分標籤 */
.item__rate {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.item__rate--green {
    background: #21d07a;
}

.item__rate--yellow {
    background: #d2d531;
    color: #222;
}

.item__rate--red {
    background: #db2360;
}

/* 影片時長標籤 */
.video-duration,
.preview-player-duration,
.gallery-video-player-duration {
    position: absolute;
    right: 12px;
    bottom: 12px;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10;
    pointer-events: none;
}

/* 手機版時長標籤較小 */
@media (max-width: 767px) {
    .video-duration,
    .preview-player-duration,
    .gallery-video-player-duration {
        font-size: 12px;
        padding: 3px 8px;
        right: 8px;
        bottom: 8px;
    }
}

/* 影片標題連結樣式 */
.item__title a,
.preview-player-title a,
.gallery-video-title a {
    color: #fff !important;
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 側邊欄預覽播放器的特殊樣式 */
.preview-player-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
    max-width: 100%;
    overflow: hidden;
}

.preview-player-row > div:last-child {
    flex: 1;
    min-width: 0; /* 重要：允許 flex 子元素縮小 */
    overflow: hidden;
}

.preview-player-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
    overflow: hidden;
}

.preview-player-title a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.preview-player-meta {
    font-size: 0.95rem;
    color: #f9ab00;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item__title a:hover,
.preview-player-title a:hover,
.gallery-video-title a:hover {
    color: #f9ab00 !important;
    text-decoration: none;
}

/* 手機版觸控提示 */
@media (max-width: 767px) {
    .gallery-video-player::after,
    .preview-player::after,
    .item__cover[data-preview]::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: radial-gradient(circle at center, transparent 40%, rgba(0,0,0,0.1) 100%);
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
        z-index: 14;
    }
    
    .gallery-video-player:active::after,
    .preview-player:active::after,
    .item__cover[data-preview]:active::after {
        opacity: 1;
    }
}

/* 載入動畫 */
@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

.gallery-video-player.loading .gallery-preview-img,
.preview-player.loading .preview-img {
    animation: pulse 1.5s ease-in-out infinite;
}

/* 響應式尺寸調整 */

/* 首頁和目錄頁的影片卡片 */
.item__cover.gallery-video-player {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
}

/* 詳情頁側邊欄的預覽播放器 */
.preview-player {
    width: 165px;
    height: 93px;
    border-radius: 8px;
}

/* 手機版尺寸調整 */
@media (max-width: 767px) {
    .item__cover.gallery-video-player {
        border-radius: 8px;
    }
    
    .preview-player {
        width: 140px;
        height: 79px;
        border-radius: 6px;
    }
}

/* 平板橫向模式 */
@media (min-width: 768px) and (max-width: 1199px) and (orientation: landscape) {
    .preview-player {
        width: 180px;
        height: 101px;
    }
}

/* 無障礙支援 */
.gallery-video-player:focus,
.preview-player:focus,
.item__cover[data-preview]:focus {
    outline: 2px solid #f9ab00;
    outline-offset: 2px;
}

/* 隱藏原生影片控制項 */
.preview-video::-webkit-media-controls {
    display: none !important;
}

.preview-video::-webkit-media-controls-enclosure {
    display: none !important;
}

