:root {
    --text-light: #e0e0e0; /* Body text, timeline highlight */
    --text-muted: #a1a1aa; /* Timeline date */
    --primary-orange: #ffa500; /* Timeline dot, year */
    --white-10: rgba(255, 255, 255, 0.1); /* Timeline card selected */
    --white-05: rgba(255, 255, 255, 0.05); /* Timeline card */
    --white-30: rgba(255, 255, 255, 0.3); /* Timeline card selected shadow */
    --orange-tint-20: rgba(255, 165, 0, 0.2); /* Hover shadow */
    --background-dark: #1a1a1a; /* Footer background */
    --border-dark: #333; /* Footer border */
    --transparent: transparent; /* Timeline container background */
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--background-dark); /* Dark background */
    border-top: 1px solid var(--border-dark);
    z-index: 20;
}

.timeline-container {
    position: relative;
    overflow-x: auto;
    white-space: nowrap;
    padding: 32px 0; /* For year clearance */
    background: var(--transparent);
    border-radius: 0;
    width: 100%;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile */
    scroll-snap-type: x mandatory; /* Enable scroll snapping */
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    -ms-overflow-style: none; /* Hide scrollbar for IE/Edge */
    overscroll-behavior-x: contain; /* Prevent overscroll bounce */
    touch-action: pan-x pan-y pinch-zoom; /* Enable all touch actions */
    will-change: transform; /* Optimize for animations */
}

.timeline-container::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
}

.timeline {
    display: flex;
    align-items: flex-start;
    padding: 0 16px;
    position: relative;
    width: max-content; /* Ensure timeline width matches content */
}

.timeline-line {
    position: absolute;
    top: 25px; /* Line position */
    left: 16px;
    height: 2px;
    background: var(--primary-orange);
    opacity: 0.5;
    z-index: 10;
}

.timeline-year-entry {
    display: inline-block;
    text-align: center;
    margin-right: 32px;
    width: 100px; /* Smaller width for year cards */
    position: relative;
}

.timeline-year-card {
    background: var(--background-dark); /* Dark card background */
    border: 1px solid var(--border-dark); /* Subtle border */
    border-radius: 8px; /* Increased from 4px */
    padding: 6px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* Shadow for depth */
    margin-top: 12px; /* Space below dot */
    opacity: 0;
    animation: fadeIn 0.5s forwards;
    animation-delay: calc(var(--index) * 0.2s);
}

.timeline-year-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-orange);
}

.timeline-entry {
    display: inline-block;
    text-align: center;
    margin-right: 32px;
    cursor: pointer;
    transition: transform 0.3s ease;
    width: auto; /* Allow card to stretch based on content */
    min-width: 180px; /* Minimum width to prevent shrinking too much */
    position: relative;
    scroll-snap-align: center; /* Snap each entry to center */
}

.timeline-entry:hover .timeline-card {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--orange-tint-20);
}

.timeline-entry.selected .timeline-card {
    background: var(--white-10);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--white-30);
}

.timeline-dot {
    position: absolute;
    top: -11px; /* Center vertically on 2px line */
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: var(--text-light);
    border-radius: 50%;
    transition: background 0.3s ease, transform 0.3s ease;
    opacity: 0.8;
    z-index: 11;
}

.timeline-entry:hover .timeline-dot,
.timeline-entry.selected .timeline-dot,
.timeline-year-entry .timeline-dot {
    background: var(--primary-orange);
    transform: translateX(-50%) scale(1.5); /* Enlarge for year and post dots */
}

.timeline-card {
    background: var(--white-05);
    border-radius: 8px;
    padding: 8px 12px;
    transition: all 0.3s ease;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
    animation-delay: calc(var(--index) * 0.2s);
    margin-top: 12px;
    white-space: normal;
    position: relative;
}

.full-moment-indicator {
    color: var(--primary-orange);
    font-size: 0.875rem;
    opacity: 0.9;
    transition: all 0.3s ease;
    position: absolute;
    top: -10px;
    right: -14px;
    z-index: 2;
    background: var(--background-dark);
    border: 1px solid var(--border-dark);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.timeline-entry:hover .full-moment-indicator,
.timeline-entry.selected .full-moment-indicator {
    opacity: 1;
    transform: scale(1.1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.timeline-date-combined {
    font-size: 0.8125rem;
    color: var(--text-muted);
    opacity: 0.85;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    margin-top: 4px; /* Add space from the title */
}

.timeline-duration {
    color: var(--text-muted);
    opacity: 0.75;
    text-align: center;
}

.timeline-highlight {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-light);
    opacity: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-align: center;
    width: 100%;
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.full-post-indicator {
    color: var(--primary-orange);
    font-size: 0.75rem;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.timeline-entry:hover .full-post-indicator,
.timeline-entry.selected .full-post-indicator {
    opacity: 1;
}

@media (max-width: 640px) {
    .timeline-container {
        padding: 42px 0;
        touch-action: pan-x pan-y pinch-zoom; /* Enable all touch actions */
        -webkit-overflow-scrolling: touch; /* Ensure momentum scrolling */
        scroll-behavior: smooth; /* Smooth scrolling */
    }
    
    .timeline {
        padding: 0 8px; /* Reduce padding on mobile */
        touch-action: pan-x pan-y pinch-zoom; /* Enable all touch actions */
    }
    
    .timeline-entry {
        margin-right: 16px;
        width: auto;
        min-width: 140px;
        scroll-snap-align: center;
        touch-action: pan-x pan-y pinch-zoom; /* Enable all touch actions */
    }
    
    .timeline-year-entry {
        margin-right: 16px;
        width: 80px;
        scroll-snap-align: center;
    }
    .timeline-year-card {
        padding: 4px 8px;
    }
    .timeline-year-text {
        font-size: 0.875rem;
    }
    .timeline-date-combined {
        opacity: 0.8; /* Maintain visibility */
        margin-top: 2px; /* Smaller margin on mobile */
    }
    .timeline-highlight {
        padding: 4px 0px;
        font-weight: 700;
        font-size: 1.125rem;
        justify-content: center;
        margin-bottom: 4px;
    }
    .timeline-card {
        padding: 6px 10px;
        margin-top: 0px;
    }
    .timeline-line {
        top: 18px;
        left: 16px;
    }
    .timeline-dot {
        top: -28px; /* Center on line for 8px dot */
        width: 8px;
        height: 8px;
    }
    .timeline-entry:hover .timeline-dot,
    .timeline-entry.selected .timeline-dot,
    .timeline-year-entry .timeline-dot {
        transform: translateX(-50%) scale(1.5);
    }
    .full-post-indicator {
        font-size: 0.625rem;
    }
    .full-moment-indicator {
        font-size: 0.75rem;
        width: 20px;
        height: 20px;
        top: -4px;
        right: -4px;
    }
}