/* Polls page: headline summary, chart shell, trend chart and view switcher. */

.polls-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.polls-hero h1 {
  font-size: clamp(1.6rem, 2.6vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.35rem;
}

.polls-hero .polls-verdict {
  color: #475467;
  font-size: 0.98rem;
  margin: 0;
}

.polls-meta {
  color: #667085;
  font-size: 0.8rem;
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
}

.polls-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #ecfdf3;
  color: #027a48;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.polls-badge.is-hung {
  background: #fff6ed;
  color: #b93815;
}

/* ------------------------------------------------------------------ */
/* Headline party summary                                             */
/* ------------------------------------------------------------------ */

.poll-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

/* Collapsed shows the leading parties plus one combined card; expanded swaps
   that combined card out for the individual parties behind it. */
.poll-summary[data-collapsed='true'] [data-role='extra'] { display: none; }
.poll-summary[data-collapsed='false'] [data-role='other'] { display: none; }

.poll-summary-card.is-other {
  --party-color: #98a2b3;
  background: #fcfcfd;
  border-style: dashed;
}

.poll-summary-note {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #98a2b3;
  margin-top: 0.15rem;
}

.poll-summary-actions {
  margin-bottom: 1.25rem;
}

.poll-summary-toggle {
  appearance: none;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 999px;
  padding: 0.34rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #344054;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.poll-summary-toggle:hover {
  border-color: #98a2b3;
  color: #101828;
}

.poll-summary-toggle:focus-visible {
  outline: 2px solid #1570ef;
  outline-offset: 1px;
}

.poll-summary-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 12px;
  padding: 0.7rem 0.8rem 0.75rem;
  overflow: hidden;
}

/* Keeps the figures on a common baseline when a party name wraps. */
.poll-summary-card .poll-summary-pct {
  margin-top: auto;
}

.poll-summary-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--party-color, #98a2b3);
}

.poll-summary-party {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: #475467;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.3rem;
  /* Names are longer than the card in the narrowest columns. */
  overflow-wrap: anywhere;
}

.poll-summary-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--party-color, #98a2b3);
  flex: 0 0 auto;
}

.poll-summary-pct {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #101828;
  font-variant-numeric: tabular-nums;
}

.poll-summary-foot {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: #667085;
  font-variant-numeric: tabular-nums;
}

.poll-delta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.poll-delta.is-up { color: #027a48; }
.poll-delta.is-down { color: #b42318; }
.poll-delta.is-flat { color: #98a2b3; }

/* ------------------------------------------------------------------ */
/* Chart shell                                                        */
/* ------------------------------------------------------------------ */

.poll-chart-card {
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 16px;
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 1.75rem;
}

.poll-chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.poll-chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #101828;
  margin: 0;
}

.poll-chart-subtitle {
  font-size: 0.78rem;
  color: #667085;
  margin: 0.1rem 0 0;
}

/* Segmented control, used for both the view switcher and the date range. */
.seg {
  display: inline-flex;
  background: #f2f4f7;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #475467;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.36rem 0.72rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.seg button:hover {
  color: #101828;
}

.seg button[aria-pressed='true'],
.seg button[aria-selected='true'] {
  background: #fff;
  color: #101828;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1);
}

.seg button:focus-visible {
  outline: 2px solid #1570ef;
  outline-offset: 1px;
}

.seg.seg-sm button {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

/* Party legend chips */
.poll-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.35rem 0 0.85rem;
}

.poll-legend button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 999px;
  padding: 0.28rem 0.7rem 0.28rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #344054;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.poll-legend button:hover {
  border-color: #98a2b3;
}

.poll-legend button:focus-visible {
  outline: 2px solid #1570ef;
  outline-offset: 1px;
}

.poll-legend .legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--party-color, #98a2b3);
  flex: 0 0 auto;
  transition: background 0.15s ease;
}

/* Muted state mirrors the reference design: the chip stays clickable. */
.poll-legend button[aria-pressed='false'] {
  color: #98a2b3;
  background: #f9fafb;
}

.poll-legend button[aria-pressed='false'] .legend-dot {
  background: #d0d5dd;
}

/* ------------------------------------------------------------------ */
/* Chart panels                                                       */
/* ------------------------------------------------------------------ */

/* These containers set an explicit display, which would otherwise beat the
   user-agent rule for [hidden]. */
.poll-panel[hidden],
.poll-legend[hidden],
.seg[hidden] { display: none !important; }

#pollTrend {
  width: 100%;
  height: 420px;
}

#seatChart {
  width: 100%;
  height: 720px;
}

