/* Training journey (includes/training_journey.html, .tj): a road that draws itself as you
   scroll. training-journey.js sets --tj-progress, places each stop on the road and marks
   stops the line has reached. A wavy road on desktop, a vertical one on phones. */
.tj {
    --tj-ink: var(--kd-ink);
    --tj-body: var(--kd-muted);
    --tj-mint: var(--kd-mint);
    --tj-mint-dark: var(--kd-mint-ink);
    --tj-brand: var(--kd-brand);
    position: relative;
    padding-top: 6rem;
}

/* The heading matches the careers page's other section headings (.cr-kicker, .cr-title). */
.tj__kicker {
    margin: 0 0 1rem;
    color: var(--tj-brand);
    font-size: 0.95rem;
    font-weight: 600;
}

.tj__title {
    margin: 0;
    color: var(--tj-ink);
    font-size: clamp(2.1rem, 4.4vw, 3.25rem);
    font-weight: 700;
    line-height: 1.07;
    letter-spacing: -0.03em;
}

.tj__lede {
    margin: 0.8rem 0 0;
    color: var(--tj-body);
    font-size: 1.05rem;
}

/* ---------- The road ---------- */
.tj__map {
    position: relative;
    height: 44rem;
    margin-top: 2.5rem;
}

@media (min-width: 768px) {
    .tj__map {
        height: 25rem;
        margin-top: 3rem;
    }
}

.tj-road {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.tj-road--h {
    display: none;
}

@media (min-width: 768px) {
    .tj-road--h {
        display: block;
    }

    .tj-road--v {
        display: none;
    }
}

.tj-road path {
    vector-effect: non-scaling-stroke;
    stroke-linecap: round;
}

.tj-road__base {
    stroke: var(--kd-line);
    stroke-width: 16;
}

.tj-road__lane {
    stroke: #FFFFFF;
    stroke-width: 2;
    stroke-dasharray: 10 12;
}

/* Drawn by scroll: the dash length is the path length, the offset shrinks to zero. */
.tj-road__progress {
    stroke: var(--tj-mint);
    stroke-width: 16;
}

.tj-road--h .tj-road__progress {
    filter: drop-shadow(0 6px 10px rgba(16, 185, 129, 0.35));
}

/* The traveller rides at the tip of the drawn line. */
.tj__traveller {
    position: absolute;
    z-index: 3;
    top: 0;
    left: 0;
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    margin: -1.3rem 0 0 -1.3rem;
    border: 3px solid #FFFFFF;
    border-radius: 999px;
    background: linear-gradient(160deg, #4F6FB8, var(--kd-brand-darker));
    box-shadow: 0 10px 22px -8px rgba(34, 54, 95, 0.7);
    color: #FFFFFF;
    transition: opacity 0.4s ease;
    will-change: transform;
}

.tj__traveller svg {
    width: 1.3rem;
    height: 1.3rem;
}

.tj.is-done .tj__traveller {
    opacity: 0;
}

/* ---------- Stops ---------- */
.tj__stops {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tj-stop {
    position: absolute;
    z-index: 2;
    top: var(--y, 0);
    left: var(--x, 0);
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 15rem;
    transform: translateY(-50%);
    margin-left: -1.8rem;
}

@media (min-width: 768px) {
    .tj-stop {
        flex-direction: column;
        gap: 0.9rem;
        width: 14rem;
        margin-left: -7rem;
        text-align: center;
        transform: translateY(-1.8rem);
    }

    /* The 2nd and 4th stops sit on the crests of the wave, where the road climbs in on both
       sides just below the dot, so their labels go above the dot instead. */
    .tj-stop:nth-child(even) {
        flex-direction: column-reverse;
        transform: translateY(calc(-100% + 1.8rem));
    }
}

.tj-stop__dot {
    position: relative;
    display: grid;
    flex: none;
    place-items: center;
    width: 3.6rem;
    height: 3.6rem;
    border: 2px dashed var(--kd-line-strong);
    border-radius: 999px;
    background: #FFFFFF;
    color: var(--kd-faint);
    font-weight: 800;
    transition: background-color 0.4s ease, border-color 0.4s ease, color 0.4s ease, box-shadow 0.4s ease;
}

.tj-stop__check {
    position: absolute;
    width: 1.5rem;
    height: 1.5rem;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.tj-stop__num {
    transition: opacity 0.2s ease;
}

.tj-stop__text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    opacity: 0.45;
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.22, 0.8, 0.25, 1);
    transform: translateY(6px);
}

@media (min-width: 768px) {
    .tj-stop__text {
        align-items: center;
    }
}

.tj-stop__title {
    color: var(--tj-ink);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.tj-stop__desc {
    margin-top: 0.2rem;
    color: var(--tj-body);
    font-size: 0.92rem;
    line-height: 1.45;
}

.tj-stop__badge {
    margin-top: 0.6rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: var(--kd-mint-wash);
    color: var(--tj-mint-dark);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.35s ease 0.2s, transform 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) 0.2s;
}

/* Without the script the stops can't be placed on the road, so they simply list below it. */
.tj:not(.is-js) .tj__map {
    height: auto;
}

.tj:not(.is-js) .tj-road,
.tj:not(.is-js) .tj__traveller {
    display: none;
}

.tj:not(.is-js) .tj__stops {
    display: grid;
    gap: 1.5rem;
}

.tj:not(.is-js) .tj-stop {
    position: static;
    margin: 0;
    transform: none;
}

.tj:not(.is-js) .tj-stop__text {
    opacity: 1;
}

/* Reached: the stop fills mint, ticks and pops. */
.tj-stop.is-reached .tj-stop__dot {
    border: 2px solid var(--tj-mint);
    background: var(--tj-mint);
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0.16), 0 14px 24px -12px rgba(15, 23, 42, 0.45);
    color: #FFFFFF;
    animation: tj-pop 0.55s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.tj-stop.is-reached .tj-stop__num {
    opacity: 0;
}

.tj-stop.is-reached .tj-stop__check {
    opacity: 1;
    transform: none;
}

.tj-stop.is-reached .tj-stop__text {
    opacity: 1;
    transform: none;
}

.tj-stop.is-reached .tj-stop__badge {
    opacity: 1;
    transform: none;
}

/* The finish line glows once the whole road is drawn. */
.tj.is-done .tj-stop:last-child .tj-stop__dot {
    animation: tj-pop 0.55s cubic-bezier(0.3, 1.6, 0.5, 1), tj-glow 2.4s ease-in-out 0.6s infinite;
}

@keyframes tj-pop {
    0% {
        transform: scale(0.7);
    }

    60% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes tj-glow {
    0%, 100% {
        box-shadow: 0 0 0 7px rgba(16, 185, 129, 0.16), 0 14px 24px -12px rgba(15, 23, 42, 0.45);
    }

    50% {
        box-shadow: 0 0 0 14px rgba(16, 185, 129, 0.1), 0 14px 24px -12px rgba(15, 23, 42, 0.45);
    }
}

/* Reached through a link (training-journey.js adds .is-instant): shown finished, not played. */
.tj.is-instant *,
.tj.is-instant.is-done .tj-stop:last-child .tj-stop__dot {
    animation: none !important;
    transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .tj *,
    .tj.is-done .tj-stop:last-child .tj-stop__dot {
        animation: none !important;
        transition: none !important;
    }
}
