/* timeline.html — 역대 선거 그리드 */

.tl-controls { margin: 16px 0; }

.tl-viz { position: relative; min-height: 200px; }

.tl-table {
  display: grid;
  /* row: [라벨 콤팩트] [17 시도 cells] [meta] */
  grid-template-columns: 200px 1fr 120px;
  gap: 11px 12px;   /* 행 간격 넉넉히 — 당색 막대 벽이 빽빽하지 않게 */
  align-items: center;
  font-size: 13px;
}

.tl-row {
  display: contents;
}

/* 종류 아이콘 옆 라벨 */
.tl-meta {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 0;
}
.tl-meta .tl-label {
  font-weight: 700;
  color: var(--ink);
  font-size: 13px;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.tl-meta .tl-kind {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
  color: #fff;
  
}
.tl-meta .tl-kind.pres { background: #5b3a8b; }
.tl-meta .tl-kind.gen  { background: #2d6e7e; }
.tl-meta .tl-kind.local{ background: #8c5a1f; }
.tl-meta .tl-indirect {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 2px;
  color: var(--ink-soft, #777);
  border: 1px dashed currentColor;
  cursor: help;
}
.tl-meta .tl-annulled {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 2px;
  color: #fff;
  background: #c0392b;
  cursor: help;
}
.tl-meta .tl-date {
  font-size: 11px;
  color: var(--ink-soft);
}

/* 시도 cells grid (17 cols) */
.tl-sidos {
  display: flex;
  width: 100%;
  height: 18px;   /* 28→18 — 색 면적 줄여 흐름 화면 차분하게 */
  border: 1px solid var(--rule);
  overflow: hidden;
}
.tl-sidos.is-empty {
  background: var(--bg3, #e6e9ef);
}
.tl-stack-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  /* 너비는 flex-grow(=의석/득표 비율)에만 비례 — basis 0으로 둬 당명 길이가 폭에 영향 못 줌
     (auto면 긴 당명 '개혁신당'이 basis를 키워 바가 과대해짐). 당명은 nowrap 한 줄, 좁으면 클립. */
  flex-basis: 0;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 2px rgba(0,0,0,0.35);
  min-width: 0;
  overflow: hidden;
  cursor: default;
  border-right: 1px solid rgba(255,255,255,0.4);
}
.tl-stack-seg:last-child { border-right: none; }
.tl-stack-seg:hover { filter: brightness(1.12); }

/* 우측 meta — 당선자(대선)·turnout */
.tl-right {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11px;
  color: var(--ink-soft);
  text-align: right;
}
.tl-right .tl-winner {
  font-weight: 600;
  color: var(--ink);
  font-size: 12px;
}

/* 시도 column 헤더 */





/* 행 hover 약한 강조 */



/* 필터 — 흐름: 해당 선거 행만 남기고 비대상 행은 숨김(display:contents → none). */
.tl-row.is-hidden { display: none; }

/* 예정·예측 회차 — sidos 회색 dim + 우측 태그 */
.tl-row.is-upcoming .tl-sidos { opacity: 0.4; }
.tl-row.is-upcoming .tl-meta .tl-label { color: var(--ink-soft); }
.tl-upcoming-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--bg3);
  color: var(--ink-soft);
  align-self: flex-end;
}

@media (max-width: 900px) {
  .tl-table { grid-template-columns: 130px 1fr 90px; gap: 4px 8px; }
  .tl-meta .tl-label { font-size: 12px; }
  .tl-right { font-size: 10px; }
  .tl-header-sidos { font-size: 7px; }
}

/* ── 상세 모드 — 실제 시간축 그리드(대선/총선/지선 3열, 카드를 날짜 y에 절대배치) ── */
.tl-detail { margin-top: 8px; }
.tld-timeline { position: relative; }
.tld-tcols { display: flex; gap: 12px; margin-left: 40px; height: 100%; }
.tld-tcol { flex: 1; position: relative; min-width: 0; }
.tld-coltitle { position: sticky; top: 4px; z-index: 3; margin: 0; padding: 6px 0; background: var(--bg); text-align: center; }
.tld-card { display: block; border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px; background: var(--bg); text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s; }
.tld-card.tld-abs { position: absolute; left: 0; right: 0; z-index: 1; }
.tld-card:hover { border-color: var(--rule-strong); box-shadow: 0 2px 8px rgba(40, 40, 80, .08); z-index: 2; }
/* 연도축 — 1년 단위 라벨·선(좌측 gutter), 10년 경계는 굵게 강조 */
.tld-axline { position: absolute; left: 40px; right: 0; border-top: 1px dashed var(--rule); z-index: 0; pointer-events: none; }
.tld-axline.is-decade { border-top: 1.5px solid var(--rule-strong); }
.tld-axyr { position: absolute; left: 0; width: 34px; text-align: right; font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--ink-soft); transform: translateY(-50%); z-index: 0; }
.tld-axyr.is-decade { font-weight: 700; color: var(--ink); font-size: 11.5px; }
.tld-head { display: flex; align-items: baseline; gap: 6px; font-size: 13px; margin-bottom: 6px; }
.tld-head b { font-size: 15px; }
.tld-date { color: var(--ink-mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.tld-win { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.tld-wtag { font-size: 11px; font-weight: 600; border: 1px solid; border-radius: 3px; padding: 0 5px; margin-left: 2px; }
.tld-bars { display: flex; flex-direction: column; gap: 3px; }
.tld-bar-row { display: grid; grid-template-columns: 54px 1fr 32px; align-items: center; gap: 6px; font-size: 11px; }
.tld-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
.tld-bar { height: 9px; background: var(--bg2); border-radius: 5px; overflow: hidden; }
.tld-bar-fill { display: block; height: 100%; border-radius: 5px; }
.tld-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.tld-donut { max-width: 240px; margin: 0 auto; }
.tld-leg { font-size: 10px; color: var(--ink-soft); text-align: center; margin-top: 2px; line-height: 1.5; }
.tld-leg span { white-space: nowrap; margin: 0 3px; }
.tld-leg .tld-sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 3px; vertical-align: -1px; box-shadow: 0 0 0 1px rgba(128,128,128,0.35) inset; }
.tld-sub { font-size: 11px; color: var(--ink-mute); margin-bottom: 4px; }
.tld-empty { font-size: 11px; color: var(--ink-mute); padding: 8px 0; text-align: center; }
/* 지선 상세 — 6직위 정당별 의석 스택. 바 6개라 얇게 둬 카드 높이 절약. */
.tld-office { margin-bottom: 3px; }
.tld-orow { display: flex; justify-content: space-between; align-items: baseline; font-size: 9px; color: var(--ink-soft); margin-bottom: 1px; }
.tld-ototal { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.tld-ostack { display: flex; height: 6px; border-radius: 2px; overflow: hidden; background: var(--bg2); }
.tld-oseg { display: block; min-width: 1px; }
