﻿/* =========================================================
 * 제9회 전국동시지방선거 투표현황 페이지 스타일
 * map.html 에서 <link rel="stylesheet" href="./css/map.css"> 로 로드
 * ========================================================= */

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Malgun Gothic', '맑은 고딕', sans-serif;
  background: linear-gradient(135deg, #0a1e3c 0%, #1a3a6e 100%);
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== 헤더 ===== */
header {
  text-align: center;
  padding: 30px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
header .badge {
  display: inline-block;
  padding: 4px 14px;
  background: #e53935;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 12px;
  animation: pulse 2s infinite;
}
header h1 {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 8px;
}
header p { font-size: 14px; color: #a0c4ff; }
header .live-clock {
  margin-top: 10px;
  font-size: 13px;
  color: #ffd700;
  font-weight: 600;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(229,57,53,0.7); }
  50% { opacity: 0.8; box-shadow: 0 0 0 8px rgba(229,57,53,0); }
}

/* ===== 전국 통계 ===== */
.national-stats {
  max-width: 1200px;
  margin: 20px auto;
  padding: 24px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.stat-card { text-align: center; }
.stat-label { font-size: 12px; color: #a0c4ff; margin-bottom: 6px; letter-spacing: 1px; }
.stat-value {
  font-size: 36px;
  font-weight: 900;
  color: #ffd700;
  letter-spacing: -1px;
}
.stat-value .unit { font-size: 18px; color: #fff; margin-left: 4px; }
.stat-sub { font-size: 11px; color: #a0c4ff; margin-top: 4px; }

/* ===== 메인 그리드 ===== */
.main-wrap {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 24px;
  align-items: start;
}
.cards-container { grid-row: span 2; }
.ticker-panel    { grid-column: 2; }

/* ===== 카드 영역 ===== */
.cards-container {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 20px;
}
.cards-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cards-title .tip { font-size: 12px; color: #a0c4ff; font-weight: 400; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.region-card {
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 12px 12px 14px;
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
  animation: cardEnter 0.5s ease both;
  position: relative;
  overflow: hidden;
}
.region-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--status-color, #78909c);
  transition: background 0.5s ease;
}
.region-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 215, 0, 0.6);
  background: rgba(255,255,255,0.07);
}
.region-card.active {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.12);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.35);
  transform: translateY(-2px);
}
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.card-name {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.card-type {
  font-size: 10px;
  color: #a0c4ff;
  padding: 2px 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
}
.card-turnout {
  font-size: 26px;
  font-weight: 900;
  color: var(--status-color, #78909c);
  line-height: 1;
  letter-spacing: -1px;
}
.card-turnout .unit {
  font-size: 12px;
  color: #a0c4ff;
  margin-left: 2px;
  font-weight: 600;
}
.card-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.card-bar-fill {
  height: 100%;
  background: var(--status-color);
  transition: width 1s ease;
  width: 0%;
}
.card-leading {
  margin-top: 8px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-leading .party-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* ===== 범례 ===== */
.legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #a0c4ff;
}
.legend-color {
  width: 14px; height: 14px;
  border-radius: 3px;
}

/* ===== 사이드 패널 ===== */
.side-panel { display: flex; flex-direction: column; gap: 20px; }
.panel {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 20px;
}
.panel-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-title .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #e53935;
  animation: blink 1.5s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== 선택 지역 상세 ===== */
.region-detail h3,
#detailName,
#wrapIndex #detailName {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
  color: #fff;
}
.region-detail .region-sub { font-size: 12px; color: #a0c4ff; margin-bottom: 14px; }
.progress-block { margin-bottom: 10px; }
.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}
.progress-bar {
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ===== 후보자 ===== */
.candidates-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.candidates-heading {
  font-size: 13px;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.candidate-card {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  margin-bottom: 10px;
  border-left: 4px solid var(--party-color);
  position: relative;
  animation: candidateIn 0.5s ease;
}
@keyframes candidateIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}
.candidate-photo {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: var(--party-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 20px;
  color: #fff;
  position: relative;
}
.candidate-rank {
  position: absolute;
  top: -6px; left: -6px;
  width: 22px; height: 22px;
  background: #ffd700;
  color: #0a1e3c;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0a1e3c;
}
.candidate-rank.rank-1 { background: #ffd700; }
.candidate-rank.rank-2 { background: #c0c0c0; }
.candidate-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.candidate-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
.candidate-party {
  font-size: 12px;
  color: var(--party-color);
  font-weight: 600;
}
.candidate-result { text-align: right; align-self: center; }
.candidate-pct {
  font-size: 22px;
  font-weight: 900;
  color: var(--party-color);
  line-height: 1;
}
.candidate-pct .unit { font-size: 13px; color: #a0c4ff; font-weight: 600; }
.candidate-votes {
  font-size: 11px;
  color: #a0c4ff;
  margin-top: 3px;
}
/* ===== 유력·확정 배지 ===== */
.win-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  margin-left: 4px;
  letter-spacing: 0.5px;
}
.win-badge.leading  { background: rgba(255,215,0,0.15); color: #ffd700; border: 1px solid rgba(255,215,0,0.5); }
.win-badge.confirmed { background: #ffd700; color: #0a1e3c; }

.gap-indicator {
  margin-top: 6px;
  font-size: 11px;
  color: #ffd700;
  text-align: center;
  font-weight: 700;
}

/* ===== 실시간 업데이트 티커 ===== */
.ticker-panel {
  background: rgba(229, 57, 53, 0.15);
  border: 1px solid rgba(229, 57, 53, 0.3);
}
.ticker-list {
  list-style: none;
  overflow: hidden;
  position: relative;
}
.ticker-list li {
  padding: 8px 0;
  font-size: 12px;
  border-bottom: 1px dashed rgba(255,255,255,0.1);
  animation: slideIn 0.5s ease;
}
.ticker-list li .time { color: #ffd700; font-weight: 700; margin-right: 8px; }
.ticker-list li .region-name { font-weight: 700; color: #4fc3f7; }
@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== 풋터 ===== */
footer {
  text-align: center;
  padding: 30px 20px;
  font-size: 11px;
  color: #a0c4ff;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 30px;
}

/* ===== 반응형 ===== */
@media (max-width: 900px) {
  .main-wrap { grid-template-columns: 1fr; }
  .national-stats { grid-template-columns: repeat(2, 1fr); }
  .cards-grid { grid-template-columns: repeat(3, 1fr); }
  .cards-container { order: 2; grid-row: auto; }
  .side-panel      { order: 1; }
  .ticker-panel    { order: 3; grid-column: auto; }
}
@media (max-width: 600px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}
