/* Base styles */
main {
  /* Allow this body grid item to shrink below the marquee's content width. */
  min-width: 0;
}
.header {
  background-color: var(--peach);
  border-bottom: 2px solid rgba(64, 64, 64, 0.3);
  max-width: 100vw;
}
.header .container {
  display: flex;
  align-items: center;
  column-gap: 1rem;
  padding-block: 0.5rem;
}
.menu-wrapper {
  align-self: start;
}
.menu {
  width: 34px;
  border: 0;
  background-color: transparent;
}
.header .cts-logo {
  width: min(100px, 15%);
  padding-top: 34px;
}
.header .logo {
  width: min(200px, 35%);
  padding-top: 34px;
}
.header .countdown-wrapper {
  align-self: end;
  flex: 1;
  padding-top: 34px;
}
.header .important-dates,
.header .important-dates-group {
  display: none;
}
.main .important-dates-group {
  margin-block: 1rem;
}
.main .important-dates-group .important-dates {
  margin-block: 0;
}
.important-dates-group .important-dates-more {
  margin: 0.25rem 0 0;
  text-align: right;
}
.important-dates {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border-radius: 9999px;
  display: flex;
  background-color: var(--apricot);
}
.important-dates > div:first-child {
  flex-shrink: 0;
  white-space: nowrap;
  background-color: var(--espresso);
  letter-spacing: 0.5rem;
  color: var(--neutral);
  font-weight: 700;
  padding: 0.5rem 0 0.5rem 1rem;
  border-radius: 9999px 0 0 9999px;
}
.important-dates .dates {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  gap: 1rem;
}
.dates > div {
  flex-shrink: 0;
}
.dates-track,
.dates-content {
  display: flex;
  width: max-content;
  gap: 1rem;
}
.dates-content {
  flex-shrink: 0;
}
.dates-track {
  position: relative;
  flex-shrink: 0;
}
.dates-content[aria-hidden="true"] {
  /* The duplicate must never change the container's intrinsic width. */
  position: absolute;
  top: 0;
  left: calc(100% + 1rem);
}
.dates.is-overflowing .dates-track {
  animation: dates-marquee var(--dates-duration) linear infinite;
}
.dates:hover .dates-track {
  animation-play-state: paused;
}
@keyframes dates-marquee {
  to {
    transform: translateX(calc(-1 * var(--dates-distance)));
  }
}
@media (prefers-reduced-motion: reduce) {
  .dates.is-overflowing .dates-track {
    animation: none;
  }
  .important-dates .dates {
    overflow-x: auto;
  }
}
.main .important-dates {
  margin-block: 1rem;
}
.hero,
.ad-large,
.hashtags.desktop {
  display: none;
}
.youtube-wrapper iframe {
  aspect-ratio: 16 / 9;
  width: 100%;
}
.countdown-wrapper {
  font-size: 1.25rem;
}
.countdown {
  display: flex;
  gap: 4px;
  justify-content: space-between;
}
.countdown-unit {
  font-size: var(--text-sm);
  align-self: end;
}
.countdown-digit {
  flex: 0 0 0.8em;
  padding: 0.1rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background-color: var(--mocha);
  border-radius: 4px;
  color: var(--neutral);
}
.footer {
  background-color: var(--taupe);
  color: var(--neutral);
  padding-block: 1rem;
  font-size: 0.75rem;
}
.footer .container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  place-items: center;
}
.footer .container > div {
  display: flex;
  place-items: center;
  gap: 0.5rem;
}
.footer .logo {
  width: 50px;
}
.ads {
  margin-block: 1rem;
  /* Centre every slot: GPT renders each ad as an inline iframe. */
  text-align: center;
}
.news {
  position: relative;
  min-width: 0;
  margin-block: 1.5rem;
}
.news-viewport {
  overflow: hidden;
  margin: 0.5rem auto;
  max-width: 300px;
}
.news-track {
  display: flex;
  touch-action: pan-y pinch-zoom;
}
.news-slide {
  flex: 0 0 100%;
  min-width: 0;
}
.news-control {
  position: absolute;
  top: 50%;
  z-index: 1;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgb(0 0 0 / 40%);
}
.news-control:hover,
.news-control:focus-visible {
  background: rgb(0 0 0 / 65%);
}
.news-control:disabled {
  opacity: 0.3;
}
.news-prev {
  left: 0;
}
.news-next {
  right: 0;
}
.news-heading {
  margin-inline: auto;
  max-width: 300px;
  text-align: center;
}
.news-card {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0.5rem auto;
  text-decoration: none;
}
.news-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.news-card-title {
  margin: 1rem 0.5rem 0;
  color: #000;
  font-size: 1rem;
  line-height: 1.4;
  text-align: center;
}
.news-card-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  margin: 0.25rem 0.25rem 0;
  color: var(--chustnut);
  font-size: 0.75rem;
  line-height: 1.5;
}
.news-button {
  padding: 0.25rem 1.25rem;
  text-decoration: none;
  text-align: center;
  color: var(--neutral);
  background-color: var(--chustnut);
  border-radius: 0.5rem;
  margin-inline: auto;
  display: inline-block;
}
.ad-note {
  font-size: 0.75rem;
  text-align: center;
  margin-top: 0.5rem;
}

