/* css/live.css — #live 라우트 전용. 기존 css/main.css와 독립. */

.live-root { max-width: 1200px; margin: 0 auto; padding: 16px 20px 64px; }

.live-hero { margin: 8px 0 24px; padding: 16px 0 20px; border-bottom: 1px solid #e5e5e5; }
.live-title { font-size: 1.8rem; font-weight: 800; margin: 0 0 12px; letter-spacing: -0.02em; }
.live-hero-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: 0.95rem; }
.live-stat { color: #555; }
.live-disclaimer { margin: 12px 0 0; font-size: 0.85rem; color: #666; line-height: 1.5; }

.live-badge { padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 0.85rem; }
.live-badge-fresh { background: #e8f3ec; color: #176d3a; }
.live-badge-stale { background: #fdecea; color: #b3261e; }
.live-badge-demo  { background: #fff4e3; color: #8b6500; }

.live-section { margin-top: 36px; }
.live-section-title { font-size: 1.3rem; font-weight: 700; margin: 0 0 14px; padding-bottom: 6px; border-bottom: 2px solid #1a1a1a; }
.live-section-count { font-size: 0.85rem; color: #888; margin-left: 10px; font-weight: 500; }

.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }

.live-race { border: 1px solid #ddd; border-radius: 8px; padding: 14px 16px; background: #fff; }
.live-race-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #eee; gap: 8px; }
.live-race-region { font-weight: 700; font-size: 1.05rem; display: inline-flex; align-items: center; gap: 8px; }
.live-race-progress { font-weight: 600; color: #444; font-size: 0.9rem; white-space: nowrap; }

/* 출구조사 배지 — race 카드 헤더에 표시 */
.live-race-exit-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  background: #fff4e3;
  color: #8b6500;
  border: 1px solid #f0d68f;
  letter-spacing: -0.01em;
}
.live-race.has-exit {
  border-color: #d8c08a;
  box-shadow: 0 0 0 1px rgba(216, 192, 138, 0.3) inset;
}

/* 출구조사 면책 박스 — phase 배너 다음 */
.live-exit-notice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 0 0 16px;
  background: #fff8e3;
  border-left: 4px solid #b8860b;
}
.live-exit-notice-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #8b6500;
}
.live-exit-notice-body {
  font-size: 0.84rem;
  color: #6a4e00;
  line-height: 1.5;
}

.live-cand { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed #eee; }
.live-cand:last-child { border-bottom: none; }
.live-cand-rank { flex: 0 0 22px; font-weight: 800; color: #888; font-size: 1.05rem; padding-top: 2px; }
.live-cand-body { flex: 1; min-width: 0; }
.live-cand-line1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.live-cand-name { font-weight: 700; font-size: 1rem; }
.live-cand-party { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.live-cand-bar-wrap {
  position: relative;
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  margin: 6px 0;
}
.live-cand-bar { height: 100%; transition: width 0.6s ease; border-radius: 3px; }

/* 출구조사 위치 표식 — 막대 위 세로선 + 작은 삼각형. 후보 정당 색상으로 테두리. */
.live-cand-exit-marker {
  position: absolute;
  top: -3px;
  width: 0;
  height: 12px;
  border-left: 2px dashed #888;
  transform: translateX(-1px);
}
.live-cand-exit-marker::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -4px;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  color: inherit;
}
.live-cand-exit-line {
  font-size: 0.74rem;
  color: #555;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.live-cand-exit-line strong {
  color: #1a1a1a;
  font-weight: 800;
}
.live-cand-exit-range {
  color: #999;
  font-weight: 400;
  margin-left: 4px;
}
.live-cand-line3 { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; color: #555; font-variant-numeric: tabular-nums; }
.live-cand-share { font-weight: 700; color: #1a1a1a; }

.live-gap { padding: 8px 0 0; margin-top: 6px; font-size: 0.85rem; color: #555; border-top: 1px solid #f0f0f0; }
.live-gap-tight { padding: 8px 0 0; margin-top: 6px; font-size: 0.9rem; color: #c41e3a; font-weight: 700; border-top: 1px solid #f0f0f0; }

/* 8회 당선 비교 한 줄 — race 카드 footer */
.live-race-history {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #eee;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #555;
  line-height: 1.4;
}
.live-race-history-label {
  color: #999;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.live-race-history-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
}
.live-race-history-name { font-weight: 700; color: #1a1a1a; }
.live-race-history-party { font-weight: 600; font-size: 0.78rem; }
.live-race-history-pct {
  color: #444;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.live-race-history-gap {
  color: #777;
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
}
.live-race-history-regime {
  margin-left: auto;
  font-weight: 700;
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.live-race-history-regime.regime-hold {
  background: #ecf6f0;
  color: #126b3f;
  border: 1px solid #c8e3d4;
}
.live-race-history-regime.regime-flip {
  background: #fff4f4;
  color: #b3261e;
  border: 1px solid #f3c8c8;
}

.live-empty { color: #888; padding: 24px 0; }
.live-empty-mini { color: #aaa; font-size: 0.85rem; margin: 0; }

/* 섹션 내부 안내문은 박스로 감싸 다른 박스들과 좌우 폭을 맞춘다 */
.live-section > .live-empty {
  margin: 0;
  padding: 28px 18px;
  background: #fafafa;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  text-align: center;
  line-height: 1.6;
  color: #666;
}

/* 시뮬레이션 진입 링크 — 6/3 18:00 이후 노출 */
.live-sim-link {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
  padding: 12px 16px;
  border: 1px solid #1a1a1a;
  border-radius: 8px;
  background: #1a1a1a;
  color: #fff;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.live-sim-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.live-sim-link-icon { font-size: 1.4rem; flex: 0 0 auto; }
.live-sim-link-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.live-sim-link-body strong { font-size: 0.95rem; }
.live-sim-link-body span { font-size: 0.78rem; opacity: 0.8; }
.live-sim-link-arrow { font-size: 1.1rem; font-weight: 700; opacity: 0.7; }

/* phase 안내 배너 — 화면 최상단, 데모 배너 다음 */
.live-phase-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px 0 16px;
  border-left: 4px solid;
  background: #fafafa;
}
.live-phase-title {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.live-phase-body {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.5;
}
.live-phase-pre     { border-left-color: #888;     background: #f6f6f6; }
.live-phase-pre     .live-phase-title { color: #444; }
.live-phase-voting  { border-left-color: #2563eb;  background: #eff4fd; }
.live-phase-voting  .live-phase-title { color: #1e40af; }
.live-phase-live    { border-left-color: #1a8754;  background: #ecf6f0; }
.live-phase-live    .live-phase-title { color: #126b3f; }
.live-phase-pending { border-left-color: #b8860b;  background: #fff8e3; }
.live-phase-pending .live-phase-title { color: #8b6500; }
.live-phase-final   { border-left-color: #1a1a1a;  background: #f0f0f0; }
.live-phase-final   .live-phase-title { color: #1a1a1a; }

.live-demo-banner {
  background: #c41e3a;
  color: #fff;
  padding: 16px 20px;
  border-radius: 8px;
  margin: 12px 0 24px;
  box-shadow: 0 2px 6px rgba(196, 30, 58, 0.25);
}
.live-demo-banner-title {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.live-demo-banner-body {
  display: block;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.5;
  opacity: 0.95;
}

/* === 투표율 섹션 === */
.live-turnout-national {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  background: #1a1a1a;
  color: #fff;
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.live-turnout-national-label { font-size: 0.9rem; opacity: 0.75; }
.live-turnout-national-pct {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.live-turnout-national-votes {
  font-size: 0.85rem;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
  flex: 1;
  text-align: right;
}

.live-turnout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.live-turnout-card {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fafafa;
}
.live-turnout-region { font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; }
.live-turnout-bar-wrap {
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.live-turnout-bar {
  height: 100%;
  background: #1a8754;
  transition: width 0.6s ease;
}
.live-turnout-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #666;
  font-variant-numeric: tabular-nums;
}
.live-turnout-pct { font-weight: 700; color: #1a1a1a; }

.live-turnout-compare {
  font-size: 0.74rem;
  color: #777;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #e8e8e8;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.live-turnout-national-compare {
  font-size: 0.85rem;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* === 시간대별 투표율 라인 차트 === */
.live-chart-wrap {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 14px 16px 6px;
  margin-bottom: 14px;
}
.live-chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: #1a1a1a;
}
.live-chart { width: 100%; height: auto; display: block; }
.chart-line {
  fill: none;
  stroke: #1a8754;
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-ref {
  stroke: #999;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}
.chart-ref-label {
  fill: #555;
  font-size: 11px;
  font-weight: 600;
}
.chart-dot { fill: #1a8754; }
.chart-end-label {
  fill: #1a1a1a;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.chart-axis-label {
  fill: #888;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.chart-tick {
  stroke: #f3f3f3;
  stroke-width: 1;
}

/* 직전 회차 시간대별 점선 — 8회는 굵고 진하게, 7회는 가늘고 옅게 */
.chart-line-hist {
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-line-hist-8 {
  stroke: #444;
  stroke-width: 1.8;
  stroke-dasharray: 6 3;
  opacity: 0.85;
}
.chart-line-hist-7 {
  stroke: #999;
  stroke-width: 1.4;
  stroke-dasharray: 3 3;
  opacity: 0.85;
}
.chart-line-hist-other {
  stroke: #bbb;
  stroke-width: 1.2;
  stroke-dasharray: 2 4;
  opacity: 0.7;
}

/* 차트 범례 */
.live-chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 2px 4px 8px;
  font-size: 0.8rem;
  color: #555;
}
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-swatch {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top-width: 2.4px;
  border-top-style: solid;
}
.chart-legend-swatch-live { border-top-color: #1a8754; }
.chart-legend-swatch-8 { border-top-color: #444;  border-top-style: dashed; }
.chart-legend-swatch-7 { border-top-color: #999;  border-top-style: dashed; }

/* 시도 카드 펼치기 */
.live-turnout-hint {
  margin: 0 2px 8px;
  font-size: 0.8rem;
  color: #777;
}
.live-turnout-card.is-expandable {
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.live-turnout-card.is-expandable:hover {
  border-color: #bbb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.live-turnout-card.is-expandable:focus-visible {
  outline: 2px solid #1a8754;
  outline-offset: 2px;
}
.live-turnout-card.is-open {
  grid-column: 1 / -1;          /* 펼쳐졌을 때는 전체 너비 차지 */
  background: #fff;
  border-color: #1a1a1a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.live-turnout-region {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.live-turnout-expand-icon {
  font-size: 0.8rem;
  color: #888;
  line-height: 1;
}
.live-turnout-card.is-open .live-turnout-expand-icon { color: #1a1a1a; }
.live-turnout-expanded {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eee;
}

/* 시도 미니 차트 */
.live-chart-wrap-mini {
  padding: 6px 4px 0;
  border: none;
  margin-bottom: 0;
  background: transparent;
}

/* 13시 사전투표 합산 강조선 */
.chart-early-vote-line {
  stroke: #c41e3a;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.7;
}
.chart-early-vote-label {
  fill: #c41e3a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* 사전투표 효과 박스 (메인 차트 하단) */
.early-vote-box {
  margin: 8px 4px 0;
  padding: 10px 12px;
  background: #faf6f6;
  border-left: 3px solid #c41e3a;
  border-radius: 4px;
  font-size: 0.85rem;
}
.early-vote-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: #1a1a1a;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.early-vote-sub {
  font-weight: 400;
  color: #777;
  font-size: 0.78rem;
}
.early-vote-header {
  display: grid;
  grid-template-columns: 16px 110px 1fr 1fr;
  gap: 8px;
  font-size: 0.74rem;
  color: #999;
  font-weight: 600;
  padding: 4px 0 4px 0;
  margin-bottom: 2px;
  border-bottom: 1px solid #efe3e3;
}
.early-vote-row {
  display: grid;
  grid-template-columns: 16px 110px 1fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-variant-numeric: tabular-nums;
}
.early-vote-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  justify-self: center;
}
.early-vote-dot.early-vote-live { background: #1a8754; }
.early-vote-dot.early-vote-8 { background: #444; }
.early-vote-dot.early-vote-7 { background: #999; }
.early-vote-label { color: #444; }
.early-vote-col { font-size: 0.86rem; color: #1a1a1a; }
.early-vote-diff { color: #c41e3a; }
.early-vote-final-pct { color: #1a1a1a; }
.early-vote-na { color: #c8c8c8; }

/* 미니 차트(시도)용 압축 표기 */
.early-vote-mini {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #777;
  font-variant-numeric: tabular-nums;
}
.early-vote-mini .early-vote-live-text { color: #1a8754; font-weight: 700; }
.early-vote-mini .early-vote-8-text { color: #444; font-weight: 600; }
.early-vote-mini .early-vote-7-text { color: #888; }

/* ===========================
   모바일 대응 (max-width 760px / 380px)
   =========================== */
@media (max-width: 760px) {
  .live-root { padding: 12px 14px 56px; }
  .live-title { font-size: 1.45rem; }
  .live-hero { margin: 4px 0 16px; padding: 12px 0 14px; }
  .live-hero-meta { gap: 8px; font-size: 0.88rem; }

  /* 전국 투표율 검은 박스 — 모바일에선 세로 스택 */
  .live-turnout-national {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
  }
  .live-turnout-national-pct { font-size: 1.55rem; }
  .live-turnout-national-votes { text-align: left; flex: none; font-size: 0.8rem; }
  .live-turnout-national-compare { font-size: 0.8rem; }

  /* 차트 박스 안쪽 패딩 줄여 폭 절약 */
  .live-chart-wrap { padding: 12px 12px 6px; }
  .live-chart-wrap-mini { padding: 6px 0 0; }
  .live-chart-title { font-size: 0.9rem; }

  /* 차트 범례 — 모바일에선 작게 + 두 줄 */
  .live-chart-legend { font-size: 0.74rem; gap: 10px; }

  /* 사전투표 비교 박스 — 4컬럼이 폭에 안 맞아 2컬럼으로 재배치 */
  .early-vote-box { padding: 10px 12px; }
  .early-vote-header { display: none; }            /* 헤더 라벨 숨김 — 행 안에서 직접 표시 */
  .early-vote-row {
    grid-template-columns: 14px 1fr;
    gap: 6px 8px;
    row-gap: 2px;
    padding: 8px 0;
    border-top: 1px dashed #efe3e3;
    align-items: start;
  }
  .early-vote-row:first-of-type { border-top: none; }
  .early-vote-label { grid-column: 2; font-weight: 700; }
  .early-vote-col {
    grid-column: 2;
    font-size: 0.84rem;
  }
  .early-vote-col::before {
    content: attr(data-label) " ";
    color: #999;
    font-weight: 400;
    font-size: 0.75rem;
    display: inline-block;
    margin-right: 4px;
  }

  /* 시도 카드 — 폭이 좁으니 minmax 줄여 2-3열 유지 */
  .live-turnout-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
  }
  .live-turnout-card { padding: 10px; }
  .live-turnout-region { font-size: 0.9rem; }
  .live-turnout-pct { font-size: 0.85rem; }
  .live-turnout-card.is-open { padding: 12px; }

  /* 출구조사 면책 + phase 배너 — 패딩 압축 */
  .live-phase-banner { padding: 10px 12px; }
  .live-phase-title { font-size: 0.92rem; }
  .live-phase-body { font-size: 0.8rem; }
  .live-exit-notice { padding: 10px 12px; }
  .live-exit-notice-title { font-size: 0.9rem; }
  .live-exit-notice-body { font-size: 0.78rem; }

  /* 후보 카드 그리드 — 1열 */
  .live-grid { grid-template-columns: 1fr; gap: 12px; }
  .live-race { padding: 12px 14px; }
}

@media (max-width: 380px) {
  /* 매우 좁은 폭 (구형 폰) — 시도 카드 1열 */
  .live-turnout-grid { grid-template-columns: 1fr; }
  .live-title { font-size: 1.3rem; }
  .live-turnout-national-pct { font-size: 1.4rem; }
  .early-vote-row .early-vote-col { font-size: 0.78rem; }
}
