/* ==========================================================================
   滾動敘事模組 (Scrollytelling Module)
   ========================================================================== */
.connect-scrolly-module {
    background-color: #f8f9fa;
    padding: 100px 0;
    position: relative;
}

/* 電腦版雙欄網格 */
.connect-scrolly-module .scrolly-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- 黏性影片區 (Sticky) --- */
.connect-scrolly-module .scrolly-visual {
    position: sticky;
    top: 120px;
    /* 距離螢幕頂部的舒適距離 */
    height: calc(100vh - 160px);
    display: flex;
    align-items: center;
}

.connect-scrolly-module .sticky-video-wrapper {
    position: relative;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    background: #000;
    aspect-ratio: 16/9;
    /* 防禦 CLS 塌陷 */
    transition: opacity 0.4s ease;
}

/* 用來製造切換時的淡入淡出效果 */
.connect-scrolly-module .sticky-video-wrapper.is-transitioning {
    opacity: 0.2;
}

.connect-scrolly-module video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- 滾動文案區 --- */
.connect-scrolly-module .scrolly-content {
    padding-bottom: 50vh;
    /* 確保最後一個項目能滾動到畫面中央 */
}

.connect-scrolly-module .scenario-item {
    position: relative;
    padding: 3rem 0;
    opacity: 0.3;
    /* 預設變暗，降低視覺干擾 */
    transform: translateX(-20px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid transparent;
    padding-left: 2rem;
}

/* 啟動狀態 (Active) - 當滾動到此區塊時觸發 */
.connect-scrolly-module .scenario-item.is-active {
    opacity: 1;
    transform: translateX(0);
    border-left-color: #ffdc19;
    /* CONNECT 色高光 */
}

.connect-scrolly-module .scenario-item h3 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
    margin-top: 0;
    margin-bottom: 1rem;
}

.connect-scrolly-module .scenario-item p {
    font-size: 1.15rem;
    line-height: 1.7;
    color: #4b5563;
    margin: 0;
}

/* --- RWD 手機版防呆 --- */
@media (max-width: 991px) {
    .connect-scrolly-module .scrolly-grid {
        grid-template-columns: 1fr;
        /* 切換為單欄 */
        gap: 2rem;
    }

    /* 手機版將影片固定在畫面上方 (Top-Sticky) */
    .connect-scrolly-module .scrolly-visual {
        position: sticky;
        top: 70px;
        /* 避開導覽列 */
        height: auto;
        z-index: 10;
        margin-bottom: 2rem;
    }

    .connect-scrolly-module .scenario-item {
        opacity: 0.5;
        /* 手機版不需太暗 */
        padding: 2rem 0 2rem 1.5rem;
    }

    .connect-scrolly-module .scenario-item.is-active {
        opacity: 1;
    }

    .connect-scrolly-module .scrolly-content {
        padding-bottom: 10vh;
    }
}

/* ==========================================================================
   滾動敘事模組 - 影片客製化控制 UI (Video Controls)
   ========================================================================== */

/* 影片控制 UI 遮罩容器 */
/* ==========================================================================
   影片客製化控制 UI - 點擊防呆優化
   ========================================================================== */
.connect-scrolly-module .custom-video-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
    /* 💡 讓控制列本身變成透明的，不阻擋游標點擊底層的影片 */
    pointer-events: none;
}

/* 💡 確保裡面的按鈕可以被點擊 */
.connect-scrolly-module .video-center-btn,
.connect-scrolly-module .video-expand-btn {
    pointer-events: auto;
}

/* 滑鼠懸停，或是影片處於「暫停狀態 (is-paused)」時，顯示 UI */
.connect-scrolly-module .sticky-video-wrapper:hover .custom-video-controls,
.connect-scrolly-module .sticky-video-wrapper.is-paused .custom-video-controls {
    opacity: 1;
}

/* --- 中央播放/暫停按鈕 --- */
.connect-scrolly-module .video-center-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ffffff;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.connect-scrolly-module .video-center-btn:hover {
    background: #ffdc19;
    /* 懸停時亮起 CONNECT 品牌黃 */
    color: #111827;
    transform: scale(1.1);
    border-color: transparent;
    box-shadow: 0 10px 25px rgba(255, 220, 25, 0.4);
}

