/* ============ 地球 ↔ 地图：同一个页面里的交叉淡变 ============
   星图 canvas 和 Leaflet 地图容器叠在同一个 .stage 里。
   缩到 z = -0.6（地球已经涨到和地图同尺度）时给 .stage 加 .mapped：
   canvas 放大一点同时淡出、地图淡入、星图那套 HUD 让位 —— 一个 class 收全部，
   反向缩回去就摘掉这个 class，两边各自回位。 */

.earth-map{
  position:absolute;z-index:2;
  top:0;right:0;bottom:0;left:0;
  opacity:0;pointer-events:none;
  background:#e9eef4;
  transition:opacity .55s ease;
  /* 地球边缘那圈蓝辉光在地图淡入时一起退场，避免出现一条亮边 */
  will-change:opacity;
}
.stage.mapped .earth-map{opacity:1;pointer-events:auto}

/* 星图在交接时继续「往下钻」一点再消失：单纯淡出像关灯，带一点缩放像真的在下降 */
#orbit{transition:opacity .5s ease, transform .55s cubic-bezier(.4,0,.7,1);transform-origin:50% 50%}
.stage.mapped #orbit{opacity:0;transform:scale(1.22);pointer-events:none}

/* 星图那套 HUD 在地图模式下让位（图例讲的是卫星，指不上地图） */
.stage.mapped .legend,
.stage.mapped .stage-hint,
.stage.mapped .cmd-dock,
.stage.mapped .detail{
  opacity:0 !important;pointer-events:none !important;
}

/* 地图模式自己的两个控件：返回宇宙 + 当前定位说明 */
.map-hud{
  position:absolute;z-index:3;
  top:10px;left:10px;right:10px;
  display:flex;align-items:center;gap:8px;
  opacity:0;pointer-events:none;transition:opacity .35s ease .18s;
}
.stage.mapped .map-hud{opacity:1;pointer-events:auto}
.map-back{
  flex:none;height:34px;padding:0 14px;border:0;border-radius:17px;
  background:rgba(9,22,38,.82);color:#dff3ff;
  font:500 13px/1 -apple-system,"PingFang SC","Microsoft YaHei",sans-serif;
  box-shadow:0 4px 14px rgba(0,0,0,.28);cursor:pointer;
  -webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
}
.map-back:active{background:rgba(9,22,38,.95)}
.map-here{
  flex:0 1 auto;min-width:0;height:34px;line-height:34px;max-width:100%;
  padding:0 12px;border-radius:17px;
  background:rgba(9,22,38,.66);color:#bcd8ee;
  font:12px/34px -apple-system,"PingFang SC","Microsoft YaHei",sans-serif;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  -webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
}
/* 罗盘：红针始终指北。地图没转的时候整体压暗，转了才亮起来（暗示可以点一下回正） */
.map-compass{
  flex:none;margin-left:auto;width:40px;height:40px;padding:0;
  border:0;border-radius:50%;cursor:pointer;
  display:grid;place-items:center;
  background:rgba(9,22,38,.7);color:#cfe4f5;
  box-shadow:0 4px 14px rgba(0,0,0,.28);
  -webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
  transition:background .2s ease,transform .15s ease;
}
.map-compass svg{width:32px;height:32px;display:block;overflow:visible}
#compassNeedle{transform-box:view-box;transform-origin:50% 50%;transition:transform .12s linear}
.map-compass .ring{transition:opacity .2s ease}
.map-compass .tail{transition:opacity .2s ease}
.map-compass.off{background:rgba(9,22,38,.44)}
.map-compass.off .ring{opacity:.45}
.map-compass.off .tail{opacity:.28}
.map-compass:active{transform:scale(.93)}

/* 桌面端左边有 88px 的竖排导航（stage-full 时仍然固定在最上层），
   胶囊从 96px 起，否则「返回宇宙」被压在导航底下只剩半截 */
@media (min-width:761px){
  .map-hud{left:96px;right:16px}
  .map-here{max-width:380px}
}

/* 地图模式下「翻层大卡片」不该出现（地图里没有层这个概念，压上去就是一块脏） */
body.map-mode .layer-flash{opacity:0 !important}

/* 地图里的缩放按钮跟着站点配色走，别让它一身白
   （leaflet.css 里 .leaflet-touch .leaflet-bar a 的白色底特异性一样高，这里压 !important，
     否则手机（带 touch 类）上是半黑半白的阴阳条） */
.earth-map .leaflet-bar{
  background:rgba(9,22,38,.86);border:0;border-radius:9px;overflow:hidden;
  box-shadow:0 4px 14px rgba(0,0,0,.3);
}
.earth-map .leaflet-control-zoom a,
.earth-map .leaflet-touch .leaflet-bar a{
  background:rgba(9,22,38,.86) !important;color:#dff3ff !important;
  border-bottom:1px solid rgba(120,200,255,.14) !important;
  font-weight:400;
}
.earth-map .leaflet-control-zoom a:hover,
.earth-map .leaflet-touch .leaflet-bar a:hover{background:rgba(14,34,56,.95) !important;color:#fff !important}
.earth-map .leaflet-container{background:#e9eef4}

/* 「我在这里」：和地图站同一个绿点，DOM 画的，不依赖图片 */
.here-dot{background:none;border:0}
.here-dot i{
  display:block;width:16px;height:16px;border-radius:50%;background:#00a854;
  border:3px solid #fff;box-shadow:0 2px 8px rgba(0,0,0,.35);box-sizing:border-box;position:relative;
}
.here-dot i::after{
  content:'';position:absolute;left:50%;top:50%;width:16px;height:16px;margin:-8px 0 0 -8px;
  border-radius:50%;background:rgba(0,168,84,.42);animation:herePulse 1.9s ease-out infinite;z-index:-1;
}
@keyframes herePulse{0%{transform:scale(.7);opacity:.85}70%{transform:scale(2.6);opacity:0}100%{opacity:0}}
@media (prefers-reduced-motion:reduce){.here-dot i::after{animation:none;opacity:.35}}

@media (max-width:760px){
  .map-hud{top:calc(8px + env(safe-area-inset-top,0px))}
  .map-back{height:36px;padding:0 15px;font-size:13.5px}
  .map-here{height:36px;line-height:36px;font-size:12.5px}
  /* 手机底部那条常驻导航压在画布上，Leaflet 默认把缩放按钮放在右下角会被它吃掉；
     连「到门口」署名一起上抬，不然只剩半截加号露在外面 */
  .earth-map .leaflet-bottom{bottom:calc(64px + env(safe-area-inset-bottom,0px))}
  .earth-map .leaflet-right{right:8px}
}

/* 关掉「减少动态效果」的机器上不做缩放，只做淡变 */
@media (prefers-reduced-motion:reduce){
  #orbit{transition:opacity .35s ease}
  .stage.mapped #orbit{transform:none}
}
