/* news.css — modern news layout */
:root {
    --site-header-height: 80px;
    --container: 1200px;
    --bg: #f6f9ff;
    --accent: #1a5cff;
    --muted: #7b8a9a;
    --card-bg: #fff;
    --radius: 14px;
    --shadow: 0 8px 28px rgba(18,36,80,0.06);
}

/* RESET-ish */
* {
    box-sizing: border-box
}

body {
    font-family: "Noto Sans TC", "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0;
    color: #10283f;
    background: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    scroll-padding-top: 90px;
}

/* 主要頁面寬度約束，置中顯示 */
.news-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 64px;
}

body.has-fixed-header {
    padding-top: var(--site-header-height);
}

.container {
    max-width: var(--container,92%);
    margin: 0 auto;
}

/* HERO */
.news-hero {
    margin-top: calc(var(--site-header-height) + 20px);
    padding: 48px 0 18px;
    text-align: center;
}

    .news-hero .eyebrow {
        color: var(--accent);
        font-weight: 700;
        letter-spacing: 1px;
        display: block;
    }

    .news-hero .headline {
        font-size: 34px;
        margin: 10px 0;
    }

    .news-hero .lead {
        color: var(--muted);
        max-width: 820px;
        margin: 0 auto;
    }

/* LAYOUT */
.news-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: start;
    padding: 32px 0 64px;
    width: 100%;
}

    /* ✅ 防止 grid/flex 子元素把欄位撐爆（非常重要） */
    .news-content > * {
        min-width: 0;
    }

/* =========================
   Spotlight / Carousel
   ✅ 修正：加第3則後不跑版
   ========================= */
.spotlight {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden; /* ✅ 關鍵：裁切軌道 */
    background: linear-gradient(180deg, rgba(26,92,255,0.06), rgba(77,141,255,0.03));
    padding: 8px 0; /* ✅ 只上下 padding，左右為 0 */
    margin-bottom: 18px;
    box-shadow: var(--shadow);
    width: 100%;
    /* ✅ 新增：確保內部容器不會溢出 */
    max-width: 100%;
    /* ✅ 更嚴格裁切，避免子像素造成溢出 */
    clip-path: inset(0 round var(--radius));
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    mask-image: radial-gradient(white, black);
}

/* ✅ 關鍵修正點：
   1) track 必須是 flex
   2) 不要 gap，避免 translateX 以 100% 計算時產生誤差＆撐爆
   3) 嚴格限制寬度和溢出
*/
.spotlight-track {
    display: flex;
    width: 100%;
    gap: 0; /* ✅ 修正：移除 gap */
    transition: transform .6s cubic-bezier(.2,.9,.3,1);
    will-change: transform;
    overflow: visible; /* ✅ 允許內部滑動，外層 .spotlight 裁切 */
    backface-visibility: hidden;
}

/* ✅ 每一張 slide 固定 100% 寬，不使用 min-width 造成溢出 */
.spot {
    flex: 0 0 100%;
    width: 100%; /* ✅ 明確設定寬度 */
    max-width: 100%;
    min-width: 100%; /* ✅ 強制最小寬度 */
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    align-items: center;
    box-sizing: border-box;
    padding: 8px 8px; /* ✅ 左右加 padding 空間 */
    overflow: hidden; /* ✅ 防止下一張圖邊緣露出 */
}

    /* ✅ 圖片不撐爆 */
    .spot img {
        width: 100%;
        height: 140px;
        max-height: 160px;
        object-fit: cover;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        display: block;
    }

    /* ✅ 內容區避免長字把版面推爆 */
    .spot > :not(img) {
        min-width: 0;
    }

    .spot .meta {
        font-size: 13px;
        color: var(--muted);
        display: flex;
        gap: 12px;
        align-items: center;
    }

    .spot h3 {
        margin: 0 0 8px;
        font-size: 20px;
        font-weight: 600;
    }

    .spot .read-more {
        color: var(--accent);
        font-weight: 600;
        text-decoration: none;
    }

/* controls */
.spot-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

    .spot-controls button {
        background: #fff;
        border: 1px solid #e6eefc;
        padding: 8px 12px;
        border-radius: 8px;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(14,40,100,0.06);
    }

    .spot-controls .dots {
        display: flex;
        gap: 8px;
    }

        .spot-controls .dots button {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            border: 0;
            background: rgba(255,255,255,0.6);
            box-shadow: inset 0 -2px 0 rgba(0,0,0,0.06);
        }

