/* ==========================================================================
   TIMELINE — replaces the whole old .timeline-* block, including the
   @media (max-width: 767px) overrides. Delete the old rules; keeping any of
   them (especially the absolutely positioned .timeline-arrow and the
   .timeline-swiper .swiper-slide::before rail) will fight these.
   ========================================================================== */

.timeline-section {
    position: relative;
    overflow: hidden;
}

.timeline-wrap {
    /* every measurement below derives from these three */
    --tn-w: 220px;    /* card / node width  */
    --tn-gap: 40px;   /* space between nodes */
    --tn-dot: 14px;   /* dot diameter — the rail sits on its centre */
    --tn-edge: 8px;   /* breathing room for the active card's scale-up */

    position: relative;
}

/* content-box sizing would push the cards past their node and knock the rail
   off the dots — don't rely on a global reset for this */
.timeline-wrap *,
.timeline-wrap *::before,
.timeline-wrap *::after {
    box-sizing: border-box;
}

/* ---------- the scroll strip ---------------------------------------------- */

.timeline-viewport {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-block: 12px 28px;      /* room for the active card's shadow/scale */
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    cursor: grab;

    /* hide the scrollbar, keep the scrolling */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

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

.timeline-viewport.is-dragging {
    cursor: grabbing;
}

.timeline-viewport.is-dragging .tn-card,
.timeline-viewport.is-dragging .tn-year {
    user-select: none;
}

.timeline-viewport:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 4px;
}

.timeline-track {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--tn-gap);
    width: max-content;
    min-width: 100%;
    /* absorbs the active card's scale-up so it can't stretch the scroll width
       and leave the next arrow enabled at the end of the strip */
    padding-inline: var(--tn-edge);
}

/* ---------- the one continuous rail -------------------------------------- */
/* Inset by half a card on both sides, so it begins at the centre of the
   first dot and ends at the centre of the last one. */

.timeline-line,
.timeline-progress {
    position: absolute;
    top: calc(var(--tn-dot) / 2);
    height: 2px;
    transform: translateY(-50%);
    pointer-events: none;
}

.timeline-line {
    left: calc(var(--tn-edge) + var(--tn-w) / 2);
    right: calc(var(--tn-edge) + var(--tn-w) / 2);
    background: var(--border-color);
    z-index: 0;
}

.timeline-progress {
    left: calc(var(--tn-edge) + var(--tn-w) / 2);
    width: 0;
    max-width: calc(100% - var(--tn-w) - 2 * var(--tn-edge));
    background: var(--accent-color);
    z-index: 1;
    transition: width 0.55s var(--ease-premium);
}

/* ---------- node: dot, year, card — always in this order ----------------- */

.timeline-node {
    position: relative;
    z-index: 2;
    flex: 0 0 var(--tn-w);
    width: var(--tn-w);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.timeline-node .tn-dot {
    width: var(--tn-dot);
    height: var(--tn-dot);
    border-radius: 50%;
    background: var(--accent-color);
    border: 3px solid var(--accent-color);
    margin-bottom: 1.35rem;
    transition: transform var(--dur-fast) var(--ease-premium),
                background-color var(--dur-fast) var(--ease-premium),
                box-shadow var(--dur-fast) var(--ease-premium);
}

.timeline-node:hover .tn-dot {
    transform: scale(1.2);
}

.timeline-node.is-active .tn-dot {
    background: var(--light-bg, #fff);
    transform: scale(1.25);
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Fixed box so the active year scaling up never shifts the cards out of
   alignment — the old layout's height problem, solved without JS. */
.timeline-node .tn-year {
    height: 2.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.85rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-muted);
    transition: transform var(--dur-fast) var(--ease-premium),
                color var(--dur-fast) var(--ease-premium);
}

.timeline-node.is-active .tn-year {
    color: var(--primary-color);
    transform: scale(1.22);
}

.timeline-node .tn-card {
    position: relative;
    width: 100%;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.5rem 1.5rem;
    transition: transform var(--dur-fast) var(--ease-premium),
                background-color var(--dur-fast) var(--ease-premium),
                border-color var(--dur-fast) var(--ease-premium),
                box-shadow var(--dur-fast) var(--ease-premium);
}

.timeline-node:not(.is-active):hover .tn-card {
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.02);
}

.timeline-node.is-active .tn-card {
    background: linear-gradient(90deg, rgba(240, 216, 132, .90) 20%, rgba(240, 216, 132, .5) 80%);
    border-color: rgba(240, 216, 132, 1);
    transform: scale(1.02);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.timeline-node .tn-card p {
    margin-bottom: 0;
    line-height: 1.55;
    color: var(--text-muted);
    transition: color var(--dur-fast) var(--ease-premium);
}

/* the panel is light now — keep the copy dark, just a shade firmer than the
   resting cards so the focused one still reads as selected */
.timeline-node.is-active .tn-card p {
    color: var(--ink);
}

/* ---------- arrows, centred below the track ------------------------------ */

.timeline-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.timeline-arrow {
    /* position: static here on purpose — it overrides the old side-pinned rule
       if any of it survives in another stylesheet */
    position: static;
    transform: none;
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-fast) var(--ease-premium);
}

.timeline-arrow:hover:not(:disabled) {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.timeline-arrow:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* The arrows stay visible even when the whole strip fits on screen, because
   they move the selected milestone, not just the scroll position. The script
   still sets .is-scrollable on .timeline-wrap when the strip overflows, if you
   ever want to hook styling to that. */

/* ---------- small screens ------------------------------------------------ */
/* Same horizontal strip, just tighter — no stacking, no reflow. */

@media (max-width: 767px) {
    .timeline-wrap {
        --tn-w: 232px;
        --tn-gap: 18px;
    }

    .timeline-node .tn-card {
        padding: 1rem;
    }

    .timeline-node .tn-year {
        font-size: 1.2rem;
    }

    .timeline-arrow {
        width: 40px;
        height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .timeline-progress,
    .timeline-node .tn-dot,
    .timeline-node .tn-year,
    .timeline-node .tn-card,
    .timeline-node .tn-card p {
        transition: none;
    }
}

.timeline-node {
    align-self: flex-start;
    height: auto !important;
    min-height: 0 !important;
}

    .timeline-node .tn-card {
        height: auto !important;
        min-height: 0;
    }
