:root {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #1f2933;
  background-color: #f8fafc;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header & Footer --- */
.page-header,
.page-footer {
  padding: 1.5rem clamp(1.5rem, 4vw, 3rem);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.page-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

.page-header p {
  margin: 0 0 0.75rem;
  color: #64748b;
}

.team-info {
  margin-bottom: 1rem;
  color: #475569;
  font-size: 0.9rem;
}

/* --- Slider Box & Controls (One Line Layout) --- */
.slider-box {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e2e8f0;
  border-radius: 50px; /* 变成全圆角，像一个大的胶囊控制条 */
  padding: 10px 20px;
  margin: 20px auto;
  width: 95%;
  max-width: 900px; /* 整体宽度可以宽一点，容纳一行 */
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  
  /* 关键布局：Flex Row */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px; /* 控件之间的间距 */
  flex-wrap: wrap; /* 小屏幕允许换行 */
}

/* 1. 左侧 Play 按钮 */
.play-button {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap; /* 防止文字换行 */
  flex-shrink: 0; /* 防止按钮被压缩 */
}

.play-button:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(59, 130, 246, 0.5);
}

.play-button:active {
  transform: translateY(0);
}

/* 2. 中间滑条组 (时间 + 滑条) */
.slider-group {
  flex: 1; /* 占据剩余空间 */
  display: flex;
  align-items: center;
  gap: 15px;
  max-width: 500px; /* 限制滑条区域最大宽度，满足“缩短滑条”的需求 */
  margin: 0 auto; /* 居中 */
}

#current-time-display {
  font-family: 'Consolas', monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 6px;
  min-width: 90px; /* 固定最小宽度，防止数字跳动导致布局抖动 */
  text-align: center;
}

input[type="range"]#time-slider {
  -webkit-appearance: none;
  flex: 1; /* 填满 slider-group 的剩余空间 */
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

input[type="range"]#time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border: 2px solid #ffffff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.1s;
}

input[type="range"]#time-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #2563eb;
}

/* 3. 右侧 Anomaly 开关 */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  padding: 5px 12px;
  border-radius: 30px;
  border: 1px solid #e2e8f0;
  flex-shrink: 0; /* 防止被压缩 */
}

.toggle-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0.0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: #ef4444;
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* 响应式适配：手机上可能需要折行 */
@media (max-width: 650px) {
  .slider-box {
    justify-content: center;
    border-radius: 20px;
  }
  .slider-group {
    order: 3; /* 把滑条放到最后一行 */
    min-width: 100%;
    margin-top: 10px;
  }
  .play-button {
    flex: 1;
    justify-content: center;
  }
  .toggle-wrapper {
    flex: 1;
    justify-content: center;
  }
}

/* --- Global Average Temperature Display --- */
.global-avg-display {
  text-align: center;
  font-size: 0.9rem;
  color: #475569;
  margin: -10px auto 15px;
  font-weight: 500;
}

#global-avg-temp {
  font-family: 'Consolas', monospace;
  font-weight: 700;
  color: #1e3a8a;
}

/* --- Layout & Map --- */
.layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.layout > * {
  width: 90%;
  max-width: 1600px;
}

.map-wrapper {
  position: relative;
}

#map {
  width: 100%;
  max-width: none;
  aspect-ratio: 2 / 1;
  position: relative;
  overflow: hidden;
}

#heatmap-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  /* background-color: #a8d8ea; canvas 覆盖后不需要这个背景色了，不过留着也无妨 */
}

#overlay-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* --- Info Panel --- */
.info-panel {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  padding: 1.25rem 2rem;
  position: static;
}

.info-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.selection-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.selection-list__item {
  border-left: 3px solid #2563eb;
  padding-left: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center; /* 垂直居中对齐 */
  font-size: 0.95rem;
}

/* --- Tooltip & Legend --- */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.2;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.15);
  opacity: 0;
  transition: opacity 120ms ease;
  z-index: 999;
}

.tooltip.is-visible {
  opacity: 1;
}

.legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
}

.legend text {
  font-size: 0.75rem;
  fill: #1f2937;
}

.legend line {
  stroke: rgba(15, 23, 42, 0.25);
}

/* --- Country Interactions --- */
.country {
  fill: #f5f5f5;
  fill-opacity: 1;
  stroke: none;
  cursor: pointer;
  transition: fill-opacity 200ms ease;
}

.country--hover {
  fill-opacity: 0;
}

.country--revealed {
  fill-opacity: 0;
}

.country-border {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 0.5px;
  pointer-events: none;
  transition: stroke 150ms ease, stroke-width 150ms ease;
}

.ocean-mask {
  fill: #a8d8ea;
  pointer-events: none;
}