/* --- 右下角全螢幕放大按鈕 --- */
.connect-scrolly-module .video-expand-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.connect-scrolly-module .video-expand-btn:hover {
    background: #ffdc19;
    color: #111827;
    border-color: transparent;
}

/* RWD 手機版：讓控制列在點擊螢幕時更容易喚出 */
@media (max-width: 991px) {
    .connect-scrolly-module .video-expand-btn {
        bottom: 12px;
        right: 12px;
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
}

/* ==========================================================================
   影片 Loading 緩衝遮罩 (Video Spinner)
   ========================================================================== */
.connect-scrolly-module .video-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 24, 39, 0.85);
    /* 深色遮罩，徹底蓋掉黑畫面 */
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 15;
    /* 層級設定在控制按鈕之上 */
    opacity: 0;
    pointer-events: none;
    /* 隱藏時不阻擋點擊 */
    transition: opacity 0.3s ease;
}

/* 當外層被加上 .is-loading 時顯示 */
.connect-scrolly-module .sticky-video-wrapper.is-loading .video-loader-overlay {
    opacity: 1;
    pointer-events: all;
}

/* 科技感旋轉光圈 */
.connect-scrolly-module .video-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 220, 25, 0.15);
    /* 軌道底色 */
    border-top: 4px solid #ffdc19;
    /* CONNECT 黃色指示器 */
    border-radius: 50%;
    animation: video-spin 1s linear infinite;
    /* 無限平滑旋轉 */
}

/* 載入提示文字 */
.connect-scrolly-module .video-loader-text {
    margin-top: 16px;
    color: #ffdc19;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(255, 220, 25, 0.3);
}

@keyframes video-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   影片 Loading 緩衝遮罩 (Video Spinner)
   ========================================================================== */
.connect-scrolly-module .video-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 24, 39, 0.85);
    /* 深色遮罩，徹底蓋掉黑畫面 */
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 15;
    /* 層級設定在控制按鈕之上 */
    opacity: 0;
    pointer-events: none;
    /* 隱藏時不阻擋點擊 */
    transition: opacity 0.3s ease;
}

/* 當外層被加上 .is-loading 時顯示 */
.connect-scrolly-module .sticky-video-wrapper.is-loading .video-loader-overlay {
    opacity: 1;
    pointer-events: all;
}

/* 科技感旋轉光圈 */
.connect-scrolly-module .video-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 220, 25, 0.15);
    /* 軌道底色 */
    border-top: 4px solid #ffdc19;
    /* CONNECT 黃色指示器 */
    border-radius: 50%;
    animation: video-spin 1s linear infinite;
    /* 無限平滑旋轉 */
}

/* 載入提示文字 */
.connect-scrolly-module .video-loader-text {
    margin-top: 16px;
    color: #ffdc19;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(255, 220, 25, 0.3);
}

@keyframes video-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   全螢幕狀態專屬優化 (Fullscreen UX Fixes)
   ========================================================================== */

/* 1. 解決手機版全螢幕影片拉伸/裁切的問題 */
/* 進入全螢幕時，將影片強制改為 contain (保持原始比例，上下或左右補黑邊) */
.connect-scrolly-module .sticky-video-wrapper:fullscreen video,
.connect-scrolly-module .sticky-video-wrapper:-webkit-full-screen video,
.connect-scrolly-module .sticky-video-wrapper:-ms-fullscreen video {
    object-fit: contain !important;
    background-color: #000000;
    /* 確保補邊的顏色是純黑 */
}

/* 2. 解決全螢幕時控制列太暗的問題 */
/* 進入全螢幕時，將暗色遮罩改為極淡的亮色遮罩 */
.connect-scrolly-module .sticky-video-wrapper:fullscreen .custom-video-controls,
.connect-scrolly-module .sticky-video-wrapper:-webkit-full-screen .custom-video-controls,
.connect-scrolly-module .sticky-video-wrapper:-ms-fullscreen .custom-video-controls {
    background: rgba(255, 255, 255, 0.05) !important;
    /* 調亮遮罩 */
}

/* (加碼優化) 全螢幕時，將右下角放大按鈕改為稍微靠內，避免被某些手機的圓角邊緣擋住 */
.connect-scrolly-module .sticky-video-wrapper:fullscreen .video-expand-btn,
.connect-scrolly-module .sticky-video-wrapper:-webkit-full-screen .video-expand-btn {
    bottom: 40px;
    right: 40px;
}