/* ============================================================
   LivePop · 实时世界人口  —  Premium Styles
   设计：玻璃拟态 + 渐变文字 + 明暗双主题 + 60fps 动效
   ============================================================ */

:root {
  --accent-1: #22d3ee;   /* cyan  */
  --accent-2: #818cf8;   /* indigo */
  --accent-3: #a855f7;   /* violet */
  --birth: #34d399;
  --death: #fb7185;
  --net: #38bdf8;

  --radius: 22px;
  --radius-sm: 14px;
  --maxw: 1080px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

/* ---------- DARK (default) ---------- */
[data-theme="dark"] {
  --bg: #060912;
  --bg-2: #0b1226;
  --text: #eef2ff;
  --text-dim: #97a3c4;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-brd: rgba(255, 255, 255, 0.10);
  --glass-hi: rgba(255, 255, 255, 0.16);
  --aurora-1: rgba(34, 211, 238, 0.22);
  --aurora-2: rgba(168, 85, 247, 0.20);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

/* ---------- LIGHT ---------- */
[data-theme="light"] {
  --bg: #eef2fb;
  --bg-2: #ffffff;
  --text: #0c1330;
  --text-dim: #5a6688;
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-brd: rgba(20, 30, 70, 0.10);
  --glass-hi: rgba(255, 255, 255, 0.85);
  --aurora-1: rgba(34, 211, 238, 0.30);
  --aurora-2: rgba(129, 140, 248, 0.32);
  --shadow: 0 20px 50px rgba(40, 60, 120, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  transition: background 0.5s var(--ease), color 0.5s var(--ease);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 背景层 ---------- */
#globe {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  opacity: 0.85;
}

.bg-aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 50% at 20% 15%, var(--aurora-1), transparent 70%),
    radial-gradient(55% 45% at 85% 25%, var(--aurora-2), transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  transition: background 0.5s var(--ease);
}

/* ---------- 导航 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(18px, 4vw, 40px);
  backdrop-filter: blur(14px);
  background: var(--glass-bg); /* fallback */
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border-bottom: 1px solid var(--glass-brd);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
  box-shadow: 0 0 16px var(--accent-1);
  animation: breathe 2.6s var(--ease) infinite;
}
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.brand-sub { color: var(--text-dim); font-size: 0.82rem; border-left: 1px solid var(--glass-brd); padding-left: 10px; }

.theme-switch {
  display: flex; gap: 4px; padding: 4px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}
.theme-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: none; border-radius: 999px;
  background: transparent; color: var(--text-dim);
  cursor: pointer; transition: all 0.25s var(--ease);
}
.theme-btn:hover { color: var(--text); transform: translateY(-1px); }
.theme-btn.active {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #06121f;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.4);
}

/* ---------- 布局容器 ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(18px, 4vw, 40px); }

.hero {
  min-height: 86vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  padding: 40px 0;
}

.eyebrow {
  font-size: 0.8rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent-1); font-weight: 600;
}
.hero-title {
  font-size: clamp(1.5rem, 4vw, 2.6rem);
  font-weight: 700; letter-spacing: -0.02em;
  color: var(--text);
}
.counter-hero {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; justify-content: center;
}
.num-huge {
  font-size: clamp(2.6rem, 9vw, 6rem);
  font-weight: 800; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  font-feature-settings: "tnum";
}
.unit { font-size: clamp(1.2rem, 3vw, 2rem); color: var(--text-dim); font-weight: 600; }
.hero-note { color: var(--text-dim); max-width: 560px; font-size: 0.95rem; line-height: 1.65; }
.hero-note b { color: var(--accent-1); font-weight: 600; }

/* 数据状态徽标 */
.data-status {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 6px; padding: 7px 16px; border-radius: 999px;
  font-size: 0.82rem; color: var(--text-dim);
  background: var(--glass-bg); border: 1px solid var(--glass-brd);
  backdrop-filter: blur(10px); transition: color 0.4s var(--ease);
}
.data-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim); transition: all 0.4s var(--ease);
}
.data-status.live { color: var(--birth); }
.data-status.live .dot { background: var(--birth); box-shadow: 0 0 12px var(--birth); animation: breathe 2s var(--ease) infinite; }
.data-status.warn { color: var(--death); }
.data-status.warn .dot { background: var(--death); }
.data-status.err { color: #ff6b6b; }
.data-status.err .dot { background: #ff6b6b; animation: breathe 2s var(--ease) infinite; }

.gradient-text {
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2) 45%, var(--accent-3));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ---------- 玻璃卡片通用 ---------- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--shadow);
}

