/* Monitor > Latency (alignvu UI v2.1). Markup: application/views/align_to/monitor_regulator_aggregator_latency.php,
   landingpage/latency_key.php and js/modules/monitor/latency/render.js.
   Each day is a band: the date, then per regulator change set the regulator's card with a branch line to a card per
   aggregator or connector. The branch is drawn here (no script): a tick from the regulator's card, a vertical line
   down the targets, and a tick with an arrowhead into each target, all at --lat-tick from the top of a card.
   Connectors have a column of their own after the aggregators; then the aggregator column sits --lat-drop lower and
   the regulator's line runs above it to the connectors, dropping down into the aggregators on the way.
   Timing colours follow the StatusBar component: earlier is a darker grey (previous month ink-grey, previous week and
   previous day the audit greys), same day on time (status-new), next day / week / month late (status-late), not seen
   removed (status-removed). */

.monitor-regulator-aggregator-latency {
    --lat-tick: 24px;
    --lat-line: var(--muted);
    --lat-gap: 12px;
    --lat-drop: 44px;
}

/* ---------- header: two rows (landingpage/tabs_header.php), "Changes" and the period on the right, then the timing
   key on the right */
.monitor-regulator-aggregator-latency .app-monitor-bar__period {
    margin-left: auto;
}

.dataflow-landing .changes-container .app-lat-key {
    gap: 6px;
}

.app-lat-badge--previousMonth::before { background: var(--ink-grey); }
.app-lat-badge--previousWeek::before { background: var(--audit-prev-week); }
.app-lat-badge--previousDay::before { background: var(--audit-prev-day); }
.app-lat-badge--sameDay::before { background: var(--status-new); }
.app-lat-badge--nextDay::before,
.app-lat-badge--nextWeek::before,
.app-lat-badge--nextMonth::before { background: var(--status-late); }
.app-lat-badge--notSeen::before { background: var(--status-removed); }

/* ---------- day bands */
.app-lat {
    margin-top: 8px;
}

.app-lat-day {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    column-gap: 16px;
    padding: 16px 8px;
    border-top: 1px solid var(--row-rule);
}

.app-lat-day:first-child {
    border-top: 0;
}

.app-lat-day:hover {
    background: var(--fill);
}

.app-lat-day__date {
    padding-top: 12px;
    font: 500 13px/18px var(--font-display);
    color: var(--heading-ink);
    font-variant-numeric: tabular-nums;
}