/* Resopnsive styles */
@media (min-width: 768px) {
  :root {
    --page-gutter: 1rem;
  }
  .header {
    background-color: transparent;
  }
  .header .container {
    padding-block: 2rem;
  }
  .menu-wrapper,
  .header .logo,
  .header .countdown-wrapper,
  main .important-dates,
  main .important-dates-group,
  .hashtags.mobile {
    display: none;
  }
  .header .important-dates-group {
    display: block;
    flex: 1 1 0;
    min-width: 0;
    margin-left: 2rem;
    position: relative;
  }
  .header .important-dates-group .important-dates {
    display: flex;
    margin-left: 0;
  }
  /* Keep the link out of flow so the bar stays vertically aligned with the logo. */
  .header .important-dates-group .important-dates-more {
    position: absolute;
    top: 100%;
    right: 0;
  }
  .header .cts-logo {
    padding-top: 0;
  }
  .header .important-dates {
    flex: 1 1 0;
    display: inherit;
    margin-left: 2rem;
    font-size: 1.25rem;
  }
  .header .important-dates > div:first-child {
    letter-spacing: 1rem;
    padding: 0.75rem 0 0.75rem 1.25rem;
  }
  .header .important-dates .dates {
    padding: 0.75rem 1rem;
  }
  .hero,
  .hashtags.desktop {
    display: block;
  }
  .hero-wrapper {
    margin-block: 2rem;
    display: grid;
    grid-template-columns: min-content 1fr;
    gap: 1rem;
  }
  .ad-small,
  .news {
    grid-column: 1 / -1;
  }
  .hero {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
  }
  .hero .countdown-wrapper {
    font-size: 2rem;
    --text-sm: 1rem;
  }
  .hero .countdown-wrapper div:first-child {
    text-align: center;
    white-space: nowrap;
  }
  .hero .countdown {
    font-size: 2rem;
    margin-top: 1rem;
  }
  .hashtags.desktop {
    margin-block: 2rem;
  }
  .footer {
    font-size: 1rem;
  }
  .footer .logo {
    width: 100px;
  }
}
@media (min-width: 1024px) {
  .ad-small,
  .ad-medium {
    display: none;
  }
  .ad-large {
    display: block;
  }
  .hero-wrapper {
    grid-template-columns: min-content 1fr 20%;
    gap: 1rem;
  }
  .news {
    margin-block: 0;
    grid-column: auto;
  }
}
@media (min-width: 1280px) {
  .header {
    border-bottom: 0;
  }
  .header .container {
    border-bottom: 2px solid rgba(64, 64, 64, 0.3);
  }
  .header .important-dates {
    margin-left: 3rem;
  }
  .header .important-dates-group {
    margin-left: 3rem;
  }
}

/* referendum.html: index header without the countdown; phones center the logos. */
@media (max-width: 767px) {
  .header-referendum .container {
    justify-content: center;
  }
}

/* Election-day header, shared by live.html and the results pages. */
/* Phones: only the logo group gets the peach band, so the ticker (live) or
 * the category menu (results) below it sits on the page background. The band bleeds to the viewport edges via
 * border-image outset, which does not add scrollable overflow. */
:is(.header-live, .header-results) {
  min-width: 0;
}
@media (max-width: 767px) {
  :is(.header-live, .header-results) {
    background-color: transparent;
    border-bottom: 0;
  }
}
:is(.header-live, .header-results) .container {
  flex-direction: column;
  align-items: stretch;
  padding-block: 0;
}
.header-brand {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  column-gap: 0.5rem;
  padding-block: 0.5rem;
  border-image: linear-gradient(
      to top,
      rgba(64, 64, 64, 0.3) 2px,
      var(--peach) 2px
    )
    fill 0 / 0 / 0 100vmax;
}
:is(.header-live, .header-results) .menu-wrapper {
  position: absolute;
  top: 0.5rem;
  left: 0;
}
:is(.header-live, .header-results) .cts-logo {
  width: 70px;
  padding-top: 0;
}
:is(.header-live, .header-results) .logo {
  width: 130px;
  padding-top: 0;
}
.live-ticker {
  min-width: 0;
  padding-top: 1rem;
}
.live-ticker:has(.vote-ticker[hidden]) {
  display: none;
}
.vote-ticker {
  min-width: 0;
  display: grid;
  gap: 0.5rem;
  font-size: var(--text-sm);
}
.ticker-note {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  text-align: right;
  color: var(--color-text);
  opacity: 0.8;
}
.ticker-row {
  display: flex;
  min-width: 0;
  overflow: hidden;
  border-radius: 9999px;
  background-color: var(--apricot);
}
.ticker-label {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0.25rem 0.75rem 0.25rem 1rem;
  border-radius: 9999px 0 0 9999px;
  background-color: var(--espresso);
  color: var(--neutral);
  font-weight: 700;
  letter-spacing: 0.25rem;
}
.ticker-items {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow: hidden;
  padding: 0.25rem 1rem;
  white-space: nowrap;
  font-weight: 700;
}
.ticker-items .dates-track,
.ticker-items .dates-content {
  gap: 2rem;
}
.ticker-items .dates-content[aria-hidden="true"] {
  left: calc(100% + 2rem);
}
.ticker-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.ticker-area {
  padding: 0 0.5rem;
  border-radius: var(--radius-md);
  background-color: var(--taupe);
  color: var(--neutral);
}
.ticker-votes {
  font-variant-numeric: tabular-nums;
}
.ticker-candidate {
  white-space: nowrap;
}
/* 當選 stamp before the ballot number. base.css makes img a block, so put it
   back inline; negative margins keep the row height. */
