/**
 * 新聞時間軸進階樣式
 * 路徑: css/timeline-advanced.css
 */

/* ===================================
   CSS 變數
   =================================== */
:root {
    --timeline-primary: #d32f2f;
    --timeline-secondary: #1976d2;
    --timeline-text: #333;
    --timeline-light: #666;
    --timeline-border: #ddd;
    --timeline-bg: #f5f5f5;
    --timeline-white: #fff;
    --timeline-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --timeline-shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.12);
    --timeline-radius: 12px;
    --timeline-radius: 12px;
    --timeline-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --timeline-card-bg: #fff;
    --timeline-date-bg: linear-gradient(135deg, #f5f5f5 0%, #fff 100%);
}

/* ===================================
   基礎容器
   =================================== */
.news-timeline-advanced {
    width: 100%;
    max-width: 1200px;
    margin: 20px auto;
    padding: 0px;
    box-sizing: border-box;
}

.timeline-items-wrapper {
    position: relative;
}

/* ===================================
   區塊標題樣式
   =================================== */
.timeline-block-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--timeline-text); /* 跟隨設定的文字顏色 */
    margin: 20px 0 12px 0; /* 減少間距 */
    padding-bottom: 8px; /* 減少內距 */
    position: relative;
    line-height: 1.4;
}

/* 裝飾線 (可選，讓標題更有質感) */
.timeline-block-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: var(--timeline-primary); /* 跟隨設定的主色調 */
    margin-top: 8px; /* 減少間距 */
    border-radius: 2px;
}

/* 針對清單模式的微調 */
.timeline-mode-list .timeline-block-title {
    padding-left: 10px; /* 對齊清單內容 */
    margin-bottom: 8px; /* 減少間距以保持一致 */
}

/* 如果是置中佈局 (例如某些 Magazine 模式)，標題也可以置中 */
/* .timeline-layout-magazine .timeline-block-title {
    text-align: center;
}
.timeline-layout-magazine .timeline-block-title::after {
    margin: 10px auto 0 auto;
} */

/* ===================================
   通用時間軸項目
   =================================== */
.timeline-item {
    position: relative;
    margin-bottom: 40px;
    opacity: 0;
    transform: translateY(20px);
}

.timeline-item.timeline-item-hidden {
    display: none;
}

/* 修改 .timeline-content：啟用 Flexbox 以支援排序 */
.timeline-content {
    background: var(--timeline-card-bg);
    border-radius: var(--timeline-radius);
    box-shadow: var(--timeline-shadow);
    transition: var(--timeline-transition);
    overflow: hidden;
    
    /* [新增] 關鍵修改：使用 Flex column 讓內部元素可以排序 */
    display: flex;
    flex-direction: column;
}


.timeline-item:hover .timeline-content {
    box-shadow: var(--timeline-shadow-hover);
    transform: translateY(-2px);
}

/* 預設：日期在內容 (Body) 之上 */
.timeline-date {
    order: 1; /* 預設順序 */
    padding: 15px 20px;
    background: var(--timeline-date-bg);
    border-bottom: 1px solid var(--timeline-border); /* 預設有底線 */
    border-top: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--timeline-primary);
}


.timeline-body {
    order: 2; /* 預設順序 */
    padding: 25px;
}

/* 針對 Step 模式的修正 (避免被上面的 order 影響導致跑版) */
.timeline-mode-step .timeline-date {
    order: unset !important; /* Step 模式通常自己控制位置 */
    border-bottom: 1px solid var(--timeline-border) !important;
    border-top: none !important;
}


/* [新增] 當日期位置設定為 Bottom 時的樣式覆寫 */
.news-timeline-advanced.timeline-date-pos-bottom .timeline-date {
    order: 3; /* 改為比 body (2) 更大的數字，排在下面 */
    
    /* 邊框樣式反轉：移除底線，改為頂線 */
    border-bottom: none; 
    border-top: 1px solid var(--timeline-border);
    
    /* 背景色調整 (可選，視視覺需求保留或移除) */
    background: rgba(0,0,0,0.02); 
}