.app-lat-day__flows {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.app-lat-message {
    margin: 12px 0 0;
    font: 400 13px/18px var(--font-display);
    color: var(--body-ink);
}

/* ---------- one flow: regulator card | branch | target cards (| connector cards) */
.app-lat-flow {
    display: grid;
    grid-template-columns: minmax(200px, 280px) minmax(280px, 540px);
    align-items: start;
}

.app-lat-flow--both {
    grid-template-columns: minmax(200px, 260px) minmax(240px, 1fr) minmax(240px, 1fr);
}

.app-lat-source {
    position: relative;
    padding-right: 24px;
}

/* tick out of the regulator's card */
.app-lat-source::after {
    content: "";
    position: absolute;
    top: var(--lat-tick);
    right: 0;
    width: 24px;
    border-top: 2px solid var(--lat-line);
}

.app-lat-flow--alone .app-lat-source::after {
    display: none;
}

.app-lat-targets {
    display: flex;
    flex-direction: column;
    gap: var(--lat-gap);
    min-width: 0;
}

.app-lat-target {
    position: relative;
    padding-left: 28px;
}

/* vertical line down the targets: from the first target's tick to the last one's, through the gaps between */
.app-lat-target::before {
    content: "";
    position: absolute;
    left: 0;
    top: calc(var(--lat-gap) / -2);
    bottom: calc(var(--lat-gap) / -2);
    border-left: 2px solid var(--lat-line);
}

.app-lat-target:first-child::before {
    top: var(--lat-tick);
}

.app-lat-target:last-child::before {
    bottom: auto;
    height: calc(var(--lat-tick) + var(--lat-gap) / 2 + 2px);
}

.app-lat-target:first-child:last-child::before {
    display: none;
}

/* aggregators beside connectors: the column sits lower, the regulator's line crosses above it to the connectors and
   the aggregators' vertical line drops from it */
.app-lat-flow--both .app-lat-targets--aggregator {
    position: relative;
    padding-top: var(--lat-drop);
    padding-right: 24px;
}

.app-lat-flow--both .app-lat-targets--aggregator::after {
    content: "";
    position: absolute;
    top: var(--lat-tick);
    left: 0;
    right: 0;
    border-top: 2px solid var(--lat-line);
}

.app-lat-flow--both .app-lat-targets--aggregator .app-lat-target:first-child::before {
    top: calc(var(--lat-tick) - var(--lat-drop));
}

.app-lat-flow--both .app-lat-targets--aggregator .app-lat-target:first-child:last-child::before {
    display: block;
    bottom: auto;
    height: calc(var(--lat-drop) + 2px);
}

/* tick into each target */
.app-lat-target::after {
    content: "";
    position: absolute;
    top: var(--lat-tick);
    left: 0;
    width: 22px;
    border-top: 2px solid var(--lat-line);
}

/* ---------- cards */
.app-lat-card {
    position: relative;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    font: 400 13px/18px var(--font-display);
    color: var(--body-ink);
}

/* arrowhead where the tick meets a target card */
.app-lat-target .app-lat-card::before {
    content: "";
    position: absolute;
    left: -7px;
    top: calc(var(--lat-tick) - 5px);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid var(--lat-line);
}

.app-lat-card__name {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-weight: 500;
    color: var(--heading-ink);
}

.app-lat-card__kind {
    flex: none;
    font: 500 11px/16px var(--font-display);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-lat-card__provider,
.app-lat-card__where {
    color: var(--muted);
}

.app-lat-card__where {
    font-size: 12px;
}

.app-lat-card__changes {
    margin-top: 10px;
    color: var(--body-ink);
}

.app-lat-card__changes strong {
    font: 600 20px/24px var(--font-display);
    color: var(--heading-ink);
    font-variant-numeric: tabular-nums;
}

.app-lat-card__picked {
    margin-top: 10px;
}

.app-lat-card__picked strong {
    font-weight: 600;
    color: var(--heading-ink);
}

.app-lat-card__missed {
    color: var(--status-removed);
    font-weight: 500;
}

/* the timing bar: StatusBar on a fill track, a hairline of white between parts */
.app-lat-bar {
    margin: 6px 0 10px;
}

.app-lat-bar > span + span {
    border-left: 2px solid var(--surface);
}

.av-bar .is-prev-month { background: var(--ink-grey); }
.av-bar .is-prev-week { background: var(--audit-prev-week); }
.av-bar .is-prev-day { background: var(--audit-prev-day); }

.app-lat-card__pills + .app-lat-card__pills {
    margin-top: 6px;
}

.app-lat-card__pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.app-lat-card__pills strong,
.app-lat-chip strong {
    font-weight: 600;
}

button.app-lat-badge,
button.app-lat-chip {
    font: inherit;
    cursor: pointer;
}

.app-lat-card__pills .app-lat-badge {
    font: 500 12px/16px var(--font-display);
}

button.app-lat-badge:hover,
button.app-lat-chip:hover {
    background: var(--fill);
}

button.app-lat-badge:focus-visible,
button.app-lat-chip:focus-visible {
    outline: 2px solid var(--heading-ink);
    outline-offset: 1px;
}

/* same-day pick-ups by hour, after the Same day pill */
.app-lat-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    font: 400 12px/16px var(--font-display);
    color: var(--body-ink);
    font-variant-numeric: tabular-nums;
}

.app-lat-empty {
    margin: 24px 8px;
}
