/* =========================================================================
   regwatch — regulatory feed, follow-a-topic toggles and the TPR tab.
   Owns every .rw-* class. All colour comes from css/app.css tokens, so light
   and dark both follow the shell; the only per-theme block is the impact tint
   set at the bottom, which needs a darker fill on a dark surface.
   ========================================================================= */

.rw-head .section-head { margin-bottom: var(--s-2); }

.rw-lede {
  margin: 0 0 var(--s-3);
  font-size: .88rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.rw-tabs { margin: var(--s-4) 0 var(--s-3); }

/* ------------------------------------------------------------------ search */

.rw-search-wrap { margin: 0 0 var(--s-3); }

.rw-search {
  width: 100%;
  display: block;
  min-height: 44px;
  padding: 10px var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
}

.rw-search::placeholder { color: var(--muted); }

.rw-search:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--accent);
}

.rw-search::-webkit-search-decoration,
.rw-search::-webkit-search-results-button { -webkit-appearance: none; }

/* ------------------------------------------------------------------- chips */

.rw-chip-host {
  display: grid;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.rw-chips { margin: 0; }

.rw-followed-only {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: 0 var(--s-1) var(--s-4);
  font-size: .85rem;
  color: var(--ink-2);
  cursor: pointer;
}

.rw-followed-only input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.rw-topic-banner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--blue-soft);
  color: var(--ink);
  font-size: .85rem;
}

.rw-count {
  margin: 0 var(--s-1) var(--s-3);
  font-size: .8rem;
  color: var(--muted);
}

/* ------------------------------------------------------------------- cards */

.rw-results {
  display: grid;
  gap: var(--s-3);
}

.rw-card {
  position: relative;
  padding-left: calc(var(--s-4) + 5px);
  cursor: pointer;
}

.rw-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* The impact stripe down the left edge of a card. */
.rw-card::before,
.rw-detail::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: var(--r) 0 0 var(--r);
  background: var(--line-strong);
}

.rw-impact-edge-high::before { background: var(--red); }
.rw-impact-edge-med::before { background: var(--orange); }
.rw-impact-edge-low::before { background: var(--blue); }

.rw-card-top {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-2);
}

.rw-kind {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

.rw-kind-glyph { font-size: .8rem; line-height: 1; }

.rw-kind-enforcement { background: var(--blue-soft); color: var(--slate); }
.rw-kind-bill { background: var(--surface-3); }

.rw-impact {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border: 1px solid transparent;
}

.rw-impact-high { background: rgba(224, 57, 57, .12); color: var(--red); border-color: rgba(224, 57, 57, .28); }
.rw-impact-med { background: rgba(255, 128, 68, .16); color: #a2520f; border-color: rgba(255, 128, 68, .34); }
.rw-impact-low { background: var(--surface-2); color: var(--muted); border-color: var(--line); }

.rw-new {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--navy);
  color: #fff;
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.rw-title {
  margin: 0 0 var(--s-1);
  font-size: 1.02rem;
  line-height: 1.32;
  font-weight: 700;
  color: var(--ink);
}

.rw-status {
  margin: 0 0 var(--s-2);
  font-size: .76rem;
  font-weight: 600;
  color: var(--accent);
}

.rw-summary {
  margin: 0 0 var(--s-2);
  font-size: .88rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.rw-dates {
  margin: 0 0 var(--s-2);
  font-size: .78rem;
  color: var(--muted);
}

/* -------------------------------------------------------------------- tags */

.rw-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.rw-tag {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  font: inherit;
  font-size: .74rem;
  cursor: pointer;
  min-height: 28px;
}

.rw-tag:hover { background: var(--surface-2); }
.rw-tag:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ------------------------------------------------------------------ detail */

.rw-back { margin-bottom: var(--s-3); }

.rw-detail {
  position: relative;
  padding-left: calc(var(--s-4) + 5px);
}

.rw-detail-title {
  margin: var(--s-1) 0 var(--s-3);
  font-size: 1.28rem;
  line-height: 1.28;
  font-weight: 800;
  color: var(--ink);
}

.rw-facts {
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr;
  gap: var(--s-1) var(--s-4);
  margin: var(--s-4) 0;
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: .84rem;
}

.rw-fact-label {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.rw-fact-value {
  margin: 0;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}

.rw-means { border-left: 4px solid var(--accent); }

.rw-means-body {
  margin: 0 0 var(--s-3);
  font-size: .92rem;
  line-height: 1.6;
  color: var(--ink);
}

/* --------------------------------------------------------------- checklist */

.rw-actions {
  list-style: none;
  margin: 0 0 var(--s-3);
  padding: 0;
  display: grid;
  gap: var(--s-2);
}

.rw-action-label {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  font-size: .88rem;
  line-height: 1.5;
  color: var(--ink-2);
  cursor: pointer;
}

.rw-action-label input {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.rw-action-label input:checked + span {
  color: var(--muted);
  text-decoration: line-through;
}

/* ------------------------------------------------------------------ topics */

.rw-topic-list { display: grid; }

.rw-topic-row {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line);
}

.rw-topic-row:last-child { border-bottom: 0; }

.rw-topic-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.rw-topic-label { font-weight: 600; font-size: .95rem; color: var(--ink); }
.rw-topic-blurb { font-size: .8rem; color: var(--muted); line-height: 1.45; }
.rw-topic-count { font-size: .74rem; color: var(--accent); }

/* An accessible checkbox that reads and looks like a switch. */
input.rw-switch {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  position: relative;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}

input.rw-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform .16s ease;
}

input.rw-switch:checked {
  background: var(--accent);
  border-color: var(--accent);
}

input.rw-switch:checked::after { transform: translateX(20px); }

input.rw-switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* --------------------------------------------------------------------- TPR */

.rw-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--s-3);
  margin: var(--s-4) 0;
}

.rw-stat {
  display: grid;
  gap: 2px;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border-left: 4px solid var(--line-strong);
}

.rw-stat-alert { border-left-color: var(--red); }
.rw-stat-warn { border-left-color: var(--orange); }

.rw-stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
}

