/* CAREER TIMELINE: one dot per work card, horizontal under the row, vertical on a phone */

/* Wide screens: the card row never wraps, it scrolls (or drags) sideways with its timeline */
@media (min-width: 721px) {
    .work-scroller {
        overflow-x: auto;
        overflow-y: hidden;
        margin: 0 -1rem;
        scrollbar-width: thin;
        scrollbar-color: rgba(52, 152, 219, 0.4) transparent;
    }

    .work-track {
        width: max-content;
        margin: 0 auto;
    }

    #work-grid {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: 212px;
        justify-content: start;
        width: auto;
        margin: 0;
        padding-bottom: 0;
    }

    .work-scroller.draggable {
        cursor: grab;
    }

    .work-scroller.dragging {
        cursor: grabbing;
        user-select: none;
    }

    .work-scroller.dragging .card {
        pointer-events: none;
    }
}

.timeline {
    position: relative;
    padding: 3rem 1rem 3.25rem;
}

.tl-line {
    position: relative;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, rgba(52, 152, 219, 0.35) 92%, transparent);
}

/* Period of the hovered / selected position, lit on the line */
.tl-range {
    position: absolute;
    top: -1px;
    left: var(--from, 0);
    width: var(--size, 0);
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    box-shadow: 0 0 12px rgba(52, 152, 219, 0.6);
    opacity: 0;
    transition: left 0.4s cubic-bezier(0.22, 1, 0.36, 1), width 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}

.tl-dot {
    position: absolute;
    top: 50%;
    left: var(--pos, 0);
    width: 18px;
    height: 18px;
    padding: 0;
    border-radius: 50%;
    border: 3px solid var(--color-primary);
    background: var(--color-bg);
    cursor: pointer;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay),
        background var(--transition-fast), box-shadow var(--transition-fast);
}

.timeline.visible .tl-dot {
    transform: translate(-50%, -50%) scale(1);
}

/* Bigger touch target than the visible dot */
.tl-dot::before {
    content: '';
    position: absolute;
    inset: -12px;
    border-radius: 50%;
}

.tl-dot:hover,
.tl-dot.active {
    background: var(--color-primary);
    box-shadow: 0 0 0 6px rgba(52, 152, 219, 0.2), 0 0 16px rgba(52, 152, 219, 0.6);
}

.tl-dot:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 4px;
}

/* Name above the line, start year under it */
.tl-dot-name,
.tl-dot-year {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
    transition: color var(--transition-fast);
}

.tl-dot-name {
    bottom: calc(100% + 12px);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--color-text-main);
}

.tl-dot-year {
    top: calc(100% + 12px);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--color-meta);
}

.tl-dot:hover .tl-dot-name,
.tl-dot.active .tl-dot-name {
    color: var(--color-primary);
}

/* "Now" end of the line, pulsing */
.tl-now {
    position: absolute;
    top: 50%;
    left: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
    transform: translate(-50%, -50%);
    animation: tl-pulse 2s infinite;
}

.tl-now span {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
}

@keyframes tl-pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.6); }
    70% { box-shadow: 0 0 0 10px rgba(52, 152, 219, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0); }
}

/* Card matching the hovered / selected dot */
.card.tl-highlight {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary), var(--glass-shadow);
}

/* Phone: vertical line along the left of the card list, inside it */
#work-grid.has-timeline {
    position: relative;
    padding-left: 2.5rem;
}

.timeline.vertical {
    position: absolute;
    top: 1rem;
    bottom: 1rem;
    left: 0.5rem;
    width: 1.5rem;
    padding: 0;
}

.timeline.vertical .tl-line {
    width: 3px;
    height: 100%;
    margin: 0 auto;
    background: linear-gradient(180deg, rgba(52, 152, 219, 0.35) 92%, transparent);
}

.timeline.vertical .tl-range {
    top: var(--from, 0);
    left: -1px;
    width: 5px;
    height: var(--size, 0);
    background: linear-gradient(180deg, var(--color-primary), var(--color-secondary));
    transition: top 0.4s cubic-bezier(0.22, 1, 0.36, 1), height 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}

.timeline.vertical .tl-dot {
    top: var(--pos, 0);
    left: 50%;
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* No room for the names (the card next to each dot has it), the start year sits above the dot */
.timeline.vertical .tl-dot-name,
.timeline.vertical .tl-now span {
    display: none;
}

.timeline.vertical .tl-dot-year {
    top: auto;
    bottom: calc(100% + 5px);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0 2px;
    background: var(--color-bg);
    border-radius: 3px;
}

.timeline.vertical .tl-now {
    top: 0;
    left: 50%;
}

@media (prefers-reduced-motion: reduce) {
    .tl-dot,
    .tl-range {
        transition: none;
    }

    .tl-now {
        animation: none;
    }
}