/* --- Responsive & Misc --- */
@media (max-width: 960px) {
  .layout {
    flex-direction: column;
  }

  .info-panel {
    position: static;
    width: 100%;
  }
}

#abstract,
#discussion {
  padding: 1rem 1rem;
  margin: 2rem auto;
  max-width: 1200px;
}

#abstract p,
#discussion p {
  line-height: 1.7;
  text-align: justify;
}

/* --- Zoom Controls --- */
.zoom-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid #ccc; 
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.zoom-controls button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  background-color: #ffffff;
  border: none;
  line-height: 1;
  transition: background-color 0.1s;
}

.zoom-controls button:hover {
  background-color: #f0f0f0;
}

#zoom-out {
  border-top: 1px solid #ccc;
}


/* --- write up --- */

.Overview,
.Features-and-Exploration,
.Technology-and-Data-Sources {
  max-width: 1000px;
  padding: 2rem clamp(1.5rem, 4vw, 3rem); 
  margin: 0 auto;
}

.Overview {
  margin-top: 1rem; 
}

.Features-and-Exploration {
  padding-bottom: 3rem; 
}

/* --- Headings --- */

.Overview h2,
.Features-and-Exploration h2,
.Technology-and-Data-Sources h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.4rem);
  font-weight: 700;
  color: #1f2937;
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e2e8f0; 
}

.Features-and-Exploration h3 {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  font-weight: 600;
  color: #3b82f6;
  margin-top: 2.5rem;
  margin-bottom: 0.5rem;
}

/* --- Paragraphs and Lists --- */

.Overview p,
.Features-and-exploration p,
.Features-and-exploration li {
  line-height: 1.7; 
  color: #475569;
}

.Features-and-Exploration ul {
  list-style-type: none;
  padding-left: 0;
  margin-top: 1rem;
}

.Features-and-Exploration ul li {
  margin-bottom: 1rem;
  padding-left: 1rem;
  position: relative;
}

.Features-and-Exploration ul li::before {
  content: "•";
  color: #3b82f6;
  font-size: 1.5rem;
  position: absolute;
  left: 0;
  top: -2px;
}

.Features-and-Exploration strong {
    color: #1e3a8a;
    font-weight: 700;
}


.Technology-and-Data-Sources table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); 
    border-radius: 8px;
    overflow: hidden;
}

.Technology-and-Data-Sources th,
.Technology-and-Data-Sources td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.Technology-and-Data-Sources th {
    background-color: #f8fafc;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.Technology-and-Data-Sources tr:last-child td {
    border-bottom: none;
}

.Technology-and-Data-Sources td strong {
    color: #1e3a8a;
}

/* --- Sidebar Statistics Styling --- */
.stats-box {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 4px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 第一行：主要统计 (Avg, Max, Min) */
.stats-row.primary {
  display: flex;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

/* 第二行：季节统计 */
.stats-row.secondary {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

/* 单个统计项容器 */
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1; /* 让每个项目均分宽度 */
}

/* 标签 (AVG, MAX, SPR...) */
.stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

/* 数值 */
.stat-value {
  font-family: 'Segoe UI', sans-serif;
  font-weight: 600;
  color: #0f172a;
  line-height: 1;
}

.primary .stat-value {
  font-size: 0.8rem;
}

.secondary .stat-value {
  font-size: 0.8rem;
}

/* --- Info Icon & Tooltip Styling --- */

/* 小图标样式 */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background-color: #94a3b8; /* 灰色背景 */
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: bold;
  cursor: help;
  position: relative; /* 关键：作为绝对定位的参考点 */
}

.info-icon:hover {
  background-color: #64748b; /* 悬浮时变深 */
}

/* 提示框文本样式 (默认隐藏) */
.info-tooltip {
  visibility: hidden;
  width: 220px;
  background-color: #1e293b; /* 深色背景 */
  color: #f8fafc;
  text-align: center;
  border-radius: 6px;
  padding: 8px 10px;
  
  /* 定位逻辑 */
  position: absolute;
  z-index: 100;
  bottom: 135%; /* 在图标上方显示 */
  left: 50%;
  transform: translateX(-50%); /* 水平居中 */
  
  /* 字体与动画 */
  font-size: 0.75rem;
  font-weight: normal;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.2s, bottom 0.2s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
  pointer-events: none; /* 防止鼠标误触提示框 */
}

/* 提示框的小箭头 */
.info-tooltip::after {
  content: "";
  position: absolute;
  top: 100%; /* 在提示框底部 */
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}

/* 鼠标悬浮时显示 */
.info-icon:hover .info-tooltip {
  visibility: visible;
  opacity: 1;
  bottom: 125%; /* 轻微的上浮动画效果 */
}