.rw-stat-label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.rw-stat-note { font-size: .74rem; color: var(--muted); line-height: 1.4; }

.rw-source-note {
  margin: 0 0 var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border-left: 3px solid var(--orange);
  font-size: .78rem;
  line-height: 1.45;
  color: var(--ink-2);
}

.rw-tpr-rows { display: grid; gap: var(--s-2); }

.rw-tpr-row {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border-left: 3px solid var(--line-strong);
}

.rw-tpr-removed { border-left-color: var(--red); }
.rw-tpr-review { border-left-color: var(--orange); }

.rw-tpr-main { display: grid; gap: 2px; min-width: 0; flex: 1 1 auto; }
.rw-tpr-name { font-weight: 700; font-size: .92rem; color: var(--ink); }
.rw-tpr-where { font-size: .78rem; color: var(--muted); }
.rw-tpr-reason { font-size: .8rem; color: var(--ink-2); line-height: 1.45; }

.rw-tpr-side {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
  flex: 0 0 auto;
}

.rw-tpr-badge {
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.rw-tpr-removed .rw-tpr-badge { background: rgba(224, 57, 57, .14); color: var(--red); }

.rw-tpr-date { font-size: .72rem; color: var(--muted); white-space: nowrap; }

/* Small links into the feed from the registry tab. */
.rw-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  width: 100%;
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: var(--s-3) 0;
  font: inherit;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.rw-mini:last-child { border-bottom: 0; }
.rw-mini:hover .rw-mini-title { color: var(--accent); }
.rw-mini:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.rw-mini-title { font-size: .9rem; font-weight: 600; min-width: 0; }
.rw-mini-date { font-size: .74rem; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }

/* ------------------------------------------------------------ narrow phones */

@media (max-width: 400px) {
  .rw-facts { grid-template-columns: 1fr; gap: 0; }
  .rw-fact-label { margin-top: var(--s-2); }
  .rw-tpr-row { flex-direction: column; }
  .rw-tpr-side { justify-items: start; text-align: left; flex-direction: row; gap: var(--s-2); }
}

/* --------------------------------------------------------------- dark mode */

@media (prefers-color-scheme: dark) {
  .rw-impact-high { background: rgba(224, 57, 57, .2); color: #ff8b8b; border-color: rgba(224, 57, 57, .4); }
  .rw-impact-med { background: rgba(255, 128, 68, .18); color: #ffb183; border-color: rgba(255, 128, 68, .36); }
  .rw-kind-enforcement { color: #a9c6e8; }
  .rw-new { background: var(--accent); }
  .rw-topic-banner { color: var(--ink); }
  .rw-tpr-removed .rw-tpr-badge { background: rgba(224, 57, 57, .22); color: #ff8b8b; }
  input.rw-switch::after { background: #f2f5fb; }

  /* SHELL BUG, scoped fix — css/app.css paints `.tabs .tab.active` and
     `.btn.secondary` with `var(--navy)`, which is a hard #002060 in BOTH
     themes, so in dark mode the active tab label and every secondary button
     are near-black text on a near-black surface. This affects conference,
     admin, courses and materials too; it belongs in app.css, which this module
     does not own, so the override here is scoped to .rw-* subtrees only.
     INTEGRATOR: a one-line fix in app.css (a --on-dark token for these two
     rules) would let this block be deleted. */
  .rw-tabs .tab.active,
  .rw-tabs > button.active {
    color: #9dbdea;
    border-bottom-color: #9dbdea;
  }

  .rw-head .btn.secondary,
  .rw-tpr-head .btn.secondary {
    background: var(--surface-3);
    color: var(--ink);
    border-color: var(--line-strong);
  }
}

/* ------------------------------------------------------------------- print */

@media print {
  .rw-tabs, .rw-chip-host, .rw-search-wrap, .rw-followed-only, .rw-back { display: none !important; }
  .rw-card, .rw-detail { break-inside: avoid; }
}
