/**
 * Jellice Timeline Styles
 * 傑樂歷史沿革時間軸樣式
 */

/* CSS 變數 - 方便調整時間軸位置 */
:root {
    --timeline-top-offset: 0px;
    /* 調整此值來對齊背景圓點 */
}

/* 主要容器 - 確保與 Elementor 相容 */
.jellice-timeline-wrapper {
    position: relative;
    width: 100%;
    /* max-width: 800px; Remove max-width to fix background issue */
    margin: 0 auto;
    /* 強制增加外部間距，防止標題換行時產生重疊 */
    margin-top: calc(var(--timeline-top-offset) + 60px);
    background: transparent;
    padding: 80px 20px 60px 20px;
    /* Increased to 80px for extra safety against overlap */
    box-sizing: border-box;
    overflow: visible;
    clear: both;
}

/* 確保在 Elementor 容器內正確顯示 */
.jellice-timeline-wrapper::after {
    content: '';
    display: table;
    clear: both;
}

/* 時間軸容器 - Add max-width here to constrain content */
.jellice-timeline-container {
    position: relative;
    overflow: visible;
    max-width: 1000px;
    margin: 0 auto;
}

.jellice-timeline {
    position: relative;
    padding-left: 0;
    overflow: visible;
}

/* 垂直線 (舊版全域線條 - Desktop/Tablet 隱藏，改用分段式) */
.jellice-timeline::before {
    content: '';
    position: absolute;
    left: 159px;
    top: 10px;
    bottom: 60px;
    width: 2px;
    background-color: #c1424f;
    display: none;
    /* Hide global line on desktop */
}

/* 時間軸項目 */
.jellice-timeline-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 75px;
    position: relative;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    min-height: 70px;
}

/* Desktop/Tablet 分段式線條 - 完美連接圓點 */
.jellice-timeline-item::after {
    content: '';
    position: absolute;
    left: 159px;
    /* Aligned with Dot */
    top: 27px;
    /* Center of Dot (22px margin + 5px radius) */
    height: calc(100% + 75px);
    /* Full height + margin-bottom */
    width: 2px;
    background-color: #c1424f;
    z-index: 1;
}

/* 最後一個項目不顯示線條 - 解決底部過長問題 */
.jellice-timeline-item:last-child::after {
    display: none;
}

/* 最後一項不需要底部間距 */
.jellice-timeline-item:last-child {
    margin-bottom: 0;
}

.jellice-timeline-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 年份 */
.jellice-timeline-year {
    flex-shrink: 0;
    width: 150px;
    /* Increased from 90px */
    min-width: 150px;
    /* Increased from 90px */
    font-size: 50px;
    font-weight: 500;
    color: #c1424f;
    text-align: right;
    padding-right: 15px;
    line-height: 1.1;
    letter-spacing: 1px;
    box-sizing: border-box;
    white-space: nowrap;
}

/* 圓點 */
.jellice-timeline-dot {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    background-color: #c1424f;
    border-radius: 50%;
    margin-top: 22px;
    /* Adjusted to 22px for perfect centering with 50px font */
    margin-left: 5px;
    margin-right: 20px;
    z-index: 2;
    position: relative;
}

/* 內容 */
.jellice-timeline-content {
    flex: 1;
    padding-top: 15px;
    /* Added 15px to align text center with Year center */
}

.jellice-timeline-content p {
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
    color: #222222;
    letter-spacing: 0.5px;
}

/* 響應式設計 - 平板 */
@media (max-width: 1024px) {
    .jellice-timeline-wrapper {
        padding: 80px 20px 30px 20px;
        /* Consistent 80px top padding */
        /* max-width: 100%; Already 100% */
    }

    .jellice-timeline-year {
        width: 110px;
        /* Increased for tablet readability */
        min-width: 110px;
        font-size: 36px;
    }

    /* 調整平板上的分段線條位置 */
    .jellice-timeline-item::after {
        left: 119px;
    }

    .jellice-timeline::before {
        left: 119px;
        /* Keep generic rule just in case, though usually hidden */
    }

    .jellice-timeline-content p {
        font-size: 15px;
    }
}

