:root {
    --text-carousel-item-ind: 0;
    --text-carousel-speed: 1s;
}

.text-carousel {
    position: relative;
    height: 30px;
    /* 每則訊息的高度 */
    overflow: hidden;
    flex-grow: 1;
    /* 使 carousel 填滿父容器 */
}

.text-carousel-msgs {
    position: relative;
    display: flex;
    flex-direction: column;
    transition: transform var(--text-carousel-speed) ease-in-out;
    /* 平滑切換效果 */
    transform: translateY(calc(-1 * var(--text-carousel-item-ind) * 30px));
}

.text-carousel-msg {
    width: 100%;
    height: 30px;
    /* 與 container 高度一致 */
    display: flex;
    align-items: center;
    flex-shrink: 1;
    /* 讓訊息縮小以適應 carousel 寬度 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.news-bg {
    background-color: #f2f2f2;
}

.index-search-area {
    width: 100%;
}

.index-search-area>.search-tips>img,
.index-search-area>.hot-resource-cloud>img {
    height: 20px;
}

#carousel_control {
    position: absolute;
    z-index: 100;
    bottom: 0;
    color: #0F3B3A;
}

#carousel_control:hover {
    color: #ffffff;
}

#carousel_control:focus-visible {
    color: #134F4E;
    background-color: var(--main-bg-color);
    border-color: var(--main-bg-color);
    outline: 2px dashed #ff0000;
    box-shadow: none;
}

.btn:focus-visible,
.btn:focus {
    outline: 2px dashed #ff0000;
    box-shadow: none;
}

.owl-carousel .owl-item>div>img {
    aspect-ratio: 2 / 1;
    object-fit: contain;
}

.owl-carousel .info-area {
    top: 0;
    left: 0;
    align-content: flex-end;
    background-color: rgba(0, 0, 0, 0.3);
    color: #fff;
    padding: 1.6rem;
    direction: ltr;
}

.owl-carousel .info-area .video-description {
    display: none;
}

.owl-carousel .info-area .play-icon {
    max-width: 70px;
}

.index-banner .plyr {
    aspect-ratio: 2 / 1;
}

.index-banner {
    width: 100%;
    height: auto;
}

.open-img-link {
    margin-right: 7px;
}

.py-5 {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
}

/* .btn:focus-visible {
    color: revert;
    background-color: revert;
    outline: none;
    box-shadow: none;
} */

.plyr--video:fullscreen,
.plyr--video:-webkit-full-screen {
    border-radius: 0 !important;
    transition: none !important;
}

/* iPhone fallback 全螢幕：補上 safe area，避免 Safari 工具列遮住控制列 */
.plyr--fullscreen-fallback .plyr__controls {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}


@media (max-width: 576px) {
    .news {
        display: none;
    }

    .py-5 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    #carousel_control {
        display: none;
    }

    .mt-4 {
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    .mt-5 {
        margin-top: 0.5rem !important;
    }

    .search-keyword {
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 1000px) and (max-height: 480px) {
    .news {
        display: none;
    }

    .py-5 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    #carousel_control {
        display: none;
    }

    .mt-4 {
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    .mt-5 {
        margin-top: 0.5rem !important;
    }

    .search-keyword {
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .owl-carousel .info-area .video-description {
        display: -webkit-box;
        /* 必須使用 flexbox-like 行為 */
        -webkit-box-orient: vertical;
        /* 設置排列方向為垂直 */
        overflow: hidden;
        /* 隱藏超出的內容 */
        text-overflow: ellipsis;
        /* 顯示省略號 */
        -webkit-line-clamp: 3;
    }

    .index-search-area {
        width: 80%;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .owl-carousel .info-area .video-description {
        -webkit-line-clamp: 3;
    }
}

/* X-Large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .index-search-area {
        width: 50%;
    }
}

/* XX-Large devices (larger desktops, 1400px and up) */
@media (min-width: 1400px) {}

/* 動態套無障礙紅框選取效果 */
/* 最新消息跑馬燈 */
.text-carousel-msgs a:focus {
    border: 2px dashed #ff0000;
}

/* "首頁"大圖跑馬燈,"首頁"中央導覽列,"教育應用","主題資源","熱門資源"列表 */
.accessibility-line-type1 {
    border: 2px dashed #ff0000;
}

/* "新上架資源" */
.category-content ul>li a:focus {
    border: 2px dashed #ff0000;
}

/* 搜尋關鍵字輸入框 */
.input-group .form-control:focus {
    outline-width: 2px !important;
    outline-style: dashed !important;
    outline-color: #ff0000 !important;
}

.search-input input:focus {
    border: 2px dashed #ff0000;
}

.video-block {
    background-color: #ddf3f6;
}

.video-block .category-item {
    background-color: #ddf3f6;
}

.video-block .category-img {
    background-color: #fff;
    aspect-ratio: 16 / 10;
    position: relative;
}

.category-item>.category-img div.video::after {
    content: "\f144";
    font-family: "Font Awesome 5 Free";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 3rem;
}

.category-item>.category-img div.video::before {
    content: "";
    position: absolute;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2);
}

.carousel-indicators [data-bs-target] {
    width: 40px;
    height: 10px;
}

.mb-3 {
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .video-block .category-item {
        height: 100%;
        background-color: #ddf3f6;
        padding-bottom: 15px;
    }

    .video-block .category-item-title {
        justify-content: space-between;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .video-block .video-block-right .category-img {
        width: 160px;
        overflow: hidden;
    }

    .video-block .video-block-right .category-item-content {
        padding-left: 10px;
        width: calc(100% - 160px);
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .video-block .video-block-left {
        width: 550px;
        padding-right: 10px;
    }

    .video-block-right {
        width: calc(100% - 550px);
        flex-grow: 1;
        max-height: none;
        flex-direction: column;
        justify-content: space-between;
        padding-left: 10px;
    }

    .video-block .video-block-left .category-item-title {
        white-space: normal;
    }

    .video-block .video-block-right .category-img {
        height: 110px;
        width: 176px;
    }

    .video-block .category-item-content {
        flex-grow: 1;
    }

    .video-block .video-block-right .category-item-content {
        width: calc(100% - 176px);
    }
}

@media (min-width: 1200px) {
    .video-block .video-block-left {
        width: 750px;
    }

    .video-block-right {
        width: calc(100% - 750px);
    }

    .video-block .video-block-right .category-img {
        height: 130px;
        width: 220px;
    }

    .video-block .video-block-right .category-item-content {
        width: calc(100% - 220px);
        flex-grow: 1;
    }
}

@media (max-width: 768px) {
    .search-tips {
        display: none !important;
    }

    .hot-resource-cloud {
        display: none !important;
    }
}

/* ===================================================
   首頁輪播影片全螢幕修復 (iOS Safari / iPad Chrome)
   原因：Plyr fallback 全螢幕用 position:fixed 模擬，
         但 owl-stage 祖先有 transform，CSS 規範下
         transform 祖先會成為 fixed 的 containing block，
         導致全螢幕被鎖在輪播容器內無法撐滿 viewport。
   解法：enterfullscreen 時將 .plyr 容器搬移至 body，
         脫離 owl-stage 的 transform containing block，
         exitfullscreen 時搬回原位。
   =================================================== */

/* plyr fallback 全螢幕時確保撐滿整個 viewport */
.plyr--fullscreen-fallback {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;       /* fallback for old browsers */
    height: 100dvh !important;      /* dynamic viewport height — 修正行動版裁切問題 */
    aspect-ratio: unset !important; /* 取消 .index-banner .plyr 的 2/1 限制，避免進度條超出 */
    z-index: 9999 !important;
    border-radius: 0 !important;
    margin: 0 !important;
}