/* ==========================================
   1. 全局初始化
   ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, "Microsoft JhengHei", sans-serif;
    background-color: #f5f5f5;
    overflow-x: clip;
}

/* ==========================================
   2. 頁首 Banner 圖片 (電腦版精準 13:2 原圖比例)
   ========================================== */
.header-banner {
    position: relative;
    z-index: 10;
    width: 100%;
    height: auto;
    aspect-ratio: 13 / 2;
    overflow: hidden;
    background-color: #1a1a1a;
}

.slideshow {
    position: relative;
    width: 100%;
    height: 100%;
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
    opacity: 0;
    transition: opacity 1.2s ease-in-out;
}

    .slide.active {
        opacity: 1 !important;
    }

/* ==========================================
   3. 吸附導航列
   ========================================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    height: 60px;
    margin-top: -60px;
    background-color: rgba(0, 164, 222, 0.85);
    backdrop-filter: blur(1px);
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

    .navbar.scrolled {
        background-color: #00A4DE !important;
    }

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    z-index: 101;
}

.nav-menu {
    display: flex;
    list-style: none;
    height: 100%;
}

.nav-item {
    position: relative;
    height: 100%;
}

    .nav-item > a {
        display: flex;
        align-items: center;
        height: 100%;
        padding: 0 20px;
        color: white;
        text-decoration: none;
        font-size: 18px;
        font-weight: bold;
        transition: all 0.25s ease;
    }

    .nav-item:hover > a {
        background-color: #A3E7FF;
        color: #000000;
        transform: scale(1.08);
        box-shadow: 0 4px 10px rgba(0,0,0,0.15);
        z-index: 2;
    }

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background-color: #00A4DE;
    list-style: none;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 105;
}

.nav-item.has-dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu li a {
    display: block;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s ease;
}

    .dropdown-menu li a:hover {
        background-color: #A3E7FF;
        color: #000000;
        padding-left: 28px;
    }

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    cursor: pointer;
    z-index: 101;
}

    .menu-toggle span {
        display: block;
        height: 3px;
        width: 100%;
        background-color: white;
        border-radius: 3px;
    }

/* ==========================================
   4. 主要內容與排版
   ========================================== */
.main-layout {
    display: flex;
    align-items: flex-start;
    width: 100%;
    position: relative;
}

.side-ad {
    position: sticky;
    top: 60px;
    z-index: 1;
    width: 160px;
    height: calc(100vh - 60px);
    background-color: #ffffff;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    flex-shrink: 0;
}

.content {
    flex: 1;
    z-index: 2;
    background-color: #ffffff;
    color: #333333;
    padding: 40px;
    min-height: 1000px;
    text-align: center;
    font-size: 24px;
}

.footer {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 120px;
    background-color: #00A4DE;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
}

/* ==========================================
   5. 手機版 AD 彈窗 (全域預設強制隱藏，絕不幹擾電腦版)
   ========================================== */
.mobile-ad-overlay {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 99999 !important;
    pointer-events: auto !important;
    justify-content: center;
    align-items: center;
}

    .mobile-ad-overlay.active {
        display: flex !important;
    }

    .mobile-ad-overlay.dismissed {
        display: none !important;
    }

.mobile-ad-box {
    position: relative !important;
    z-index: 100000 !important;
    overflow: visible !important;
    width: 85%;
    max-width: 320px;
    height: 250px;
    background-color: #bfbfbf;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    border-radius: 12px;
}

.close-btn {
    position: absolute !important;
    top: -15px !important;
    right: -15px !important;
    width: 40px !important;
    height: 40px !important;
    background-color: #ff4d4d;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer !important;
    border: 2px solid white;
    z-index: 100001 !important;
    pointer-events: auto !important;
}

/* ==========================================
   6. 文章頂部 Banner (電腦版精準 3:1 原圖比例 + 無縫向左滑動)
   ========================================== */
.article-banner {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 1;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 25px;
    background-color: #222222;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.article-banner-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translateX(100%);
    opacity: 0;
    visibility: hidden;
    z-index: 1;
}

    .article-banner-item.active {
        transform: translateX(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
        transition: transform 0.6s ease-in-out, opacity 0.6s ease-in-out;
        z-index: 3;
    }

    .article-banner-item.prev-slide {
        transform: translateX(-100%) !important;
        opacity: 1 !important;
        visibility: visible !important;
        transition: transform 0.6s ease-in-out, opacity 0.6s ease-in-out;
        z-index: 2;
    }

.article-banner-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

.article-banner-box {
    position: absolute;
    top: 20px;
    left: 20px;
    max-width: 480px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    color: #ffffff;
    padding: 16px 20px;
    border-radius: 6px;
    border-left: 5px solid #00A4DE;
    text-align: left;
    z-index: 5;
}

.banner-badge {
    display: inline-block;
    background-color: #00A4DE;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.banner-title {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 6px;
    color: #ffffff;
    line-height: 1.3;
}

.banner-subtitle {
    font-size: 14px;
    color: #e0e0e0;
    line-height: 1.5;
}

.article-banner .art-prev,
.article-banner .art-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent !important;
    color: #ffffff !important;
    border: none;
    outline: none;
    font-size: 36px;
    cursor: pointer;
    z-index: 15;
    padding: 10px;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.75;
}

    .article-banner .art-prev:hover,
    .article-banner .art-next:hover {
        background: transparent !important;
        color: #ffffff !important;
        opacity: 1;
        transform: translateY(-50%) scale(1.15);
    }

.article-banner .art-prev {
    left: 10px;
}

.article-banner .art-next {
    right: 10px;
}

.article-banner-dots {
    position: absolute !important;
    bottom: 15px !important;
    right: 20px !important;
    display: flex !important;
    gap: 8px;
    z-index: 20 !important;
}