.timeline-title {
    margin: 0 0 12px 0;
    font-size: 20px;
    line-height: 1.4;
}

.timeline-title a {
    color: var(--timeline-text);
    text-decoration: none;
    transition: color 0.3s;
}

.timeline-title a:hover {
    color: var(--timeline-primary);
}

.timeline-excerpt {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.timeline-excerpt.line-clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recommended-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ff4757;
    color: #fff;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.timeline-read-more {
    display: inline-block;
    align-items: center;
    color: var(--timeline-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    margin-top: 15px;
    transition: var(--timeline-transition);
}

.timeline-read-more:hover {
    color: #0d47a1;
    transform: translateX(3px);
}

/* ===================================
   整個卡片可點擊樣式
   =================================== */
.timeline-item-clickable {
    cursor: pointer;
}

.timeline-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    width: 100%;
}

/* 當整個卡片可點擊時，移除內部連結的樣式 */
.timeline-item-clickable .timeline-title {
    color: inherit;
}

.timeline-item-clickable .timeline-title a {
    color: inherit;
    text-decoration: none;
    pointer-events: none;
}

/* 整個卡片的 hover 效果 */
.timeline-item-clickable:hover .timeline-content {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.timeline-item-clickable:hover .timeline-title {
    color: var(--timeline-primary);
}

/* ===================================
   布局 1: 標準時間軸（圖片右側）
   =================================== */
.timeline-layout-default .timeline-items-wrapper {
    padding-left: 60px;
}

.timeline-layout-default .timeline-items-wrapper::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        var(--timeline-border) 5%, 
        var(--timeline-border) 95%, 
        transparent 100%);
}

.timeline-layout-default .timeline-dot {
    position: absolute;
    left: -48px;
    top: 20px;
    width: 16px;
    height: 16px;
    background: var(--timeline-primary);
    border: 4px solid var(--timeline-white);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--timeline-border);
    z-index: 2;
    transition: var(--timeline-transition);
}

.timeline-layout-default .timeline-item:hover .timeline-dot {
    transform: scale(1.3);
    box-shadow: 0 0 0 6px rgba(211, 47, 47, 0.2);
}

.timeline-layout-default .timeline-body {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 25px;
    align-items: start;
}

.timeline-layout-default .timeline-image {
    order: 2;
}

.timeline-layout-default .timeline-text {
    order: 1;
}

/* ===================================
   布局 2: 左圖右文
   =================================== */
.timeline-layout-left-image .timeline-items-wrapper {
    padding-left: 60px;
}

.timeline-layout-left-image .timeline-items-wrapper::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        var(--timeline-border) 5%, 
        var(--timeline-border) 95%, 
        transparent 100%);
}

.timeline-layout-left-image .timeline-dot {
    position: absolute;
    left: -48px;
    top: 20px;
    width: 16px;
    height: 16px;
    background: var(--timeline-primary);
    border: 4px solid var(--timeline-white);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--timeline-border);
    z-index: 2;
    transition: var(--timeline-transition);
}

.timeline-layout-left-image .timeline-body {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 25px;
    align-items: start;
}

.timeline-layout-left-image .timeline-image {
    order: 1;
}

.timeline-layout-left-image .timeline-text {
    order: 2;
}

/* ===================================
   布局 3: 上圖下文
   =================================== */
.timeline-layout-top-image .timeline-items-wrapper {
    padding-left: 60px;
}

.timeline-layout-top-image .timeline-items-wrapper::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        var(--timeline-border) 5%, 
        var(--timeline-border) 95%, 
        transparent 100%);
}

.timeline-layout-top-image .timeline-dot {
    position: absolute;
    left: -48px;
    top: 20px;
    width: 16px;
    height: 16px;
    background: var(--timeline-primary);
    border: 4px solid var(--timeline-white);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--timeline-border);
    z-index: 2;
}

