/* liveRoute: the call on air as a route of stops joined by links; the
   links carry a pulse in the direction the audio travels while live. */
.lr-card { overflow: hidden; }

.lr-card h2 { margin-bottom: 0.5rem; }

/* Lanes: one call each (a duplex DMR hotspot has one per timeslot) */
.lr-lanes {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.lr-lane { --lr-c: var(--ps-accent); --lr-t: var(--ps-accent-text, var(--ps-accent)); }
.lr-lane-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.3rem;
}
.lr-lane-name {
    font-family: var(--ps-font-mono, monospace);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--lr-t);
    letter-spacing: 0.04em;
}

.lr-state {
    font-family: var(--ps-font-mono, monospace);
    font-size: 0.8125rem;
    color: var(--ps-text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.lr-state-live { color: var(--lr-t); font-weight: 600; }
.lr-state-live::before {
    content: "";
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin-right: 0.4rem;
    border-radius: 50%;
    background: var(--ps-danger);
    box-shadow: 0 0 0 0 var(--ps-danger);
    animation: lr-beacon 1.4s ease-out infinite;
    vertical-align: 0.05rem;
}

/* The mode's colour, as Recent Activity shows it */
.lr-mode-dmr { --lr-c: var(--ps-accent); --lr-t: var(--ps-accent-text, var(--ps-accent)); }
.lr-mode-dstar { --lr-c: var(--ps-info); --lr-t: var(--ps-info-text, var(--ps-info)); }
.lr-mode-ysf { --lr-c: var(--ps-success); --lr-t: var(--ps-success-text, var(--ps-success)); }
.lr-mode-p25 { --lr-c: var(--ps-warning); --lr-t: var(--ps-warning-text, var(--ps-warning)); }
.lr-mode-nxdn { --lr-c: var(--ps-danger); --lr-t: var(--ps-danger-text, var(--ps-danger)); }
.lr-mode-pocsag { --lr-c: var(--ps-info); --lr-t: var(--ps-info-text, var(--ps-info)); }

/* A page's message: up to two lines */
.lr-sub.lr-msg { -webkit-line-clamp: 2; }

.lr-route {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0.25rem 0 0.25rem;
}
.lr-lanes > .lr-idle { min-height: 5rem; display: flex; align-items: center; justify-content: center; }
.lr-lane .lr-idle { margin: 0.4rem 0; }

.lr-idle {
    margin: auto;
    color: var(--ps-text-secondary);
    font-style: italic;
}

.lr-node {
    flex: 1 1 0;
    min-width: 0;
    position: relative;
    padding: 0.75rem 0.85rem 0.8rem;
    border: 1px solid var(--ps-border);
    border-top: 3px solid var(--lr-c);
    border-radius: 0.6rem;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--lr-c) 10%, transparent), transparent 70%),
        var(--ps-bg-secondary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: opacity 0.4s, filter 0.4s;
}

.lr-icon {
    width: 1.6rem;
    height: 1.6rem;
    color: var(--lr-c);
    margin-bottom: 0.2rem;
}
.lr-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lr-label {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ps-text-secondary);
}

/* The callsign (with its flag) on the first line; the caller's ID after
   it when there is room, else on the next line */
.lr-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 0.4rem;
    row-gap: 0;
    margin-top: 0.15rem;
    font-family: var(--ps-font-mono, monospace);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ps-text-primary);
    line-height: 1.25;
}
.lr-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* The callsign stays whole unless even a line of its own is too narrow;
   the caller's ID after it, in brackets, quieter and smaller */
.lr-title .lr-name {
    flex: 0 1 auto;
    min-width: 0;
    white-space: normal;    /* "430.200 MHz" may break at its space */
}
.lr-title .lr-id {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 0.72em;
    font-weight: 500;
    color: var(--ps-text-secondary);
}
.lr-title .flag {
    transform: scale(1.25);
    transform-origin: left center;
    margin-right: 0.15rem;
}

/* A stop's details (the caller's name and country, a talkgroup's name):
   they wrap in a narrow box, up to three lines */
.lr-sub {
    margin-top: 0.2rem;
    font-size: 0.8125rem;
    color: var(--ps-text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
}

.lr-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
}
.lr-stats:empty { display: none; }
.lr-stats span {
    font-family: var(--ps-font-mono, monospace);
    font-size: 0.72rem;
    padding: 0.05rem 0.4rem;
    border-radius: 1rem;
    background: color-mix(in srgb, var(--lr-c) 14%, transparent);
    color: var(--ps-text-primary);
    max-width: 100%;
}

