/* ============================================
   滚动叙事专属样式 - scrollytelling.css
   实现粘性图表区与文本滚动联动效果
   ============================================ */

/* === 滚动叙事容器 === */
.scrolly-section {
  position: relative;
  display: flex;
  flex-direction: column;
}

.scrolly-graphic {
  position: sticky;
  top: 80px;
  width: 100%;
  height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: var(--space-xl);
  overflow: hidden;
}

.scrolly-graphic .chart-stage {
  width: 100%;
  height: 100%;
  padding: var(--space-lg);
  position: relative;
}

.scrolly-graphic .chart-stage canvas {
  width: 100% !important;
  height: 100% !important;
}

/* 图表切换过渡动画 */
.scrolly-graphic .chart-view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--space-lg);
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.6s ease, transform 0.6s ease;
  will-change: opacity, transform;
}

.scrolly-graphic .chart-view.active {
  opacity: 1;
  transform: scale(1);
}

/* === 叙事文本步骤 === */
.scrolly-steps {
  position: relative;
  z-index: 2;
}

.scrolly-step {
  min-height: 60vh;
  display: flex;
  align-items: center;
  padding: var(--space-xl) 0;
}

.scrolly-step-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  max-width: 480px;
  opacity: 0.4;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  will-change: opacity, transform;
}

.scrolly-step.active .scrolly-step-content {
  opacity: 1;
  transform: translateY(0);
}

.scrolly-step-content h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-md);
  color: var(--primary);
}

.scrolly-step-content p {
  font-size: var(--text-base);
  color: var(--text);
  line-height: 1.8;
}

.scrolly-step-content .step-indicator {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  margin-bottom: var(--space-md);
}

/* === 进度指示器 === */
.scrolly-progress {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: var(--z-sticky);
}

.scrolly-progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: all var(--transition-base);
}

.scrolly-progress-dot.active {
  background: var(--primary);
  transform: scale(1.4);
}

/* === 桌面端双栏布局 === */
@media (min-width: 992px) {
  .scrolly-section {
    flex-direction: row;
  }

  .scrolly-graphic {
    position: sticky;
    top: 100px;
    width: 55%;
    height: calc(100vh - 140px);
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .scrolly-steps {
    width: 45%;
    padding-left: var(--space-2xl);
  }

  .scrolly-step {
    min-height: 80vh;
  }

  .scrolly-progress {
    display: flex;
  }
}

/* === 时间轴组件 === */
.timeline {
  position: relative;
  padding-left: 30px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--space-2xl);
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  will-change: opacity, transform;
}

.timeline-item.visible {
  opacity: 1;
  transform: translateX(0);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -34px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--primary);
  transition: background var(--transition-fast);
}

.timeline-item.active::before {
  background: var(--primary);
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-light);
  margin-bottom: var(--space-xs);
}

.timeline-content {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  border: 1px solid var(--border);
}

.timeline-content h4 {
  margin-bottom: var(--space-sm);
}

.timeline-content p {
  font-size: var(--text-sm);
  color: var(--text-light);
}

/* === 地图容器 === */
.map-container {
  width: 100%;
  height: 400px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card-bg);
}

@media (min-width: 768px) {
  .map-container {
    height: 600px;
  }
}

/* === 网络图容器 === */
.network-container {
  width: 100%;
  height: 500px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card-bg);
  position: relative;
}

.network-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.network-legend {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: rgba(255, 255, 255, 0.9);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
}

.network-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.network-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

@media (min-width: 768px) {
  .network-container {
    height: 700px;
  }
}