/* ---------- 今日小计 ---------- */
.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  width: 100%;
  margin-top: 14px;
}
.mini-card {
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease);
}
.mini-card:hover { transform: translateY(-4px); border-color: var(--glass-hi); }
.mini-label { font-size: 0.78rem; color: var(--text-dim); letter-spacing: 0.04em; }
.mini-num { font-size: clamp(1.1rem, 2.4vw, 1.5rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.mini-card.birth .mini-num { color: var(--birth); }
.mini-card.death .mini-num { color: var(--death); }
.mini-card.net .mini-num { color: var(--net); }
.mini-card.rate .mini-num { color: var(--accent-2); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }

/* ---------- 区块标题 ---------- */
.section { padding: 70px 0; }
.section-title {
  font-size: clamp(1.4rem, 3.4vw, 2.1rem); font-weight: 800;
  letter-spacing: -0.02em; text-align: center; margin-bottom: 8px;
}
.section-sub { text-align: center; color: var(--text-dim); font-size: 0.9rem; margin-bottom: 32px; }

/* ---------- 本年累计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stat-card {
  padding: 30px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
  transition: transform 0.35s var(--ease), border-color 0.35s var(--ease);
}
.stat-card:hover { transform: translateY(-6px) scale(1.02); border-color: var(--glass-hi); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.5rem; font-weight: 800;
}
.stat-icon.birth { background: rgba(52, 211, 153, 0.16); color: var(--birth); }
.stat-icon.death { background: rgba(251, 113, 133, 0.16); color: var(--death); }
.stat-icon.net { background: rgba(56, 189, 248, 0.16); color: var(--net); }
.stat-num { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-dim); font-size: 0.9rem; }

/* ---------- 国家列表 ---------- */
.country-list { list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.country-list li {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border-radius: var(--radius-sm);
  background: var(--glass-bg); border: 1px solid var(--glass-brd);
  backdrop-filter: blur(14px);
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease);
}
.country-list li:hover { transform: translateX(4px); border-color: var(--glass-hi); }
.country-rank { font-weight: 800; color: var(--accent-2); width: 26px; font-variant-numeric: tabular-nums; }
.country-flag { font-size: 1.4rem; }
.country-name { flex: 1; font-weight: 600; }
.country-pop { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 0.92rem; }

/* ---------- 查看全部国家 按钮 ---------- */
.all-btn-wrap { display: flex; justify-content: center; margin-top: 26px; }
.all-btn {
  appearance: none; cursor: pointer;
  padding: 12px 28px; border-radius: 999px;
  font-size: 0.92rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--text);
  background: var(--glass-bg); border: 1px solid var(--glass-hi);
  backdrop-filter: blur(14px);
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.all-btn:hover { transform: translateY(-3px); border-color: var(--accent-1); box-shadow: 0 8px 30px -10px var(--accent-1); }
.all-btn:active { transform: translateY(-1px); }

/* ---------- 查看全部国家 overlay ---------- */
.all-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: flex-start; justify-content: center;
  padding: clamp(16px, 4vh, 56px) 16px;
  background: rgba(4, 8, 22, 0.55);
  backdrop-filter: blur(8px);
  overflow-y: auto;
}
.all-overlay.open { display: flex; animation: allFade 0.3s var(--ease); }
@keyframes allFade { from { opacity: 0; } to { opacity: 1; } }

.all-panel {
  width: min(860px, 100%); max-height: min(88vh, 860px);
  display: flex; flex-direction: column;
  border-radius: var(--radius); padding: 0; overflow: hidden;
  animation: allPop 0.35s var(--ease);
}
@keyframes allPop { from { transform: translateY(20px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

.all-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 24px 26px 18px; border-bottom: 1px solid var(--glass-brd);
}
.all-title { font-size: 1.15rem; font-weight: 700; }
.all-count { margin-top: 4px; color: var(--text-dim); font-size: 0.82rem; }
.all-close {
  appearance: none; cursor: pointer; flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-dim); background: transparent; border: 1px solid var(--glass-brd);
  transition: all 0.25s var(--ease);
}
.all-close:hover { color: var(--text); border-color: var(--glass-hi); transform: rotate(90deg); }

.all-search-wrap { position: relative; padding: 16px 26px; border-bottom: 1px solid var(--glass-brd); }
.all-search-icon { position: absolute; left: 38px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }
.all-search {
  width: 100%; box-sizing: border-box;
  padding: 11px 16px 11px 38px; border-radius: 999px;
  font-size: 0.92rem; color: var(--text);
  background: var(--glass-bg); border: 1px solid var(--glass-brd);
  transition: border-color 0.25s var(--ease);
}
.all-search:focus { outline: none; border-color: var(--accent-1); }
.all-search::placeholder { color: var(--text-dim); }

.all-list { list-style: none; margin: 0; padding: 8px 12px 20px; overflow-y: auto; flex: 1; }
.all-list li {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 16px; border-radius: var(--radius-sm);
  transition: background 0.2s var(--ease);
}
.all-list li:hover { background: var(--glass-bg); }
.all-rank { font-weight: 700; color: var(--accent-2); width: 38px; font-variant-numeric: tabular-nums; font-size: 0.85rem; text-align: right; }
.all-flag { font-size: 1.3rem; }
.all-name { flex: 1; font-weight: 600; font-size: 0.95rem; }
.all-pop { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 0.9rem; }

/* ---------- 方法论 ---------- */
.method-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.method-card { padding: 26px 22px; transition: transform 0.3s var(--ease); }
.method-card:hover { transform: translateY(-5px); }
.method-card h3 { font-size: 1.05rem; margin-bottom: 10px; }
.method-card p { color: var(--text-dim); line-height: 1.65; font-size: 0.92rem; }
.method-card b { color: var(--accent-1); }

/* ---------- 页脚 ---------- */
.footer {
  text-align: center; padding: 50px 20px 60px;
  color: var(--text-dim); font-size: 0.85rem; line-height: 1.8;
  border-top: 1px solid var(--glass-brd);
}
.footer .sources { font-size: 0.78rem; opacity: 0.8; }

/* ---------- 入场动画 ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- 关键帧 ---------- */
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: 0.7; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .mini-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid, .method-grid { grid-template-columns: 1fr; }
  .country-list { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}
