/* ------------------------------------------------------------------
   The election scoreboard: portraits, the leaderboard, seat changes.
   Loaded after rounds.css.
   ------------------------------------------------------------------ */

/*
 * A portrait is an image file now, so this is a frame with a picture in it
 * rather than the picture itself. The size is set inline by the renderer
 * because every screen asks for a different one.
 */
.portrait {
  position: relative;
  display: block;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ink-3);
  box-shadow: 0 1px 0 rgba(18, 32, 54, 0.09);
}
.portrait-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.portrait.has-image .portrait-img { opacity: 1; }

/*
 * What shows while a picture is loading, and instead of it when the file is
 * not there. Initials rather than an empty circle: a face that is missing
 * should still say whose it was meant to be.
 */
.portrait-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted-2);
  user-select: none;
}
.portrait.has-image .portrait-fallback { opacity: 0; }

/* ---------------------------------------------------- results screen */

.round-results {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--wheat-deep);
  background:
    radial-gradient(760px 380px at 50% -10%, var(--wash-gold), transparent 70%),
    var(--ink-2);
}

.results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.results-kicker {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.results-heading {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  text-wrap: balance;
}
.results-next { text-align: right; }
.results-next-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  color: var(--wheat);
  line-height: 1.1;
}

/* --------------------------------------------------------- banners */

.results-banners:empty { display: none; }
.results-banners { display: flex; flex-direction: column; gap: 8px; }

.banner {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--line);
  background: var(--ink-3);
}
.banner-kicker {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.banner-headline { font-family: var(--font-display); font-size: 1.1rem; }
.banner-detail { font-size: 0.86rem; color: var(--muted); }

.banner-new-leader {
  border-left-color: var(--party);
  background: linear-gradient(90deg, color-mix(in srgb, var(--party) 18%, transparent), var(--ink-3) 55%);
}
.banner-new-leader .banner-kicker { color: var(--party); }
.banner-close { border-left-color: var(--wheat); }
.banner-close .banner-kicker { color: var(--wheat); }

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .banner-new-leader { background: var(--ink-3); }
}

/* ------------------------------------------------------ leaderboard */

.board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  counter-reset: board;
}

.board-row {
  display: grid;
  grid-template-columns: 20px auto minmax(0, 1fr) minmax(60px, 1.4fr) auto 34px;
  align-items: center;
  gap: 12px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--ink-3);
  position: relative;
}
.board-row.is-you {
  border-color: var(--wheat-deep);
  background: linear-gradient(90deg, rgba(232, 184, 74, 0.09), var(--ink-3) 40%);
}
.board-row.is-leading { border-color: var(--party); }
.board-row.is-out { opacity: 0.55; }

.board-rank {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--muted-2);
  text-align: center;
}
.board-row.is-leading .board-rank { color: var(--party); }

.board-face { display: block; line-height: 0; }
.board-face .portrait { border: 2px solid var(--party); }
.board-face-blank {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--party);
  color: var(--party-ink, #fff);
  font-size: 0.72rem;
  font-weight: 700;
}

.board-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.board-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-party {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--party);
}
.board-tag {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--wash-ink);
  color: var(--muted-2);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.board-tag.is-you { background: rgba(232, 184, 74, 0.18); color: var(--wheat); }
.board-tag.is-out { background: rgba(226, 99, 79, 0.18); color: var(--warm-bad); }

.board-bar {
  position: relative;
  height: 12px;
  border-radius: 4px;
  background: var(--wash-ink);
  overflow: hidden;
}
.board-bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--party);
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.board-bar-majority {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--rule);
}

.board-seats { text-align: right; line-height: 1.1; }
.board-seats strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}
.board-seats-label {
  display: block;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.board-change {
  text-align: right;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted-2);
}
.board-change.is-up { color: var(--warm-good); }
.board-change.is-down { color: var(--warm-bad); }

.board-leading {
  position: absolute;
  top: -8px;
  left: 52px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--party);
  color: var(--party-ink, #fff);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.board.is-compact .board-row { padding: 7px 11px; gap: 9px; }
.board.is-compact .board-name { font-size: 0.9rem; }
.board.is-compact .board-seats strong { font-size: 1.05rem; }

/* ---------------------------------------------------------- totals */

.results-totals {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.86rem;
  color: var(--muted);
}
.results-totals strong { color: var(--cream); font-variant-numeric: tabular-nums; }
.results-changecount { margin-left: auto; color: var(--muted-2); }

/* ------------------------------------------------------- sections */

.results-section { display: flex; flex-direction: column; gap: 9px; }
.results-title {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* --------------------------------------------------- seat changes */

.changes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.change-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  background: var(--ink-3);
  border-left: 3px solid var(--to);
  font-size: 0.86rem;
  animation: change-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes change-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}

.change-ac { color: var(--muted-2); font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.change-name {
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.change-flip { display: inline-flex; align-items: center; gap: 7px; }
.change-from {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--from);
  opacity: 0.7;
  text-decoration: line-through;
}
.change-arrow { color: var(--muted-2); font-size: 0.8rem; }
.change-to {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--to);
  color: var(--to-ink, #fff);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.changes-none,
.moves-none {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--ink-3);
  color: var(--muted-2);
  font-size: 0.86rem;
}
.changes-more { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted-2); }

/* --------------------------------------------------------- moves */

.moves { display: flex; gap: 8px; flex-wrap: wrap; }
.move {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--ink-3);
  border: 1px solid var(--line-soft);
}
.move-party { font-size: 0.72rem; font-weight: 700; color: var(--party); }
.move-value { font-variant-numeric: tabular-nums; }
.move.is-up .move-value { color: var(--warm-good); }
.move.is-down .move-value { color: var(--warm-bad); }