.ticker-elected {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  /* base.css's max-width: 100% lets a squeezed row collapse the stamp. */
  max-width: none;
  margin: -0.25em 0.25rem -0.25em 0;
  vertical-align: middle;
}
@media (prefers-reduced-motion: reduce) {
  .ticker-items {
    overflow-x: auto;
  }
}
.hero-wrapper.is-live {
  margin-block: 1rem;
}
.has-drawer {
  /* Keep the fixed drawer tab (and the round button above it) from
   * covering the last content, such as the bottom ads. */
  padding-bottom: 7.5rem;
}
.results-drawer {
  position: fixed;
  inset: auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  transition: transform 0.55s cubic-bezier(0.7, 0, 0.3, 1);
}
/* Pull the tab and the curtain below it up until the curtain fills the
 * viewport, then js/scripts.js navigates. */
.results-drawer.is-leaving {
  transform: translateY(-100vh);
  transform: translateY(-100dvh);
}
.results-drawer.no-transition {
  transition: none;
}
/* A triangle tab with a round chevron button on its apex. */
.results-toggle {
  position: relative;
  isolation: isolate;
  display: block;
  width: min(100%, 360px);
  padding: 2.5rem 3rem 0.5rem;
  color: var(--neutral);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.1rem;
  text-align: center;
  text-decoration: none;
  /* Only the triangle and the circle take clicks, not the empty corners. */
  pointer-events: none;
}
.results-toggle::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--espresso);
  clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%);
  pointer-events: auto;
}
.results-chevron {
  position: absolute;
  top: -1.25rem;
  left: 50%;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background-color: var(--mocha);
  transform: translateX(-50%);
  transition: transform 0.2s;
  pointer-events: auto;
}
.results-chevron::after {
  content: "";
  position: absolute;
  top: 55%;
  left: 50%;
  width: 0.9rem;
  height: 0.9rem;
  border-top: 3px solid var(--apricot);
  border-left: 3px solid var(--apricot);
  transform: translate(-50%, -50%) rotate(45deg);
}
.results-toggle:hover .results-chevron {
  transform: translate(-50%, -2px);
}
.results-toggle:focus-visible {
  outline: 3px solid var(--apricot);
  outline-offset: -3px;
}
.results-curtain {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  /* Matches the results pages so the page change looks seamless. */
  background-color: var(--color-background);
  border-top: 4px solid var(--espresso);
}
/* Phones: the triangle spans the full width. */
@media (max-width: 767px) {
  .has-drawer {
    padding-bottom: 8.5rem;
  }
  .results-toggle {
    width: 100%;
    padding: 3.5rem 1rem 0.75rem;
    font-size: 1.375rem;
  }
  .results-toggle::before {
    clip-path: polygon(43% 0, 57% 0, 100% 100%, 0 100%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .results-drawer,
  .results-chevron {
    transition: none;
  }
}
@media (min-width: 768px) {
  /* Desktop: logos and ticker (or category tabs) share one header row. */
  :is(.header-live, .header-results) .container {
    flex-direction: row;
    align-items: center;
    column-gap: 1rem;
    padding-block: 2rem;
  }
  .header-brand {
    flex-shrink: 0;
    column-gap: 1rem;
    padding-block: 0;
    border-image: none;
  }
  .live-ticker {
    flex: 1 1 0;
    margin-left: 1rem;
    padding-top: 0;
  }
  :is(.header-live, .header-results) .cts-logo {
    width: 70px;
  }
  :is(.header-live, .header-results) .logo {
    display: block;
    flex-shrink: 0;
    width: 160px;
  }
  .vote-ticker {
    font-size: var(--text-base);
  }
  .hero-wrapper.is-live {
    margin-block: 2rem;
    grid-template-columns: minmax(0, 1fr);
  }
  .results-toggle {
    width: 480px;
    padding-top: 2rem;
  }
}
@media (min-width: 1024px) {
  .hero-wrapper.is-live {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 35%);
    gap: 2rem;
  }
  .hero-wrapper.is-live .news {
    align-self: start;
  }
}

/* Results pages (mayor.html, council.html, ...) */
/* Header tab bar plus the 資料來源 note right below it. */
.results-header-nav {
  flex: 1 1 100%;
  min-width: 0;
}
.results-header-nav .results-source {
  margin-bottom: 0;
  padding-inline: 1.5rem;
}
.results-nav ul {
  display: flex;
  margin: 0;
  /* Inline padding keeps the end tabs clear of the rounded ends,
   * and scroll-padding keeps the same gap when a tab is scrolled into view. */
  padding: 0 1.5rem;
  scroll-padding-inline: 1.5rem;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  border-radius: 9999px;
  background-color: var(--apricot);
}
.results-nav li {
  flex-shrink: 0;
}
.results-nav a {
  display: block;
  padding: 0.375rem 0.75rem;
  white-space: nowrap;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
}
.results-nav a:hover {
  background-color: rgb(0 0 0 / 8%);
}
.results-nav a[aria-current="page"] {
  background-color: var(--espresso);
  color: var(--neutral);
}
.results-nav a:focus-visible {
  outline: 2px solid var(--espresso);
  outline-offset: -2px;
}
.results-source {
  margin-block: 0.75rem;
  color: var(--color-muted);
  font-size: 0.75rem;
  text-align: center;
}
@media (min-width: 768px) {
  .results-source {
    text-align: end;
  }
}
.results-status,
.results-empty {
  padding-block: 2rem;
  text-align: center;
  color: var(--color-muted);
}
.results-batch {
  margin-bottom: 1rem;
}
.results-batch:focus {
  outline: none;
}
.results-grid {
  display: grid;
  gap: 1rem;
  align-items: start;
}
.results-ad {
  margin-block: 1rem;
}
.results-more-cities {
  display: block;
  margin: 1rem auto 2rem;
  padding: 0.5rem 2rem;
  border: 0;
  border-radius: var(--radius-lg);
  background-color: var(--chustnut);
  color: var(--neutral);
  font-size: var(--text-lg);
  font-weight: 700;
  cursor: pointer;
}
.result-card {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background-color: #e8cdb7;
}
.result-card-heading {
  padding: 0.25rem 1rem;
  background-color: var(--chustnut);
  color: var(--neutral);
  font-size: var(--text-base);
  letter-spacing: 0.5rem;
  text-align: center;
}
.result-main-list,
.result-sub-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.result-main-list {
  display: grid;
  /* minmax(0, 1fr): a long unbreakable name can't widen the column past the card. */
  grid-template-columns: minmax(0, 1fr);
  gap: 0.375rem;
  padding: 0.375rem;
}
.result-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  /* Extra right space leaves room for the 當選 stamp. */
  padding: 0.5rem 1.25rem 0.5rem 0.75rem;
  border-radius: var(--radius-lg);
  background-color: var(--peach);
}
.result-main .result-number {
  flex: 0 0 1.25rem;
  text-align: center;
  font-size: var(--text-lg);
}
.result-avatar {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  overflow: hidden;
  border-radius: 50%;
  background-color: #d9a98a;
}
.result-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* 政黨圖案 (fallback when a candidate has no avatar): show the whole logo. */
.result-avatar img[src*="images/parties/"] {
  object-fit: contain;
  background-color: #fff;
}
.result-main .result-who {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  line-height: 1.2;
}
/* 原住民族語名 (e.g. Malereleve·Maabaivi) has no break point on Windows;
   let it wrap anywhere instead of overflowing the card. */
