/* ================ The Timeline ================ */

.timeline {
    position: relative;
    width: 1000px;
    margin: 0 auto;
    margin-top: 60px;
    margin-bottom: 50px;
    padding: 100px 0;
    list-style-type: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Horizontal line for large screens */
.timeline:before {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    content: " ";
    display: block;
    width: 100%;
    height: 6px;
    background: rgb(80, 80, 80);
    background: linear-gradient(to right,
            rgba(80, 80, 80, 0) 0%,
            rgb(80, 80, 80) 8%,
            rgb(80, 80, 80) 92%,
            rgba(80, 80, 80, 0) 100%);
    z-index: 5;
    transform: translateY(-50%);
}

.timeline li {
    flex: 1;
    position: relative;
    text-align: center;
    padding: 0 20px;
}

.timeline li:after {
    content: "";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}

/* Alternating positioning for large screens */
.direction-l,
.direction-r {
    position: relative;
    width: 100%;
}

/* Items 1 and 3 (odd) go above the line */
.timeline li:nth-child(odd) .flag-wrapper {
    position: absolute;
    bottom: 66px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    z-index: 100;
}

/* Items 2 and 4 (even) go below the line */
.timeline li:nth-child(even) .flag-wrapper {
    position: absolute;
    top: 55px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    z-index: 100;
}

.flag-wrapper {
    position: relative;
    display: inline-block;
    text-align: center;
}

.flag {
    position: relative;
    display: inline-block;
    background: rgb(248, 248, 248);
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.direction-l .flag {
    -webkit-box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.15),
        0 0 1px rgba(0, 0, 0, 0.15);
    -moz-box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
    box-shadow: -1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
}

.direction-r .flag {
    -webkit-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15),
        0 0 1px rgba(0, 0, 0, 0.15);
    -moz-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
    box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.15);
}


.flag:hover {
    transform: translateY(-3px);
    box-shadow: rgba(50, 50, 93, 0.25) 0px 6px 12px -2px, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;
}






@media screen and (min-width: 1000px) {

    /* Arrow pointing down for flags above the timeline (large screens only) */
    .timeline li:nth-child(odd) .flag:after {
        content: "";
        position: absolute;
        left: 50%;
        top: 63px;
        height: 0;
        width: 0;
        margin-left: -8px;
        border: solid transparent;
        border-top-color: rgb(248, 248, 248);
        border-width: 8px;
        pointer-events: none;
    }


    /* Arrow pointing up for flags below the timeline (large screens only) */
    .timeline li:nth-child(even) .flag:after {
        content: "";
        position: absolute;
        left: 50%;
        top: -8px;
        height: 0;
        width: 0;
        margin-left: -8px;
        border: solid transparent;
        border-bottom-color: rgb(248, 248, 248);
        border-width: 8px;
        pointer-events: none;
    }
}


/* Numbered circles */
.direction-l .flag:before,
.direction-r .flag:before {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    content: attr(data-number);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #00adef;
    color: white;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    z-index: 10;
    border: 4px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Connecting lines from circles to content */
.timeline li::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    background: #00adef;
    z-index: 8;
}

/* Lines for odd items (above) */
.timeline li:nth-child(odd)::after {
    top: 50%;
    height: 30px;
}

/* Lines for even items (below) */
.timeline li:nth-child(even)::after {
    bottom: 50%;
    height: 30px;
}

/* Position circles on the main timeline */
.timeline li:nth-child(odd) .flag:before {
    top: 130px;
}

.timeline li:nth-child(even) .flag:before {
    top: -55px;
}

/* ================ Mobile Timeline (Vertical) ================ */

@media screen and (max-width: 1000px) {
    .timeline {
        width: 100%;
        padding: 4em 0 1em 0;
        flex-direction: column;
        align-items: center;
    }

    /* Vertical line for mobile */
    .timeline:before {
        position: absolute;
        left: 50%;
        top: 0;
        bottom: 0;
        width: 6px;
        height: 100%;
        margin-left: -3px;
        background: rgb(80, 80, 80);
        background: linear-gradient(to bottom,
                rgba(80, 80, 80, 0) 0%,
                rgb(80, 80, 80) 8%,
                rgb(80, 80, 80) 92%,
                rgba(80, 80, 80, 0) 100%);
        z-index: 5;
        transform: none;
    }

    .timeline li {
        padding: 2em 0;
        width: 100%;
        flex: none;
    }

    .timeline li::after {
        display: none;
    }

    .timeline li:nth-child(odd) .flag-wrapper,
    .timeline li:nth-child(even) .flag-wrapper {
        position: static;
        transform: none;
        width: auto;
        text-align: center;
    }

    .direction-l,
    .direction-r {
        float: none;
        width: 100%;
        text-align: center;
    }

    .flag {
        background: rgb(255, 255, 255);
        z-index: 15;
    }

    .direction-l .flag:before,
    .direction-r .flag:before {
        position: absolute;
        top: -40px;
        left: 50%;
        transform: translateX(-50%);
        width: 30px;
        height: 30px;
        margin-left: 0;
        background: #00adef;
        border-radius: 50%;
        border: 4px solid #fff;
        z-index: 10;
        font-size: 16px;
    }

    .timeline li:nth-child(odd) .flag:before,
    .timeline li:nth-child(even) .flag:before {
        top: -40px;
    }

    .flag:after {
        content: "";
        position: absolute;
        left: 50%;
        top: -8px;
        height: 0;
        width: 0;
        margin-left: -8px;
        border: solid transparent;
        border-bottom-color: rgb(255, 255, 255);
        border-width: 8px;
        pointer-events: none;
    }
}

@media screen and (min-width: 400px) and (max-width: 1000px) {
    .flag {
        margin: 0 2em;
    }
}