/* /static/css/components/region-globe.css
   3D 地球组件样式：容器与控件的主题外观
   重构：使用 CSS 变量模块化，消除重复选择器
   依赖：region-globe-vars.css（必须先加载）
   相关：static/js/globe/region-globe.js, static/js/globe/region-globe-integration.js */

/**
 * Region Globe 3D地球组件样式
 */

/* ========== 地球容器 ========== */
#region-globe-container {
  width: 100%;
  min-height: var(--globe-container-min-height);
  margin-top: 1rem;
  border-radius: 0.5rem;
  position: relative;
  background: var(--globe-container-bg);
  transition: all 0.3s var(--globe-transition-timing);
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#region-globe-container.hidden {
  display: none;
}

#region-globe-container::-webkit-scrollbar {
  display: none;
}

/* ========== 地球包装器 ========== */
#region-globe-wrapper {
  width: 100%;
  height: var(--globe-wrapper-height);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}

#region-globe-wrapper > div {
  background: transparent !important;
}

#region-globe-wrapper canvas {
  display: block;
  cursor: inherit;
}

#region-globe-wrapper canvas:active {
  cursor: grabbing;
}

/* ========== 控制按钮组 ========== */
.globe-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  gap: 0.5rem;
  background: var(--globe-controls-bg);
  padding: var(--globe-controls-padding);
  border-radius: var(--globe-controls-radius);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
  max-width: calc(100% - 2rem);
  transition: all 0.3s var(--globe-transition-cubic);
  box-shadow: var(--globe-controls-shadow);
  border: 1px solid var(--globe-controls-border);
}

.globe-controls.collapsed {
  padding: var(--globe-controls-padding);
  width: auto;
  height: auto;
  overflow: hidden;
}

.globe-controls.collapsed .globe-control-items {
  display: none;
}

/* ========== 控制项容器 ========== */
.globe-control-items {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ========== 折叠触发按钮 ========== */
.globe-toggle-btn {
  padding: 0.5rem;
  border: none;
  border-radius: var(--globe-toggle-radius);
  background: var(--globe-toggle-bg);
  color: var(--globe-toggle-color);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--globe-transition-speed) var(--globe-transition-timing);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--globe-toggle-size);
  min-height: var(--globe-toggle-size);
}

.globe-toggle-btn:hover {
  background: var(--globe-toggle-bg-hover);
  color: var(--globe-toggle-color-hover);
  transform: scale(1.05);
}

/* ========== 控制按钮 ========== */
.globe-controls button {
  padding: var(--globe-btn-padding);
  border: none;
  border-radius: var(--globe-btn-radius);
  background: var(--globe-btn-bg);
  color: var(--globe-btn-color);
  font-size: var(--globe-btn-font-size);
  cursor: pointer;
  transition: all var(--globe-transition-speed) var(--globe-transition-timing);
  white-space: nowrap;
}

.globe-controls button:hover {
  background: var(--globe-btn-bg-hover);
  color: var(--globe-btn-color-hover);
}

.globe-controls button.active {
  background: var(--globe-btn-bg-active);
  color: var(--globe-btn-color-active);
}

/* ========== 加载状态 ========== */
.globe-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--globe-loading-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--globe-loading-bg);
  padding: var(--globe-loading-padding);
  border-radius: var(--globe-loading-radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--globe-loading-shadow);
}

.globe-loading i {
  font-size: var(--globe-loading-icon-size);
  animation: spin var(--globe-animation-spin);
}

.globe-loading p {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

/* ========== 加载进度条 ========== */
.globe-loading-progress {
  width: var(--globe-progress-width);
  margin-top: 1rem;
  transition: opacity 0.3s ease-out;
}

.progress-bar-container {
  width: 100%;
  height: var(--globe-progress-height);
  background: var(--globe-progress-bg);
  border-radius: var(--globe-progress-radius);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--globe-progress-fill);
  background-size: 200% auto;
  border-radius: var(--globe-progress-radius);
  transition: width 0.4s var(--globe-transition-cubic);
  box-shadow: var(--globe-progress-glow);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.progress-text {
  font-size: 0.75rem;
  text-align: center;
  color: var(--secondary-text-color);
  margin-top: 0.5rem;
  font-weight: 500;
}

/* ========== 降级方案 ========== */
.globe-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: var(--globe-fallback-min-height);
}

/* ========== 2D/3D 切换按钮 ========== */
.view-toggle {
  display: inline-flex;
  background: var(--globe-btn-bg);
  border-radius: var(--globe-btn-radius);
  padding: 0.125rem;
  gap: 0.125rem;
}

.view-toggle button {
  padding: 0.375rem 0.75rem;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all var(--globe-transition-speed) var(--globe-transition-timing);
}

.view-toggle button.active {
  background: var(--globe-btn-bg-active);
  color: var(--globe-accent-lightest);
}

/* ========== Tooltip ========== */
.globe-tooltip {
  position: absolute;
  padding: var(--globe-tooltip-padding);
  border-radius: var(--globe-tooltip-radius);
  font-size: var(--globe-tooltip-font-size);
  pointer-events: none;
  z-index: 100;
}