/* ------------------------------------------------------ position */

.position {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left: 4px solid var(--party);
  background: var(--ink-3);
}
.position-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.position-party { font-family: var(--font-display); font-size: 1.05rem; color: var(--party); }
.position-numbers { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.position-count { font-size: 0.95rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.position-count strong { font-family: var(--font-display); font-size: 1.7rem; color: var(--cream); }
.position-need { font-weight: 700; color: var(--wheat); }
.position-need.is-clear { color: var(--warm-good); }
.position-lead { margin: 0; font-size: 0.82rem; color: var(--muted-2); }

/* ------------------------------------------------------- history */

.results-history { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.history-table-wrap { width: 100%; overflow-x: auto; }
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}
.history-table th {
  padding: 0 10px 6px;
  text-align: left;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  border-bottom: 1px solid var(--line-soft);
}
.history-table td {
  padding: 5px 10px;
  color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
}
.history-table tr:last-child td { border-bottom: 0; }
.history-table .is-num { text-align: right; }
.history-table .is-top { color: var(--party); font-weight: 700; }

/* --------------------------------------------------- final results */

.final-board { margin-bottom: 4px; }
/*
 * Whoever formed the government, in gold.
 *
 * Gold means "this is the one" everywhere else in this game — the action
 * worth taking, the seat you chose, the tab you are on — so the one card at
 * the end of twenty rounds that says who won is the place it has been saving
 * itself for. The party colour stays on the portrait ring and the rule at the
 * foot, because who they are is not the same fact as that they won.
 */
.winner-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold), var(--shadow-card);
  background:
    linear-gradient(168deg, var(--wash-gold) 0%, transparent 62%),
    var(--paper-2);
}
.winner-card::after {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 2px;
  background: var(--party);
}
.winner-card .portrait { border: 3px solid var(--party); flex: none; }
.winner-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.winner-kicker {
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.winner-name { font-family: var(--font-display); font-size: 1.7rem; line-height: 1.1; }
.winner-party { color: var(--party); font-weight: 700; }
.winner-seats { font-size: 0.9rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .change-row { animation: none; }
  .board-bar-fill { transition: none; }
}

@media (max-width: 720px) {
  .board-row {
    grid-template-columns: 18px auto minmax(0, 1fr) auto 30px;
    gap: 9px;
  }
  .board-bar { display: none; }
  .board-leading { left: 44px; }
  .results-heading { font-size: 1.25rem; }
  .change-row { grid-template-columns: 46px minmax(0, 1fr) auto; }
  .winner-card { flex-direction: column; text-align: center; }
}

/* ------------------------------------ a seat's change since last round */

.seat-change {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--ink-3);
  font-size: 0.86rem;
  color: var(--muted);
}
.seat-change-none { color: var(--muted-2); }
.seat-change-held strong { color: var(--cream); }
.seat-change-flip { border-left: 3px solid var(--to); }
.seat-change-kicker {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* ----------------------------------- the halfway and checkpoint screens */

.ms-note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--wheat);
  border-radius: var(--radius-sm);
  background: var(--ink-2);
}
.ms-note.is-out { border-left-color: var(--danger); }
.ms-note.is-safe { border-left-color: var(--good); }

.ms-note-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}
.ms-note-line {
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--muted);
}

.ms-rows {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ms-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0 9px 9px;
  border-top: 1px solid var(--line-soft);
  border-left: 2px solid transparent;
}
.ms-row:first-child { border-top: 0; }
.ms-row.is-you { border-left-color: var(--party, var(--wheat)); }
.ms-row.is-out { opacity: 0.5; }

.ms-row-party {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
}
.ms-row-name {
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ms-row-seats {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ms-row-need {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
}

.ms-foot {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted-2);
}

@media (max-width: 359px) {
  .ms-row { gap: 7px; }
  .ms-row-name { font-size: 0.76rem; }
}
