.localgov-elections {
  --election-label-bg: var(--color-grey-dark, #505a5f);
  --election-label-fg: #fff;
  --sidebar-exposed-form-padding-horizontal: 0;
  --sidebar-exposed-form-padding-vertical: 0;
  --sidebar-exposed-form-bg-color: #fff;
  --table-header-border-color: transparent;
  --table-bg-color: var(--color-white, #fff);
  --table-padding: 0.5rem 0;
  --table-border: none;

  .lgd-region__inner--sidebar-first > * {
    border: none;
  }

  table {
    border-block-start: none;
  }
}

@media screen and (min-width: 48rem) {
  .main .lgd-row__one-third.sidebar--first {
    grid-column: span 3;
  }

  .main .lgd-row__two-thirds {
    grid-column: span 9;
  }
}

.area-summary {
  margin-block-end: 2rem;
}

.area-summary__header h2 {
  margin-block-end: 0;
}

.views-field-localgov-election-electorate {
  display: flex;
  column-gap: 0.25rem;
}

.area-summary .label-wrapper {
  display: inline-flex;
}

.area-summary .party {
  width: fit-content;
  padding: 0.25rem;
  text-transform: uppercase;
  color: white;
  font-family: sans-serif;
  font-weight: bold;
}

.area-summary .views-field-election-majority {
  padding: 1rem;
}

.area-summary .seat-not-contested {
  display: inline-flex;
  padding: 0.25rem;
  text-transform: uppercase;
  border: 1px solid black;
  font-weight: bold;
}

table.table-election-areas {
  border-bottom: 0.0625rem solid var(--color-black, #000);
  font-size: var(--font-size-large, 1.125rem);

  thead {
    border-bottom: 0.0625rem solid var(--color-black, #000);
  }

  th {
    font-weight: 700;
  }
}

table.table-election-areas thead th:nth-child(3),
table.table-election-areas td:nth-child(3) {
  text-align: right;
}

table.table-election-areas .table-election-areas__area th {
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
}

table.table-election-areas tbody + tbody tr.table-election-areas__area th {
  border-top: 0.0625rem solid var(--color-black, #000);
}

table.table-election-areas tbody tr:last-child td {
  padding-bottom: 1.25rem;
}

table.table-election-areas thead th:first-child {
  width: 45%;
}

@media (max-width: 600px) {
  table.table-election-areas thead {
    display: none;
  }

  table.table-election-areas tr:not(.table-election-areas__area) {
    position: relative;
    display: block;
    margin-bottom: 1rem;
    padding-left: 1.5rem;
  }

  table.table-election-areas td {
    display: block;
    padding: 0;
  }

  table.table-election-areas tbody tr:last-child td {
    padding-bottom: 0;
  }

  table.table-election-areas td:not(:has(.party)) {
    font-size: var(--font-size, 1rem);
  }

  table.table-election-areas td:nth-child(3) {
    text-align: left;
  }

  table.table-election-areas td[data-label]::before {
    display: block;
    content: attr(data-label);
    font-weight: 700;
  }

  /* Full-height party colour bar via :has() */
  table.table-election-areas tbody tr:has(.party)::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0.625rem;
    content: "";
    background-color: var(--party-bg-colour, transparent);
  }

  .table-election-areas span.party {
    padding-left: 0;
    border-left: none;
  }
}

span.tie-winner,
span.votes-not-contested {
  display: block;
  font-size: var(--font-size, 1rem);
}

span.party {
  display: inline-block;
  padding-left: 1rem;
  border-left: 0.625rem solid var(--party-bg-colour);
  font-weight: 700;
}
