/* =============================
   IP横断 歴史・年表図 — ダークモード対応版
   レイアウト: HTML/CSS Grid + SVG overlay
   - 凡例・フィルタ・列ヘッダを timeline-sticky-top で固定
   - 縦軸は非線形（時代別の pixelsPerYear）
   ============================= */

.timeline-section {
  margin: 32px 0;
}

/* タイムライン本体（スクロールコンテナ） */
.timeline-wrapper {
  position: relative;
  background: var(--bg-elevated);
  border: 0.5px solid var(--rule);
  border-radius: var(--radius-soft, 4px);
  max-height: 80vh;
  overflow: auto;
  box-shadow: var(--shadow-card);
}

/* ===== Sticky Top: 凡例 + フィルタ + 列ヘッダ ===== */
.timeline-sticky-top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--rule-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* 凡例 */
.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border-bottom: 0.5px solid var(--rule);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.timeline-legend-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.timeline-legend-group strong {
  font-weight: 700;
  margin-right: 4px;
  color: var(--accent-primary);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.timeline-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--chip);
  border: 0.5px solid var(--rule);
  color: var(--text-primary);
  font-size: 0.7rem;
  white-space: nowrap;
}

.timeline-legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.timeline-legend-line {
  width: 22px;
  height: 0;
  border-top: 2px solid;
  display: inline-block;
}

/* フィルタコントロール */
.timeline-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-paper);
  border-bottom: 0.5px solid var(--rule);
  align-items: center;
}

.timeline-controls strong {
  font-size: 0.72rem;
  color: var(--accent-primary);
  margin-right: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
}

.timeline-filter-button {
  padding: 5px 14px;
  background: var(--chip);
  border: 0.5px solid var(--rule);
  border-radius: 16px;
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  font-family: var(--font-sans);
  font-weight: 500;
}

.timeline-filter-button:hover {
  background: rgba(255, 184, 77, 0.12);
  color: var(--text-primary);
  border-color: rgba(255, 184, 77, 0.4);
}

.timeline-filter-button.active {
  background: var(--accent-primary);
  color: #1a1815;
  border-color: var(--accent-primary);
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(255, 184, 77, 0.25);
}

/* 列ヘッダ */
.timeline-header {
  display: grid;
  grid-template-columns: 80px repeat(4, 1fr);
  background: var(--bg-paper);
  border-bottom: 1px solid var(--rule-strong);
  padding: 8px 0;
  font-weight: 700;
  text-align: center;
  font-size: 0.85rem;
  font-family: var(--font-sans);
}

.timeline-header-cell {
  padding: 4px;
}

.timeline-header-year { color: var(--text-muted); font-size: 0.72rem; }
.timeline-header-music { color: var(--color-music); }
.timeline-header-anime { color: var(--color-anime); }
.timeline-header-manga { color: var(--color-manga); }
.timeline-header-platform { color: var(--text-secondary); }

/* グリッド本体（スクロール可能領域） */
.timeline-grid {
  position: relative;
  min-width: 880px;
  background: var(--bg-elevated);
  /* JSが高さを設定 */
}

/* 縦軸（年代） */
.timeline-axis {
  position: absolute;
  left: 0;
  top: 0;
  width: 80px;
  bottom: 0;
  background: var(--bg-paper);
  border-right: 0.5px solid var(--rule);
  z-index: 5;
}

.timeline-axis-tick {
  position: absolute;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-family: var(--font-mono);
  border-top: 0.5px dashed var(--rule);
  padding-top: 2px;
}

/* 半年 tick（2022.5 = July）はサブ表示 */
.timeline-axis-tick--half {
  font-size: 0.58rem;
  color: var(--text-muted);
  border-top-style: dotted;
  opacity: 0.65;
  font-weight: 500;
}

/* 時代区分バンド（薄い背景・干渉ゼロ） */
.timeline-era-band {
  position: absolute;
  left: 80px;
  right: 0;
  pointer-events: none;
  z-index: 1;
}
.timeline-era-band--odd {
  background: rgba(255, 255, 255, 0.008);
}
.timeline-era-band--even {
  background: rgba(255, 184, 77, 0.015);
}

/* 時代区切り（水平セパレータ + ラベル） */
.timeline-era-divider {
  position: absolute;
  left: 80px;
  right: 0;
  height: 0;
  border-top: 1px solid rgba(255, 184, 77, 0.45);
  z-index: 3;
  pointer-events: none;
}
.timeline-era-divider-label {
  position: absolute;
  left: 16px;
  top: -10px;
  background: var(--bg-elevated);
  padding: 2px 12px;
  font-size: 0.66rem;
  color: var(--accent-primary);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 0.5px solid rgba(255, 184, 77, 0.5);
  border-radius: 12px;
  white-space: nowrap;
  font-family: var(--font-mono);
}

/* イベントカード */
.timeline-event {
  position: absolute;
  width: calc(25% - 24px);
  background: var(--bg-paper);
  border: 0.5px solid var(--rule);
  border-left: 3px solid;
  border-radius: var(--radius-soft, 4px);
  padding: 6px 9px;
  font-size: 0.78rem;
  text-decoration: none;
  color: var(--text-primary);
  z-index: 4;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.timeline-event:hover {
  z-index: 30;
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  border-color: var(--rule-strong);
  background: var(--bg-elevated);
}

.timeline-event--music { border-left-color: var(--color-music); }
.timeline-event--anime { border-left-color: var(--color-anime); }
.timeline-event--manga { border-left-color: var(--color-manga); }
.timeline-event--platform { border-left-color: var(--text-secondary); }

.timeline-event--high { border-left-width: 5px; }
.timeline-event--high .timeline-event-title { font-weight: 700; }

.timeline-event-year {
  display: inline-block;
  font-weight: 700;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-right: 5px;
  font-family: var(--font-mono);
}

.timeline-event-title {
  display: inline;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.32;
}

.timeline-event-desc {
  display: none;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.42;
}

.timeline-event:hover .timeline-event-desc {
  display: block;
}

.timeline-event[href]::after {
  content: " →";
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* SVG overlay */
.timeline-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.timeline-influence {
  fill: none;
  stroke-width: 1.5;
  opacity: 0.55;
  transition: opacity 0.2s ease, stroke-width 0.2s ease;
}

.timeline-influence.highlighted {
  opacity: 1;
  stroke-width: 3;
  filter: drop-shadow(0 0 4px currentColor);
}

/* 透明な hit area path（細い影響線でもホバー検知できる） */
.timeline-influence-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
  pointer-events: stroke;
  cursor: help;
}

/* ===== ホバーツールチップ ===== */
.timeline-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 380px;
  min-width: 240px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-soft, 4px);
  padding: 10px 14px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  font-family: var(--font-sans);
}

.timeline-tooltip-type {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.timeline-tooltip-route {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid var(--rule);
  font-weight: 600;
  line-height: 1.45;
}

.timeline-tooltip-route .timeline-tooltip-arrow {
  color: var(--accent-primary);
  margin: 0 6px;
  font-weight: 700;
}

.timeline-tooltip-desc {
  font-size: 0.78rem;
  color: var(--text-primary);
  line-height: 1.55;
}

/* レスポンシブ */
@media (max-width: 768px) {
  .timeline-grid {
    min-width: 720px;
  }
  .timeline-event {
    font-size: 0.72rem;
    padding: 5px 7px;
  }
  .timeline-wrapper {
    max-height: 70vh;
  }
  .timeline-legend {
    font-size: 0.7rem;
  }
}
