/**
 * Top metal rates bar (header.php, .top-rate-bar).
 *
 * The rates scroll left to right across the page's content width -- from the
 * logo's edge to the login icon's, not the full screen -- and start again
 * from the left. The bar stays one line high (main.js measures it to pin the
 * category nav below it).
 *
 * How the scroll works: .rate-track carries a left padding as wide as the
 * ticker, so the track is (ticker width + rates). Moving it from -100% to 0
 * takes the rates from just off the left edge to just off the right edge.
 * Only transform is animated, so the browser does not re-lay out the page.
 *
 * Hover pauses it so a rate can be read. Visitors who ask their system for
 * less motion get the rates standing still, as before.
 */

.top-rate-bar {
    background-color: var(--color-primary);
    color: var(--color-white);
    font-size: 0.76rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    position: sticky;
    top: 0;
    z-index: 1002;
}

.top-rate-bar .container {
    display: flex;
    align-items: center;
    padding-top: 8px;
    padding-bottom: 8px;
}

/* The window the rates move through: the container's content box. */
.rate-ticker {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.rate-track {
    display: flex;
    flex: none;
    align-items: center;
    gap: 16px;
    padding-left: 100%;
    animation: rate-bar-scroll 25s linear infinite;
    will-change: transform;
}

.rate-ticker:hover .rate-track {
    animation-play-state: paused;
}

@keyframes rate-bar-scroll {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}

.rate-item {
    white-space: nowrap;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.rate-item strong {
    color: var(--gold-200);
    font-weight: 700;
    margin-left: 3px;
}

/* The day's move, in brackets after the rate as MJDTA print it. Plain text in
   the bar's own colour; only kept from wrapping away from its rate. */
.rate-move {
    white-space: nowrap;
}

/* A narrower bar is a shorter trip, so it takes less time: about the same
   speed on every screen. */
@media (max-width: 992px) {
    .rate-track {
        animation-duration: 18s;
    }
}

@media (max-width: 576px) {
    .rate-track {
        animation-duration: 12s;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rate-ticker {
        justify-content: flex-end;
        overflow-x: auto;
    }

    .rate-track {
        animation: none;
        padding-left: 0;
    }
}
