/* Incidents TV / wall view — a responsive grid of incident cards, styled in the spirit of the
   resources board. Each card is one active Event: a header of headline facts (status colour on
   top, agency colour on the left bar) over a body listing the vehicles in attendance, grouped by
   agency on a multi-agency job. Theme-aware (Bootstrap vars) so it works on a light or dark wall;
   the vehicle status (.st-*) and capability (.cap*) colours come from board.css. */

/* ── Page shell — fills the viewport; only the card grid scrolls ─────────────── */
.tv-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height));
    padding: 0.45rem 0.6rem;
    gap: 0.4rem;
}

/* ── Toolbar (search · status · agency · region · type · sort) ───────────────── */
.tv-toolbar {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 0.4rem; flex: 0 0 auto;
}
.tv-toolbar .tv-search { flex: 1 1 14rem; min-width: 11rem; max-width: 22rem; }
.tv-toolbar .tv-select { width: auto; min-width: 8rem; max-width: 14rem; }
.tv-sort-label {
    font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.03em; color: var(--bs-secondary-color); margin: 0;
}

/* ── Scroll area + card grid ────────────────────────────────────────────────── */
.tv-scroll {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto; overflow-x: hidden;
}
.tv-summary {
    font-size: 0.7rem; color: var(--bs-secondary-color);
    padding: 1px 2px 5px;
}
.tv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.6rem;
    align-items: start;
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.tv-card {
    display: flex;
    flex-direction: column;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-left: 4px solid var(--agency, var(--bs-border-color));
    border-top: 5px solid var(--status, var(--bs-secondary));
    border-radius: 6px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.12s ease, transform 0.12s ease;
}
.tv-card:hover {
    box-shadow: 0 0.35rem 0.9rem rgba(0, 0, 0, 0.18);
    transform: translateY(-1px);
    color: inherit;
}

.tv-card-head {
    padding: 0.45rem 0.6rem 0.5rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}
.tv-type {
    font-size: 1.02rem; font-weight: 700; line-height: 1.15;
    text-transform: uppercase; letter-spacing: 0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tv-loc {
    margin-top: 0.15rem; font-size: 0.82rem; line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tv-street { color: var(--bs-secondary-color); }

/* Operator's free-typed note on the card — up to 2 lines, then ellipsis; full note on hover. */
.tv-desc {
    margin-top: 0.2rem;
    font-size: 0.74rem; line-height: 1.2;
    color: var(--bs-secondary-color);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; overflow-wrap: anywhere;
}

.tv-meta {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 0.25rem 0.4rem; margin-top: 0.4rem;
}
.tv-meta .badge { font-size: 0.66rem; }
.tv-chip {
    font-size: 0.64rem; font-weight: 700; border-radius: 0.25rem;
    padding: 0.05rem 0.4rem; line-height: 1.4;
}
.tv-agency-chip {
    background: color-mix(in srgb, var(--agency) 22%, var(--bs-tertiary-bg));
    border-left: 3px solid var(--agency);
    color: var(--bs-body-color); letter-spacing: 0.02em;
}
.tv-din {
    font-family: var(--bs-font-monospace, monospace);
    background: var(--bs-secondary-bg); color: var(--bs-secondary-color);
}
.tv-dot {
    display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%;
    background: var(--agency, var(--bs-secondary)); vertical-align: middle;
}
.tv-time, .tv-stale {
    font-size: 0.68rem; color: var(--bs-secondary-color); white-space: nowrap;
    display: inline-flex; align-items: center; gap: 0.2rem;
}
.tv-stale { margin-left: auto; }
.tv-stale .stale-timer { font-weight: 600; }

/* ── Card body — vehicles in attendance ─────────────────────────────────────── */
.tv-card-body { padding: 0.45rem 0.5rem; }

/* Vehicles are listed VERTICALLY (one row each), grouped by their Group. Row background = the
   vehicle's live status (.st-* from board.css). */
.tv-vrow {
    display: flex; align-items: center; gap: 0.3rem;
    font-size: 0.76rem; line-height: 1.3; font-weight: 600;
    padding: 0.12rem 0.4rem; border-radius: 0.25rem; margin-bottom: 2px;
}
.tv-vrow-time { margin-left: auto; font-size: 0.64rem; font-weight: 500; opacity: 0.9; }
.tv-vrow-lead {
    font-size: 0.56rem; font-weight: 800; letter-spacing: 0.04em; padding: 0 0.2rem;
    border: 1px solid currentColor; border-radius: 0.2rem; opacity: 0.85;
}
.tv-noveh { font-size: 0.72rem; font-style: italic; color: var(--bs-secondary-color); }

/* Group sub-heading within a leg (e.g. STIRLING GROUP), then its vehicles below. */
.tv-grp { margin-bottom: 0.3rem; }
.tv-grp:last-child { margin-bottom: 0; }
.tv-grp-head {
    font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--bs-secondary-color); margin: 0.15rem 0 0.1rem;
}

/* Strike-team block inside a card — blue frame, its member vehicles listed vertically. */
.tv-stblock {
    border: 1.5px solid #2f7fe0; border-radius: 0.3rem;
    background: rgba(47, 127, 224, 0.10); padding: 0 0.25rem 0.2rem;
    margin-bottom: 0.35rem;
}
.tv-stblock-head {
    font-size: 0.64rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em;
    color: #1c5fb0; padding: 0.18rem 0.15rem;
}
.tv-stblock .tv-stnum { font-family: monospace; }
.tv-stblock .tv-sttask { font-weight: 700; opacity: 0.85; }

/* Multi-agency: one sub-group per attending agency, identified by its colour. */
.tv-agency-group {
    border-left: 3px solid var(--agency);
    padding-left: 0.4rem;
    margin-bottom: 0.45rem;
}
.tv-agency-group:last-child { margin-bottom: 0; }
.tv-agency-head {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.35rem;
    margin-bottom: 0.25rem;
}
.tv-agency-head .badge { font-size: 0.62rem; }
.tv-agency-code {
    font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em;
    color: color-mix(in srgb, var(--agency) 70%, var(--bs-body-color));
}
.tv-agency-count {
    font-size: 0.62rem; font-weight: 700; background: var(--bs-secondary-bg);
    color: var(--bs-secondary-color); border-radius: 0.7rem;
    padding: 0 0.4rem; min-width: 1.2rem; text-align: center; margin-left: auto;
}

/* ── Empty state ────────────────────────────────────────────────────────────── */
.tv-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; color: var(--bs-secondary-color);
    padding: 4rem 1rem; gap: 0.6rem;
}
.tv-empty .bi { font-size: 2.6rem; opacity: 0.6; }
.tv-empty p { font-size: 1rem; }