.art-dot {
    width: 11px;
    height: 11px;
    background-color: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

    .art-dot:hover {
        background-color: rgba(255, 255, 255, 0.8);
    }

    .art-dot.active {
        background-color: #00A4DE !important;
        transform: scale(1.25);
    }

/* ==========================================
   7. 內文圖文包幻燈片 (防炸開 + 無縫向左滑動)
   ========================================== */
figure.news-figure.article-slideshow {
    position: relative !important;
    overflow: hidden !important;
    margin: 1.5rem auto;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    max-width: 100%;
}

    figure.news-figure.article-slideshow .article-slide-item:not(:first-child) {
        display: none;
    }

    figure.news-figure.article-slideshow .article-slide-item {
        display: none;
        position: relative;
        width: 100%;
        text-align: center;
    }

        figure.news-figure.article-slideshow .article-slide-item.active {
            display: block !important;
            position: relative;
            z-index: 2;
        }

        figure.news-figure.article-slideshow .article-slide-item.sliding-in {
            display: block !important;
            position: relative;
            transform: translateX(0);
            transition: transform 0.5s ease-in-out;
            z-index: 3;
        }

        figure.news-figure.article-slideshow .article-slide-item.sliding-out {
            display: block !important;
            position: absolute;
            top: 10px;
            left: 10px;
            width: calc(100% - 20px);
            transform: translateX(-100%);
            transition: transform 0.5s ease-in-out;
            z-index: 2;
        }

        figure.news-figure.article-slideshow .article-slide-item img {
            display: block;
            max-width: 100%;
            max-height: 500px;
            width: auto;
            height: auto;
            margin: 0 auto;
            object-fit: contain;
        }

        figure.news-figure.article-slideshow .article-slide-item figcaption {
            margin-top: 8px;
            font-size: 0.95rem;
            color: #555;
            text-align: center;
        }

    figure.news-figure.article-slideshow .art-prev,
    figure.news-figure.article-slideshow .art-next {
        position: absolute !important;
        top: 45% !important;
        transform: translateY(-50%);
        background: rgba(0, 0, 0, 0.6) !important;
        color: white !important;
        border: none !important;
        width: 44px !important;
        height: 44px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 22px !important;
        z-index: 20 !important;
        border-radius: 50% !important;
        transition: background 0.3s, transform 0.2s;
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    }

    figure.news-figure.article-slideshow .art-prev {
        left: 15px !important;
    }

    figure.news-figure.article-slideshow .art-next {
        right: 15px !important;
    }

        figure.news-figure.article-slideshow .art-prev:hover,
        figure.news-figure.article-slideshow .art-next:hover {
            background: rgba(0, 0, 0, 0.85) !important;
            transform: translateY(-50%) scale(1.1);
        }

    figure.news-figure.article-slideshow .article-thumbnail-bar {
        position: absolute !important;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 28%;
        min-height: 70px;
        background: rgba(0, 0, 0, 0.7);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 10px 15px;
        box-sizing: border-box;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 25 !important;
    }

    figure.news-figure.article-slideshow:hover .article-thumbnail-bar {
        opacity: 1 !important;
        visibility: visible !important;
    }

    figure.news-figure.article-slideshow .art-thumb {
        flex: 0 1 auto;
        height: 100%;
        max-height: 65px;
        max-width: 90px;
        width: auto;
        object-fit: cover;
        border-radius: 6px;
        cursor: pointer;
        border: 2px solid transparent;
        opacity: 0.65;
        transition: all 0.25s ease;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    }

        figure.news-figure.article-slideshow .art-thumb:hover {
            opacity: 1;
            transform: translateY(-2px) scale(1.05);
        }

        figure.news-figure.article-slideshow .art-thumb.active {
            border-color: #ff9800;
            opacity: 1;
            transform: scale(1.05);
        }

/* ==========================================
   8. RWD 響應式調整 (手機版 <= 768px)
   ========================================== */
@media (max-width: 768px) {
    .header-banner {
        height: 150px;
        aspect-ratio: auto;
    }

    .menu-toggle {
        display: flex;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        width: 100%;
        background-color: #00A4DE;
        flex-direction: column;
        height: auto;
    }

        .nav-menu.active {
            display: flex;
        }

    .nav-item {
        width: 100%;
        height: auto;
    }

        .nav-item > a {
            padding: 15px 20px;
        }

        .nav-item:hover > a {
            transform: none;
        }

    .dropdown-menu {
        position: static;
        width: 100%;
        background-color: #0081ae;
    }

    .side-ad {
        display: none;
    }

    .mobile-ad-overlay {
        display: flex !important;
    }

        .mobile-ad-overlay.dismissed {
            display: none !important;
        }

    .content {
        padding: 20px 15px;
    }

    /* 手機版文章頂部 Banner：防止高度塌陷消失，維持圖上文下結構 */
    .article-banner {
        position: relative !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        aspect-ratio: auto !important;
        min-height: 280px !important;
        overflow: hidden !important;
    }

    .article-banner-item {
        display: none !important;
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

        .article-banner-item.active {
            display: block !important;
            position: relative !important;
            transform: translateX(0) !important;
            opacity: 1 !important;
            visibility: visible !important;
            animation: mobileSlideIn 0.4s ease-out;
        }

        .article-banner-item.prev-slide {
            display: none !important;
        }

    .article-banner-img {
        display: block !important;
        width: 100% !important;
        height: 180px !important;
        object-fit: cover !important;
    }

    .article-banner-box {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        max-width: 100% !important;
        background: #222222 !important;
        border-radius: 0 0 8px 8px !important;
    }
}

@keyframes mobileSlideIn {
    from {
        opacity: 0.4;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}
