/* Critical Alerts to Action product page. Builds on site.css and the shared product page pieces in time.css.
   Colour roles: blue is the sensor reading and the response being sent, amber is the alarm itself,
   red is a check that failed, and green is work done or an alarm cleared. */

/* Alarm figure */

.alarm {
    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;
}

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

.alarm-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.alarm-pill {
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    background: var(--verified-soft);
    color: var(--verified);
}

.alarm-pill[data-state="watching"] {
    background: var(--signal-soft);
    color: var(--signal);
}

.alarm-pill[data-state="alarm"] {
    background: var(--escalate);
    color: var(--surface);
}

.alarm-chart {
    display: block;
    width: 100%;
    height: auto;
    padding: 10px 14px 0;
}

.alarm-chart .grid {
    stroke: var(--line);
    stroke-width: 1;
}

.alarm-chart .axis-x,
.alarm-chart .axis-y {
    fill: var(--ink-soft);
    font-size: 11px;
}

.alarm-chart .axis-x {
    text-anchor: middle;
}

.alarm-chart .threshold {
    stroke: var(--escalate);
    stroke-width: 1.5;
    stroke-dasharray: 5 5;
}

.alarm-chart .threshold-label {
    fill: var(--escalate);
    font-size: 11px;
    font-weight: 700;
    text-anchor: end;
}

.alarm-chart .temp {
    fill: none;
    stroke: var(--signal);
    stroke-width: 3;
    stroke-linejoin: round;
    stroke-linecap: round;
}

/* The power cut, before the compressor failed to restart */
.alarm-chart .outage {
    fill: var(--lapsed-soft);
}

.alarm-chart .outage-label {
    fill: var(--ink-soft);
    font-size: 10px;
    font-weight: 600;
    text-anchor: middle;
}

/* The ten minutes the reading had to hold before the alarm */
.alarm-chart .sustain {
    fill: var(--signal-soft);
}

.alarm-chart .band {
    fill: var(--escalate-soft);
}

/* The response timeline */

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

.rs {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    column-gap: 12px;
    align-items: center;
    padding: 7px 22px;
    font-size: 0.86rem;
    transition: opacity 0.35s ease;
}

.rs.is-pending {
    opacity: 0;
}

.rs-what {
    display: flex;
    flex-direction: column;
    font-weight: 600;
}

.rs-detail {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--ink-soft);
}

.rs-time {
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.rs-mark {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--verified);
}

.rs-alarm .rs-mark {
    background: var(--escalate);
}

.rs-send .rs-mark {
    background: var(--signal);
}

.rs-fail {
    background: var(--stop-soft);
}

.rs-fail .rs-mark {
    background: var(--stop);
}

.rs-clear .rs-mark {
    box-shadow: 0 0 0 3px var(--verified-soft);
}

/* Alarm flow, as built in Flows */

.rule {
    display: grid;
    gap: 0;
    padding: 24px;
    border-radius: var(--radius-lg);
    background: var(--signal-soft);
}

.rule-step {
    position: relative;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    border-left: 4px solid var(--signal);
    background: var(--surface);
}

.rule-step + .rule-step {
    margin-top: 22px;
}

/* Connector between steps */
.rule-step + .rule-step::before {
    content: "";
    position: absolute;
    left: 28px;
    top: -23px;
    width: 2px;
    height: 22px;
    background: var(--signal);
}

.rule-when,
.rule-escalate {
    border-left-color: var(--escalate);
}

.rule-kind {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.rule-title {
    font-weight: 650;
}

.rule-detail {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.rule-outcomes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.rule-outcomes p {
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--verified-soft);
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.rule-outcomes b {
    color: var(--verified);
    font-size: 0.85rem;
}

.rule-outcomes p.is-fail {
    background: var(--stop-soft);
}

.rule-outcomes p.is-fail b {
    color: var(--stop);
}

/* An issue still in progress, on top of the shared issue card in time.css */

.issue-state.is-progress {
    background: var(--signal);
}

/* Sensors */

.sensors-section {
    padding-top: var(--space-section);
}

.sensors {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
}

.sensors li {
    padding: 26px 22px 28px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.sensors p {
    margin-top: 6px;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.uses-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
}

.uses-list li {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 0.92rem;
    font-weight: 500;
}

/* Responsive */

@media (max-width: 1080px) {
    .sensors {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .sensors {
        grid-template-columns: minmax(0, 1fr);
    }

    .rule-outcomes {
        grid-template-columns: minmax(0, 1fr);
    }

    .rs {
        padding: 7px 16px;
    }

    .alarm-head {
        padding-left: 16px;
        padding-right: 16px;
    }
}
