/* AI Timeline - Infographic Style Design */

:root {
    --primary: #2c3e50;
    --accent: #3498db;
    --bg: #f8fafb;
    --text: #2c3e50;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --year-color: #94a3b8;
    --node-size: 10px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Layout constants */
    --timeline-vertical-padding: 320px;
    --timeline-horizontal-padding: 100px;
    --year-margin-right: 60px;
    --event-card-width: 220px;
    --event-gap: 30px;
    
    /* Animation durations */
    --transition-fast: 0.2s;
    --transition-normal: 0.3s;
    --transition-slow: 0.5s;
}

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 100%;
    padding: 20px;
}

header {
    display: none;
}

/* Horizontal Scrollable Timeline */
.timeline-wrapper {
    overflow-x: auto;
    padding: var(--timeline-vertical-padding) 0;
    cursor: grab;
    scrollbar-width: none; /* Scrubber is the only scroll control */
    user-select: none;
}

.timeline-wrapper:active {
    cursor: grabbing;
}

.timeline-wrapper::-webkit-scrollbar {
    display: none;
}

.timeline {
    display: flex;
    position: relative;
    padding: 0 var(--timeline-horizontal-padding);
    min-width: max-content;
    align-items: center;
    height: 2px;
}

/* The central line */
.timeline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--border);
    z-index: 1;
}

.timeline-year {
    display: flex;
    position: relative;
    z-index: 2;
    margin-right: var(--year-margin-right);
}

.year-marker {
    position: absolute;
    top: 50%;
    left: 5px;
    transform: translateY(-50%);
    font-size: 5.5rem;
    font-weight: 900;
    color: #10b981;
    opacity: 0.07;
    letter-spacing: -0.03em;
    pointer-events: none;
    user-select: none;
    z-index: 0;
    white-space: nowrap;
}

.year-events {
    display: flex;
    gap: var(--event-gap);
    padding: 0 10px;
}

.event-card {
    position: relative;
    width: var(--event-card-width);
    flex-shrink: 0;
}

/* The node on the timeline */
.event-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: var(--node-size);
    height: var(--node-size);
    background: var(--accent);
    border: 2px solid white;
    border-radius: 2px;
    z-index: 3;
    transition: all 0.2s ease;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.event-card:hover::before {
    transform: translate(-50%, -50%) scale(1.4);
    background: var(--primary);
}

/* Category-colored nodes */
.event-card[data-category="Foundation Models"]::before {
    background: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.25);
}
.event-card[data-category="Generative AI"]::before {
    background: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}
.event-card[data-category="Autonomous Systems"]::before {
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}
.event-card[data-category="Research Breakthroughs"]::before {
    background: #9333ea;
    box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.25);
}
.event-card[data-category="AI Products"]::before {
    background: #ec4899;
    box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.25);
}
.event-card[data-category="Hardware & Infrastructure"]::before {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}
.event-card[data-category="Enterprise & Developer Tools"]::before {
    background: #0284c7;
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}
.event-card[data-category="Governance & Society"]::before {
    background: #ca8a04;
    box-shadow: 0 0 0 2px rgba(202, 138, 4, 0.25);
}

/* Keep landmark (weight=3) override as red ring but preserve category color */
.event-card[data-weight="3"]::before {
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.45);
}

/* Alternating content boxes with levels */
.event-content {
    position: absolute;
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 12px; /* More compact padding */
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 4;
}

.event-card:hover .event-content {
    box-shadow: var(--shadow-hover);
    transform: translateX(-50%) translateY(-5px);
    border-color: var(--accent);
}

/* Visual Weight Indicators - High Impact Events */
.event-card[data-weight="3"] .event-content {
    box-shadow: 0 6px 12px -2px rgba(231, 76, 60, 0.15);
}

.event-card[data-weight="3"] .event-title {
    color: #e74c3c;
}

.event-card[data-weight="3"]::before {
    background: #e74c3c;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.3);
}

/* Medium Impact Events */
.event-card[data-weight="2"] .event-content {
    /* No special styling for medium weight */
}

/* Standard Impact Events */
.event-card[data-weight="1"] .event-content {
    opacity: 0.95;
}

/* Vertical Stacking Logic */

