/**
 * 2026年選挙候補者一覧ページ用スタイル
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --page-content-max-width: 1100px;
  --page-content-padding: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  background: #fff;
  color: #1a1a1a;
  line-height: 1.5;
  min-height: 100vh;
}

.election-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.election-header {
  margin-bottom: 24px;
}

.election-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 10px;
}

.election-title svg {
  width: 28px;
  height: 28px;
  color: #2D8A6E;
}

.election-subtitle {
  font-size: 0.875rem;
  color: #666;
  margin-top: 6px;
  font-weight: 400;
}

.election-switch {
  margin-top: 12px;
  display: inline-flex;
  border: 1px solid #ddd;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.election-switch-item {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #333;
  text-decoration: none;
  background: #fff;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.election-switch-item:hover {
  background: #f5f5f5;
}

.election-switch-item.active {
  background: #2D8A6E;
  color: #fff;
}

.election-switch--centered {
  margin: 28px auto 0;
  display: inline-flex;
  left: 50%;
  transform: translateX(-50%);
  position: relative;
}

/* 当確議席サマリー */
.seat-summary {
  margin: 20px 0 32px;
}

.seat-summary__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.seat-summary__layout {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(320px, 2fr) minmax(180px, 1fr);
  grid-template-areas: "ruling chart opposition";
  gap: 18px;
  align-items: start;
}

.seat-summary__title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1a1a1a;
}

.seat-summary__side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  --accent-color: #555;
}

.seat-summary__side--ruling {
  --accent-color: #e11d48;
  grid-area: ruling;
}

.seat-summary__side--opposition {
  --accent-color: #2563eb;
  text-align: right;
  grid-area: opposition;
}

.seat-side__label {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-color);
}

.seat-side__value {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent-color);
}

.seat-side__pre {
  align-self: flex-start;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-color);
  padding: 6px 10px;
  border-radius: 6px;
  background: repeating-linear-gradient(
    -45deg,
    rgba(225, 29, 72, 0.15),
    rgba(225, 29, 72, 0.15) 4px,
    rgba(255, 255, 255, 0.7) 4px,
    rgba(255, 255, 255, 0.7) 8px
  );
}

.seat-summary__side--opposition .seat-side__pre {
  align-self: flex-end;
  background: repeating-linear-gradient(
    -45deg,
    rgba(37, 99, 235, 0.15),
    rgba(37, 99, 235, 0.15) 4px,
    rgba(255, 255, 255, 0.7) 4px,
    rgba(255, 255, 255, 0.7) 8px
  );
}

.seat-side__cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  gap: 4px;
  margin-top: 4px;
}

.seat-summary__side--opposition .seat-side__cards {
  grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
  justify-items: end;
  gap: 4px;
}

.seat-summary__side--opposition .seat-party-card {
  min-width: 50px;
  padding: 6px 4px;
}

.seat-summary__side--opposition .seat-party-card__name {
  font-size: 0.7rem;
}

.seat-summary__side--opposition .seat-party-card__value {
  font-size: 1.15rem;
}

.seat-party-card {
  border: 1px solid #e4e4e4;
  border-top: 5px solid var(--party-color, #999);
  border-radius: 0;
  background: #fff;
  padding: 10px 6px;
  text-align: center;
  box-shadow: none;
}

.seat-party-card__name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #222;
  letter-spacing: 0.02em;
}

.seat-party-card__value {
  margin-top: 4px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--party-color, #333);
}

.seat-summary__chart {
  text-align: center;
  margin-top: 0;
  grid-area: chart;
}

.seat-summary__cards-all {
  display: none;
  grid-area: cards;
}

.seat-chart {
  width: 100%;
  max-width: 520px;
  margin: 20px auto 0;
}

#seatChartSvg {
  width: 100%;
  height: auto;
  display: block;
}

#seatChartBase {
  fill: none;
  stroke: #e6e6e6;
  stroke-width: 75;
  stroke-linecap: butt;
}

.seat-arc {
  fill: none;
  stroke-width: 75;
  stroke-linecap: butt;
}

/* 選挙前勢力（内側レイヤー） */
.seat-arc-pre {
  fill: none;
  stroke-width: 28;
  stroke-linecap: butt;
}

#seatChartPreRuling {
  stroke: #e11d48;
  opacity: 0.3;
}

#seatChartPreOpposition {
  stroke: #2563eb;
  opacity: 0.3;
}

#seatChartPreLabel {
  font-size: 11px;
  font-weight: 600;
  fill: #666;
  text-anchor: middle;
}

/* 与党・野党（最外側レイヤー） */
.seat-arc-outer {
  fill: none;
  stroke-width: 18;
  stroke-linecap: butt;
}

.seat-arc-outer--ruling {
  stroke: #e11d48;
}

.seat-arc-outer--opposition {
  stroke: #2563eb;
}

