/* LoRELEI - live engagement features (lorelei-demo-egqc), shared by /live
   and /screen. Loaded by both pages; used when FX_DEFAULT or ?fx=1 turns
   the features on.

   Medal gold, silver and bronze, the Fastest on course yellow, and the trail
   pace ramp are data colors like the status greens and the checkpoint
   orange, not brand paint. The yellow is the fast end of the pace ramp, so
   the badge and the trail color say the same thing. Each page sizes these
   in its own stylesheet. */

:root {
    --fx-gold: #f5c542;
    --fx-silver: #c4cad3;
    --fx-bronze: #c98a4b;
    --fx-fast: #fde047;
    --fx-fast-rgb: 253, 224, 71;
    --fx-clean: var(--status-go);
}

.fx-icon {
    width: 1em;
    height: 1em;
    flex: none;
    display: inline-block;
    vertical-align: -0.14em;
}

/* Place colors */
.fx-place-1 { --fx-place: var(--fx-gold); }
.fx-place-2 { --fx-place: var(--fx-silver); }
.fx-place-3 { --fx-place: var(--fx-bronze); }

/* Medal chip: numbered disc + stage label, e.g. (1) S2 */
.fx-medal {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.05em 0.45em 0.05em 0.1em;
    border: 1px solid var(--fx-place);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-weight: 600;
    white-space: nowrap;
}

.fx-medal-disc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35em;
    height: 1.35em;
    border-radius: 50%;
    background: var(--fx-place);
    color: #0d0e0f;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85em;
    line-height: 1;
    flex: none;
}

.fx-medal-disc.is-none {
    background: transparent;
}

/* Text badges: podium, clean card, fastest on course */
.fx-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.05em 0.45em;
    border: 1px solid var(--fx-place, var(--color-border));
    color: var(--fx-place, var(--color-text));
    font-family: var(--font-mono);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.fx-chip--clean {
    --fx-place: var(--fx-clean);
}

.fx-chip--fastest {
    --fx-place: var(--fx-fast);
    background: rgba(var(--fx-fast-rgb), 0.1);
}

/* SUPERFAST: pace off the top of the trail scale (lorelei-demo-me84).
 * Solid yellow so it outranks the outlined chips, with a glint sweeping
 * across it and a twinkling sparkle icon. */
.fx-chip--superfast {
    --fx-place: var(--fx-fast);
    color: #0d0e0f;
    background:
        linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.75) 50%, transparent 65%) no-repeat,
        var(--fx-fast);
    background-size: 250% 100%, auto;
    animation: fx-glint 2.4s linear infinite;
}

.fx-chip--superfast .fx-icon {
    animation: fx-twinkle-icon 1.2s ease-in-out infinite;
}

@keyframes fx-glint {
    from { background-position: 100% 0, 0 0; }
    to { background-position: -150% 0, 0 0; }
}

@keyframes fx-twinkle-icon {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(0.7) rotate(45deg); }
}

/* Trail sparkle dots (LiveFxSparkle). Raising the dash offset by one gap
 * moves each dot back one place along the trail, away from the runner,
 * so the loop is seamless; the two lines drift and twinkle out of step.
 * Each gap must match its dashArray in LiveFxSparkle.LINES. */
.fx-sparkle {
    filter: drop-shadow(0 0 3px rgb(var(--fx-fast-rgb))) drop-shadow(0 0 1px #ffffff);
}

.fx-sparkle--a {
    animation: fx-drift-18 0.9s linear infinite, fx-twinkle 1.3s ease-in-out infinite;
}

.fx-sparkle--b {
    animation: fx-drift-27 1.5s linear infinite, fx-twinkle 0.8s ease-in-out -0.4s infinite;
}

@keyframes fx-drift-18 {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: 18; }
}

@keyframes fx-drift-27 {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: 27; }
}

@keyframes fx-twinkle {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .fx-chip--superfast,
    .fx-chip--superfast .fx-icon,
    .fx-sparkle--a,
    .fx-sparkle--b {
        animation: none;
    }
}

/* Race feed lines */
.fx-feed-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.fx-feed-item {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 0.5em;
    min-width: 0;
    transition: opacity 1s ease;
}

/* Older than RaceFeed.QUIET_SEC (3 min) */
.fx-feed-item.is-old {
    opacity: 0.45;
}

.fx-feed-time {
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    font-size: 0.85em;
}

.fx-feed-icon {
    display: inline-flex;
    color: var(--color-text-muted);
}

.fx-feed-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.fx-feed--gold .fx-feed-icon { color: var(--fx-gold); }
.fx-feed--silver .fx-feed-icon { color: var(--fx-silver); }
.fx-feed--bronze .fx-feed-icon { color: var(--fx-bronze); }
.fx-feed--finish .fx-feed-icon { color: var(--color-text); }
.fx-feed--dnf .fx-feed-icon,
.fx-feed--shoot-dnf .fx-feed-icon { color: var(--status-stop); }
.fx-feed--gold .fx-feed-text,
.fx-feed--finish .fx-feed-text { font-weight: 600; }

/* Pace legend: the trail ramp, slow to fast */
.fx-pace-legend {
    display: inline-flex;
    flex-direction: column;
    gap: 0.2em;
    padding: 0.35em 0.6em;
    background: rgba(13, 14, 15, 0.82);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.2;
    pointer-events: none;
}

.fx-pace-legend-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.fx-pace-legend-scale {
    display: flex;
    align-items: center;
    gap: 0.45em;
    color: var(--color-text);
}

.fx-pace-legend-bar {
    width: 84px;
    height: 6px;
    /* Stops sit where LiveInsights.PACE_COLOR_STOPS put them on a speed
       axis from 30:00 to 9:00 min/mile (20:00 at 21%, 13:00 at 56%). */
    background: linear-gradient(90deg,
        rgb(139, 92, 246) 0%, rgb(236, 72, 153) 21%, rgb(245, 158, 11) 56%, rgb(253, 224, 71) 100%);
}

/* Past the fast end: faster than 9:00 sparkles (SUPERFAST). */
.fx-pace-legend-superfast {
    display: inline-flex;
    color: var(--fx-fast);
}