.timeline-layout-top-image .timeline-image {
    margin: -25px -25px 20px -25px;
    border-radius: var(--timeline-radius) var(--timeline-radius) 0 0;
}

/* ===================================
   布局 4: 下圖上文
   =================================== */
.timeline-layout-bottom-image .timeline-items-wrapper {
    padding-left: 60px;
}

.timeline-layout-bottom-image .timeline-items-wrapper::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        var(--timeline-border) 5%, 
        var(--timeline-border) 95%, 
        transparent 100%);
}

.timeline-layout-bottom-image .timeline-dot {
    position: absolute;
    left: -48px;
    top: 20px;
    width: 16px;
    height: 16px;
    background: var(--timeline-primary);
    border: 4px solid var(--timeline-white);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--timeline-border);
    z-index: 2;
}

.timeline-layout-bottom-image .timeline-image {
    margin: 20px -25px -25px -25px;
    border-radius: 0 0 var(--timeline-radius) var(--timeline-radius);
}

/* ===================================
   布局 5: 卡片網格
   =================================== */
.timeline-layout-card-grid .timeline-items-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.timeline-layout-card-grid .timeline-item {
    margin-bottom: 0;
}

.timeline-layout-card-grid .timeline-image {
    margin: -25px -25px 15px -25px;
    border-radius: var(--timeline-radius) var(--timeline-radius) 0 0;
}

/* ===================================
   布局 6: 雜誌式
   =================================== */
.timeline-layout-magazine .timeline-items-wrapper {
    padding-left: 60px;
}

.timeline-layout-magazine .timeline-items-wrapper::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        var(--timeline-border) 5%, 
        var(--timeline-border) 95%, 
        transparent 100%);
}

.timeline-layout-magazine .timeline-dot {
    position: absolute;
    left: -48px;
    top: 20px;
    width: 16px;
    height: 16px;
    background: var(--timeline-primary);
    border: 4px solid var(--timeline-white);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--timeline-border);
    z-index: 2;
}

/* Dot Shapes */
.timeline-dot-shape-square .timeline-dot {
    border-radius: 0;
}

.timeline-dot-shape-diamond .timeline-dot {
    border-radius: 0;
    transform: rotate(45deg);
}

/* ===================================
   [修改] Highlight 高亮模式修復
   =================================== */
/* 預設狀態：所有項目不透明 */
.timeline-item {
    opacity: 1!important;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* 當容器開啟高亮模式時，先將「所有」項目變暗 */
.news-timeline-advanced.timeline-highlight-first .timeline-item,
.news-timeline-advanced.timeline-highlight-manual .timeline-item {
    opacity: 0.3!important; /* 降低透明度使效果更明顯 */
    transform: scale(0.98);
}

/* 再將「被選中」的項目恢復不透明並放大 */
.news-timeline-advanced.timeline-highlight-first .timeline-item.highlight,
.news-timeline-advanced.timeline-highlight-manual .timeline-item.highlight,
.news-timeline-advanced.timeline-highlight-first .timeline-item:hover,
.news-timeline-advanced.timeline-highlight-manual .timeline-item:hover {
    opacity: 1 !important;
    transform: scale(1) !important;
    z-index: 5;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); /* 增加陰影突顯 */
}

/* 讓高亮項目的卡片陰影更明顯 */
.timeline-item.highlight .timeline-content {
    box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
    border-left: 5px solid var(--timeline-primary); /* 左側加強邊框 */
}

/* ===================================
   [修改] Step 模式修正
   =================================== */
/* 重置 Step 模式的氣泡，強制跟時間軸日期氣泡一模一樣 */
.timeline-mode-step .timeline-date {
    background: var(--timeline-date-bg) !important;
    width: auto !important;     /* 跟隨內容寬度 */
    min-width: unset !important;
    height: auto !important;
    padding: 15px 20px !important; /* 跟原本時間軸一樣的 padding */
    border-radius: 0 !important;   /* 移除圓形強制設定，跟隨原本設計 */
    border-bottom: 1px solid var(--timeline-border);
    position: static !important;
    display: block !important;
    text-align: left !important;
    font-weight: 600;
    color: var(--timeline-primary);
    aspect-ratio: auto !important; /* 移除強制正方形 */
}