/* ========== 性能模式指示器 ========== */
.performance-indicator {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  font-size: var(--globe-perf-font-size);
  color: var(--globe-perf-color);
  background: var(--globe-perf-bg);
  padding: var(--globe-perf-padding);
  border-radius: var(--globe-perf-radius);
}

/* ========== 国旗样式 ========== */
.globe-flag {
  position: relative;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: opacity var(--globe-transition-speed) var(--globe-transition-timing);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}

.globe-flag img {
  display: block;
  width: var(--globe-flag-width);
  height: var(--globe-flag-height);
  border-radius: var(--globe-flag-radius);
  box-shadow: var(--globe-flag-shadow);
  filter: brightness(0.98) contrast(1.02);
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  transition: transform 0.15s var(--globe-transition-timing);
}

.globe-flag-emoji {
  display: inline-block;
  font-size: var(--globe-flag-emoji-size);
  line-height: 1;
  filter: drop-shadow(0 0.5px 1px rgba(0, 0, 0, 0.2));
  text-rendering: optimizeLegibility;
}

/* ========== 动画定义 ========== */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn var(--globe-animation-fade);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* 节点脉冲动画 */
@keyframes pulse-glow {
  0%, 100% {
    opacity: 0.8;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

.globe-node-pulse {
  animation: pulse-glow var(--globe-animation-pulse);
  will-change: transform, opacity;
}

/* 国家高亮效果 */
@keyframes country-highlight {
  0% { opacity: 0.2; stroke-width: 1; }
  50% { opacity: 0.8; stroke-width: 2; }
  100% { opacity: 0.2; stroke-width: 1; }
}

.globe-country-active {
  animation: country-highlight var(--globe-animation-highlight);
}

/* 成就解锁动画 */
@keyframes achievement-unlock {
  0% {
    filter: brightness(1);
    box-shadow: 0 0 0 rgba(var(--globe-accent-rgb), 0);
  }
  20% {
    filter: brightness(1.5);
    box-shadow: 0 0 50px rgba(var(--globe-accent-rgb), 0.8), 0 0 100px rgba(139, 92, 246, 0.4);
  }
  40% {
    filter: brightness(1.3);
    box-shadow: 0 0 30px rgba(var(--globe-accent-rgb), 0.6), 0 0 60px rgba(139, 92, 246, 0.3);
  }
  100% {
    filter: brightness(1.1);
    box-shadow: 0 0 20px rgba(var(--globe-accent-rgb), 0.4);
  }
}

.globe-achievement-unlock {
  animation: achievement-unlock var(--globe-animation-achievement);
}

/* 波纹扩散效果 */
@keyframes ripple-effect {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

.globe-ripple {
  animation: ripple-effect var(--globe-animation-ripple);
}

/* ========== 响应式适配 - 移动端 ========== */
@media (max-width: 768px) {
  #region-globe-container {
    min-height: var(--globe-container-mobile-min-height);
    position: relative;
  }

  #region-globe-wrapper {
    height: var(--globe-wrapper-mobile-height);
    min-height: var(--globe-wrapper-mobile-min);
    max-height: var(--globe-wrapper-mobile-max);
  }

  .globe-controls {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    left: auto;
    border-radius: var(--globe-controls-radius-mobile);
    max-width: calc(100% - 1rem);
    padding: var(--globe-controls-padding-mobile);
    background: var(--globe-controls-bg-mobile);
    box-shadow: var(--globe-controls-shadow-mobile);
  }

  .globe-toggle-btn {
    display: flex !important;
    padding: 0.375rem;
    min-width: var(--globe-toggle-size-mobile);
    min-height: var(--globe-toggle-size-mobile);
  }

  .globe-control-items {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.375rem;
    max-width: 280px;
  }

  .globe-controls.collapsed .globe-control-items {
    display: none;
  }

  .globe-controls.collapsed {
    padding: var(--globe-controls-padding-mobile);
    width: auto;
  }

  .globe-controls button {
    padding: var(--globe-btn-padding-mobile);
    font-size: var(--globe-btn-font-size-mobile);
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* ========== 响应式适配 - 平板 ========== */
@media (min-width: 769px) and (max-width: 1024px) {
  #region-globe-wrapper {
    height: var(--globe-wrapper-tablet-height);
  }

  .globe-controls {
    bottom: 1.5rem;
    right: 1.5rem;
  }
}

/* ========== 高分辨率屏幕优化 ========== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .globe-flag img {
    width: var(--globe-flag-width-2x);
    height: var(--globe-flag-height-2x);
  }
  .globe-flag-emoji {
    font-size: var(--globe-flag-emoji-size-2x);
  }
}

@media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 288dpi) {
  .globe-flag img {
    width: var(--globe-flag-width-3x);
    height: var(--globe-flag-height-3x);
  }
  .globe-flag-emoji {
    font-size: var(--globe-flag-emoji-size-3x);
  }
}
