/* ============================================================
 * 地球海陆占比 - 页面样式（深色星空教学风格）
 * ============================================================ */
:root {
  --bg: #0A1630;
  --panel: rgba(16, 32, 62, 0.85);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #E8F1FA;
  --text-dim: #9FB6CF;
  --accent: #FFC53D;
  --accent2: #35C2E8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  background: radial-gradient(ellipse at 30% 20%, #14264a 0%, #0A1630 55%, #060D20 100%);
  color: var(--text);
  overflow: hidden;
}

/* ---------- 输入方式适配（鼠标 / 触摸 / 不同窗口尺寸） ----------
 * 去点按高亮与 300ms 延迟；不阻塞页面滚动与双指缩放（仅地球本身 touch-action:none） */
body { -webkit-tap-highlight-color: transparent; }
button, input, select, label, .chip, .swatch, .panel-sec h2 { touch-action: manipulation; }

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---------- 左侧地球区 ---------- */
#globeBox {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

/* ===== 品牌标题（还原参考 UI：可爱地球 + 蓝色渐变主标题 + 副标题 + 创作者徽章） =====
   参考 UI 版式：[地球 Logo] 地理3D实验室 —— 地球海陆占比  [✨ 要可爱不耍赖]
   深色星空页适配：主标题用蓝→青渐变，副标题浅色，徽章用暖色渐变胶囊。 */
#topbar {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  max-width: calc(100% - 40px);
}

/* --- Logo：可爱蓝色地球 52×52 --- */
.brand-logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 8px rgba(30, 90, 180, 0.45));
}
.brand-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- 主标题行（基线对齐） --- */
.brand-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.brand-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  /* 参考 UI 蓝色渐变主标题（深色页上提亮） */
  background: linear-gradient(92deg, #7CC0F5 0%, #3B9DF0 48%, #4FD1EA 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 2px 8px rgba(56, 150, 235, 0.35));
}
.brand-sep {
  font-size: 15px;
  font-weight: 600;
  color: #7E93B4;
  letter-spacing: 1px;
}
.brand-sub {
  font-size: 18px;
  font-weight: 700;
  color: #EAF2FB;
  letter-spacing: 1px;
}

/* --- 创作者徽章（参考 UI 暖色胶囊 + ✨；与标题同行并垂直居中对齐） --- */
.brand-creator {
  display: inline-flex;
  align-items: center;
  align-self: center;      /* 在基线行内与标题垂直居中对齐 */
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #8A5A2B;
  background: linear-gradient(100deg, #FFF8DC 0%, #FCE7F1 52%, #EDE0FB 100%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 2px 12px rgba(255, 205, 230, 0.3);
  white-space: nowrap;
  user-select: none;
}

#stage {
  flex: 1;
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#globe {
  height: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
}
#globe:active { cursor: grabbing; }

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  background: var(--bg);
  z-index: 5;
}

/* ---------- 占比面板（仿参考图） ---------- */
#ratioPanel {
  margin: 0 auto 20px;
  width: min(640px, 92%);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 20px 12px;
  backdrop-filter: blur(6px);
}
.ratio-title { font-size: 15px; color: var(--text-dim); margin-bottom: 10px; }
.ratio-title #viewName { color: #FFE9A0; font-weight: 700; }
.ratio-title #viewCenter { color: var(--text); }

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.bar-label { width: 42px; font-size: 17px; font-weight: 700; }
#barLand .bar-label { color: var(--accent); }
#barOcean .bar-label { color: var(--accent2); }