.result-who {
  overflow-wrap: anywhere;
}
.result-party {
  font-size: 0.75rem;
}
.result-main .result-name {
  font-size: var(--text-lg);
  letter-spacing: 0.1rem;
}
.result-votes {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* 當選 stamp, overlapping the end of the vote count like a seal. */
.result-elected {
  position: absolute;
  top: 50%;
  right: -1.375rem;
  width: 1.75rem;
  height: 1.75rem;
  transform: translateY(-50%);
  pointer-events: none;
}
.result-main .result-elected {
  right: -1.5rem;
  width: 2.25rem;
  height: 2.25rem;
}
.result-main .result-votes {
  padding-inline: 0.25rem;
  border-bottom: 2px solid var(--taupe);
}
.result-main .result-votes-number {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: 0.05rem;
}
.result-sub-list {
  padding: 0 1.5rem 0.5rem 1rem;
}
.result-sub {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-block: 0.375rem;
  border-bottom: 2px solid var(--mocha);
  font-weight: 700;
}
.result-sub .result-who {
  min-width: 0;
}
.result-sub .result-number {
  flex: 0 0 1.5rem;
  font-variant-numeric: tabular-nums;
}
/* 10+ candidates: two-digit-wide 號次 keeps the names aligned. */
.result-card-wide-number .result-main .result-number {
  flex-basis: 2ch;
  font-variant-numeric: tabular-nums;
}
.result-card-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0 0.75rem 0.5rem;
}
.result-card-footer:has(> [hidden]) {
  display: none;
}
.result-toggle {
  padding: 0 0.75rem;
  border: 0;
  border-radius: 9999px;
  background-color: var(--chustnut);
  color: var(--neutral);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05rem;
  cursor: pointer;
}
.result-card-single {
  max-width: 420px;
  margin-inline: auto;
}
.result-card-single .result-sub-list {
  padding-bottom: 1.5rem;
}
.result-selects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
  letter-spacing: 0.1rem;
}
.result-select {
  position: relative;
  max-width: 100%;
  border-radius: var(--radius-sm);
}
/* Visible label of the chosen option; wraps when the name is long. */
.result-select-value {
  display: block;
  padding: 0.125rem 1.25rem 0.125rem 0.25rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 2h8L5 9z' fill='%23d6d6d6'/%3E%3C/svg%3E")
    no-repeat right 0.25rem center / 0.625rem;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}
