/* ============================================================
   SCROLL ROUTE — prototype
   A GPS-style navigation rail. The truck drives the route as you
   scroll; each waypoint is a link to that section.

   Wide desktop : vertical rail down the left margin
   Everything else : horizontal bar under the header

   Both layouts read the same --p custom property (0 → 1), set by
   route.js. CSS decides whether that maps to Y or X.

   ORDER MATTERS: component styles come first, layout media queries
   last, so the media queries win on source order. (The site's
   header had three dead rules from getting this backwards.)
   ============================================================ */

.route {
    --p: 0;
    --rail: rgba(201, 168, 76, 0.18);
    position: fixed;
    z-index: 880;              /* under the topnav (900), over content */
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;      /* re-enabled on the stops themselves */
}

.route.is-visible { opacity: 1; }

.route-track,
.route-progress {
    position: absolute;
    border-radius: 3px;
}

.route-track { background: var(--rail); }

/* ── Waypoints ───────────────────────────────────────────── */
.route-stop {
    position: absolute;
    text-decoration: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 12px;
}

.route-dot {
    display: block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--navy);
    border: 2px solid var(--rail);
    box-sizing: border-box;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.route-stop.is-reached .route-dot {
    background: var(--gold);
    border-color: var(--gold-light);
    transform: scale(1.25);
}

/* Labels are opt-in — only shown where there is genuinely room
   (see the wide-desktop block at the bottom). */
.route-label {
    display: none;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: rgba(107, 114, 128, 0.55);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.3s ease, transform 0.3s ease, color 0.3s ease;
}

/* Mid-tone gold, not gold-dark: the rail crosses both cream and navy
   sections, and gold-dark disappears against the navy footer. */
.route-stop.is-reached .route-label {
    opacity: 1;
    transform: translateX(0);
    color: var(--gold);
}

.route-stop:hover .route-label,
.route-stop:focus-visible .route-label {
    opacity: 1;
    transform: translateX(0);
    color: var(--gold-light);
}

.route-stop:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 6px;
    border-radius: 4px;
}

/* ── The truck ───────────────────────────────────────────── */
.route-truck {
    display: block;
    border-radius: 50%;
    background: var(--navy);
    border: 2px solid var(--gold);
    box-shadow: 0 4px 16px rgba(11, 28, 53, 0.45);
    box-sizing: border-box;
}

.route-truck svg { display: block; width: 100%; height: 100%; }

.route-truck .truck-body  { fill: var(--gold); }
.route-truck .truck-glass { fill: var(--navy); }
.route-truck .truck-wheel { fill: var(--gold-light); }

/* Wheels turn only while the page is actually moving. route.js adds
   .is-rolling on scroll and drops it ~150ms after it stops. */
.route.is-rolling .truck-wheel {
    animation: routeWheel 0.6s linear infinite;
    transform-box: fill-box;
    transform-origin: center;
}

@keyframes routeWheel {
    to { transform: rotate(360deg); }
}

/* ============================================================
   LAYOUT — horizontal bar (default: phones, tablets, laptops)
   The truck travels an inset range so it never hangs off an edge.
   ============================================================ */
.route {
    left: 0;
    right: 0;
    top: 64px;                 /* directly under the fixed header */
    height: 3px;
}

.route-track,
.route-progress {
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
}

.route-progress {
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
    transform: scaleX(var(--p));
    transform-origin: left center;
}

.route-stop {
    top: 1.5px;
    left: calc(var(--sp) * 100%);
    transform: translate(-50%, -50%);
}

.route-dot {
    width: 5px;
    height: 5px;
    border-width: 1px;
}

/* Sits just below the bar rather than centred on it, so it never
   ducks behind the header. */
.route-vehicle {
    position: absolute;
    top: 7px;
    left: calc(14px + var(--p) * (100% - 28px));
    transform: translateX(-50%);
    transition: left 0.08s linear;
    pointer-events: none;
}

.route-truck {
    width: 26px;
    height: 26px;
    padding: 5px;
}

/* ============================================================
   LAYOUT — vertical rail (only where the left margin is clear)

   The content column is max-width 1200px, so free margin each side
   is (vw - 1200) / 2. The rail plus truck needs ~60px, hence 1320.
   Below that the horizontal bar above applies instead.
   ============================================================ */
@media (min-width: 1320px) {
    .route {
        left: 34px;
        right: auto;
        top: 108px;
        bottom: 88px;
        width: 2px;
        height: auto;
    }

    .route-track,
    .route-progress {
        top: 0;
        left: 0;
        width: 2px;
        height: 100%;
    }

    .route-progress {
        background: linear-gradient(180deg, var(--gold-light), var(--gold-dark));
        transform: scaleY(var(--p));
        transform-origin: top center;
    }

    .route-stop {
        left: 1px;
        top: calc(var(--sp) * 100%);
        transform: translate(-50%, -50%);
        pointer-events: auto;
    }

    .route-dot {
        width: 9px;
        height: 9px;
        border-width: 2px;
    }

    .route-vehicle {
        left: 1px;
        top: calc(var(--p) * 100%);
        transform: translate(-50%, -50%);
        transition: top 0.08s linear;
    }

    .route-truck {
        width: 38px;
        height: 38px;
        padding: 7px;
    }
}

/* Waypoint labels need ~90px of clear margin on top of the rail. */
@media (min-width: 1500px) {
    .route-label { display: block; }
}

/* ── Motion preferences ──────────────────────────────────────
   The rail still tracks scroll (direct manipulation, not
   animation) but nothing eases, spins, or slides on its own. */
@media (prefers-reduced-motion: reduce) {
    .route,
    .route-vehicle,
    .route-dot,
    .route-label { transition: none; }

    .route.is-rolling .truck-wheel { animation: none; }
}

@media print {
    .route { display: none; }
}