/* The links: a track, and a pulse running along it while live */
.lr-link {
    flex: 0 0 2.75rem;
    position: relative;
    align-self: center;
    height: 4px;
    margin: 0 -1px;
    border-radius: 2px;
    background: repeating-linear-gradient(90deg,
        color-mix(in srgb, var(--lr-c) 55%, transparent) 0 6px,
        transparent 6px 11px);
    background-size: 11px 4px;
}
.lr-live .lr-link {
    animation: lr-flow 0.6s linear infinite;
}
.lr-pulse {
    position: absolute;
    top: 50%;
    left: 0;
    width: 10px;
    height: 10px;
    margin-top: -5px;
    border-radius: 50%;
    background: var(--lr-c);
    box-shadow: 0 0 10px 2px var(--lr-c);
    opacity: 0;
}
.lr-live .lr-pulse {
    animation: lr-run 1.1s ease-in-out infinite;
}
.lr-live .lr-link:nth-of-type(4) .lr-pulse { animation-delay: 0.35s; }
.lr-live .lr-link:nth-of-type(6) .lr-pulse { animation-delay: 0.7s; }
.lr-live .lr-link:nth-of-type(8) .lr-pulse { animation-delay: 1.05s; }

/* A Pi-Star cross-mode bridge on the way: dashed, as a hop of our own */
.lr-node-bridge { border-top-style: dashed; flex-grow: 0.75; }

/* Live: the hotspot glows; the stops' tops shine */
.lr-live .lr-node-hotspot {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--lr-c) 40%, transparent), 0 0 18px -2px color-mix(in srgb, var(--lr-c) 55%, transparent);
}
.lr-live .lr-node-hotspot .lr-icon { animation: lr-breathe 1.4s ease-in-out infinite; }

/* Past: the last call, quieter */
.lr-past .lr-node { opacity: 0.72; filter: saturate(0.6); }

@keyframes lr-flow { to { background-position: 11px 0; } }
@keyframes lr-run {
    0% { left: -4px; opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { left: calc(100% - 6px); opacity: 0; }
}
@keyframes lr-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}
@keyframes lr-beacon {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ps-danger) 70%, transparent); }
    100% { box-shadow: 0 0 0 0.5rem transparent; }
}

/* Lane sizes (both timeslots): half while both are busy; once one has
   been quiet 30 s, the latest is full size and the quiet one slim */
.lr-lanes { gap: 0.6rem; }
.lr-size-half .lr-lane-head { margin-bottom: 0.15rem; }
.lr-size-half .lr-node { padding: 0.45rem 0.65rem 0.5rem; border-radius: 0.5rem; }
.lr-size-half .lr-icon { width: 1.2rem; height: 1.2rem; margin-bottom: 0.05rem; }
.lr-size-half .lr-label { font-size: 0.65rem; }
.lr-size-half .lr-title { font-size: 1rem; margin-top: 0.05rem; }
.lr-size-half .lr-sub { font-size: 0.75rem; margin-top: 0.1rem; }
.lr-size-half .lr-stats { margin-top: 0.3rem; }
.lr-size-half .lr-route { padding: 0.1rem 0; }

/* Slim: one line of names, the rest put away. The links keep their
   width at every size, so a lane's boxes line up with the others' */
.lr-size-slim .lr-lane-head { margin-bottom: 0.1rem; }
.lr-size-slim .lr-lane-name, .lr-size-slim .lr-state { font-size: 0.72rem; }
.lr-size-slim .lr-route { padding: 0; }
.lr-size-slim .lr-node { padding: 0.25rem 0.55rem; border-top-width: 2px; border-radius: 0.4rem; box-shadow: none; }
.lr-size-slim .lr-icon, .lr-size-slim .lr-label, .lr-size-slim .lr-sub, .lr-size-slim .lr-stats { display: none; }
/* One line: the ID gives way before the callsign */
.lr-size-slim .lr-title { font-size: 0.85rem; margin-top: 0; flex-wrap: nowrap; }
.lr-size-slim .lr-title .lr-name { flex-shrink: 0; max-width: 100%; white-space: nowrap; }
.lr-size-slim .lr-title .flag { transform: none; }

/* Narrow screens: the route runs down, as a compact timeline: each stop
   a row (its icon, then its label, name and detail), the links a short
   line between the icons, all in one box rather than a tall box each */
