.story-timeline {
    margin: 2rem 0;
    padding: 20px 0 0; /* Remove horizontal padding to prevent scroll issues */
    overflow-x: scroll; /* Changed from auto to ensure scrollbar is always visible */
    overflow-y: hidden; /* Prevent vertical scrolling */
    width: 100%;
    scrollbar-width: thin; /* Show thin scrollbar in Firefox */
    -ms-overflow-style: scrollbar; /* Show scrollbar in IE/Edge */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    position: relative; /* For absolute positioning of children */
}

.timeline-container {
    display: flex;
    align-items: center;
    min-width: max-content;
    padding: 300px 0;
    position: relative;
    margin: 0 100px;
    width: auto; /* Allow container to grow based on content */
}

/* Main timeline line */
.timeline-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -100px;
    right: -100px;
    height: 2px;
    background: #007bff;
    z-index: 1;
}

.timeline-item {
    position: relative;
    margin: 0 -25px; /* More negative margin for overlapping */
    min-width: 120px;
    max-width: 160px;
}

.timeline-item.top .timeline-content {
    bottom: 120px;
}

.timeline-item.bottom .timeline-content {
    top: 120px;
}

.timeline-connector {
    position: absolute;
    left: 50%;
    height: 120px;
    width: 1px;
    background: #007bff;
    z-index: 2;
}

.timeline-metadata {
    position: absolute;
    left: 50%;
    white-space: nowrap;
    font-size: 0.65em;
    color: #666;
    z-index: 3;
    text-align: center;
    background: white;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid #ddd;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.timeline-item.top .timeline-metadata {
    bottom: 15px;
    transform: translateX(-50%);
}

.timeline-item.bottom .timeline-metadata {
    top: 15px;
    transform: translateX(-50%);
}

.timeline-metadata .timeline-date {
    font-weight: 500;
    color: #444;
}

.timeline-metadata .timeline-source {
    margin-top: 2px;
    color: #888;
    font-size: 0.9em;
    padding: 1px 3px;
    background: #f8f9fa;
    border-radius: 2px;
}

.timeline-item.top .timeline-connector {
    bottom: 0;
    height: calc(120px + 1px);
}

.timeline-item.bottom .timeline-connector {
    top: 0;
    height: calc(120px + 1px);
}

.timeline-point {
    width: 5px;
    height: 5px;
    background: #007bff;
    border: 1px solid #fff;
    border-radius: 50%;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    box-shadow: 0 0 0 1px rgba(0,123,255,0.2);
}

.timeline-item.top .timeline-point {
    bottom: 0;
    transform: translate(-50%, 50%);
}

.timeline-item.bottom .timeline-point {
    top: 0;
    transform: translate(-50%, -50%);
}

.timeline-content {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 4px 6px;
    width: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    z-index: 2;
    transition: transform 0.2s, z-index 0.2s;
}

/* Staggered positioning for more overlap */
.timeline-item:nth-child(4n) .timeline-content {
    transform: translateX(-40%);
}

.timeline-item:nth-child(4n+1) .timeline-content {
    transform: translateX(-60%);
}

.timeline-item:nth-child(4n+2) .timeline-content {
    transform: translateX(-45%);
}

.timeline-item:nth-child(4n+3) .timeline-content {
    transform: translateX(-55%);
}

.timeline-date {
    font-size: 0.6em;
    color: #666;
    margin-bottom: 2px;
}

.timeline-title {
    font-weight: bold;
    margin-bottom: 2px;
    font-size: 0.75em;
    line-height: 1.1;
}

.timeline-title a {
    color: #333;
    text-decoration: none;
}

.timeline-title a:hover {
    color: #007bff;
}

.timeline-source {
    font-size: 0.6em;
    color: #888;
    padding: 0px 2px;
    border: 1px solid #ddd;
    border-radius: 2px;
    display: inline-block;
}

/* Enhanced hover effect */
.timeline-item:hover .timeline-point {
    background: #0056b3;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.3);
}

.timeline-item:hover .timeline-content {
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    z-index: 4;
    transform: translateX(-50%) scale(1.02);
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    .story-timeline {
        margin: 4rem 0;
        overflow-x: scroll; /* Ensure scrolling on mobile */
        -webkit-overflow-scrolling: touch;
    }

    .timeline-container {
        padding: 600px 0;
        margin: 0 50px; /* Reduced side margins on mobile */
        width: auto;
    }

    /* Ensure the timeline line extends on mobile */
    .timeline-container::before {
        left: -50px;
        right: -50px;
    }

    .timeline-item.top .timeline-content {
        bottom: 280px; /* More space between content and line */
    }

    .timeline-item.bottom .timeline-content {
        top: 280px;
    }

    .timeline-connector {
        height: 280px; /* Longer connectors */
    }

    .timeline-item.top .timeline-connector {
        height: calc(280px + 1px);
    }

    .timeline-item.bottom .timeline-connector {
        height: calc(280px + 1px);
    }

    .timeline-item {
        margin: 0 -20px;
        min-width: 140px;
        max-width: 180px;
    }

    /* Adjust staggered positioning for mobile */
    .timeline-item:nth-child(4n) .timeline-content {
        transform: translateX(-45%);
    }

    .timeline-item:nth-child(4n+1) .timeline-content {
        transform: translateX(-55%);
    }

    .timeline-item:nth-child(4n+2) .timeline-content {
        transform: translateX(-48%);
    }

    .timeline-item:nth-child(4n+3) .timeline-content {
        transform: translateX(-52%);
    }

    .timeline-metadata {
        font-size: 0.7em; /* Slightly larger text */
        padding: 3px 5px;
    }

    .timeline-title {
        font-size: 0.8em; /* Slightly larger title */
    }
}

/* Even more space for smaller screens */
@media screen and (max-width: 480px) {
    .story-timeline {
        margin: 5rem 0;
    }

    .timeline-container {
        padding: 800px 0;
        margin: 0 30px; /* Even smaller margins on very small screens */
    }

    .timeline-container::before {
        left: -30px;
        right: -30px;
    }

    .timeline-item.top .timeline-content {
        bottom: 380px;
    }

    .timeline-item.bottom .timeline-content {
        top: 380px;
    }

    .timeline-connector {
        height: 380px;
    }

    .timeline-item.top .timeline-connector {
        height: calc(380px + 1px);
    }

    .timeline-item.bottom .timeline-connector {
        height: calc(380px + 1px);
    }
} 