/* ================================================================
   IP 过场层 · 页面与页面之间的那道光
   —— 点击风铃/返回时出现，人物捧着星星往前走，走到头才换页
   ================================================================ */

.gate {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(16px, 3vh, 28px);
  background:
    radial-gradient(120% 80% at 50% 82%, rgba(58, 40, 96, 0.55), transparent 62%),
    radial-gradient(90% 60% at 50% 12%, rgba(38, 30, 68, 0.5), transparent 70%),
    #07050e;
  opacity: 1;
  transition: opacity 0.55s var(--ease-out, ease);
}

.gate[hidden] { display: none; }

/* 刚到达新页面：过场层要在第一帧就在场，否则会闪一下白 */
html.gate-arriving .gate[hidden] { display: grid; }
html.gate-arriving body { overflow: hidden; }

/* 首访启动层：同样要在解析 HTML 的第一帧就铺上，不能让首页先闪一下 */
html.gate-booting .gate[hidden] { display: grid; }
html.gate-booting,
html.gate-booting body { overflow: hidden; }
.gate.is-out { opacity: 0; pointer-events: none; }
.gate.is-in { animation: gateFadeIn 0.32s ease both; }

@keyframes gateFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- 人物（A 方案：悬于条上）----
   高度定死、宽度随形象比例自适应，五个形象换场不跳版 */
.gate-figure {
  position: relative;
  height: clamp(158px, 27vh, 236px);
  display: grid;
  place-items: end center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.gate-figure.is-ready { opacity: 1; }

.gate-ip {
  display: block;
  height: 100%;
  width: auto;
  filter: drop-shadow(0 14px 26px rgba(4, 2, 10, 0.8)) drop-shadow(0 0 22px rgba(255, 208, 122, 0.14));
}

/* 人物脚下那圈光 */
.gate-figure::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 62%;
  height: 12px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 214, 138, 0.32), transparent 72%);
  filter: blur(3px);
  animation: gateGlow 2.4s ease-in-out infinite;
}

@keyframes gateGlow {
  0%, 100% { opacity: 0.55; transform: translateX(-50%) scale(0.94); }
  50% { opacity: 0.9; transform: translateX(-50%) scale(1.06); }
}

/* ---- 进度 ---- */
.gate-ui {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(58vw, 320px);
}

.gate-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: rgba(242, 236, 221, 0.62);
  text-transform: uppercase;
  white-space: nowrap;
}

.gate-label b {
  color: var(--amber, #f5c777);
  font-weight: 500;
  letter-spacing: 0.08em;
}

.gate-track {
  position: relative;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: rgba(242, 236, 221, 0.13);
  overflow: visible;
}

.gate-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(245, 199, 119, 0.35), #f7d79b 62%, #fff6e4);
  box-shadow: 0 0 12px rgba(245, 199, 119, 0.55);
  transition: width 0.28s ease-out;
}

/* 进度头那颗星 */
.gate-spark {
  position: absolute;
  top: 50%;
  left: 0;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: #fff8e8;
  box-shadow: 0 0 10px 2px rgba(255, 226, 170, 0.9), 0 0 26px 8px rgba(255, 200, 120, 0.35);
  transition: left 0.28s ease-out;
}

.gate-pct {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(242, 236, 221, 0.42);
  font-variant-numeric: tabular-nums;
}

/* ================================================================
   新设备守护：JS 尚未接管时（gate-booting 阶段），过场层也要"活着"
   —— 呼吸的标签、晃动的星点、缓升的进度，并让访客随时能点掉
   ================================================================ */
html.gate-booting .gate { cursor: pointer; }
/* 只在脚本尚未接管时（还没加 .is-in）才呼吸，接管后交给真实进度 */
html.gate-booting .gate:not(.is-in) .gate-label { animation: gateBreathe 1.8s ease-in-out infinite; }
html.gate-booting .gate:not(.is-in) .gate-spark { animation: gateSparkWarm 1.5s ease-in-out infinite; }
html.gate-booting .gate:not(.is-in) .gate-fill { width: 7%; }

.gate-skip {
  margin: 2px 0 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: rgba(242, 236, 221, 0.52);
  opacity: 0;
  white-space: nowrap;
}
/* 启动层一铺出来，2.2 秒后浮现"点一下"提示（不依赖 JS） */
html.gate-booting .gate-skip { animation: gateHintIn 0.7s ease 2.2s forwards; }
/* 启动脚本接管后（有真实进度了），隐藏这条提示，交给 label 文案 */
html.gate-booting .gate.is-in .gate-skip { animation: none; opacity: 0; }

@keyframes gateHintIn { to { opacity: 1; } }
@keyframes gateBreathe { 0%, 100% { opacity: 0.62; } 50% { opacity: 1; } }
@keyframes gateSparkWarm {
  0%, 100% { transform: translateX(0); opacity: 0.8; }
  50% { transform: translateX(20px); opacity: 1; }
}
