/* 世界地图前端样式：深色海洋 + 绿色陆地 */
:root {
  --ocean: #0b1e33;        /* 深色海洋 */
  --land: #2e8b57;         /* 绿色陆地 */
  --land-hover: #ffd966;   /* 悬停暖黄 */
  --border: #0e2a1e;       /* 国家边界 */
  --text: #e8f1f8;
}

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

[hidden] { display: none !important; }  /* 防止 display:flex/block 覆盖 hidden 属性 */

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  background: var(--ocean);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

.topbar {
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}
.topbar h1 { font-size: 18px; letter-spacing: 1px; }
.topbar .hint { font-size: 12px; opacity: 0.65; margin-top: 2px; }

#map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--ocean);
  cursor: grab;
  touch-action: none;              /* 手势交给 d3.zoom，禁用浏览器默认缩放/滚动 */
  -webkit-tap-highlight-color: transparent;
}
#map-wrap:active { cursor: grabbing; }

/* 3D 地球仪视图（与 2D 同页切换） */
#globe-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--ocean);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#globe-wrap canvas { display: block; }

.modeswitch {
  display: inline-flex;
  gap: 4px;
  margin-left: 14px;
  vertical-align: 2px;
}
.mbtn {
  padding: 3px 12px;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  cursor: pointer;
}
.mbtn:hover { background: rgba(255, 255, 255, 0.1); }
.mbtn.active {
  color: #10240f;
  background: var(--land-hover);
  border-color: var(--land-hover);
  font-weight: 700;
}

svg#map { display: block; width: 100%; height: 100%; }

.country {
  fill: var(--land);
  stroke: var(--border);
  transition: fill 0.12s ease;
}
.country:hover,
.country.hovered,
.country.selected {
  fill: var(--land-hover);
}
.country.selected {
  stroke: #b8860b;
}
.graticule { fill: none; stroke: #ffffff; stroke-opacity: 0.07; stroke-width: 0.5; }

.tooltip {
  position: absolute;
  pointer-events: none;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(10, 20, 35, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transform: translate(12px, -8px);
}

.statusbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  padding: 6px 18px;
  font-size: 12px;
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ===== 登录页 ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(46, 139, 87, 0.25), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(255, 217, 102, 0.12), transparent 60%),
    var(--ocean);
}
.login-card {
  width: min(380px, 92vw);
  padding: 34px 36px 26px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}