.bar-track {
  flex: 1;
  height: 18px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 9px;
  transition: width 0.12s linear;
}
.bar-fill.land { background: linear-gradient(90deg, #E8A82A, #FFC53D); }
.bar-fill.ocean { background: linear-gradient(90deg, #1F9BC8, #35C2E8); }

.bar-val { width: 58px; text-align: right; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

.ratio-sub { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* ---------- 右侧控制面板 ---------- */
#panel {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 16px 14px 24px;
  background: rgba(10, 22, 44, 0.72);
  border-left: 1px solid var(--panel-border);
  transition: width 0.3s ease, padding 0.3s ease, border-left 0.3s ease, opacity 0.3s ease;
}
#panel.collapsed {
  width: 0;
  padding: 0;
  border-left: none;
  overflow: hidden;
  opacity: 0;
}

/* 折叠/展开按钮 — 贴在 globeBox 右侧边缘 */
#panelToggle {
  position: absolute;
  right: -14px;          /* 按钮一半贴在 panel 左边 */
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: 28px;
  height: 64px;
  border-radius: 10px 0 0 10px;
  background: rgba(10, 22, 44, 0.88);
  border: 1px solid var(--panel-border);
  border-right: none;
  color: #CFE3F7;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, right 0.3s ease;
}
#panelToggle:hover { background: rgba(20, 40, 74, 0.92); color: #FFE9A0; }
/* panel collapsed 时按钮贴到屏幕最右边 */
body.panel-collapsed #panelToggle { right: 0; }

.panel-sec {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.panel-sec h2 {
  font-size: 15px;
  margin-bottom: 10px;
  color: #CFE3F7;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
}
/* 折叠箭头 */
.toggle-arrow {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  transition: transform 0.25s ease;
  display: inline-block;
  line-height: 1;
}
.panel-sec.collapsed .toggle-arrow { transform: rotate(-90deg); }
.panel-sec.collapsed h2 { margin-bottom: 0; }
/* 折叠时隐藏 h2 以下所有子元素 */
.panel-sec.collapsed > *:not(h2) { display: none; }
.sec-tip { font-size: 11px; color: var(--text-dim); margin: 4px 0 8px; }

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
button {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 233, 160, 0.5); }
button.primary { background: linear-gradient(90deg, #1F6FB2, #2C8CC9); border-color: rgba(140, 200, 255, 0.4); }
button.primary:hover { filter: brightness(1.15); }

.custom-view {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.custom-view label { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.custom-view input {
  width: 50px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 4px;
  font-size: 13px;
}
.custom-view select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 2px;
  font-size: 13px;
  cursor: pointer;
}
.custom-view option { background: #14264a; color: var(--text); }
.custom-view button { flex: 1 1 100%; }

/* 区域色卡（分七大洲/四大洋两块） */
.chips-block { margin-bottom: 10px; }
.chips-block:last-child { margin-bottom: 0; }
.chips-sub-title {
  font-size: 12px;
  font-weight: 600;
  color: #CFE3F7;
  letter-spacing: 1px;
  padding: 3px 4px 6px;
  border-left: 3px solid rgba(255, 197, 61, 0.55);
}
#chipsLand, #chipsOcean {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: default;
}
.chip:hover { background: rgba(255, 255, 255, 0.08); }
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}
.swatch input {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}
.swatch input::-webkit-color-swatch-wrapper { padding: 0; }
.swatch input::-webkit-color-swatch { border: none; border-radius: 4px; }

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.btn-row button { flex: 1; }

/* 开关 */
.tg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 5px 0;
  cursor: pointer;
  color: var(--text);
}
.tg input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.tg select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  margin-left: auto;          /* 推到 label 文字右侧，对齐 checkbox 的视觉节奏 */
}
.tg select option { background: #14264a; color: var(--text); }
.tg select:hover { border-color: rgba(255, 233, 160, 0.5); }

/* 滚动条 */
#panel::-webkit-scrollbar { width: 8px; }
#panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  #app { flex-direction: column; height: auto; }
  #stage { height: 90vw; max-height: 70vh; }
  #panel { width: 100%; border-left: none; border-top: 1px solid var(--panel-border); }
  /* 品牌标题缩窄，避免小屏溢出 */
  .brand-logo { width: 42px; height: 42px; }
  .brand-title { font-size: 20px; }
  .brand-sub { font-size: 15px; }
  .brand-sep { font-size: 12px; }
  .brand-creator { font-size: 11px; padding: 3px 10px; }
}

/* ---------- 触摸设备（coarse pointer）：放大点击目标 ---------- */
@media (pointer: coarse) {
  button { padding: 12px 8px; font-size: 14px; }
  .custom-view input, .custom-view select, .tg select { padding: 9px 6px; font-size: 14px; }
  .tg input { width: 18px; height: 18px; }
  .swatch { width: 28px; height: 28px; }
  .chip { padding: 7px 8px; font-size: 14px; }
  .panel-sec h2 { padding-top: 5px; padding-bottom: 5px; }
  #panelToggle { width: 38px; height: 78px; font-size: 22px; }
}

/* ---------- 小屏手机（≤640px）：标题三级收缩 ---------- */
@media (max-width: 640px) {
  #topbar { top: 14px; left: 14px; gap: 4px 10px; max-width: calc(100% - 28px); }
  .brand-logo { width: 38px; height: 38px; }
  .brand-title { font-size: 17px; letter-spacing: 0.5px; }
  .brand-sub { font-size: 12px; }
  .brand-sep { font-size: 10px; }
  .ratio-title { font-size: 14px; }
  #ratioPanel { padding: 12px 14px 10px; }
}