/* The real select covers the label invisibly to keep native behaviour. */
.result-select select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  appearance: none;
  opacity: 0;
  cursor: pointer;
}
.result-select:has(select:focus-visible) {
  outline: 2px solid var(--apricot);
}
.result-select option {
  color: var(--espresso);
}
@media (min-width: 768px) {
  /* Results pages: no bottom rule on the header (≥1280px draws it on
   * .container, so clear both). */
  .header-results,
  .header-results .container {
    border-bottom: 0;
  }
  .results-header-nav {
    flex: 1 1 0;
    margin-left: 1rem;
  }
  .results-nav a {
    padding: 0.5rem 1rem;
  }
  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1280px) {
  .results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* Results menu: a dropdown at the top of main below the tablet breakpoint;
 * the header tab bar takes over from 768px. */
.results-menu {
  position: relative;
  z-index: 20;
  /* A fixed width that fits the longest option (6 characters) plus the
   * toggle's letter-spacing and arrow. Not max-content: iOS Safari measures
   * that too narrow with the fluid font size and clips the last characters. */
  width: 15em;
  max-width: 100%;
  height: 2.25rem;
  margin: 1rem auto 1.25rem;
}
.results-menu:has(> .results-menu-toggle[hidden]) {
  /* Without JS the list is always shown, so let it take up space. */
  height: auto;
}
/* A dark label block with a grey arrow segment on its right edge. */
.results-menu-toggle {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  height: 2.25rem;
  padding: 0 0 0 1.5rem;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background-color: var(--espresso);
  color: var(--neutral);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.3rem;
  line-height: 2.25rem;
  cursor: pointer;
}
.results-menu-toggle[hidden] {
  display: none;
}
.results-menu-toggle::after {
  content: "";
  flex: 0 0 2.25rem;
  background: var(--taupe)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1.2 1h9.6a.8.8 0 0 1 .7 1.2L6.7 9.1a.8.8 0 0 1-1.4 0L.5 2.2A.8.8 0 0 1 1.2 1z' fill='%23d9d4cf'/%3E%3C/svg%3E")
    center / 0.8rem no-repeat;
  transition: transform 0.2s;
}
.results-menu-toggle[aria-expanded="true"]::after {
  transform: scaleY(-1);
}
.results-menu-toggle:focus-visible {
  outline: 2px solid var(--espresso);
  outline-offset: 2px;
}
.results-menu ul {
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background-color: var(--apricot);
  box-shadow: 0 4px 12px rgb(0 0 0 / 20%);
}
.results-menu-toggle[aria-expanded="false"] + ul {
  visibility: hidden;
}
.results-menu li + li {
  border-top: 1px solid rgb(0 0 0 / 10%);
}
.results-menu a {
  display: block;
  padding: 0.625rem 1rem;
  /* Wrap rather than clip if a label ever outgrows the menu. */
  overflow-wrap: anywhere;
  color: var(--color-text);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.results-menu a:hover {
  background-color: rgb(0 0 0 / 8%);
}
.results-menu a[aria-current="page"] {
  background-color: var(--espresso);
  color: var(--neutral);
}
.results-menu a:focus-visible {
  outline: 2px solid var(--espresso);
  outline-offset: -2px;
}
@media (prefers-reduced-motion: reduce) {
  .results-menu-toggle::after {
    transition: none;
  }
}
@media (max-width: 767px) {
  /* Phones use .results-menu instead; js/results.js moves the source note
   * out of this wrapper into main, so hiding it here is safe. */
  .header-results .results-header-nav {
    display: none;
  }
}
@media (min-width: 768px) {
  .results-menu {
    display: none;
  }
}

/* Referendum page (referendum.html) */
.referendum {
  --rust: #b25b3c;
  max-width: 960px;
  margin-inline: auto;
  padding: 0 0.75rem 1rem;
}
.referendum-title {
  margin-block: 1.5rem 1rem;
  text-align: center;
}
.referendum-title h1 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: var(--leading-tight);
}
.referendum-title p {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  font-weight: 700;
}
.referendum-question {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 640px;
  margin: 0 auto 1.5rem;
}
.referendum-badge {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto auto;
  place-content: center;
  align-items: center;
  column-gap: 0.125rem;
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 50%;
  background-color: var(--rust);
  color: var(--neutral);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.1;
}
.referendum-badge > span:first-child {
  grid-column: 1 / -1;
  text-align: center;
}
.referendum-badge-number {
  font-size: 1.5rem;
  font-weight: 800;
}
.referendum-question-text {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 800;
  line-height: 1.35;
}
.referendum-question-note {
  margin: 0.25rem 0 0;
  color: var(--color-muted);
  font-size: 0.75rem;
}
.referendum-section {
  margin-block: 1.5rem;
}
/* 「公投 + 副標」title: a pre-drawn image (images/referendum-*heading.png). */
.referendum-heading {
  margin: 0 0 1.5rem;
  line-height: 1;
  text-align: center;
}
.referendum-heading img {
  display: inline-block;
  width: auto;
  max-width: 100%;
  height: 5.5rem;
  object-fit: contain;
}
/* 正方/反方: two columns side by side on every screen size. */
.referendum-sides {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-block: 1.5rem;
}
.referendum-points + .referendum-points {
  padding-left: 0.75rem;
  border-left: 2px solid rgb(64 64 64 / 20%);
}
.referendum-points h3 {
  margin: 0 0 0.5rem;
  font-size: var(--text-base);
  font-weight: 800;
  line-height: var(--leading-tight);
}
.referendum-points ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: point;
  display: grid;
  gap: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
}
.referendum-points li {
  position: relative;
  /* Hanging indent: wrapped lines line up with the text after the number. */
  padding-left: 1.5em;
  counter-increment: point;
}
.referendum-points li::before {
  content: counter(point);
  /* Circled number like ①②③. */
  position: absolute;
  top: 0.3em;
  left: 0;
  display: grid;
  place-items: center;
  width: 1.1em;
  height: 1.1em;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.875em;
  line-height: 1;
}
@media (max-width: 767px) {
  /* Phones: centred heading with the stance on its own line, and each
   * point's label on its own line above the explanation. */
  .referendum-points h3 {
    text-align: center;
  }
  .referendum-points h3 span,
  .referendum-points li strong {
    display: block;
  }
}
.referendum .ads {
  margin-block: 1.5rem;
}
.referendum-criteria {
  max-width: 640px;
  margin: 0 auto 2rem;
  font-weight: 700;
}
.referendum-criteria h3 {
  margin: 0 0 0.5rem;
  font-size: var(--text-lg);
  font-weight: 800;
}
.referendum-criteria ol {
  margin: 0;
  padding-left: 1.25rem;
  font-size: var(--text-sm);
  line-height: 1.8;
}
.referendum-criteria-note {
  display: block;
  font-size: 0.75rem;
}
.referendum-criteria-extra {
  margin: 0.75rem 0 0;
  font-size: var(--text-sm);
}
.referendum-outcomes {
  display: grid;
  gap: 2rem;
}
.referendum-outcome {
  max-width: 480px;
  width: 100%;
  margin-inline: auto;
}
.referendum-outcome-heading {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin: 0 0 -1.5rem;
  padding-left: 1.5rem;
  position: relative;
  z-index: 1;
}
/* A round sign on a stick, like a vote paddle (images/referendum-sign-*.png). */
.referendum-sign {
  flex-shrink: 0;
  width: auto;
  height: 7.5rem;
}
.referendum-outcome-label {
  margin-bottom: 2.5rem;
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: 0.25rem;
}
.referendum-card {
  padding: 2.5rem 1.75rem 2rem;
  border-radius: var(--radius-3xl);
  background-color: var(--rust);
  color: var(--neutral);
  font-weight: 700;
  line-height: 1.7;
  box-shadow: 0 4px 8px rgb(0 0 0 / 15%);
}
.referendum-card h4 {
  margin: 0 0 0.25rem;
  font-size: var(--text-xl);
  font-weight: 800;
}
.referendum-card h4 + p {
  margin-top: 0;
}
.referendum-card p {
  margin: 0;
  font-size: var(--text-sm);
}
.referendum-card p + h4 {
  margin-top: 1.25rem;
}
/* 公投注意事項: pill tags with short notes under each. */
.referendum-notes {
  max-width: 640px;
  margin-inline: auto;
  font-weight: 700;
}
.referendum-note + .referendum-note {
  margin-top: 1.75rem;
}
.referendum-note-tag {
  display: inline-block;
  min-width: 13rem;
  margin: 0 0 0.75rem;
  padding: 0.375rem 1.25rem;
  border-radius: 999px;
  background-color: var(--chustnut);
  color: var(--neutral);
  font-size: var(--text-lg);
  font-weight: 800;
  line-height: 1.3;
}
.referendum-note-tag-rust {
  min-width: 0;
  background-color: var(--rust);
}
.referendum-note-date {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0 0 0.25rem 1rem;
  font-size: var(--text-xl);
  font-weight: 800;
}
.referendum-note-weekday {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background-color: var(--chustnut);
  color: var(--neutral);
  font-size: 0.875rem;
}
.referendum-note-time {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 0 1.25rem 3.5rem;
  font-size: var(--text-base);
  font-weight: 800;
}
.referendum-note-dash {
  width: 2.5rem;
  border-top: 2px solid currentColor;
}
.referendum-note-text {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.75;
}
.referendum-note-big {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 800;
}
.referendum-note-sub {
  margin: 0;
}
.referendum-note-list,
.referendum-note-warnings {
  margin: 0;
  padding-left: 1.25rem;
  font-size: var(--text-sm);
  line-height: 1.6;
}
.referendum-note-list {
  padding-left: 2.25rem;
}
.referendum-note-list li + li {
  margin-top: 0.5rem;
}
.referendum-note-warnings {
  list-style: none;
  margin-top: 0.5rem;
}
.referendum-note-warnings li {
  position: relative;
  padding-left: 1.75rem;
}
.referendum-note-warnings li + li {
  margin-top: 0.5rem;
}
/* ⚠ warning triangle before each note. */
.referendum-note-warnings li::before {
  content: "!";
  position: absolute;
  top: 0.2em;
  left: 0;
  display: grid;
  place-items: end center;
  width: 1.25rem;
  height: 1.1rem;
  padding-bottom: 0.05rem;
  background-color: var(--chustnut);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  color: var(--neutral);
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
}
.referendum-ok {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-left: 0.25rem;
  border-radius: 50%;
  background-color: var(--chustnut);
  color: var(--neutral);
  font-size: 0.75rem;
  font-weight: 800;
  vertical-align: middle;
}
.referendum-note-color {
  margin: 0 0 0 1.25rem;
  font-size: var(--text-sm);
}
/* 「白色」 as a small dark pill, like the 公投票樣式 tag. */
.referendum-note-color strong {
  display: inline-block;
  margin-inline: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  background-color: var(--chustnut);
  color: var(--neutral);
  font-weight: 800;
}
/* 公投票示意圖 (images/ballot.jpg) in a dark frame. */
.referendum-ballot {
  max-width: 340px;
  margin: 3rem auto 0;
  padding: 0.5rem;
  border: 3px solid var(--chustnut);
  background-color: #fff;
}
.referendum-ballot img {
  display: block;
  width: 100%;
  height: auto;
}
@media (min-width: 768px) {
  .referendum-title {
    margin-top: 0.5rem;
  }
  .referendum-heading img {
    height: 7rem;
  }
  .referendum-sides {
    gap: 2rem;
  }
  .referendum-points + .referendum-points {
    padding-left: 2rem;
  }
  .referendum-points h3 {
    font-size: var(--text-lg);
  }
  .referendum-points ol {
    font-size: var(--text-sm);
  }
  /* PC: 通過 / 未通過 side by side. */
  .referendum-outcomes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
  .referendum-outcome {
    display: flex;
    flex-direction: column;
    max-width: none;
  }
  .referendum-card {
    flex: 1;
  }
}