/* Top Levels */
.timeline-year:nth-child(odd) .event-card.level-0 .event-content,
.timeline-year:nth-child(even) .event-card.level-1 .event-content {
    bottom: 35px; /* Slightly closer to line */
    left: 50%;
    transform: translateX(-50%);
}

.timeline-year:nth-child(odd) .event-card.level-2 .event-content {
    bottom: 160px; /* More compact level 2 */
    left: 50%;
    transform: translateX(-50%);
}

/* Bottom Levels */
.timeline-year:nth-child(even) .event-card.level-0 .event-content,
.timeline-year:nth-child(odd) .event-card.level-1 .event-content {
    top: 35px; /* Slightly closer to line */
    left: 50%;
    transform: translateX(-50%);
}

.timeline-year:nth-child(even) .event-card.level-2 .event-content {
    top: 160px; /* More compact level 2 */
    left: 50%;
    transform: translateX(-50%);
}

/* Connecting lines (stems) */
.event-content::before {
    content: '';
    position: absolute;
    left: 50%;
    width: 1px;
    background: var(--border);
    z-index: -1;
}

/* Stems for top events - Terminate 8px away from square (35px - 8px = 27px) */
.timeline-year:nth-child(odd) .event-card.level-0 .event-content::before,
.timeline-year:nth-child(even) .event-card.level-1 .event-content::before {
    bottom: -27px;
    height: 27px;
}

.timeline-year:nth-child(odd) .event-card.level-2 .event-content::before {
    bottom: -152px; /* 160px - 8px */
    height: 152px;
}

/* Stems for bottom events - Terminate 8px away from square */
.timeline-year:nth-child(even) .event-card.level-0 .event-content::before,
.timeline-year:nth-child(odd) .event-card.level-1 .event-content::before {
    top: -27px;
    height: 27px;
}

.timeline-year:nth-child(even) .event-card.level-2 .event-content::before {
    top: -152px;
    height: 152px;
}

.event-title {
    font-size: 0.85rem; /* Slightly smaller */
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--primary);
    line-height: 1.25;
}

.event-people {
    font-size: 0.7rem; /* Smaller */
    color: var(--year-color);
    margin: 0 0 8px 0;
    font-weight: 500;
}

.event-meta {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.event-category {
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg);
    color: var(--year-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    border: 1px solid var(--border);
}

/* Category-specific colors */
.event-category[data-category="Foundation Models"] {
    background: #e8f4fd;
    color: #1a73e8;
    border-color: #a3d1ff;
}

.event-category[data-category="Generative AI"] {
    background: #fef3e8;
    color: #f59e0b;
    border-color: #fcd34d;
}

.event-category[data-category="Autonomous Systems"] {
    background: #e8fdf5;
    color: #10b981;
    border-color: #6ee7b7;
}

.event-category[data-category="Research Breakthroughs"] {
    background: #f3e8fd;
    color: #9333ea;
    border-color: #d8b4fe;
}

.event-category[data-category="AI Products"] {
    background: #fce7f3;
    color: #ec4899;
    border-color: #fbcfe8;
}

.event-category[data-category="Hardware & Infrastructure"] {
    background: #fef2f2;
    color: #ef4444;
    border-color: #fecaca;
}

.event-category[data-category="Enterprise & Developer Tools"] {
    background: #e0f2fe;
    color: #0284c7;
    border-color: #bae6fd;
}

.event-category[data-category="Governance & Society"] {
    background: #fefce8;
    color: #ca8a04;
    border-color: #fef08a;
}

.event-link {
    margin-top: 8px;
    font-size: 0.7rem;
}

.event-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    background: rgba(52, 152, 219, 0.05);
    border-radius: 4px;
    transition: all 0.2s;
}

.event-link a:hover {
    background: rgba(52, 152, 219, 0.15);
    text-decoration: none;
    transform: translateX(2px);
}

/* Card title */
.event-title {
    position: relative;
}

/* Scrubber year label */
.timeline-scrubber-wrap {
    position: relative;
}

.scrubber-year-label {
    position: absolute;
    top: 4px;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.scrubber-year-label.visible {
    opacity: 1;
}

/* Unified Toolbar — single header bar */
.toolbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 24px;
    height: 72px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 var(--border);
}

