/* REV UP Texas Election Results widget.
   Colors are custom properties on .rer so the site can restyle them, e.g.
   .rer { --rer-accent: #5b2a86; }                                                     */

.rer {
  --rer-bezel: #26262b;
  --rer-bezel-edge: #3d3d44;
  --rer-screen: #ffffff;
  --rer-text: #1b1b1f;
  --rer-muted: #4b4b55;
  --rer-line: #c9c9d1;
  --rer-soft: #f2f3f6;
  --rer-accent: #0b5f68;      /* bars and highlights: a neutral teal, not a party color */
  --rer-accent-soft: #9cc3c7;
  --rer-focus: #0a4ea3;
  --rer-notice-bg: #fff6d6;
  --rer-notice-line: #8a6d00;
  --rer-radius: 12px;
  --rer-list-height: 70vh;

  color: var(--rer-text);
  font-size: 1rem;
  line-height: 1.5;
  max-width: 1100px;
  margin: 0 auto 2rem;
}

.rer *, .rer *::before, .rer *::after { box-sizing: border-box; }

/* Visually hidden, still read by screen readers. */
.rer .rer-vh {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---- The television ---- */
.rer--tv .rer-tv {
  position: relative;
  background: var(--rer-bezel);
  border: 2px solid var(--rer-bezel-edge);
  border-radius: 28px;
  padding: 22px 22px 34px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25), inset 0 0 0 6px rgba(255, 255, 255, .04);
}
.rer--tv .rer-led {
  position: absolute; right: 30px; bottom: 12px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #6a6a72;
}
.rer--tv.is-live .rer-led { background: #2fbf5b; box-shadow: 0 0 8px #2fbf5b; }
.rer--tv.is-paused .rer-led { background: #d0a400; box-shadow: none; }
@media (prefers-reduced-motion: no-preference) {
  .rer--tv.is-live:not(.is-paused) .rer-led { animation: rer-pulse 2.4s ease-in-out infinite; }
}
@keyframes rer-pulse { 50% { opacity: .45; } }
.rer--tv .rer-stand {
  width: 34%; height: 18px; margin: 0 auto;
  background: linear-gradient(var(--rer-bezel-edge), var(--rer-bezel));
  clip-path: polygon(12% 0, 88% 0, 100% 100%, 0 100%);
  border-radius: 0 0 6px 6px;
}

.rer-screen {
  background: var(--rer-screen);
  border-radius: var(--rer-radius);
  padding: 20px;
}
.rer--plain .rer-screen { border: 1px solid var(--rer-line); }

/* ---- Header ---- */
.rer-titlebar { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; }
.rer .rer-title { margin: 0; font-size: 1.6rem; line-height: 1.2; color: var(--rer-text); }
.rer-badge {
  display: inline-block; font-size: .85rem; font-weight: 600;
  padding: .1rem .6rem; border-radius: 999px;
  border: 1px solid var(--rer-muted); color: var(--rer-muted);
}
.rer .rer-status { margin: .5rem 0 .25rem; color: var(--rer-muted); font-size: .95rem; }
.rer-updates { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: .5rem 0; }
.rer-next { color: var(--rer-muted); font-size: .95rem; font-variant-numeric: tabular-nums; }
.rer .rer-notice {
  margin: .75rem 0 0; padding: .6rem .8rem;
  background: var(--rer-notice-bg); border-left: 4px solid var(--rer-notice-line);
  border-radius: 6px;
}

/* ---- Buttons and form controls ---- */
.rer .rer-btn {
  font: inherit; font-size: .95rem; font-weight: 600;
  min-height: 44px; padding: .4rem 1rem;
  color: var(--rer-text); background: var(--rer-soft);
  border: 1px solid var(--rer-muted); border-radius: 8px;
  cursor: pointer;
}
.rer .rer-btn:hover { background: #e4e6ec; }
.rer .rer-pause[aria-pressed="true"] { background: var(--rer-notice-bg); border-color: var(--rer-notice-line); }

.rer-filters {
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1.25rem;
  margin: 1rem 0 .5rem; padding: 1rem;
  background: var(--rer-soft); border-radius: 10px;
}
.rer-field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.rer-field label, .rer-fieldset legend { font-weight: 600; }
.rer .rer-input {
  font: inherit; color: var(--rer-text); background: #fff;
  min-height: 44px; width: 100%;
  padding: .45rem .6rem;
  border: 1px solid var(--rer-muted); border-radius: 8px;
}
.rer-hint { color: var(--rer-muted); font-size: .9rem; }
.rer-more { grid-column: 1 / -1; }
.rer-more-summary {
  display: list-item; list-style-position: inside;
  padding: .55rem .25rem; min-height: 44px;
  font-weight: 600; cursor: pointer;
  border-radius: 6px;
}
.rer-more-summary:hover { background: #e4e6ec; }
.rer-more-body { display: grid; gap: .75rem; padding-top: .25rem; }
.rer-fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.rer-fieldset legend { padding: 0; margin-bottom: .35rem; }
.rer-groups { display: flex; flex-wrap: wrap; gap: .5rem; }
.rer-toggles { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; }
.rer-check { display: flex; align-items: center; gap: .45rem; min-height: 44px; }
.rer-check input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--rer-accent); flex: none; }
.rer-check label { cursor: pointer; }
.rer-chip {
  padding: 0 .75rem; background: #fff;
  border: 1px solid var(--rer-line); border-radius: 999px;
}
.rer-chip:has(input:checked) { border-color: var(--rer-accent); box-shadow: inset 0 0 0 1px var(--rer-accent); }
.rer-reset { margin-left: auto; }

.rer .rer-count { margin: .75rem 0 .5rem; font-weight: 600; }

/* ---- Race list ---- */
.rer-list {
  max-height: var(--rer-list-height);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 .25rem .5rem 0;
  border-top: 1px solid var(--rer-line);
  border-bottom: 1px solid var(--rer-line);
}
.rer-group + .rer-group { margin-top: 1rem; }
.rer .rer-group-title {
  position: sticky; top: 0; z-index: 1;
  margin: 0; padding: .6rem 0 .4rem;
  font-size: 1.2rem; line-height: 1.3; color: var(--rer-text);
  background: var(--rer-screen);
  border-bottom: 2px solid var(--rer-accent);
}
.rer .rer-races {
  list-style: none; margin: .75rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: .75rem;
}
.rer .rer-races > li { margin: 0; padding: 0; }
.rer-race {
  height: 100%;
  padding: .75rem .9rem;
  border: 1px solid var(--rer-line); border-radius: 10px;
  background: #fff;
}
.rer-race.is-starred { border-color: var(--rer-accent); box-shadow: inset 4px 0 0 var(--rer-accent); }
.rer-race-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.rer .rer-race-title { margin: .35rem 0 0; font-size: 1.05rem; line-height: 1.3; color: var(--rer-text); }
.rer .rer-star {
  flex: none; width: 44px; height: 44px; margin: -.25rem -.4rem 0 0;
  font-size: 1.5rem; line-height: 1; color: var(--rer-muted);
  background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.rer .rer-star:hover { background: var(--rer-soft); border-color: var(--rer-line); }
.rer .rer-star[aria-pressed="true"] { color: #8a5a00; }
.rer .rer-meta { margin: .25rem 0 .5rem; color: var(--rer-muted); font-size: .9rem; }
.rer-meta-item { display: block; }

.rer .rer-cands { list-style: none; margin: 0; padding: 0; }
.rer .rer-cand { margin: 0; padding: .45rem 0; border-top: 1px solid var(--rer-soft); }
.rer .rer-cand:first-child { border-top: 0; }
.rer-cand-top { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
.rer-name { font-weight: 600; }
.rer-cand.is-leading .rer-name { font-weight: 800; }
.rer-tag {
  font-size: .75rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  padding: .05rem .45rem; border-radius: 4px;
  border: 1px solid currentColor;
}
.rer-tag--lead { color: #fff; background: var(--rer-accent); border-color: var(--rer-accent); }
.rer-tag--tie { color: var(--rer-text); }
.rer-tag--inc { color: var(--rer-muted); }
.rer-cand-nums {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 4.2rem; gap: .25rem .75rem; align-items: baseline;
  color: var(--rer-muted); font-size: .92rem; font-variant-numeric: tabular-nums;
}
.rer-votes { text-align: right; }
.rer-pct { text-align: right; font-weight: 700; color: var(--rer-text); }
.rer-bar { height: 8px; margin-top: .3rem; background: var(--rer-soft); border-radius: 4px; overflow: hidden; }
.rer-bar > span { display: block; height: 100%; background: var(--rer-accent-soft); }
.rer-cand.is-leading .rer-bar > span { background: var(--rer-accent); }
.rer .rer-wi { margin: .35rem 0 0; color: var(--rer-muted); font-size: .9rem; }
.rer .rer-empty { margin: 1rem 0; }

.rer .rer-source { margin: .75rem 0 0; color: var(--rer-muted); font-size: .9rem; }
.rer .rer-source a { color: var(--rer-focus); }

/* ---- Focus ---- */
.rer :focus { outline: none; }
.rer :focus-visible, .rer .rer-list:focus {
  outline: 3px solid var(--rer-focus);
  outline-offset: 2px;
}
.rer .rer-list:focus:not(:focus-visible) { outline: none; }
.rer .rer-check input:focus-visible { outline-offset: 3px; }

/* ---- Small screens ---- */
@media (max-width: 640px) {
  .rer--tv .rer-tv { padding: 10px 10px 22px; border-radius: 18px; }
  .rer--tv .rer-led { right: 18px; bottom: 7px; width: 8px; height: 8px; }
  .rer-screen { padding: 14px; border-radius: 10px; }
  .rer .rer-title { font-size: 1.35rem; }
  .rer-filters { grid-template-columns: 1fr; padding: .75rem; }
  .rer-reset { margin-left: 0; }
}

/* ---- Windows High Contrast and other forced-color modes ---- */
@media (forced-colors: active) {
  .rer-bar { border: 1px solid CanvasText; }
  .rer-bar > span, .rer-cand.is-leading .rer-bar > span { background: Highlight; forced-color-adjust: none; }
  .rer-tag--lead { forced-color-adjust: auto; }
  .rer .rer-star, .rer-chip { border: 1px solid ButtonText; }
}