/* 響應式設計 - 手機 */
@media (max-width: 768px) {
    .jellice-timeline-wrapper {
        padding: 20px 15px;
    }

    /* 手機版改為垂直堆疊佈局 */
    .jellice-timeline-item {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 50px;
        padding-left: 25px;
    }

    /* 手機版不使用分段線條，改回全域線條 */
    .jellice-timeline-item::after {
        display: none;
    }

    /* 恢復顯示全域垂直線 */
    .jellice-timeline::before {
        display: block;
        left: 10px;
        top: 0;
        bottom: 0;
        /* Ensure it covers full height on mobile if needed, or stick to old top/bottom logic */
    }

    .jellice-timeline-year {
        width: auto;
        min-width: auto;
        font-size: 28px;
        padding-right: 0;
        margin-bottom: 8px;
        text-align: left;
    }

    .jellice-timeline-dot {
        position: absolute;
        left: -20px;
        top: 12px;
        margin: 0;
    }

    .jellice-timeline-content {
        width: 100%;
    }

    .jellice-timeline-content p {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .jellice-timeline-wrapper {
        padding: 15px 10px;
    }

    .jellice-timeline-item {
        padding-left: 20px;
        margin-bottom: 40px;
    }

    .jellice-timeline-year {
        font-size: 24px;
    }

    .jellice-timeline-dot {
        width: 8px;
        height: 8px;
        left: -15px;
        top: 10px;
    }

    .jellice-timeline-content p {
        font-size: 13px;
        line-height: 1.5;
    }
}

/* 動畫延遲效果 - 逐項淡入 */
.jellice-timeline-item:nth-child(1) {
    transition-delay: 0s;
}

.jellice-timeline-item:nth-child(2) {
    transition-delay: 0.05s;
}

.jellice-timeline-item:nth-child(3) {
    transition-delay: 0.1s;
}

.jellice-timeline-item:nth-child(4) {
    transition-delay: 0.15s;
}

.jellice-timeline-item:nth-child(5) {
    transition-delay: 0.2s;
}

.jellice-timeline-item:nth-child(6) {
    transition-delay: 0.25s;
}

.jellice-timeline-item:nth-child(7) {
    transition-delay: 0.3s;
}

.jellice-timeline-item:nth-child(8) {
    transition-delay: 0.35s;
}

.jellice-timeline-item:nth-child(9) {
    transition-delay: 0.4s;
}

.jellice-timeline-item:nth-child(10) {
    transition-delay: 0.45s;
}

/* ========================================
   Elementor 相容性樣式
   ======================================== */

/* 確保在 Elementor widget 內正確顯示 */
.elementor-widget-shortcode .jellice-timeline-wrapper,
.elementor-widget-text-editor .jellice-timeline-wrapper,
.elementor-element .jellice-timeline-wrapper {
    position: relative;
    display: block;
    overflow: visible;
    float: none;
    clear: both;
}

/* 防止 Elementor 容器 overflow:hidden 裁切內容 */
.elementor-widget-shortcode,
.elementor-widget-text-editor {
    overflow: visible !important;
}

/* 確保時間軸容器高度正確計算 */
.elementor-element .jellice-timeline-container {
    min-height: auto;
    height: auto;
}

/* 確保最後一個項目之後有適當的間距，避免與 footer 重疊 */
.jellice-timeline-wrapper {
    padding-bottom: 60px;
    margin-bottom: 0;
}

/* 防止 transform 動畫導致的佈局問題 */
.jellice-timeline-item {
    will-change: opacity, transform;
    backface-visibility: hidden;
}

/* 確保垂直線不會超出容器 */
.jellice-timeline::before {
    pointer-events: none;
}