/* TOOLS */
.tools {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.search-wrap input {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #e4eefc;
    min-width: 260px;
    width: 100%;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    border: 1px solid rgba(30,90,255,0.12);
    background: transparent;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--accent);
}

    .filter-btn.active {
        background: linear-gradient(90deg,var(--accent),#4d8dff);
        color: white;
        border: 0;
        box-shadow: 0 6px 18px rgba(26,92,255,0.12);
    }

/* NEWS GRID */
.news-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: 220px;
    overflow-y: auto;
    padding: 12px 8px 12px 12px;
    background: #ffffff;
    border: 1px solid #e0e8f7;
    border-radius: 10px;
    /* Firefox 捲動條支援 */
    scrollbar-width: thin;
    scrollbar-color: #5a8fe8 #f0f5ff;
}

    /* Webkit 瀏覽器（Chrome、Safari）捲動條樣式 */
    .news-grid::-webkit-scrollbar {
        width: 10px;
    }

    .news-grid::-webkit-scrollbar-thumb {
        background: #5a8fe8;
        border-radius: 8px;
    }

    .news-grid::-webkit-scrollbar-track {
        background: #f0f5ff;
        border-radius: 8px;
    }

.card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    height: 180px;
    transition: height 0.3s ease;
}

    .card.expanded {
        height: auto;
    }

    .card:hover {
        transform: translateY(-6px);
        box-shadow: 0 18px 48px rgba(18,36,80,0.12);
    }

    .card .thumb {
        width: 60%;
        height: 100%;
        object-fit: cover;
        display: none !important;
    }

    .card .card-body {
        width: 100%;
        flex: 1;
        padding: 10px 12px 10px 12px;
        padding-right: 50px; /* 留空间給右側按鈕 */
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow: hidden;
        min-width: 0; /* 允許 flex 元素縮小 */
    }

    .card .meta {
        font-size: 12px;
        color: var(--muted);
        margin-bottom: 8px;
        display: flex;
        justify-content: space-between;
    }

    .card h4 {
        margin: 0 0 4px;
        font-size: 16px;
    }

    .card p {
        margin: 0 0 12px;
        color: #5d6b7a;
        flex: 1;
    }

    .card .read {
        text-decoration: none;
        color: var(--accent);
        font-weight: 600;
    }

    /* 卡片內文區塊的捲動設定（僅在展開時可見） */
    .card .full-text {
        max-height: 1.6em; /* 嚴格限制在一行高度 */
        overflow-y: auto;
        padding: 0 8px 0 0;
        line-height: 1.6;
    }

        .card .full-text::-webkit-scrollbar {
            width: 6px;
        }

        .card .full-text::-webkit-scrollbar-thumb {
            background: #c9d6eb;
            border-radius: 6px;
        }

        .card .full-text::-webkit-scrollbar-track {
            background: transparent;
        }

/* 通用：捲動框架（可重用到其他區塊） */
.scroll-box {
    background: #ffffff;
    border: 1px solid #e0e8f7;
    border-radius: 8px;
    padding: 6px 10px;
    overflow-y: auto;
}

    .scroll-box::-webkit-scrollbar {
        width: 6px;
    }

    .scroll-box::-webkit-scrollbar-thumb {
        background: #c9d6eb;
        border-radius: 6px;
    }

    .scroll-box::-webkit-scrollbar-track {
        background: transparent;
    }

/* Pagination */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.page-btn {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e6eefc;
    background: #fff;
    cursor: pointer;
}

    .page-btn.active {
        background: var(--accent);
        color: #fff;
        border: 0;
        box-shadow: 0 8px 20px rgba(26,92,255,0.12);
    }