/* Title block — left side */
.toolbar-title {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-right: auto;
    line-height: 1;
    flex-shrink: 0;
}

.toolbar-title-text {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.025em;
}

.toolbar-title-sub {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--year-color);
    margin-top: 4px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Thin divider between groups */
.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    flex-shrink: 0;
}

/* Search input */
.toolbar-search {
    padding: 9px 10px 9px 32px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg);
    width: 170px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.toolbar-search::placeholder {
    color: var(--year-color);
    opacity: 0.7;
}

.toolbar-search:hover {
    border-color: rgba(52, 152, 219, 0.4);
}

.toolbar-search:focus {
    outline: none;
    border-color: var(--accent);
    background: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Search icon */
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrap::before {
    content: '';
    position: absolute;
    left: 9px;
    width: 13px;
    height: 13px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none"><circle cx="6.5" cy="6.5" r="4.5" stroke="%2394a3b8" stroke-width="1.5"/><path d="M10 10L13.5 13.5" stroke="%2394a3b8" stroke-width="1.5" stroke-linecap="round"/></svg>');
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    opacity: 0.8;
}

/* Category select */
.toolbar-select {
    padding: 9px 28px 9px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 4L5 7L8 4" stroke="%2394a3b8" stroke-width="1.5" stroke-linecap="round"/></svg>');
    background-repeat: no-repeat;
    background-position: right 9px center;
    font-family: inherit;
}

.toolbar-select:hover {
    border-color: rgba(52, 152, 219, 0.4);
}

.toolbar-select:focus {
    outline: none;
    border-color: var(--accent);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none"><path d="M2 4L5 7L8 4" stroke="%233498db" stroke-width="1.5" stroke-linecap="round"/></svg>');
    background-repeat: no-repeat;
    background-position: right 9px center;
}

/* Segmented button group (significance) */
.seg-group {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 0;
}

.seg-btn {
    padding: 7px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--year-color);
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
}

.seg-btn:hover {
    color: var(--text);
    background: rgba(52, 152, 219, 0.06);
}

.seg-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 4px rgba(52, 152, 219, 0.35);
}

/* Stats inside toolbar */
.toolbar-stats {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--year-color);
    white-space: nowrap;
}

.toolbar-stats .timeline-version,
.toolbar-stats .timeline-date {
    opacity: 0.6;
    font-size: 0.7rem;
}

/* Fixed bottom-right Model Basics link */
.model-basics-fab {
    position: fixed;
    bottom: 56px;
    right: 20px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: var(--year-color);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.model-basics-fab:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
}



/* Bottom timeline scrubber – neutral “position” control, distinct from timeline nodes */
.timeline-scrubber-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    padding: 12px 24px 20px;
    box-sizing: border-box;
}

.timeline-scrubber-wrap::before {
    content: 'timeline';
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--year-color);
    margin-bottom: 6px;
    opacity: 0.9;
}

.timeline-scrubber {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: grab;
}

.timeline-scrubber:active {
    cursor: grabbing;
}

.timeline-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.timeline-scrubber::-webkit-slider-thumb:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transform: scale(1.1);
}

.timeline-scrubber::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.timeline-scrubber::-moz-range-thumb:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transform: scale(1.1);
}

.hidden {
    display: none;
}

/* Error Message Styles */
.error-message {
    display: none;
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #fee;
    color: #c33;
    border: 1px solid #fcc;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    animation: slideIn 0.2s ease-out;
}

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

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .event-card::before,
    .event-content,
    .year-marker {
        transition: none !important;
    }
}

/* Focus visible styles for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Tablet: 768px - 1023px */
@media (max-width: 1023px) {
    
    .container {
        padding: 16px;
    }
    
    .timeline-wrapper {
        padding: 280px 0;
    }
    
    .timeline {
        padding: 0 60px;
    }
    
    .event-card {
        width: 200px;
    }
    
    .timeline-year {
        margin-right: 50px;
    }
    
    /* Toolbar adapts on tablet */
    .toolbar {
        gap: 12px;
        padding: 14px 20px;
    }

    .toolbar-search {
        width: 160px;
    }

    .seg-btn {
        padding: 7px 14px;
        font-size: 0.8rem;
    }
    
}

