/* ========== 设计令牌：科技深色主题 ========== */
:root {
  /* 背景层级色 */
  --color-bg-deep: #050810;
  --color-bg-mid: #0a1224;
  /* 主强调色（青蓝呼吸灯） */
  --color-accent: #3dd6c6;
  --color-accent-dim: rgba(61, 214, 198, 0.35);
  /* 文字色阶 */
  --color-text-primary: #e8f0ff;
  --color-text-secondary: rgba(232, 240, 255, 0.65);
  --color-text-muted: rgba(232, 240, 255, 0.4);
  /* 毛玻璃卡片 */
  --glass-bg: rgba(12, 22, 42, 0.55);
  --glass-border: rgba(61, 214, 198, 0.22);
  --glass-blur: 18px;
  /* 圆角与阴影 */
  --radius-lg: 20px;
  --shadow-glow: 0 0 40px rgba(61, 214, 198, 0.15);
  /* 动效时长 */
  --duration-fade: 0.6s;
  --duration-breathe: 2.8s;
  /* 字体栈 */
  --font-sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

/* ========== 全局重置与基础排版 ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--color-bg-deep);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
}

/* 根应用容器占满视口 */
.app {
  position: relative;
  width: 100%;
  height: 100%;
}

/* hidden 属性与 display:flex 冲突时强制隐藏（否则授权后弹窗仍遮挡主界面） */
[hidden] {
  display: none !important;
}

/* ========== 全屏层通用样式 ========== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity var(--duration-fade) ease, visibility var(--duration-fade) ease;
}

/* 淡出隐藏状态 */
.screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 加载层背景：径向渐变营造深空感 */
.screen--loading {
  background: radial-gradient(ellipse 80% 60% at 50% 40%, var(--color-bg-mid) 0%, var(--color-bg-deep) 70%);
  z-index: 200;
}

/* 权限弹窗层：半透明遮罩 */
.screen--permission {
  background: rgba(5, 8, 16, 0.72);
  backdrop-filter: blur(6px);
  z-index: 150;
}

/* ========== 加载卡片 ========== */
.loading-card {
  text-align: center;
  padding: 2.5rem;
}

.loading-card__title {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.loading-card__subtitle {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: 2.5rem;
}

.loading-card__status {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* 呼吸灯圆环加载器 */
.loading-spinner {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid var(--color-accent-dim);
  border-top-color: var(--color-accent);
  animation: spin 1s linear infinite, breathe var(--duration-breathe) ease-in-out infinite;
  box-shadow: 0 0 24px var(--color-accent-dim);
}

/* ========== 毛玻璃卡片（权限引导） ========== */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-glow);
  animation: breathe var(--duration-breathe) ease-in-out infinite;
}

.permission-card {
  max-width: 420px;
  width: calc(100% - 2rem);
  padding: 2rem 1.75rem;
  text-align: center;
}

.permission-card__icon {
  color: var(--color-accent);
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

.permission-card__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.permission-card__desc {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

.permission-card__hint {
  font-size: 0.8rem;
  color: #f5a623;
  background: rgba(245, 166, 35, 0.1);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.permission-card__actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(135deg, #2ab8a8 0%, #3dd6c6 100%);
  color: #041018;
  box-shadow: 0 4px 20px rgba(61, 214, 198, 0.35);
}

.btn--primary:hover {
  box-shadow: 0 6px 28px rgba(61, 214, 198, 0.45);
}

.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid rgba(232, 240, 255, 0.15);
}

.btn--ghost:hover {
  border-color: var(--color-accent-dim);
  color: var(--color-text-primary);
}

/* ========== 主场景占位 ========== */
.main-scene {
  position: fixed;
  inset: 0;
  z-index: 10;
}

.main-scene.is-visible {
  display: block;
}

.globe-container {
  width: 100%;
  height: 100%;
  /* 深空底色由 Three.js 场景 background 接管，此处仅作加载前占位 */
  background: radial-gradient(ellipse at 50% 40%, #0a1428 0%, #030610 75%);
}

/* 摄像头预览：默认隐藏，仅供 MediaPipe 采样 */
.camera-feed {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  object-fit: cover;
}

/* 交互模式角标（可点击切换） */
.interaction-badge {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  z-index: 200;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.interaction-badge:hover {
  border-color: rgba(61, 214, 198, 0.45);
  box-shadow: 0 0 20px rgba(61, 214, 198, 0.18);
}

.interaction-badge:active {
  transform: translateX(-50%) scale(0.97);
}

.interaction-badge:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.interaction-badge--mouse {
  color: var(--color-text-secondary);
  border-color: rgba(232, 240, 255, 0.12);
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-glow);
  animation: toast-in 0.35s ease forwards;
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast.is-leaving {
  animation: toast-out 0.3s ease forwards;
}

/* ========== 关键帧动画 ========== */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes breathe {
  0%,
  100% {
    box-shadow: 0 0 24px rgba(61, 214, 198, 0.12);
    border-color: rgba(61, 214, 198, 0.18);
  }
  50% {
    box-shadow: 0 0 48px rgba(61, 214, 198, 0.28);
    border-color: rgba(61, 214, 198, 0.38);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ========== 地理悬停：宏观 Tooltip ========== */
.geo-tooltip {
  position: fixed;
  z-index: 60;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-accent);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: var(--shadow-glow);
}

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

/* ========== 地理悬停：微观国家信息卡片 ========== */
.country-info-panel {
  position: fixed;
  z-index: 55;
  width: min(300px, calc(100vw - 2rem));
  padding: 1rem 1.15rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.country-info-panel--visible {
  opacity: 1;
}

.country-info-panel__name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 0.25rem;
}

.country-info-panel__subtitle {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.65rem;
}

.country-info-panel__area {
  font-size: 0.8125rem;
  color: var(--color-accent);
  margin-bottom: 0.75rem;
}

.country-info-panel__advantages {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.country-info-panel__advantages li {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--color-text-secondary);
  padding-left: 0.75rem;
  position: relative;
}

.country-info-panel__advantages li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-accent-dim);
}