/* ===== 選後頁面 (after.html, mayor-after.html, council-after.html,
 * referendum-after.html) ===== */

/* after.html 縣市議員 row: 選區 follow one another (data-council-mode="district"). */
.district-track {
  display: flex;
  flex-shrink: 0;
  gap: 2rem;
  width: max-content;
  will-change: transform;
}

/* council-after.html: 得票率 after the vote count (data-percent). */
.results[data-percent] .result-card-single {
  max-width: 760px;
}
.result-percent {
  margin-left: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.05rem;
}
.result-main .result-percent {
  font-size: var(--text-lg);
}
/* Keep the 當選 stamp clear of the "%". */
.result-votes.has-percent:has(.result-elected) {
  padding-right: 0.75rem;
}
@media (max-width: 767px) {
  /* Phones: 得票率 on its own line under the vote count. */
  .result-main .result-percent {
    display: block;
    margin-left: 0;
    font-size: var(--text-base);
    text-align: right;
  }
  .result-sub .result-percent {
    margin-left: 0.75rem;
  }
}

/* mayor-after.html: 2022 / 2026 政黨版圖 (js/party-map.js). */
.party-maps {
  margin-block: 2rem;
}
.party-maps-grid {
  display: grid;
  gap: 2rem;
}
.party-map {
  position: relative;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  aspect-ratio: 740 / 1032;
}
.party-map svg {
  display: block;
  width: 100%;
  height: 100%;
}
.party-map-caption {
  position: absolute;
  right: 6%;
  bottom: 4%;
  color: var(--chustnut);
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: 0.2em;
  line-height: 1.1;
  text-align: center;
  pointer-events: none;
}
.party-map-year {
  display: block;
  font-size: var(--text-3xl);
  letter-spacing: 0.05em;
}
/* Labels (outlined text) sit above the shapes; let clicks reach the shapes. */
.party-map svg > :not([data-code]) {
  pointer-events: none;
}
.party-map-area {
  cursor: pointer;
  transition: opacity 0.15s;
}
.party-map-area:hover {
  opacity: 0.8;
}
.party-map-area:focus {
  outline: none;
}
.party-map .party-map-area:focus-visible,
.party-map .party-map-area.is-selected {
  stroke: var(--espresso);
  stroke-width: 4px;
}
.party-map-popup {
  position: absolute;
  top: 8%;
  left: 50%;
  z-index: 5;
  width: min(100%, 30rem);
  max-height: 84%;
  overflow-y: auto;
  padding: 0.75rem 1rem 1rem;
  border-radius: var(--radius-xl);
  background-color: rgb(126 89 70 / 92%);
  color: var(--neutral);
  transform: translateX(-50%);
  box-shadow: 0 4px 12px rgb(0 0 0 / 25%);
}
.party-map-popup[hidden] {
  display: none;
}
.party-map-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}
.party-map-popup-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: 0.15em;
}
.party-map-popup-close {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: rgb(255 255 255 / 75%);
  color: var(--chustnut);
  font: inherit;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.party-map-popup-close:focus-visible {
  outline: 2px solid var(--neutral);
  outline-offset: 2px;
}
.party-map-popup-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.party-map-popup-row {
  display: grid;
  grid-template-columns: 2ch minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  padding-block: 0.375rem;
  border-bottom: 1px solid rgb(255 255 255 / 55%);
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.party-map-popup-who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.5rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.party-map-popup-votes,
.party-map-popup-percent {
  text-align: right;
  white-space: nowrap;
}
.party-map-popup-elected {
  width: 1.5em;
  height: 1.5em;
  margin-block: -0.25em;
}
.party-map-popup-empty {
  padding-block: 1rem;
  text-align: center;
}
.party-map-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  font-weight: 700;
}
.party-map-legend li {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.party-map-legend span {
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 2px;
  background-color: var(--swatch);
}
.party-map-hint {
  margin: 0.5rem 0 0;
  color: var(--color-muted);
  font-size: 0.75rem;
  text-align: center;
}
.party-maps:not(.is-ready) .party-map-legend,
.party-maps:not(.is-ready) .party-map-hint {
  visibility: hidden;
}
@media (min-width: 768px) {
  .party-maps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 1100px;
    margin-inline: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  .party-map-area {
    transition: none;
  }
}

/* referendum-after.html: 同意 / 不同意票 bar with the 通過 / 不通過 stamp. */
.referendum-result {
  max-width: 1280px;
  padding-top: 1.5rem;
}
.referendum-result .referendum-heading {
  margin-bottom: 1.5rem;
}
.referendum-result-question {
  max-width: 60rem;
  margin: 0 auto 1.5rem;
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}
.referendum-unit {
  font-size: 0.6em;
}
.referendum-threshold {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  font-weight: 800;
}
.referendum-threshold-label {
  padding-right: 0.75rem;
  border-right: 3px solid currentColor;
  font-size: var(--text-lg);
  line-height: 1;
}
.referendum-threshold-value {
  font-size: var(--text-2xl);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.referendum-result-body {
  /* Room for the stamp hanging below the bar. */
  padding-bottom: 3rem;
}
.referendum-bar {
  display: flex;
  min-height: 4.5rem;
}
.referendum-bar-agree,
.referendum-bar-disagree {
  position: relative;
  flex: 1 1 0;
  /* Keep each side's numbers readable even when its share is small. */
  min-width: max-content;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* Extra bottom space keeps the hanging stamp off the numbers. */
  padding: 0.5rem 0.625rem 1rem;
  font-weight: 800;
  transition: flex-grow 0.8s ease-out;
}
.referendum-bar-agree {
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background-color: #9a6633;
  color: var(--neutral);
}
.referendum-bar-disagree {
  align-items: flex-end;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  background-color: #bdb2a7;
  color: #4a4038;
}
/* Phones: sizes follow the viewport so both sides fit side by side even on
 * a 320px screen (each side never shrinks below its text). */
.referendum-bar-label {
  font-size: min(var(--text-sm), 4vw);
}
.referendum-bar-count {
  font-size: min(var(--text-xl), 6.2vw);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  white-space: nowrap;
}
/* The seal overlaps the agree side's end and hangs below the bar. */
.referendum-stamp {
  position: absolute;
  top: 100%;
  right: -2.25rem;
  z-index: 1;
  width: 4.5rem;
  height: 4.5rem;
  transform: translateY(-25%);
  /* The text scales with the seal's own size (cqi). */
  container-type: size;
}
.referendum-stamp[hidden] {
  display: none;
}
/* 通過 / 不通過 seal drawn in CSS: a thick red ring with the result inside. */
.referendum-stamp-text {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  border: 0.75rem solid #c8102e;
  border-radius: 50%;
  background-color: rgb(255 255 255 / 85%);
  color: #c8102e;
  font-size: 20cqi;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  transform: rotate(12deg);
}
.referendum-result-more {
  margin: 0 0 1rem;
  font-size: var(--text-sm);
  text-align: center;
}
.referendum-result-more a {
  color: var(--chustnut);
  font-weight: 700;
}
@media (min-width: 768px) {
  .referendum-result {
    padding-top: 0;
  }
  .referendum-result-question {
    margin-bottom: 2.5rem;
  }
  .referendum-threshold {
    margin-bottom: 1.75rem;
  }
  .referendum-bar {
    min-height: 6rem;
  }
  /* Label above the count, as on phones (column layout from the base rule). */
  .referendum-bar-agree,
  .referendum-bar-disagree {
    gap: 0.25rem;
    /* Sizes scale with the viewport so tablets (768–1023px) fit too. */
    padding: 1rem min(2rem, 2.5vw);
  }
  .referendum-bar-label {
    font-size: min(var(--text-lg), 2.2vw);
  }
  .referendum-bar-count {
    font-size: min(var(--text-3xl), 4vw);
  }
  /* As on phones, the seal straddles the agree/disagree boundary and hangs
   * below the bar; it is absolutely positioned and reserves no bar width, so
   * both sides stay proportional to their votes. */
  .referendum-stamp {
    --stamp-size: min(7.5rem, 9.5vw);
    right: calc(var(--stamp-size) / -2);
    width: var(--stamp-size);
    height: var(--stamp-size);
    transform: translateY(-30%);
  }
  .referendum-result-body {
    /* The seal's lower 70% hangs below the bar. */
    padding-bottom: 5.5rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  .referendum-bar-agree,
  .referendum-bar-disagree {
    transition: none;
  }
}