.trend-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.trend-gridline {
  stroke: #eaecf0;
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.trend-axis-line {
  stroke: #d0d5dd;
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.trend-ylabel,
.trend-xlabel {
  fill: #98a2b3;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.trend-xlabel { fill: #667085; }

.trend-endlabel {
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.trend-empty {
  fill: #98a2b3;
  font-size: 13px;
}

.trend-crosshair {
  stroke: #98a2b3;
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.trend-line { pointer-events: none; }
.trend-dots { pointer-events: none; }
.trend-hover-dot { pointer-events: none; }

.trend-tip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  min-width: 178px;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
  padding: 0.55rem 0.65rem;
  font-size: 0.78rem;
  color: #344054;
}

.trend-tip-date {
  font-weight: 800;
  color: #101828;
  font-size: 0.78rem;
}

.trend-tip-sub {
  color: #667085;
  font-size: 0.72rem;
  margin-bottom: 0.35rem;
}

.trend-tip-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.09rem 0;
}

.trend-tip-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.trend-tip-name {
  flex: 1 1 auto;
  white-space: nowrap;
}

.trend-tip-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #101828;
}

.poll-chart-note {
  color: #667085;
  font-size: 0.76rem;
  margin: 0.6rem 0 0;
}

/* ------------------------------------------------------------------ */
/* Single-poll vote share chart                                       */
/* ------------------------------------------------------------------ */

.share-chart {
  --share-cols: 9rem 1fr 3.6rem 4.6rem;
  padding: 0.35rem 0 0;
}

.share-row,
.share-axis {
  display: grid;
  grid-template-columns: var(--share-cols);
  align-items: center;
  gap: 0.7rem;
}

.share-row {
  padding: 0.34rem 0;
}

.share-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #344054;
  min-width: 0;
}

.share-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--party-color, #98a2b3);
  flex: 0 0 auto;
}

.share-track {
  position: relative;
  height: 22px;
  border-radius: 5px;
  background-color: #f9fafb;
  background-image: repeating-linear-gradient(
    to right, #eaecf0 0 1px, transparent 1px var(--tick, 25%)
  );
}

.share-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 5px;
  background: var(--party-color, #98a2b3);
  min-width: 2px;
}

.share-value {
  text-align: right;
  font-size: 0.9rem;
  font-weight: 800;
  color: #101828;
  font-variant-numeric: tabular-nums;
}

.share-seats {
  text-align: right;
  font-size: 0.78rem;
  color: #667085;
  font-variant-numeric: tabular-nums;
}

.share-axis {
  margin-top: 0.3rem;
}

.share-axis-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 600;
  color: #98a2b3;
  font-variant-numeric: tabular-nums;
}

.share-delta {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ */
/* Poll detail furniture                                              */
/* ------------------------------------------------------------------ */

.poll-detail-source {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.poll-fulltable {
  border: 1px solid #e4e7ec;
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  background: #fff;
  margin-bottom: 1.5rem;
}

.poll-fulltable > summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  color: #344054;
}

.poll-fulltable > summary::marker { color: #98a2b3; }

.poll-fulltable table {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
}

.poll-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #e4e7ec;
  padding-top: 1rem;
}

.poll-nav-link {
  display: inline-flex;
  flex-direction: column;
  gap: 0.1rem;
  max-width: 20rem;
  text-decoration: none;
  color: #101828;
  font-size: 0.85rem;
  font-weight: 600;
}

.poll-nav-link span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #98a2b3;
}

.poll-nav-link:hover { color: #1570ef; }

@media (max-width: 575.98px) {
  .share-chart { --share-cols: 5.6rem 1fr 3.2rem; }
  .share-seats { display: none; }
}

/* ------------------------------------------------------------------ */
/* Poll archive cards                                                 */
/* ------------------------------------------------------------------ */

.poll-archive-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 0.75rem;
  color: #101828;
}

.poll-card {
  height: 100%;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 14px;
  padding: 0.95rem 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.poll-card:hover {
  border-color: #d0d5dd;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.07);
}

.poll-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.poll-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  margin: 0 0 0.15rem;
  line-height: 1.3;
}

.poll-card-title a {
  color: #101828;
  text-decoration: none;
}

.poll-card-title a:hover { text-decoration: underline; }

.poll-card-meta {
  color: #667085;
  font-size: 0.78rem;
}

.poll-card-bars {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.poll-bar-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr 3rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.poll-bar-name {
  color: #475467;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.poll-bar-track {
  background: #f2f4f7;
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.poll-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--party-color, #98a2b3);
}

.poll-bar-value {
  text-align: right;
  font-weight: 700;
  color: #101828;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 575.98px) {
  #pollTrend { height: 320px; }
  #seatChart { height: 460px; }
  /* Two columns rather than three, so long names like "Conservative" fit. */
  .poll-summary { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .poll-summary-pct { font-size: 1.35rem; }
}