/* 政党名ラベル（円弧内テキスト） */
.seat-party-label {
  font-size: 12px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

#seatChartMajority {
  stroke: #333;
  stroke-width: 2;
}

#seatChartMajorityLabel {
  font-size: 12px;
  font-weight: 700;
  fill: #333;
  text-anchor: middle;
}

/* 円弧アニメーション */
@keyframes drawArc {
  from {
    stroke-dashoffset: var(--arc-length);
  }
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes drawArcReverse {
  from {
    stroke-dashoffset: calc(-1 * var(--arc-length));
  }
  to {
    stroke-dashoffset: 0;
  }
}

.seat-arc-animated {
  stroke-dasharray: var(--arc-length);
  stroke-dashoffset: var(--arc-length);
  animation: drawArc 0.8s ease-out forwards;
}

.seat-arc-animated--reverse {
  stroke-dasharray: var(--arc-length);
  stroke-dashoffset: calc(-1 * var(--arc-length));
  animation: drawArcReverse 0.8s ease-out forwards;
}

/* 内側レイヤーは早めに開始 */
.seat-arc-pre.seat-arc-animated {
  animation-duration: 0.6s;
}

.seat-arc-pre.seat-arc-animated--reverse {
  animation-duration: 0.6s;
}

/* 外側レイヤーは遅れて開始 */
.seat-arc-outer.seat-arc-animated,
.seat-arc-outer.seat-arc-animated--reverse {
  animation-delay: 0.3s;
  animation-duration: 0.5s;
}

/* ラベルのフェードイン */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.seat-party-label {
  opacity: 0;
  animation: fadeIn 0.3s ease-out 0.7s forwards;
}

.seat-summary__remaining {
  margin-top: 6px;
  font-size: 0.85rem;
  color: #666;
}

/* フィルターセクション */
.filter-section {
  padding: 12px 0;
  margin-bottom: 24px;
}

.filter-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  flex: 1;
  min-width: 160px;
}

.filter-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.filter-select,
.filter-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.9rem;
  border: 1px solid #999;
  background: #fff;
  font-family: inherit;
  color: #1a1a1a;
  transition: border-color 0.15s ease;
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: #2D8A6E;
}

.filter-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M1 4l5 4 5-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.filter-input::placeholder {
  color: #999;
}

.filter-clear {
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
  background: #fff;
  border: 1px solid #999;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.filter-clear:hover {
  background: #f5f5f5;
  border-color: #666;
}

.filter-clear:active {
  background: #e8e8e8;
}

/* モバイル版フィルター */
.filter-mobile-tabs {
  display: none;
}

.filter-mobile-expanded {
  display: none;
}

/* 都道府県セクション */
.prefecture-section {
  margin-bottom: 32px;
}

.prefecture-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111;
  padding-left: 12px;
  border-left: 4px solid #2D8A6E;
  margin-bottom: 16px;
}

/* テーブル */
.candidates-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.candidates-table thead {
  background: #2D8A6E;
  color: #fff;
}

.candidates-table th {
  padding: 12px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
}

.candidates-table th.col-party,
.candidates-table th.col-attr,
.candidates-table th.col-wins,
.candidates-table th.col-pr,
.candidate-party,
.candidate-attribute,
.candidate-wins,
.candidate-pr {
  text-align: center;
}

/* 選挙区ヘッダー */
.district-row {
  background: #E8F5F0;
}

.district-row td {
  padding: 8px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: #2D8A6E;
  border-bottom: 1px solid #ddd;
}

/* 候補者行 */
.candidate-row {
  border-bottom: 1px solid #eee;
}

.candidate-row:hover {
  background: #fafafa;
}

.candidate-row td {
  padding: 14px 16px;
  vertical-align: middle;
}

.candidate-name-cell {
  min-width: 200px;
}

.candidate-name-wrap {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.candidate-name-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.candidate-reading {
  font-size: 0.7rem;
  color: #888;
  margin-bottom: 2px;
}

.candidate-name {
  font-size: 1rem;
  font-weight: 600;
  color: #111;
}

.candidate-name-text {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.candidate-age {
  color: #666;
  font-weight: 400;
}

.confirmed-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid #dc2626;
  white-space: nowrap;
  align-self: flex-start;
}

.confirmed-badge svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
}

.candidate-party {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
}

.candidate-party a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.candidate-party a:hover {
  text-decoration: underline;
}

.candidate-party .no-page {
  cursor: default;
  opacity: 0.7;
}

.candidate-party .no-page:hover {
  text-decoration: none;
}

/* ツールチップ */
.tooltip-container {
  position: relative;
  display: inline-block;
}

.tooltip-text {
  visibility: hidden;
  background: #fff;
  color: #333;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 6px 10px;
  position: absolute;
  z-index: 100;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  margin-bottom: 6px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #fff;
}

.tooltip-text::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #ddd;
}

.tooltip-container:hover .tooltip-text {
  visibility: visible;
}

