/* Bellwethers page (js/views/bellwethers.js). Owner: the alerts module agent.
   Loaded after app.css. Every class carries the .bw- prefix; shared components (.card, .btn, .seg-toggle, .chip, .tag, .meter, .kpis,
   table.data, .m-D/.m-R) and variables come from app.css. Margin and swing colours come from js/core/colors.js through the
   shared marginSpan/swingSpan helpers, never from this file. */

.bw-page {
  display: grid;
  gap: 14px;
}
.bw-intro p {
  max-width: 112ch;
  line-height: 1.5;
}
.bw-intro code,
.bw-method code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 12.5px;
}

.bw-head {
  align-items: end;
  margin-bottom: 8px;
}
.bw-views {
  align-self: center;
}
.bw-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.bw-controls .field select {
  min-width: 11em;
  max-width: 100%;
}
.bw-blurb {
  max-width: 90ch;
  margin-bottom: 10px;
  font-size: 13.5px;
  line-height: 1.45;
}
.bw-ctx {
  margin-bottom: 12px;
}
.bw-ctx .kpi-value {
  font-size: 22px;
}
.bw-ctx .kpi-sub .chip {
  vertical-align: 1px;
}

/* ---- tables --------------------------------------------------------------------------------------------------------------------- */
.bw-table .num {
  text-align: right;
}
.bw-table th.num {
  text-align: right;
}
.bw-table td {
  vertical-align: top;
}
.bw-table .bw-c-rank {
  width: 2.4em;
  color: var(--muted);
}
.bw-table .bw-c-score {
  min-width: 82px;
}
.bw-c-county {
  min-width: 170px;
}
.bw-cname {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 650;
}
.bw-cname a {
  color: var(--text);
}
.bw-exp {
  flex: none;
  width: 24px;
  height: 24px;
  margin-left: -6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.bw-exp:hover {
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text);
}
.bw-tags {
  display: block;
  margin-top: 2px;
}
.bw-tag {
  cursor: help;
}
.bw-score {
  display: grid;
  gap: 3px;
  min-width: 70px;
}
.bw-score b {
  font-variant-numeric: tabular-nums;
}
.bw-in {
  display: block;
  white-space: nowrap;
}
.bw-in .meter {
  margin-left: auto;
  max-width: 70px;
}
.bw-gap {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.bw-gap-D {
  color: var(--d);
}
.bw-gap-R {
  color: var(--r);
}
.bw-gap-even {
  color: var(--text);
}
.bw-tb.is-open > .bw-row td {
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
.bw-tb.is-suspect > .bw-row td {
  opacity: 0.8;
}
.bw-detail > td {
  padding: 4px 10px 16px 34px;
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
.bw-more {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}
.bw-note {
  max-width: 100ch;
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.45;
}
.bw-yes {
  color: var(--ok);
}
.bw-no {
  color: var(--warn);
}

/* track record */
.bw-rec {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 28px;
}
.bw-rec h3 {
  margin-bottom: 2px;
}
.bw-rec p {
  margin-bottom: 6px;
  font-size: 13px;
}
.bw-rec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.bw-rec-table th {
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.bw-rec-table td {
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}
.bw-rec-table .num {
  text-align: right;
}

/* scorecard */
.bw-score-card .bw-note {
  margin-top: 0;
  margin-bottom: 8px;
}
.bw-method summary {
  cursor: pointer;
}
.bw-method summary h2 {
  display: inline;
}
.bw-method-body {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-width: 100ch;
  font-size: 13.5px;
  line-height: 1.5;
}

/* ---- narrow screens: each county becomes a card -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .bw-table thead {
    display: none;
  }
  .bw-table,
  .bw-table tbody,
  .bw-table tr,
  .bw-table td {
    display: block;
  }
  .bw-tb {
    padding: 10px 0;
    border-top: 1px solid var(--line);
  }
  .bw-tb:first-of-type {
    border-top: 0;
  }
  .bw-table tr.bw-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px 14px;
  }
  .bw-row td {
    padding: 0;
    border: 0;
    text-align: left;
  }
  .bw-row td.num {
    text-align: left;
  }
  .bw-row td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .bw-row td.bw-c-county,
  .bw-row td.bw-c-rank {
    grid-column: 1 / -1;
  }
  .bw-row td.bw-c-county::before,
  .bw-row td.bw-c-rank::before {
    display: none;
  }
  .bw-row td.bw-c-rank {
    display: none;
  }
  .bw-in .meter {
    margin-left: 0;
  }
  .bw-detail > td {
    padding: 8px 0 4px;
  }
  .bw-rec {
    grid-template-columns: minmax(0, 1fr);
  }
  .bw-table .bw-c-score {
    min-width: 0;
  }
}
@media (max-width: 560px) {
  .bw-controls,
  .bw-controls .field,
  .bw-controls .field select {
    width: 100%;
  }
  .bw-views {
    width: 100%;
  }
  .bw-views button {
    flex: 1 1 auto;
  }
}

/* the "what each side needs" KPI on the National view */
.bw-chambers {
  display: grid;
  gap: 3px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
}
.bw-chamber .muted {
  font-size: 11.5px;
  font-weight: 400;
}