.login-logo { font-size: 34px; text-align: center; }
.login-title { font-size: 22px; text-align: center; margin-top: 4px; }
.login-sub { font-size: 12px; text-align: center; opacity: 0.65; margin: 4px 0 20px; }
.login-label {
  display: block;
  font-size: 12px;
  opacity: 0.8;
  margin: 12px 0 4px;
}
.login-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  outline: none;
}
.login-input:focus { border-color: var(--land-hover); }
.login-error {
  margin-top: 12px;
  padding: 8px 10px;
  font-size: 13px;
  color: #ffb3a7;
  background: rgba(231, 76, 60, 0.18);
  border: 1px solid rgba(231, 76, 60, 0.5);
  border-radius: 8px;
}
.login-btn {
  width: 100%;
  margin-top: 18px;
  padding: 11px 0;
  font-size: 15px;
  font-weight: 600;
  color: #10240f;
  background: linear-gradient(135deg, #7ec97e, var(--land-hover));
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.login-btn:hover { filter: brightness(1.08); }
.login-btn:disabled { opacity: 0.6; cursor: wait; }
.login-tip { margin-top: 14px; font-size: 11px; text-align: center; opacity: 0.45; }

/* 顶栏用户区 */
.userbox {
  position: absolute;
  right: 16px;
  top: 10px;
  z-index: 5;
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.userbox .uname { opacity: 0.85; }
.userbox button {
  padding: 3px 12px;
  font-size: 12px;
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  cursor: pointer;
}
.userbox button:hover { background: rgba(255, 255, 255, 0.1); }

/* ===== 修改密码弹层 ===== */
.pwd-card { text-align: left; }
.pwd-title {
  font-size: 17px;
  text-align: center;
  color: #16324f;
  margin-bottom: 6px;
}
.pwd-label {
  display: block;
  font-size: 12px;
  color: #4a5568;
  margin: 12px 0 4px;
}
.pwd-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  color: #16324f;
  background: #fff;
  border: 1px solid #b8c4d0;
  border-radius: 8px;
  outline: none;
}
.pwd-input:focus { border-color: #1d7a44; }
.pwd-msg {
  margin-top: 12px;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 8px;
}
.pwd-err { color: #b03a2e; background: rgba(231, 76, 60, 0.1); border: 1px solid rgba(231, 76, 60, 0.4); }
.pwd-ok  { color: #1d7a44; background: rgba(46, 139, 87, 0.12); border: 1px solid rgba(29, 122, 68, 0.4); }
.pwd-actions { display: flex; gap: 10px; justify-content: center; }
.pwd-save { background: #1d7a44; }
.pwd-save:hover { background: #166036; }
.pwd-save:disabled { opacity: 0.6; cursor: wait; }

/* ===== 小屏（手机）适配 ===== */
@media (max-width: 640px) {
  .topbar { padding: 6px 12px; }
  .topbar h1 { font-size: 15px; }
  .topbar .hint { font-size: 10px; }
  .userbox {
    right: 10px;
    top: 6px;
    font-size: 11px;
    gap: 6px;
  }
  .userbox button { padding: 4px 8px; font-size: 11px; }
  .statusbar { padding: 5px 12px; font-size: 11px; }
  .modal-card { width: 88vw; min-width: 0; padding: 18px 16px; }
  .modal-zh { font-size: 22px; }
  .login-card { width: 92vw; padding: 26px 22px 20px; }
}

/* 点击国家后的中英文弹层 */
.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
}
.modal[hidden] { display: none; }
.modal-card {
  min-width: 260px;
  padding: 22px 30px;
  border-radius: 14px;
  text-align: center;
  background: #fbfbf6;
  border: 2px solid #ffd966;
  color: #16324f;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.65);
  animation: pop 0.15s ease-out;
}
@keyframes pop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.modal-flag { font-size: 26px; }
.modal-zh {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 800;
  color: #d35400;
}
.modal-en {
  margin-top: 4px;
  font-size: 15px;
  color: #4a5568;
}
.modal-capital {
  margin-top: 10px;
  padding: 6px 12px;
  font-size: 14px;
  color: #1d7a44;
  background: rgba(46, 139, 87, 0.12);
  border: 1px solid rgba(29, 122, 68, 0.4);
  border-radius: 8px;
  display: inline-block;
}
.modal-close {
  margin-top: 16px;
  padding: 6px 22px;
  font-size: 13px;
  color: #fbfbf6;
  background: #16324f;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.modal-close:hover { background: #1d4468; }

/* ===== 太阳系 / 银河系 3D 页面 ===== */
.navlink {
  margin-left: 14px;
  font-size: 13px;
  font-weight: 400;
  vertical-align: 2px;
  color: var(--land-hover);
  text-decoration: none;
  padding: 3px 10px;
  border: 1px solid rgba(255, 217, 102, 0.5);
  border-radius: 8px;
}
.navlink:hover { background: rgba(255, 217, 102, 0.15); }

#solar-wrap,
#galaxy-wrap,
#tiangong-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#solar-wrap canvas,
#galaxy-wrap canvas,
#tiangong-wrap canvas { display: block; }

.backlink {
  position: absolute;
  right: 16px;
  top: 12px;
  font-size: 13px;
  color: var(--land-hover);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid rgba(255, 217, 102, 0.5);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
}
.backlink:hover { background: rgba(255, 217, 102, 0.15); }

.topnav {
  position: absolute;
  right: 16px;
  top: 12px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
.topnav .backlink { position: static; }

/* 行星信息卡（点击后右侧显示） */
.info-card {
  position: absolute;
  right: 16px;
  top: 64px;
  width: min(300px, 78vw);
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(10, 18, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  color: var(--text);
  z-index: 6;
  animation: pop 0.15s ease-out;
}
.info-card[hidden] { display: none; }
.info-head { display: flex; align-items: center; gap: 10px; }
.info-dot {
  width: 14px; height: 14px; border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}
.info-zh { font-size: 20px; font-weight: 800; color: var(--land-hover); }
.info-en { font-size: 13px; opacity: 0.7; }
.info-close {
  margin-left: auto;
  width: 26px; height: 26px;
  font-size: 16px; line-height: 1;
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  cursor: pointer;
}
.info-close:hover { background: rgba(255, 255, 255, 0.12); }
.info-body {
  margin-top: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 13px;
}
.info-body dt { opacity: 0.65; white-space: nowrap; }
.info-body dd { color: #dce9f5; }

/* 底部时间控制条 */
.timebar[hidden] { display: none; }   /* display:flex 会覆盖 hidden，须显式屏蔽 */
.timebar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(10, 18, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  z-index: 6;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 94vw;
}
.tlabel { font-size: 12px; opacity: 0.65; }
.tbtn {
  min-width: 34px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.tbtn:hover { background: rgba(255, 255, 255, 0.12); }
.tbtn.active {
  color: #10240f;
  background: var(--land-hover);
  border-color: var(--land-hover);
  font-weight: 700;
}
.sdate { font-size: 12px; opacity: 0.8; margin-left: 4px; }

@media (max-width: 640px) {
  .info-card { top: auto; bottom: 76px; right: 10px; max-height: 46vh; overflow: auto; }
  .timebar { bottom: 10px; gap: 6px; padding: 6px 10px; }
  .tbtn { padding: 5px 8px; font-size: 12px; }
  .sdate { display: none; }
  .backlink { top: 8px; right: 10px; font-size: 12px; }
}
