/* Ballot summary and featured races cards */

.ballot-summary,
.featured-races {
  display: grid;
  gap: 12px;
}

.ballot-summary .card-head,
.featured-races .card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ballot-summary .card-head h2,
.featured-races .card-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.ballot-summary .card-link,
.ballot-summary .card-more,
.featured-races .card-link,
.featured-races .card-more {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 0;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.ballot-summary .card-link,
.featured-races .card-link {
  font-weight: 650;
}

.ballot-summary .card-link .icon,
.featured-races .card-link .icon,
.ballot-summary .card-more .icon,
.featured-races .card-more .icon {
  width: 16px;
  height: 16px;
  color: inherit;
}

.ballot-summary .race-cards,
.featured-races .race-cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.ballot-summary .race-card,
.featured-races .race-card {
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2, var(--surface));
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
}

.ballot-summary .race-card:hover,
.ballot-summary .race-card:focus-visible,
.featured-races .race-card:hover,
.featured-races .race-card:focus-visible {
  border-color: var(--accent);
}

.ballot-summary .race-icon,
.featured-races .race-icon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: var(--accent-soft, var(--line));
  display: flex;
  align-items: center;
  justify-content: center;
}

.ballot-summary .race-icon svg,
.featured-races .race-icon svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.ballot-summary .race-card-count,
.featured-races .race-card-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.ballot-summary .race-card-chevron,
.featured-races .race-card-chevron {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.featured-races .card-note,
.featured-races .card-empty,
.ballot-summary .card-note,
.ballot-summary .card-empty {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

.featured-races .featured-race h3 {
  margin: 4px 0;
  font-size: 0.95rem;
}

/* Pick, party, name (Incumbent under it), links, open: long names wrap inside their column and the chevron
   always ends the row. */
.featured-races .candidate-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 2px 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.featured-races .candidate-row > .pick { grid-column: 1; grid-row: 1 / span 2; }
.featured-races .candidate-row > .party-box { grid-column: 2; grid-row: 1 / span 2; }
.featured-races .candidate-row > .candidate-row-name { grid-column: 3; grid-row: 1; }
.featured-races .candidate-row > .incumbent-tag-line { grid-column: 3; grid-row: 2; justify-self: start; }
.featured-races .candidate-row > .candidate-row-links { grid-column: 4; grid-row: 1 / span 2; }
.featured-races .candidate-row > .candidate-row-open { grid-column: 5; grid-row: 1 / span 2; }

.featured-races .candidate-row:first-child {
  border-top: none;
}

.featured-races .candidate-row-name {
  min-width: 0;
}

.featured-races .candidate-row-name strong {
  font-weight: inherit;
}

.featured-races .candidate-row-party {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 6px;
}

.featured-races .incumbent-tag {
  font-size: 0.72rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 1px 8px;
}

.featured-races .candidate-row-links {
  display: inline-flex;
  gap: 4px;
}

.featured-races .candidate-row-open {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.featured-races .candidate-row-open svg {
  width: 18px;
  height: 18px;
}

.featured-races .endorse-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 8px 34px;
}

.featured-races .endorse-line .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  background: var(--accent-soft, var(--line));
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 8px;
}

.featured-races .endorse-line .endorse-link {
  color: var(--ink);
  text-decoration: underline;
  font-size: 0.85rem;
}
.ballot-summary .race-card-text {display:grid;gap:4px;min-width:0;}
.ballot-summary .race-card-text strong {overflow-wrap:anywhere;}

/* Party color inheritance for incumbent tag and social links in featured races */
.featured-races .candidate-row .party-D ~ .incumbent-tag-line .incumbent-tag {
  border-color: var(--party-d);
  color: var(--party-d);
}

.featured-races .candidate-row .party-R ~ .incumbent-tag-line .incumbent-tag {
  border-color: var(--party-r);
  color: var(--party-r);
}

.featured-races .candidate-row .party-G ~ .incumbent-tag-line .incumbent-tag {
  border-color: var(--party-g);
  color: var(--party-g);
}

.featured-races .candidate-row .party-L ~ .incumbent-tag-line .incumbent-tag {
  border-color: var(--party-l);
  color: var(--party-l);
}

.featured-races .candidate-row .party-I ~ .incumbent-tag-line .incumbent-tag,
.featured-races .candidate-row .party-other ~ .incumbent-tag-line .incumbent-tag {
  border-color: var(--party-i);
  color: var(--party-i);
}

.featured-races .candidate-row .party-D ~ .candidate-row-links .candidate-social {
  color: var(--party-d);
}

.featured-races .candidate-row .party-R ~ .candidate-row-links .candidate-social {
  color: var(--party-r);
}

.featured-races .candidate-row .party-G ~ .candidate-row-links .candidate-social {
  color: var(--party-g);
}

.featured-races .candidate-row .party-L ~ .candidate-row-links .candidate-social {
  color: var(--party-l);
}

.featured-races .candidate-row .party-I ~ .candidate-row-links .candidate-social,
.featured-races .candidate-row .party-other ~ .candidate-row-links .candidate-social {
  color: var(--party-i);
}
