/* Alerts (views/alerts.js): how you are told, the feed, ready-made alerts, the rules and the form. */

/* How you are told: one line, the detail folded beneath it. */
.alert-delivery { margin-bottom: var(--space-6); padding: var(--space-4) var(--space-5); }
.alert-delivery-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); }
.card.alert-delivery .alert-delivery-head > h2 { margin: 0; font: 700 var(--step--2)/1.3 var(--font-text); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.alert-delivery-summary { margin: 0; font-size: var(--step-0); color: var(--ink); max-width: none; }
.alert-delivery-more { margin-top: var(--space-1); font-size: var(--step--1); }
.alert-delivery-more > summary { cursor: pointer; color: var(--accent-ink); font-weight: 650; min-height: 24px; padding: 2px 0; display: list-item; }
.alert-delivery-more[open] > summary { margin-bottom: var(--space-2); }
.alert-delivery-list { margin: 0; padding-left: 18px; display: grid; gap: var(--space-2); max-width: var(--measure); }
.alert-delivery-admin { margin: var(--space-3) 0 0; font-size: var(--step--1); max-width: var(--measure); }

/* The groups: one control of four, each with its count as a badge (the brackets are for screen
   readers). The chosen one is raised, bold and underlined, as in every segmented control. */
.alert-groups {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin: 0 0 var(--space-3); padding: 3px;
  border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--surface-2);
}
.alert-groups button {
  display: inline-flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px var(--space-2); min-height: 44px; padding: 6px var(--space-3);
  border: 0; border-radius: 5px; background: transparent; cursor: pointer; font-size: var(--step--1); font-weight: 600; color: var(--ink-2); text-align: center; line-height: 1.25;
}
.alert-groups button:hover { color: var(--ink); background: color-mix(in srgb, var(--raised) 55%, transparent); }
.alert-groups button[aria-pressed="true"] { background: var(--raised); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-1), inset 0 -2px 0 var(--accent); }
.count-badge {
  display: inline-block; min-width: 1.6em; padding: 1px 7px; border-radius: var(--radius-pill); background: var(--page); border: 1px solid var(--border);
  font-size: var(--step--2); font-weight: 650; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.count[data-new="yes"] .count-badge { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.alert-group-note { max-width: var(--measure); margin: 0 0 var(--space-4); font-size: var(--step--1); color: var(--ink-2); }
/* What close-approach reports are, before the reports: calm, in no warning colour. */
.screening-note { max-width: var(--measure); margin: 0 0 var(--space-4); }
.screening-note h2 { margin: 0 0 var(--space-1); font: 700 var(--step-0)/1.35 var(--font-text); }
.screening-note p { margin: 0 0 var(--space-2); }
.screening-note p:last-child { margin: 0; }
.visitor-note { max-width: var(--measure); margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font-size: var(--step--1); }

/* One compact bar of filters; the time zone and "mark all" at its end. */
.alert-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-5); margin: 0 0 var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--hairline); }
.alert-kind-field { width: 260px; max-width: 100%; }
.alert-unread-field { min-height: 40px; }
.alert-filters-end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-left: auto; }
.alert-times { display: flex; }
.alert-summary { margin: 0 0 var(--space-4); max-width: none; font-size: var(--step--1); color: var(--ink-2); }
.alert-summary-count { font-weight: 700; color: var(--ink); }

/* The feed: one card per alert, the kind's drawing on the left. Unread ones carry an edge, a
   "New" tag in words and a stronger title. */
.alert-list { display: grid; gap: var(--space-3); }
.alert-list > .card + .card { margin-top: 0; }
.alert {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-1) var(--space-4);
  padding: var(--space-4) var(--space-5); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.alert.unread { border-left: 4px solid var(--accent); padding-left: calc(var(--space-5) - 3px); }
