/* YouTube Video Embedding Styles */
.youtube-video-container {
    /* Full-bleed container to replace any black page background */
    width: 100vw;                 /* 佔滿整個視窗寬度 */
    max-width: none;              /* 取消 max-width 限制 */
    margin: -230px 0 0 0 !important;         /* 取消自動左右間距 */
    padding: 0 !important;        /* 移除所有 padding */
    background: transparent;      /* 保持透明，底下會由影片覆蓋 */
    box-shadow: none !important;  /* 移除外框陰影 */
    border-radius: 0;             /* 移除圓角 */
    border: none !important;      /* 移除邊框 */
    overflow: hidden;             /* 避免 iframe 溢出時出現黑邊 */
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1); /* 平滑快速的過渡效果 */
}

/* 當滾動到影片區域時的全屏效果 */
.youtube-video-container.fullscreen-active {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    z-index: 9999 !important;
    background: #000 !important;
    pointer-events: none; /* 允許滾動事件穿透 */
}

.youtube-video-container.fullscreen-active .youtube-video-wrapper iframe {
    pointer-events: auto; /* 但影片本身可以互動 */
}

.youtube-video-wrapper {
    position: relative;
    width: 100%;
    /* 使用 16:9 比例的 padding-bottom 技巧 */
    padding-bottom: 56.25%; /* 16:9 比例 (9/16 = 0.5625) */
    height: 0;
    overflow: hidden;
    border-radius: 0;             /* 移除圓角 */
    box-shadow: none !important;  /* 移除外框陰影 */
    border: none !important;      /* 移除邊框 */
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1); /* 平滑快速的過渡效果 */
}

/* 全屏模式下的影片包裝器 */
.youtube-video-container.fullscreen-active .youtube-video-wrapper {
    width: 100vw !important;
    height: 100vh !important;
    padding-bottom: 0 !important;
}

.youtube-video-wrapper iframe {
    /* iframe 填滿整個容器 */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none !important;   /* 移除邊框 */
    border-radius: 0;          /* 移除圓角 */
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .youtube-video-container {
        width: 100vw;
        margin: -100px 0 0 0 !important;
        padding: 0 !important;
        border-radius: 0;
        box-shadow: none !important;
        border: none !important;
    }

    .youtube-video-wrapper {
        /* 手機版使用相同的 16:9 比例 */
        padding-bottom: 56.25%;
        height: 0;
        border-radius: 0;
        box-shadow: none !important;
        border: none !important;
    }

    .youtube-video-wrapper iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none !important;
    }
}

@media (max-width: 480px) {
    .youtube-video-container {
        padding: 0 !important;
        margin: -100px 0 0 0 !important;
        border-radius: 0;
        box-shadow: none !important;
        border: none !important;
    }

    .youtube-video-wrapper {
        padding-bottom: 56.25%;
        height: 0;
        border-radius: 0;
        box-shadow: none !important;
        border: none !important;
    }

    .youtube-video-wrapper iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none !important;
    }
}

/* Loading and Hover Effects */
.youtube-video-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.youtube-video-container:hover .youtube-video-wrapper {
    transform: none !important; /* ✅ 移除放大效果 */
    transition: none !important; /* ✅ 移除動畫效果 */
}

/* Focus and Accessibility */
.youtube-video-wrapper iframe:focus {
    outline: none !important; /* ✅ 移除焦點外框 */
    outline-offset: 0;
}

/* Print Styles */
@media print {
    .youtube-video-container {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