/* 隱藏 Step 模式下原本可能出現的舊標籤樣式 */
.timeline-mode-step .step-label {
    display: none; 
}

/* [新] 獨立的步驟標題樣式 */
.timeline-step-heading {
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--timeline-secondary, #1976d2); /* 使用次要顏色 */
    margin-bottom: 5px;
    display: inline-block;
    padding: 2px 8px;
    /*background: rgba(0,0,0,0.05);*/
    border-radius: 4px;
}


/* Recommended Badge - Refined */
.recommended-badge {
    display: block !important;
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff4757;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 4px;
    z-index: 20;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transform: rotate(5deg);
}

.timeline-layout-magazine .timeline-item:first-child {
    margin-bottom: 60px;
}

.timeline-layout-magazine .timeline-item:first-child .timeline-content {
    padding: 0;
}

.timeline-layout-magazine .timeline-item:first-child .timeline-image {
    margin: 0;
    height: 400px;
    border-radius: var(--timeline-radius) var(--timeline-radius) 0 0;
}

.timeline-layout-magazine .timeline-item:first-child .timeline-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.timeline-layout-magazine .timeline-item:first-child .timeline-body {
    padding: 30px;
}

.timeline-layout-magazine .timeline-item:first-child .timeline-title {
    font-size: 28px;
}

/* ===================================
   第一則大圖樣式
   =================================== */
.timeline-item-large .timeline-content {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
}

.timeline-item-large .timeline-image {
    height: 350px;
    margin: -25px -25px 20px -25px;
    border-radius: var(--timeline-radius) var(--timeline-radius) 0 0;
    overflow: hidden;
}

.timeline-item-large .timeline-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.timeline-item-large:hover .timeline-image img {
    transform: scale(1.05);
}

.timeline-item-large .timeline-title {
    font-size: 26px;
    margin-bottom: 15px;
}

.timeline-item-large .timeline-excerpt {
    font-size: 16px;
}

/* ===================================
   圖片樣式
   =================================== */
.timeline-image {
    overflow: hidden;
    border-radius: 8px;
}

.timeline-image a {
    display: block;
    position: relative;
    overflow: hidden;
}

.timeline-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.5s ease;
}

.timeline-item:hover .timeline-image img {
    transform: scale(1.05);
}

/* ===================================
   展開按鈕
   =================================== */
.timeline-expand-section {
    text-align: center;
    padding: 30px 0;
}

.timeline-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 30px;
    background: var(--timeline-white);
    border: 2px solid var(--timeline-border);
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    color: var(--timeline-text);
    cursor: pointer;
    transition: var(--timeline-transition);
    box-shadow: var(--timeline-shadow);
}

/*.timeline-expand-btn:hover {
    background: var(--timeline-primary);
    color: var(--timeline-white);
    border-color: var(--timeline-primary);
    transform: translateY(-2px);
    box-shadow: var(--timeline-shadow-hover);
}*/

.timeline-expand-btn .expand-icon {
    transition: transform 0.3s;
}

.timeline-expand-btn.expanded .expand-icon {
    transform: rotate(180deg);
}

.timeline-expand-count {
    background: var(--timeline-bg);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 13px;
}

/* ===================================
   動畫效果
   =================================== */
