/* Party Mode: the electorate page candidate vote table. Scoped to :root[data-party="on"] main; see party-skin.css.

   Same set pieces as the party vote bars (party-bars.css): outlined tracks
   with a hard drop, the party colour filling them, the counted share printed
   on the bar, and a slug on the leader that matches the seat's status.

   detailTop() adds, with Party Mode on only: .cb-bar (with --w, --m, --c, --on)
   in place of the thin meter, .cb-in (the share; .in when it fits inside the
   fill), .cb-model (a tick at the final model), .cb-slug on the leader's row
   (tr.cb-lead), and .pre on the table before any vote is counted. */

:root[data-party="on"] main .cand-table {
  --cb-ink: var(--pm-ink);
  --cb-drop: var(--pm-ink);
  --cb-track: var(--surface-2);
}
:root[data-party="on"][data-scheme="dark"] main .cand-table {
  --cb-ink: #000;
  --cb-drop: #07011a;
  --cb-track: #12053a;
}

/* ---------- Header and columns: the share moves onto the bar ---------- */
:root[data-party="on"] main .cand-table th {
  font-family: var(--pm-display);
  font-stretch: 80%;
  font-style: italic;
  font-weight: 900;
  letter-spacing: 0.04em;
  font-size: 11.5px;
  border-bottom: var(--pm-line) solid var(--cb-ink);
}
:root[data-party="on"] main .cand-table :is(th, td):nth-child(3) {
  display: none;
}
:root[data-party="on"] main .cand-table td {
  padding-top: 13px;
  padding-bottom: 15px;
}
:root[data-party="on"] main .cand-table td.num {
  font-family: var(--pm-display);
  font-stretch: 80%;
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
}
/* The final model is the headline number: big, italic, like the seat counts. */
:root[data-party="on"] main .cand-table td.num.strong {
  font-stretch: 75%;
  font-style: italic;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -0.01em;
}

/* ---------- Names ---------- */
:root[data-party="on"] main .cand-table .cand {
  align-items: center;
}
:root[data-party="on"] main .cand-table .cand b {
  font-family: var(--pm-display);
  font-stretch: 85%;
  font-weight: 800;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
:root[data-party="on"] main .cand-table .face {
  box-shadow:
    0 0 0 2.5px var(--c, var(--muted)),
    0 0 0 4.5px var(--cb-ink);
}

/* The leader's slug: skewed yellow, matching the status. */
:root[data-party="on"] main .cb-slug {
  flex: none;
  margin-left: auto;
  align-self: center;
  padding: 3px 9px 2px;
  font-family: var(--pm-display);
  font-stretch: 78%;
  font-style: italic;
  font-weight: 900;
  font-size: 11.5px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--pm-ink);
  background: var(--pm-yellow);
  border: 2px solid var(--cb-ink);
  border-radius: 5px;
  box-shadow: 2px 2px 0 var(--cb-drop);
  transform: skew(-10deg);
}
/* Projected is the big moment: pink. Too close stays a quieter outline. */
:root[data-party="on"] main .cb-slug-projected {
  color: #fff;
  background: var(--pm-pink);
}
:root[data-party="on"] main .cb-slug-too-close {
  color: var(--ink);
  background: var(--surface);
}

/* ---------- The bar ---------- */
:root[data-party="on"] main .cb-bar {
  position: relative;
  display: block;
  height: 24px;
  margin-top: 10px;
  box-sizing: border-box;
  border: var(--pm-line) solid var(--cb-ink);
  border-radius: 7px;
  background: var(--cb-track);
  box-shadow: 3px 3px 0 var(--cb-drop);
}
:root[data-party="on"] main .cb-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w);
  border-radius: 4px 0 0 4px;
  background: var(--c);
  box-shadow: inset 0 -5px 0 #00000024;
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
:root[data-party="on"] main .cand-table:not(.pre) .cb-fill {
  border-right: var(--pm-line) solid var(--cb-ink);
}
/* Runners-up are knocked back a touch so the leader's bar pops. */
:root[data-party="on"] main .cand-table:not(.pre) tr:not(.cb-lead) .cb-fill {
  filter: saturate(0.8);
}
:root[data-party="on"] main .cand-table tr.cb-lead .cb-bar {
  box-shadow: 3px 3px 0 var(--pm-pink);
}

/* The counted share, printed on the bar. */
:root[data-party="on"] main .cb-in {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  /* Past the fill and the model tick, whichever ends later: the tick's own
     half-width and halo (3.5px) plus a clear 6px gap. */
  left: calc(max(var(--w), var(--m, 0%)) + 9.5px);
  margin: 2px 0;
  padding: 0 3px;
  display: flex;
  align-items: center;
  font-family: var(--pm-display);
  font-stretch: 75%;
  font-style: italic;
  font-weight: 900;
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  color: var(--ink);
  background: var(--cb-track);
  border-radius: 3px;
  pointer-events: none;
}
:root[data-party="on"] main .cb-in.in {
  left: 6px;
  background: none;
  color: var(--on);
}

/* The final model: an ink tick with a halo, a pointer on top. */
:root[data-party="on"] main .cb-model {
  position: absolute;
  z-index: 3;
  top: -7px;
  bottom: -7px;
  width: 4px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 0 1.5px var(--surface);
  cursor: help;
}

/* ---------- Before the count: empty tracks, waiting their turn ---------- */
:root[data-party="on"] main .cand-table.pre .cb-bar {
  border-style: dashed;
  box-shadow: none;
  background: repeating-linear-gradient(
      -45deg,
      color-mix(in srgb, var(--c) 18%, transparent) 0 4px,
      transparent 4px 9px
    )
    var(--cb-track);
}
:root[data-party="on"] main .cand-table.pre .cb-in {
  left: 8px;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
}
/* One "No votes yet" is enough. */
:root[data-party="on"] main .cand-table.pre tr:not(:first-child) .cb-in {
  display: none;
}

/* ---------- Phone ---------- */
@media (max-width: 600px) {
  :root[data-party="on"] main .cand-table .cand b {
    font-size: 14.5px;
  }
  :root[data-party="on"] main .cb-slug {
    font-size: 10.5px;
    padding: 2px 7px 1px;
  }
  :root[data-party="on"] main .cand-table td.num.strong {
    font-size: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-party="on"] main .cb-fill {
    transition: none;
  }
}