.alert.screening.unread { border-left-color: var(--ink-2); }
.kind-icon {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-2);
}
.alert.unread .kind-icon { background: var(--accent-soft); color: var(--accent-ink); }
.alert.screening .kind-icon { background: var(--surface-2); color: var(--ink-2); }
.alert-main { min-width: 0; display: grid; gap: var(--space-1); }
.alert-kind { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); margin: 0; font-size: var(--step--2); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); max-width: none; }
.alert .sev { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); }
.alert .sev svg { flex: none; }
.alert .new-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--on-accent); letter-spacing: 0.04em;
}
.alert.screening .new-tag { background: var(--ink-2); color: var(--surface); }
.alert h3.title { margin: 0; font-size: var(--step-0); font-weight: 600; line-height: 1.4; }
.alert.unread h3.title { font-weight: 700; }
.alert h3.title a { color: var(--ink); text-decoration-color: color-mix(in srgb, var(--ink) 35%, transparent); }
.alert h3.title a:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
.alert p.body { margin: 0; color: var(--ink-2); font-size: var(--step--1); line-height: 1.5; max-width: 80ch; }
.alert .meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-4); margin-top: var(--space-1); font-size: var(--step--1); color: var(--muted); }
.alert-when { display: inline-flex; flex-wrap: wrap; gap: 0 var(--space-2); align-items: baseline; }
.alert-when time { font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.alert-when-exact { font-size: var(--step--2); color: var(--muted); }
.alert .mark-read { margin-left: auto; height: 32px; padding: 0 var(--space-3); color: var(--accent-ink); }
/* What takes the place of "Mark read" once it has worked. */
.read-done { margin-left: auto; font-size: var(--step--1); font-weight: 650; color: var(--ink-2); }
.alert-list > .card.empty { padding: 0; margin: 0; width: 100%; }
.alert-more { margin-top: var(--space-5); text-align: center; }

/* Ready-made alerts: a card each, its state in a word at the top, one clear button. */
.ready-made { margin-bottom: var(--space-10); }
.ready-made > h2, .rules-in-use > h2 { margin-bottom: var(--space-1); }
/* Two by two on a wide screen (there are four), one column on a phone. */
.ready-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); }
.ready-grid > .card + .card { margin-top: 0; }
.ready-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.ready-card.on { background: var(--surface); }
.ready-card.absent { border-style: dashed; border-color: var(--border); box-shadow: none; }
.ready-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.ready-card h3 { font: 600 var(--step-1)/1.3 var(--font-display); }
.ready-card p { margin: 0; }
.ready-what { font-size: var(--step--1); color: var(--ink-2); }
.ready-overlap { font-size: var(--step--1); color: var(--ink-2); padding-left: var(--space-3); border-left: 3px solid var(--hairline); }
.ready-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; padding-top: var(--space-3); border-top: 1px solid var(--hairline); }
.ready-actions .btn { height: 44px; padding: 0 var(--space-5); }
.ready-status { font-size: var(--step--1); font-weight: 650; color: var(--ink); }
.ready-status.absent, .ready-status.off { font-weight: 500; color: var(--ink-2); }

/* Rules in use: rows in one card, the switch first, the actions last. */
.rules-in-use { margin-bottom: var(--space-10); }
.rule-list { padding: 0; }
.rule { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-1) var(--space-5); align-items: start; padding: var(--space-4) var(--space-5); border-top: 1px solid var(--hairline); }
.rule:first-child { border-top: 0; }
.rule .switch { margin-top: 2px; }
.rule-text { display: grid; gap: 2px; min-width: 0; }
.rule-text h3 { display: flex; align-items: center; gap: var(--space-2); font-size: var(--step-0); line-height: 1.35; }
.rule-text h3 .kind-icon { width: 28px; height: 28px; }
.rule-text h3 .kind-icon svg { width: 16px; height: 16px; }
.rule .desc { margin: 0; color: var(--ink-2); font-size: var(--step--1); max-width: var(--measure); }
.rule .summary { margin: 0; font-size: var(--step--2); color: var(--muted); }
.rule.is-off .rule-text { opacity: 0.72; }
.rule-actions { display: flex; gap: var(--space-2); }
.rule-state { margin-top: 2px; }

/* The rule form: every field has its help line beneath it, so fields line up at the top. */
.rule-form-section { margin-top: var(--space-2); }
.rule-form { display: grid; gap: var(--space-4) var(--space-5); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; margin-top: var(--space-4); }
.rule-form .full { grid-column: 1 / -1; }
.rule-form fieldset.object-types { border: 0; padding: 0; margin: 0; }
.rule-form fieldset.object-types legend { font-size: var(--step--1); font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: var(--space-2); }
.object-type-choices { display: flex; gap: var(--space-2) var(--space-5); flex-wrap: wrap; }
.alerts-page .form-msg { margin: var(--space-4) 0 0; max-width: var(--measure); padding: var(--space-3) var(--space-4); border-left: 4px solid var(--critical); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font-weight: 600; }
.alerts-page .form-msg:empty { display: none; }

@media (max-width: 900px) {
  .alert-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .alert-delivery { padding: var(--space-3) var(--space-4); }
  .alert-filters-end { margin-left: 0; width: 100%; justify-content: space-between; }
  .alert-filters { gap: var(--space-3) var(--space-4); }
  .alert-kind-field { flex: 1 1 180px; width: auto; }
  .alert { column-gap: var(--space-3); padding: var(--space-4); }
  .alert.unread { padding-left: calc(var(--space-4) - 3px); }
  .alert > .kind-icon { width: 32px; height: 32px; }
  .alert > .kind-icon svg { width: 18px; height: 18px; }
  .rule { grid-template-columns: auto minmax(0, 1fr); padding: var(--space-4); }
  .rule-actions { grid-column: 2; }
}