/* Mobile: up to 767px */
@media (max-width: 767px) {
    
    .container {
        padding: 12px;
    }
    
    .timeline-wrapper {
        padding: 240px 0 200px;
    }
    
    .timeline {
        padding: 0 40px;
    }
    
    .event-card {
        width: 180px;
    }
    
    .event-content {
        padding: 10px;
    }
    
    .event-title {
        font-size: 0.8rem;
    }
    
    .event-people {
        font-size: 0.65rem;
    }
    
    .event-category {
        font-size: 0.5rem;
        padding: 2px 5px;
    }
    
    .timeline-year {
        margin-right: 40px;
    }
    
    .year-marker {
        font-size: 4rem;
    }
    
    .year-events {
        gap: 20px;
    }
    
    /* Toolbar wraps on mobile */
    .toolbar {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 16px;
        gap: 8px;
    }

    .toolbar-title {
        flex: 1;
        min-width: 0;
    }

    .toolbar-divider {
        display: none;
    }

    .search-wrap {
        width: 100%;
    }

    .toolbar-search {
        width: 100%;
    }

    .toolbar-group {
        flex: 1;
    }

    .toolbar-select {
        width: 100%;
    }

    .seg-group {
        justify-content: center;
    }

    .seg-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .toolbar-stats {
        display: none;
    }
    
    
    /* Timeline scrubber - adjust for mobile */
    .timeline-scrubber-wrap {
        padding: 10px 16px 16px;
    }
    
    .timeline-scrubber-wrap::before {
        font-size: 0.6rem;
        margin-bottom: 4px;
    }
    
    /* Adjust event card levels for mobile - reduce spacing */
    .timeline-year:nth-child(odd) .event-card.level-0 .event-content,
    .timeline-year:nth-child(even) .event-card.level-1 .event-content {
        bottom: 30px;
    }
    
    .timeline-year:nth-child(odd) .event-card.level-2 .event-content {
        bottom: 140px;
    }
    
    .timeline-year:nth-child(even) .event-card.level-0 .event-content,
    .timeline-year:nth-child(odd) .event-card.level-1 .event-content {
        top: 30px;
    }
    
    .timeline-year:nth-child(even) .event-card.level-2 .event-content {
        top: 140px;
    }
    
    /* Adjust stems for mobile */
    .timeline-year:nth-child(odd) .event-card.level-0 .event-content::before,
    .timeline-year:nth-child(even) .event-card.level-1 .event-content::before {
        bottom: -22px;
        height: 22px;
    }
    
    .timeline-year:nth-child(odd) .event-card.level-2 .event-content::before {
        bottom: -132px;
        height: 132px;
    }
    
    .timeline-year:nth-child(even) .event-card.level-0 .event-content::before,
    .timeline-year:nth-child(odd) .event-card.level-1 .event-content::before {
        top: -22px;
        height: 22px;
    }
    
    .timeline-year:nth-child(even) .event-card.level-2 .event-content::before {
        top: -132px;
        height: 132px;
    }
}

/* Small Mobile: up to 480px */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.3rem;
    }
    
    .subtitle {
        font-size: 0.75rem;
    }
    
    .timeline-wrapper {
        padding: 200px 0 180px;
    }
    
    .timeline {
        padding: 0 30px;
    }
    
    .event-card {
        width: 160px;
    }
    
    .event-content {
        padding: 8px;
    }
    
    .event-title {
        font-size: 0.75rem;
        margin-bottom: 3px;
    }
    
    .event-people {
        font-size: 0.6rem;
        margin-bottom: 6px;
    }
    
    .timeline-year {
        margin-right: 30px;
    }
    
    .year-events {
        gap: 15px;
    }
    
    .toolbar {
        padding: 8px 10px;
        gap: 6px;
    }
    
    .seg-btn {
        padding: 5px 8px;
        font-size: 0.7rem;
    }
    
}

/* Large screens: 1440px and up */
@media (min-width: 1440px) {
    .container {
        max-width: 100%;
    }
    
    .event-card {
        width: 240px;
    }
    
    .timeline-year {
        margin-right: 70px;
    }
    
    .toolbar-search {
        width: 220px;
    }
    
    .seg-btn {
        padding: 8px 20px;
        font-size: 0.85rem;
    }
}