/* 淡入 */
.timeline-animation-fade .timeline-item {
    animation: fadeIn 0.6s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 滑入 */
.timeline-animation-slide .timeline-item {
    animation: slideIn 0.6s ease forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 縮放 */
.timeline-animation-zoom .timeline-item {
    animation: zoomIn 0.6s ease forwards;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 無動畫 */
.timeline-animation-none .timeline-item {
    opacity: 1;
    transform: none;
}

/* 漸進延遲 */
.timeline-item:nth-child(1) { animation-delay: 0.1s; }
.timeline-item:nth-child(2) { animation-delay: 0.2s; }
.timeline-item:nth-child(3) { animation-delay: 0.3s; }
.timeline-item:nth-child(4) { animation-delay: 0.4s; }
.timeline-item:nth-child(5) { animation-delay: 0.5s; }
.timeline-item:nth-child(6) { animation-delay: 0.6s; }
.timeline-item:nth-child(7) { animation-delay: 0.7s; }
.timeline-item:nth-child(8) { animation-delay: 0.8s; }
.timeline-item:nth-child(9) { animation-delay: 0.9s; }
.timeline-item:nth-child(10) { animation-delay: 1s; }

/* ===================================
   響應式設計 - 平板
   =================================== */
@media (max-width: 992px) {
    .timeline-layout-default .timeline-body,
    .timeline-layout-left-image .timeline-body {
        grid-template-columns: 1fr;
    }
    
    .timeline-layout-default .timeline-image,
    .timeline-layout-left-image .timeline-image {
        order: 1;
        max-width: 100%;
    }
    
    .timeline-layout-default .timeline-text,
    .timeline-layout-left-image .timeline-text {
        order: 2;
    }
    
    .timeline-layout-card-grid .timeline-items-wrapper {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* ===================================
   響應式設計 - 手機
   =================================== */
@media (max-width: 768px) {
    .news-timeline-advanced {
        margin: 20px auto;
        padding: 0 15px;
    }
    
    .timeline-layout-default .timeline-items-wrapper,
    .timeline-layout-left-image .timeline-items-wrapper,
    .timeline-layout-top-image .timeline-items-wrapper,
    .timeline-layout-bottom-image .timeline-items-wrapper,
    .timeline-layout-magazine .timeline-items-wrapper {
        padding-left: 40px;
    }
    
    .timeline-layout-default .timeline-items-wrapper::before,
    .timeline-layout-left-image .timeline-items-wrapper::before,
    .timeline-layout-top-image .timeline-items-wrapper::before,
    .timeline-layout-bottom-image .timeline-items-wrapper::before,
    .timeline-layout-magazine .timeline-items-wrapper::before {
        left: 10px;
    }
    
    .timeline-dot {
        left: -35px !important;
        width: 12px !important;
        height: 12px !important;
        border-width: 3px !important;
    }
    
    .timeline-body {
        padding: 20px !important;
    }
    
    .timeline-title {
        font-size: 18px !important;
    }
    
    .timeline-item-large .timeline-title {
        font-size: 22px !important;
    }
    
    .timeline-excerpt {
        font-size: 14px;
    }
    
    .timeline-layout-card-grid .timeline-items-wrapper {
        grid-template-columns: 1fr;
    }
    
    .timeline-layout-magazine .timeline-item:first-child .timeline-image {
        height: 250px;
    }
    
    .timeline-expand-btn {
        padding: 12px 30px;
        font-size: 14px;
    }
}

/* ===================================
   列印樣式
   =================================== */
@media print {
    .timeline-expand-section {
        display: none;
    }
    
    .timeline-item-hidden {
        display: block !important;
    }
    
    .timeline-content {
        box-shadow: none;
        border: 1px solid var(--timeline-border);
        page-break-inside: avoid;
    }
}

/* ===================================
   Step Mode Styles
   =================================== */
.timeline-mode-step .timeline-date {
    background: transparent;
    padding: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    text-align: left;
    margin-bottom: 10px;
    position: relative;
    left: auto;
    top: auto;
    transform: none;
}

.timeline-mode-step .step-label {
    display: inline-block;
    padding: 5px 12px;
    background-color: var(--timeline-primary);
    color: #fff;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/*.timeline-mode-step .timeline-content {
    padding-top: 15px;
}*/

/* Adjust dot position for step mode if needed */
.timeline-mode-step .timeline-dot {
    top: 25px;
}

/* Responsive adjustments for Step Mode */
@media (max-width: 768px) {
    .timeline-mode-step .timeline-date {
        margin-bottom: 10px;
        text-align: left;
    }
}

/* ===================================
   個別項目布局覆寫 (Per-item Layouts)
   =================================== */

/* 左圖右文 */
.timeline-item.item-layout-left-image .timeline-body {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 25px;
    align-items: start;
}
.timeline-item.item-layout-left-image .timeline-image {
    order: 1;
    margin: 0;
    border-radius: 8px;
}
.timeline-item.item-layout-left-image .timeline-text {
    order: 2;
}

/* 右圖左文 */
.timeline-item.item-layout-right-image .timeline-body {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 25px;
    align-items: start;
}
.timeline-item.item-layout-right-image .timeline-image {
    order: 2;
    margin: 0;
    border-radius: 8px;
}
.timeline-item.item-layout-right-image .timeline-text {
    order: 1;
}

/* 上圖下文 */
.timeline-item.item-layout-top-image .timeline-body {
    display: block;
}
.timeline-item.item-layout-top-image .timeline-image {
    margin: -25px -25px 20px -25px;
    border-radius: var(--timeline-radius) var(--timeline-radius) 0 0;
    order: unset;
}
.timeline-item.item-layout-top-image .timeline-image img {
    border-radius: var(--timeline-radius) var(--timeline-radius) 0 0;
}

/* 純文字 (無圖) */
.timeline-item.item-layout-text-only .timeline-image {
    display: none !important;
}
.timeline-item.item-layout-text-only .timeline-body {
    display: block;
}

/* 響應式調整 */
@media (max-width: 992px) {
    .timeline-item.item-layout-left-image .timeline-body,
    .timeline-item.item-layout-right-image .timeline-body {
        grid-template-columns: 1fr;
    }
    .timeline-item.item-layout-left-image .timeline-image,
    .timeline-item.item-layout-right-image .timeline-image {
        order: 1;
        margin-bottom: 20px;
    }
    .timeline-item.item-layout-left-image .timeline-text,
    .timeline-item.item-layout-right-image .timeline-text {
        order: 2;
    }
}

/* ==========================================================================
   List Mode (清單模式) - 完美置中 + 連線修復版
   ========================================================================== */

/* 1. 容器設定 */
.news-timeline-advanced.timeline-mode-list .timeline-items-wrapper {
    max-height: var(--timeline-list-height, 400px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important; 
    /* 左側留白 60px */
    padding: 40px 40px 40px 60px !important; 
    position: relative !important;
    background: #fff;
    border: 1px solid #eee;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f0f0f0;
}

/* 隱藏容器長線 */
.news-timeline-advanced.timeline-mode-list .timeline-items-wrapper::before {
    display: none !important;
}

/* 2. 項目卡片 */
.news-timeline-advanced.timeline-mode-list .timeline-item {
    display: block !important;
    margin: 0 !important; /* 移除外距，改用 padding 撐開，方便畫線 */
    padding: 0px 0 20px 0 !important; /* 底部間距 */
    background: transparent !important;
    width: 100% !important;
    position: relative !important;
    border-bottom: 1px solid #f0f0f0 !important;
    opacity: 1 !important;
    transform: none !important;
}
.news-timeline-advanced.timeline-mode-list .timeline-item:last-child {
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

/* --------------------------------------------------------------------------
   3. 精準置中線條 (Line)
   -------------------------------------------------------------------------- */
.news-timeline-advanced.timeline-mode-list .timeline-item::before {
    content: '' !important;
    display: block !important;
    position: absolute !important;
    
    /* [數學置中] Padding 60px -> 中心 30px -> 線寬 2px -> Left 29px */
    left: -31px !important; 
    
    /* 線條從最頂端畫到最底端 (貫穿整個 Item) */
    top: 0 !important;
    height: 100% !important; 
    
    width: 2px !important;
    background: #e0e0e0 !important;
    z-index: 1 !important;
}

/* 第一個項目：線條從圓點開始往下畫 (避免凸出頂部) */
.news-timeline-advanced.timeline-mode-list .timeline-item:first-child::before {
    top: 20px !important; /* 對齊圓點中心 */
    height: calc(100% - 20px) !important;
}

/* 最後一個項目：線條從頂部畫到圓點為止 (避免凸出底部) */
.news-timeline-advanced.timeline-mode-list .timeline-item:last-child::before {
    top: 0 !important;
    height: 20px !important; /* 只畫到圓點中心 */
}

/* --------------------------------------------------------------------------
   4. 精準置中圓點 (Dot)
   -------------------------------------------------------------------------- */
.news-timeline-advanced.timeline-mode-list .timeline-dot {
    display: block !important;
    opacity: 1 !important;
    position: absolute !important;
    
    /* [數學置中] Padding 60px -> 中心 30px -> 點寬 12px (半徑6) -> Left 24px */
    /* 相對定位 (-60 + 24 = -36) */
    left: -36px !important; 
    
    top: 15px !important; /* 固定垂直高度 */
    
    width: 10px !important; /* 內圓大小 */
    height: 10px !important;
    
    background: var(--timeline-primary, #d32f2f) !important;
    border: 2px solid #fff !important; /* 白邊 */
    border-radius: 50% !important;
    
    /* 陰影環 (視覺大小約 14px) */
    box-shadow: 0 0 0 1px #ccc !important;
    
    transform: none !important;
    z-index: 5 !important;
}

/* 第一則高亮圓點 */
.news-timeline-advanced.timeline-mode-list .timeline-item[data-index="1"] .timeline-dot {
    background: #1976d2 !important;
    /* 藍色光暈 */
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2) !important; 
    transform: scale(1.2) !important; /* 微微放大 */
}

/* 第一則藍色背景 */
.news-timeline-advanced.timeline-mode-list .timeline-item[data-index="1"] .timeline-content {
    background-color: #e3f2fd !important;
}

/* --------------------------------------------------------------------------
   5. 內容與佈局
   -------------------------------------------------------------------------- */
.news-timeline-advanced.timeline-mode-list .timeline-content {
    display: flex !important;
    flex-direction: column !important;
    padding: 10px !important;
    border: none !important;
    border-radius: 4px !important;
    position: relative !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.news-timeline-advanced.timeline-mode-list .timeline-body {
    order: 0 !important;
    width: 100% !important;
    margin: 0 !important;
}

/* 隱藏元素 */
.news-timeline-advanced.timeline-mode-list .timeline-excerpt,
.news-timeline-advanced.timeline-mode-list .timeline-read-more,
.news-timeline-advanced.timeline-mode-list .recommended-badge {
    display: none !important;
}

/* ==========================================================================
   (修改) List Mode 日期樣式 - 恢復成時間軸風格
   ========================================================================== */
.news-timeline-advanced.timeline-mode-list .timeline-date {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    
    /* [恢復] 背景色與邊框 (跟標準時間軸一致) */
    background: var(--timeline-date-bg) !important;
    border-bottom: 1px solid var(--timeline-border) !important;
    
    /* [恢復] 內距 */
    padding: 10px 15px !important;
    
    /* [關鍵技巧] 使用負 Margin */
    /* 因為 List 模式的 Content 有 10px padding，我們要用負值把日期條「撐」出去到邊緣 */
    margin: -10px -10px 10px -10px !important;
    
    /* [恢復] 字體樣式 */
    font-size: 14px !important;
    color: var(--timeline-primary) !important; /* 使用主色調 */
    font-weight: 600 !important;
    text-align: left !important;
    
    /* [設定] 圓角 (上方有圓角) */
    border-radius: 4px 4px 0 0 !important;
    
    /* 確保順序變數有效 (支援上/下切換) */
    order: var(--timeline-date-order, -1) !important;
}

/* [新增] 針對「日期在下方」時的特殊處理 */
.news-timeline-advanced.timeline-mode-list.timeline-date-pos-bottom .timeline-date {
    /* 邊框與圓角反轉 */
    border-bottom: none !important;
    border-top: 1px solid var(--timeline-border) !important;
    border-radius: 0 0 4px 4px !important;
    
    /* Margin 方向調整 */
    margin: 10px -10px -10px -10px !important;
}

/* --------------------------------------------------------------------------
   6. 萬能佈局支援
   -------------------------------------------------------------------------- */

/* (A) 左圖右文 */
.news-timeline-advanced.timeline-mode-list.timeline-layout-left-image .timeline-body {
    display: flex !important;
    flex-direction: row !important;
    gap: 15px !important;
}
.news-timeline-advanced.timeline-mode-list.timeline-layout-left-image .timeline-image {
    order: 1 !important;
    width: 100px !important;
    flex: 0 0 100px !important;
    margin: 0 !important;
}
.news-timeline-advanced.timeline-mode-list.timeline-layout-left-image .timeline-text {
    order: 2 !important;
    flex: 1 !important;
}

/* (B) 標準 / 右圖左文 */
.news-timeline-advanced.timeline-mode-list.timeline-layout-default .timeline-body,
.news-timeline-advanced.timeline-mode-list.timeline-layout-right-image .timeline-body {
    display: flex !important;
    flex-direction: row !important;
    gap: 15px !important;
}
.news-timeline-advanced.timeline-mode-list.timeline-layout-default .timeline-image,
.news-timeline-advanced.timeline-mode-list.timeline-layout-right-image .timeline-image {
    order: 2 !important;
    width: 100px !important;
    flex: 0 0 100px !important;
    margin: 0 !important;
}
.news-timeline-advanced.timeline-mode-list.timeline-layout-default .timeline-text,
.news-timeline-advanced.timeline-mode-list.timeline-layout-right-image .timeline-text {
    order: 1 !important;
    flex: 1 !important;
}

/* (C) 上圖 / 雜誌 */
.news-timeline-advanced.timeline-mode-list.timeline-layout-top-image .timeline-body,
.news-timeline-advanced.timeline-mode-list.timeline-layout-magazine .timeline-body {
    display: block !important;
}
.news-timeline-advanced.timeline-mode-list.timeline-layout-top-image .timeline-image,
.news-timeline-advanced.timeline-mode-list.timeline-layout-magazine .timeline-image {
    width: 100% !important;
    margin: 0 0 10px 0 !important;
    flex: none !important;
}

/* (D) 下圖 */
.news-timeline-advanced.timeline-mode-list.timeline-layout-bottom-image .timeline-body {
    display: flex !important;
    flex-direction: column !important;
}
.news-timeline-advanced.timeline-mode-list.timeline-layout-bottom-image .timeline-image {
    order: 2 !important;
    width: 100% !important;
    margin: 10px 0 0 0 !important;
    flex: none !important;
}
.news-timeline-advanced.timeline-mode-list.timeline-layout-bottom-image .timeline-text {
    order: 1 !important;
}

/* (E) 純文字 */
.news-timeline-advanced.timeline-mode-list.timeline-layout-text-only .timeline-image {
    display: none !important;
}

/* 圖片與標題樣式 */
.news-timeline-advanced.timeline-mode-list .timeline-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transform: none !important;
    border-radius: 4px !important;
}
.news-timeline-advanced.timeline-mode-list .timeline-title {
    font-size: 15px !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
    margin: 0 !important;
}
.news-timeline-advanced.timeline-mode-list .timeline-item[data-index="1"] .timeline-title {
    font-weight: bold !important;
    color: #000 !important;
}
.news-timeline-advanced.timeline-mode-list .timeline-title a {
    color: #333 !important;
    text-decoration: none !important;
}
.news-timeline-advanced.timeline-mode-list .timeline-title a:hover {
    color: var(--timeline-primary) !important;
    text-decoration: none !important;
}