.candidate-attribute {
  text-align: center;
  font-size: 0.9rem;
  color: #333;
}

.candidate-wins {
  text-align: center;
  font-size: 0.9rem;
  color: #333;
}

.candidate-pr {
  text-align: center;
  font-size: 0.9rem;
  color: #333;
}

.candidate-pr a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.candidate-pr a:hover {
  text-decoration-thickness: 2px;
}

/* 空状態 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: #ccc;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ローディング */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

/* 投票参加モーダル */
.invite-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.invite-modal-overlay.show {
  display: flex;
}

.invite-modal {
  background: #fff;
  border-radius: 12px;
  padding: 32px 28px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.invite-modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 12px;
}

.invite-modal-text {
  font-size: 0.9rem;
  color: #666;
  line-height: 1.6;
  margin-bottom: 24px;
}

.invite-modal-btn {
  display: inline-block;
  background: #2D8A6E;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.invite-modal-btn:hover {
  background: #247a5e;
}

.invite-modal-close {
  display: block;
  margin-top: 16px;
  font-size: 0.8rem;
  color: #999;
  background: none;
  border: none;
  cursor: pointer;
}

.invite-modal-close:hover {
  color: #666;
}

/* モバイル対応 */
@media (max-width: 640px) {
  .election-container {
    padding: 16px 12px 40px;
  }

  .seat-summary__layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "ruling opposition"
      "chart chart"
      "cards cards";
    gap: 10px 12px;
  }

  .seat-side__value {
    font-size: 1.9rem;
  }

  .seat-chart {
    max-width: 320px;
  }

  .seat-side__cards {
    display: none;
  }

  .seat-summary__side--opposition .seat-party-card {
    min-width: 0;
  }

  .seat-party-card {
    padding: 4px 2px;
    min-width: 52px;
  }

  .seat-party-card__name {
    font-size: 0.68rem;
  }

  .seat-party-card__value {
    font-size: 1.1rem;
  }

  .seat-summary__side--opposition {
    text-align: right;
  }

  .seat-summary__side--opposition .seat-side__pre {
    align-self: flex-end;
  }

  .seat-summary__cards-all {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(2, auto);
    grid-auto-columns: minmax(56px, 1fr);
    gap: 2px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .seat-summary__cards-all .seat-party-card {
    min-width: 0;
    width: 100%;
  }

  .election-header {
    margin-bottom: 12px;
  }

  .election-title {
    font-size: 1.2rem;
  }

  .election-title svg {
    width: 22px;
    height: 22px;
  }

  .election-subtitle {
    font-size: 0.75rem;
  }

  .filter-section {
    padding: 0;
    margin-bottom: 16px;
  }

  /* デスクトップ版を非表示 */
  .filter-row {
    display: none;
  }

  /* モバイル版を表示 */
  .filter-mobile-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border-bottom: 1px solid #ddd;
  }

  .filter-mobile-tab {
    flex: 1;
    padding: 10px 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #666;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
  }

  .filter-mobile-tab.active {
    border-bottom-color: #2D8A6E;
    color: #2D8A6E;
  }

  .filter-mobile-expanded {
    display: none;
    padding-top: 12px;
  }

  .filter-mobile-expanded.active {
    display: block;
  }

  .filter-mobile-expanded .filter-group {
    margin-bottom: 16px;
  }

  .filter-mobile-search-wrapper {
    position: relative;
  }

  .filter-mobile-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .filter-mobile-search-btn svg {
    width: 20px;
    height: 20px;
    color: #2D8A6E;
  }

  .filter-mobile-expanded .filter-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
  }

  .filter-mobile-expanded .filter-select,
  .filter-mobile-expanded .filter-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 1rem;
    border: 1px solid #999;
    background: #fff;
    font-family: inherit;
    color: #1a1a1a;
  }

  .filter-mobile-expanded .filter-select:focus,
  .filter-mobile-expanded .filter-input:focus {
    outline: none;
    border-color: #2D8A6E;
  }

  .filter-mobile-expanded .filter-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M1 4l5 4 5-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
  }

  .candidates-table th,
  .candidates-table td {
    padding: 10px 8px;
    font-size: 0.8rem;
  }

  .candidates-table th.col-wins {
    font-size: 0 !important;
  }

  .candidates-table th.col-wins::before {
    content: '当';
    font-size: 0.75rem;
    display: inline-block;
  }

  .candidates-table th.col-attr,
  .candidate-attribute {
    display: none;
  }

  .candidate-name-cell {
    min-width: 140px;
  }

  .candidate-name {
    font-size: 0.9rem;
  }

  .confirmed-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    gap: 3px;
  }

  .confirmed-badge svg {
    width: 11px;
    height: 11px;
  }

  .candidate-reading {
    font-size: 0.65rem;
  }

  .prefecture-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .prefecture-section {
    margin-bottom: 24px;
  }
}