/* SIDE COLUMN */
.side-col {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.hot-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    .hot-list li a {
        text-decoration: none;
        color: #10283f;
        font-weight: 600;
    }

.side-card {
    width: 240px; /* 你可微調寬度 */
    background: #ffffff;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 0 10px rgba(0,0,0,0.05);
    font-family: 'Noto Sans TC', sans-serif;
}

    /* 確保列表是直排（覆蓋任何外部 flex 規則） */
    .side-card .cat-list {
        display: block !important;
        margin: 0;
        padding: 0;
        list-style: none;
    }

        /* 每個 li 要排成區塊 */
        .side-card .cat-list > li {
            display: block;
            margin-bottom: 8px;
        }

    /* 連結（一般連結）樣式 */
    .side-card .cat {
        display: block;
        width: 100%;
        text-decoration: none;
        color: #1565f9;
        font-weight: 600;
        font-size: 16px;
        padding: 6px 0;
        text-align: left;
        background: none;
        border: none;
        cursor: pointer;
        transition: color .18s ease, background .18s ease;
    }

        /* hover/active */
        .side-card .cat:hover,
        .side-card .cat:focus {
            color: #0044cc;
            outline: none;
        }

    /* ---------- 下拉主按鈕（button）覆蓋瀏覽器預設藍底 ---------- */
    .side-card .dropdown-btn {
        all: unset; /* 清除 button 預設 */
        display: block;
        width: 100%;
        text-align: left;
        color: #1565f9;
        font-weight: 700;
        font-size: 16px;
        padding: 6px 0;
        cursor: pointer;
        line-height: 1.2;
    }

        /* 箭頭（向下） */
        .side-card .dropdown-btn::after {
            content: "▾";
            transition: transform .25s ease;
            color: #666;
        }

    /* 下拉展開時箭頭旋轉 */
    .side-card .dropdown.open .dropdown-btn::after {
        transform: rotate(180deg);
    }

    /* 下拉內容：預設收合（動畫） */
    .side-card .dropdown-content {
        display: block;
        max-height: 0;
        overflow: hidden;
        transition: max-height .32s cubic-bezier(.2,.9,.3,1);
        padding-left: 12px;
        margin-top: 6px;
        border-left: 2px solid rgba(214,227,255,0.6);
    }

    /* 展開狀態 */
    .side-card .dropdown.open .dropdown-content {
        max-height: 400px;
    }

    /* 下拉內的連結風格 */
    .side-card .dropdown-content .cat {
        color: #1565f9;
        font-weight: 500;
        padding: 4px 0;
        font-size: 15px;
    }

    /* 避免橫排 */
    .side-card .cat-list li {
        display: block;
    }

/* 小螢幕微調 */
@media (max-width: 420px) {
    .side-card {
        width: 100%;
        padding: 14px;
    }

        .side-card .dropdown-content {
            padding-left: 10px;
        }
}

/* SUBSCRIBE */
#subForm {
    display: flex;
    gap: 8px;
}

    #subForm input {
        flex: 1;
        padding: 10px;
        border-radius: 8px;
        border: 1px solid #e6eefc;
    }

.btn-sub {
    padding: 10px 12px;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

/* responsive */
@media (max-width: 980px) {
    .news-content {
        grid-template-columns: 1fr;
        padding: 28px 0 60px;
    }

    .spotlight {
        padding: 12px;
        margin-bottom: 24px;
    }

    .spotlight-track {
        gap: 12px;
    }

    .spot {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 8px;
        min-height: auto;
    }

        .spot .meta {
            justify-content: flex-start;
            gap: 8px
        }

        .spot img {
            height: 200px;
            width: 100%;
        }

        .spot > div {
            min-width: 0;
        }

        .spot h3 {
            font-size: 18px;
        }

    .news-grid {
        grid-template-columns: 1fr;
        max-height: none;
        overflow: visible;
        padding: 0;
        background: transparent;
        border: 0;
        gap: 16px;
    }

    .card {
        height: auto;
        min-height: 120px;
    }

    .main-col {
        order: 1;
        width: 100%;
    }

    .side-col {
        order: 2;
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 16px;
    }

    .side-card {
        width: 100%;
        flex: 1;
    }
}

/* HEADER */
.site-header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    background: #002855;
}

/* 這段是你原本全域 cat-list，保留 */
.cat-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
    list-style: none;
}

    .cat-list .cat {
        display: inline-block;
        padding: 10px 14px;
        border-radius: 8px;
        background: transparent;
        color: #1a5cff;
        text-decoration: none;
        transition: all .18s ease;
        font-weight: 600;
    }

        .cat-list .cat:hover,
        .cat-list .cat:focus {
            transform: translateY(-3px);
            outline: none;
        }

        /* current page marker */
        .cat-list .cat.active,
        .cat-list .cat[aria-current="page"] {
            background: linear-gradient(90deg, var(--accent, #1a5cff), #4d8dff);
            color: #fff;
            border-color: transparent;
        }

        .cat-list .cat.active {
            background: transparent !important;
            color: #1a5cff;
        }

/* =========================================================
   ✅ 平板直向（769–1024px portrait）：
   side-col 維持顯示，不被 max-width:980px 的規則蓋掉
========================================================= */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
    .news-content {
        grid-template-columns: 1fr 260px !important;
    }

    .main-col {
        order: 1 !important;
    }

    .side-col {
        order: 2 !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    .side-card {
        width: 100% !important;
    }
}
