/* Guard & Security Patrols page. Builds on site.css and the shared product page pieces in time.css.
   Colour roles: green is a checkpoint verified, blue is the next checkpoint and the guard,
   red is the failed door check itself, and amber is the issue it opened or a missed checkpoint. */

/* Patrol map figure */

.patrolmap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 0 var(--line), 0 24px 48px -24px rgba(20, 33, 61, 0.28);
    overflow: hidden;
}

.patrol-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.map-stage {
    position: relative;
    margin: 16px 22px 8px;
}

.map-svg {
    width: 100%;
    height: auto;
}

.map-wall {
    fill: var(--base);
    stroke: var(--ink-soft);
    stroke-width: 2;
}

.map-block {
    fill: var(--surface);
    stroke: var(--line);
    stroke-width: 2;
}

.map-room {
    fill: none;
    stroke: var(--line);
    stroke-width: 1.5;
}

.map-label {
    fill: var(--ink-soft);
    font-size: 13px;
    text-anchor: middle;
}

.map-door {
    fill: var(--stop);
}

.route {
    fill: none;
    stroke: var(--line);
    stroke-width: 3;
    stroke-dasharray: 5 7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.route-walked {
    fill: none;
    stroke: var(--verified);
    stroke-width: 4;
    stroke-dasharray: 850;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.officer {
    fill: var(--signal);
    stroke: var(--surface);
    stroke-width: 3;
}

.checkpoints {
    position: absolute;
    inset: 0;
}

.cp {
    position: absolute;
    transform: translate(-50%, -50%);
}

.cp span {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 0.75rem;
    font-weight: 700;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.cp.is-done span {
    border-color: var(--verified);
    background: var(--verified);
    color: var(--surface);
}

.cp.is-next span {
    border-color: var(--signal);
    color: var(--signal);
    box-shadow: 0 0 0 5px var(--signal-soft);
}

.cp.is-failed span {
    border-color: var(--stop);
    background: var(--stop);
    color: var(--surface);
    box-shadow: 0 0 0 5px var(--stop-soft);
}

/* The round, row by row */

.round {
    padding: 6px 0;
    border-top: 1px solid var(--line);
}

.round-row {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr) auto 46px;
    align-items: center;
    column-gap: 12px;
    padding: 7px 22px;
    font-size: 0.88rem;
    transition: background-color 0.3s ease;
}

.round-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--line);
}

.round-name {
    font-weight: 600;
}

.round-status {
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.round-time {
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    text-align: right;
}

.round-note {
    grid-column: 2 / -1;
    margin-top: 2px;
    font-size: 0.8rem;
    font-weight: 600;
}

.round-note:empty {
    display: none;
}

.round-row.is-done .round-dot {
    border-color: var(--verified);
    background: var(--verified);
}

.round-row.is-next .round-dot {
    border-color: var(--signal);
}

.round-row.is-next .round-status {
    color: var(--signal);
    font-weight: 600;
}

.round-row.is-pending .round-name,
.round-row.is-pending .round-status {
    opacity: 0.45;
}

.round-row.is-pending .round-time,
.round-row.is-next .round-time {
    visibility: hidden;
}

/* The failed door check: a red cross on the dot, so the state doesn't rely on colour alone */
.round-row.is-failed {
    background: var(--stop-soft);
}

.round-row.is-failed .round-dot {
    position: relative;
    border-color: var(--stop);
    background: var(--stop);
}

.round-row.is-failed .round-dot::before,
.round-row.is-failed .round-dot::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 8px;
    height: 2px;
    margin: -1px 0 0 -4px;
    background: var(--surface);
    transform: rotate(45deg);
}

.round-row.is-failed .round-dot::after {
    transform: rotate(-45deg);
}

.round-row.is-failed .round-status {
    color: var(--stop);
    font-weight: 700;
}

.round-row.is-failed .round-note {
    color: var(--escalate);
}

.round-summary {
    padding: 12px 22px;
    border-top: 1px solid var(--line);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--verified);
}

.round-summary.is-live {
    color: var(--ink-soft);
}

.round-summary.is-alert {
    color: var(--stop);
}

/* Live console */

.console-rows li {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}

.console-rows li:last-child {
    border-bottom: 0;
}

.console-rows li.is-issue,
.console-rows li.is-missed {
    background: var(--escalate-soft);
}

.console-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.console-top .who {
    font-weight: 600;
}

.console-bar {
    height: 6px;
    margin: 10px 0 8px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.console-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--verified);
}

.is-missed .console-bar span {
    background: var(--escalate);
}

.console-meta {
    font-size: 0.82rem;
    color: var(--ink-soft);
}

.state.is-issue,
.state.is-missed {
    background: var(--escalate);
    color: var(--surface);
}

/* Responsive */

@media (max-width: 640px) {
    .map-stage {
        margin: 12px 12px 6px;
    }

    .cp span {
        width: 22px;
        height: 22px;
        font-size: 0.7rem;
    }

    .round-row {
        padding: 7px 16px;
        grid-template-columns: 16px minmax(0, 1fr) 46px;
    }

    .round-status {
        grid-column: 2;
        grid-row: 2;
    }

    .round-time {
        grid-column: 3;
        grid-row: 1;
    }

    .round-note {
        grid-row: 3;
    }

    .patrol-head,
    .round-summary {
        padding-left: 16px;
        padding-right: 16px;
    }
}