@media (max-width: 860px) {
    .lr-route {
        flex-direction: column;
        padding: 0.45rem 0.7rem;
        border: 1px solid var(--ps-border);
        border-top: 3px solid var(--lr-c);
        border-radius: 0.6rem;
        background:
            linear-gradient(180deg, color-mix(in srgb, var(--lr-c) 8%, transparent), transparent 60%),
            var(--ps-bg-secondary);
    }
    .lr-node,
    .lr-size-half .lr-node {
        display: grid;
        grid-template-columns: 1.5rem minmax(0, 1fr);
        column-gap: 0.65rem;
        align-items: start;
        padding: 0.2rem 0;
        border: 0;
        border-radius: 0;
        background: none;
        box-shadow: none;
    }
    .lr-node-bridge { border-top-style: none; }
    .lr-icon,
    .lr-size-half .lr-icon {
        grid-row: 1 / span 4;
        width: 1.5rem;
        height: 1.5rem;
        margin: 0.1rem 0 0;
    }
    .lr-label, .lr-title, .lr-sub, .lr-stats { grid-column: 2; }
    .lr-label { font-size: 0.65rem; }
    .lr-title { font-size: 1rem; margin-top: 0; }
    .lr-sub { font-size: 0.78rem; margin-top: 0.05rem; }
    .lr-stats { margin-top: 0.25rem; }
    /* Live: the hotspot's icon glows instead of its box */
    .lr-live .lr-node-hotspot { box-shadow: none; }
    .lr-live .lr-node-hotspot .lr-icon {
        border-radius: 50%;
        box-shadow: 0 0 12px 1px color-mix(in srgb, var(--lr-c) 55%, transparent);
    }
    .lr-past .lr-node { opacity: 0.8; }

    /* The links: a short dashed line down from one icon to the next */
    .lr-link {
        flex: 0 0 0.7rem;
        width: 2px;
        height: auto;
        align-self: flex-start;
        margin: 0 0 0 calc(0.75rem - 1px);
        background: repeating-linear-gradient(180deg,
            color-mix(in srgb, var(--lr-c) 60%, transparent) 0 4px,
            transparent 4px 7px);
        background-size: 2px 7px;
    }
    .lr-live .lr-link { animation-name: lr-flow-down; }
    .lr-pulse { width: 6px; height: 6px; left: 50%; top: 0; margin: 0 0 0 -3px; box-shadow: 0 0 6px 1px var(--lr-c); }
    .lr-live .lr-pulse { animation-name: lr-run-down; }
    @keyframes lr-flow-down { to { background-position: 0 7px; } }
    @keyframes lr-run-down {
        0% { top: -3px; opacity: 0; }
        15% { opacity: 1; }
        85% { opacity: 1; }
        100% { top: calc(100% - 3px); opacity: 0; }
    }

    /* Both timeslots busy: the label lines go, each stop one or two lines */
    .lr-size-half .lr-route { padding: 0.3rem 0.6rem; }
    .lr-size-half .lr-label { display: none; }
    .lr-size-half .lr-icon { grid-row: 1 / span 3; width: 1.2rem; height: 1.2rem; }
    .lr-size-half .lr-node { grid-template-columns: 1.2rem minmax(0, 1fr); padding: 0.1rem 0; }
    .lr-size-half .lr-link { flex-basis: 0.4rem; margin-left: calc(0.6rem - 1px); }

    /* Slim (a quiet timeslot): its stops' names on one line, joined by
       short dashes */
    .lr-size-slim .lr-route {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        row-gap: 0.1rem;
        padding: 0.25rem 0.55rem;
        border-top-width: 2px;
    }
    .lr-size-slim .lr-node { display: block; padding: 0; flex: 0 1 auto; }
    .lr-size-slim .lr-title { font-size: 0.8rem; }
    .lr-size-slim .lr-link {
        flex: 0 0 0.9rem;
        height: 2px;
        width: auto;
        align-self: center;
        margin: 0 0.25rem;
        background: repeating-linear-gradient(90deg,
            color-mix(in srgb, var(--lr-c) 60%, transparent) 0 3px,
            transparent 3px 5px);
        background-size: 5px 2px;
    }
    .lr-size-slim .lr-pulse { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .lr-live .lr-link, .lr-live .lr-pulse, .lr-live .lr-node-hotspot .lr-icon, .lr-state-live::before {
        animation: none;
    }
    .lr-live .lr-pulse { opacity: 1; left: calc(50% - 5px); }
}
