/* common.css — shared styles for leaderboard pages */

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #f9fafc;
  color: #111;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Helvetica, Arial, sans-serif;
  height: 100vh;
}

/* Tabs */
.tabs-container {
  display: flex;
  align-items: center;
  gap: clamp(10px, 3vw, 40px);
  position: relative;
}

.tab {
  font-size: clamp(10px, 1.6vw, 16px);
  font-weight: 600;
  color: #999;
  white-space: nowrap;
  cursor: pointer;
  padding: 8px 0;
  transition: color 0.2s ease;
  user-select: none;
  position: relative;
}

.tab:hover {
  color: #666;
}

.tab.active {
  color: #2756d3;
}

.tab-indicator {
  position: absolute;
  bottom: 0;
  height: 3px;
  background: #2756d3;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
}

.tab-indicator.active {
  opacity: 1;
}

.tab-separator {
  width: 1px;
  height: 20px;
  background: #d0d0d7;
  margin: 0 clamp(4px, 2vw, 24px);
}

/* Answer section */
.answer-section {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 12px);
  opacity: 1;
  max-width: 500px;
  transition: opacity 0.3s ease, max-width 0.3s ease, margin 0.3s ease;
  overflow: hidden;
}

.answer-section.hidden {
  opacity: 0;
  max-width: 0;
  margin: 0;
}

.answer-text {
  font-size: clamp(12px, 1.6vw, 16px);
  font-weight: 700;
  color: #1a73e8;
  white-space: nowrap;
  padding: clamp(6px, 1vw, 10px) clamp(12px, 1.5vw, 16px);
  background: #e8f3ff;
  border-radius: 1px;
}

/* Selector group (palette, period) */
.selector-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.5vw, 6px);
  padding: clamp(2px, 0.4vw, 4px);
  border-radius: 6px;
  border: 1px solid rgba(17, 24, 39, 0.15);
  background: #f8fafc;
  max-width: 100%;
  flex-shrink: 1;
  min-width: 0;
}

.selector-button {
  border: none;
  background: transparent;
  padding: clamp(4px, 0.8vh, 8px) clamp(8px, 1.5vw, 14px);
  border-radius: 6px;
  font-size: clamp(9px, 1.4vw, 13px);
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.selector-button.active {
  background: #2756d3;
  color: #fff;
}

/* Source text */
.source-text {
  font-size: clamp(10px, 1.6vw, 16px);
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-style: normal;
}

.source-text a {
  color: #2756d3;
  text-decoration: underline;
  cursor: pointer;
  font-style: normal;
}

.source-text a:visited {
  color: #2756d3;
}

/* Logo container */
.logo-container .logo {
  height: 100%;
  width: auto;
  max-height: 100%;
  max-width: clamp(80px, 15vw, 200px);
  pointer-events: auto;
  object-fit: contain;
  flex-shrink: 0;
}

/* Tooltip */
#tooltip {
  position: absolute;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1000;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1vw, 14px);
  background: transparent;
  padding: clamp(4px, 1vh, 10px) 0;
  border-radius: 0;
  max-width: 100%;
  max-height: 100%;
  font-size: clamp(0.625rem, 1.4vw, 1rem);
  font-style: normal;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 8px);
  cursor: pointer;
  transition: opacity 0.2s ease;
  font-weight: 600;
  color: #333;
  font-size: inherit;
  padding: 2px 6px;
}

.legend-item.dim {
  opacity: 0.35;
}

.legend-item:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.5);
  outline-offset: 2px;
}

.legend-square {
  width: clamp(10px, 1vw, 14px);
  height: clamp(10px, 1vw, 14px);
  border-radius: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #111;
  transition: background 0.7s ease, border-color 0.7s ease;
}

.legend-square svg {
  width: 75%;
  height: 75%;
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.legend-square[data-palette="0"] svg {
  stroke: #111;
}

.legend-square[data-palette="1"] svg {
  stroke: #fff;
}

.legend-square[data-palette="2"] svg {
  stroke: #fff;
}

.legend-item[data-geo="China"] .legend-square[data-palette="2"] svg {
  stroke: #111;
}

