/**
 * Milestone Timeline Styles
 * Horizontal scroll-driven timeline with smooth animations
 */

/* Define plugin color/font variables that pull from theme (with fallbacks) */
.cd-timeline {
    /* Try theme primary/accent color, fallback to coral */
    --timeline-primary-color: var(--global-palette1, var(--accent-color, var(--primary-color, #f46b45)));

    /* Try theme secondary color, fallback to gold */
    --timeline-secondary-color: var(--global-palette2, var(--secondary-color, #eea849));

    /* Try theme heading font, fallback to Jost */
    --timeline-heading-font: var(--global-heading-font-family, var(--heading-font, Jost, sans-serif));

    /* Try theme body font, fallback to system */
    --timeline-body-font: var(--global-body-font-family, var(--body-font, system-ui, sans-serif));

    /* Text colors - pull from theme's text color settings */
    --timeline-text-dark: var(--global-heading-color, var(--heading-color, #1a1a1a));
    --timeline-text-medium: var(--global-body-color, var(--body-color, #666));
}

/* Mobile: Horizontal timeline (same as desktop but smaller) */
.cd-timeline {
    padding: 40px 15px;
    max-width: 100%;
    margin: 0 auto;
    min-height: 600vh;
    position: relative;
}

.cd-timeline__container {
    position: sticky;
    top: 60px;
    height: 70vh;
    display: flex;
    align-items: flex-start;
    padding-top: 35vh;
    justify-content: center;
    overflow: visible;
    padding-left: 15px;
    padding-right: 15px;
    padding-bottom: 20px;
}

/* Horizontal line */
.cd-timeline__container::before {
    content: '';
    position: absolute;
    left: 30px;
    right: 30px;
    top: 35vh;
    width: calc(100% - 60px);
    height: 3px;
    background: linear-gradient(to right, var(--timeline-primary-color), var(--timeline-secondary-color));
    box-shadow: 0 0 15px color-mix(in srgb, var(--timeline-primary-color) 20%, transparent);
}

.cd-timeline__block {
    position: absolute;
    left: 50%;
    top: 35vh;
    margin: 0;
    transform-origin: center top;
    will-change: transform, opacity, filter;
    transition: none;
}

/* Marker (dot on timeline) with pulse animation */
.cd-timeline__img {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: 4px solid var(--timeline-primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--timeline-primary-color) 70%, transparent);
}

.cd-timeline__block.is-active .cd-timeline__img {
    transform: translate(-50%, -50%) scale(1.3);
    background: var(--timeline-primary-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--timeline-primary-color) 70%, transparent);
    }
    70% {
        box-shadow: 0 0 0 12px color-mix(in srgb, var(--timeline-primary-color) 0%, transparent);
    }
    100% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--timeline-primary-color) 0%, transparent);
    }
}

/* Year badge */
.cd-timeline__date {
    display: block;
    font-size: 10px;
    font-weight: bold;
    color: var(--timeline-primary-color);
    white-space: nowrap;
    line-height: 1;
}

.cd-timeline__block.is-active .cd-timeline__img .cd-timeline__date {
    color: white;
}

/* Content cards - positioned above and below timeline */
.cd-timeline__content {
    width: 200px;
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

.cd-timeline__block.is-active .cd-timeline__content {
    box-shadow: 0 10px 35px color-mix(in srgb, var(--timeline-primary-color) 18%, transparent);
}

/* Alternating pattern */
/* Even items (0, 2, 4): image above, text below */
.cd-timeline__block--top .cd-timeline__content--image {
    bottom: 100%;
    margin-bottom: 25px;
    top: auto;
    margin-top: 0;
}

.cd-timeline__block--top .cd-timeline__content--text {
    top: 100%;
    margin-top: 25px;
    bottom: auto;
    margin-bottom: 0;
}

/* Odd items (1, 3, 5): swap positions */
.cd-timeline__block--bottom .cd-timeline__content--image {
    top: 100%;
    margin-top: 25px;
    bottom: auto;
    margin-bottom: 0;
}

.cd-timeline__block--bottom .cd-timeline__content--text {
    bottom: 100%;
    margin-bottom: 25px;
    top: auto;
    margin-top: 0;
}

.cd-timeline__img-wrapper {
    width: 180px;
    height: 110px;
    border-radius: 6px;
    overflow: hidden;
}

.cd-timeline__img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cd-timeline__text {
    padding: 5px;
}

.cd-timeline__content h3 {
    margin: 0 0 6px 0;
    color: var(--timeline-text-dark);
    font-size: 15px;
    font-family: var(--timeline-heading-font);
    line-height: 1.2;
}

.cd-timeline__text p {
    color: var(--timeline-text-medium);
    margin: 0;
    line-height: 1.4;
    font-size: 12px;
    font-family: var(--timeline-body-font);
}

/* Desktop: Horizontal timeline with scroll-driven movement */
@media (min-width: 768px) {
    .cd-timeline {
        padding: 60px 40px;
        max-width: 1400px;
        margin: 0 auto;
        min-height: 300vh;
        position: relative;
    }

    .cd-timeline__container {
        position: sticky;
        top: 80px;
        height: 75vh;
        display: flex;
        align-items: flex-start;
        padding-top: 35vh;
        justify-content: center;
        overflow: visible;
        padding-left: 40px;
        padding-right: 40px;
        padding-bottom: 40px;
    }

    /* Horizontal line - positioned at padding-top */
    .cd-timeline__container::before {
        left: 60px;
        right: 60px;
        top: 35vh;
        width: calc(100% - 120px);
        height: 3px;
    }

    .cd-timeline__block {
        top: 35vh;
    }

    /* Marker on horizontal line */
    .cd-timeline__img {
        width: 50px;
        height: 50px;
        border-width: 5px;
    }

    .cd-timeline__block.is-active .cd-timeline__img {
        transform: translate(-50%, -50%) scale(1.4);
    }

    /* Show year in marker */
    .cd-timeline__date {
        font-size: 12px;
    }

    /* Larger cards on desktop */
    .cd-timeline__content {
        width: 280px;
        padding: 12px;
    }

    .cd-timeline__img-wrapper {
        width: 260px;
        height: 150px;
    }

    .cd-timeline__text {
        padding: 8px;
    }

    .cd-timeline__content h3 {
        font-size: 17px;
        margin-bottom: 8px;
    }

    .cd-timeline__text p {
        font-size: 14px;
        line-height: 1.5;
    }
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}
