/* =========================================================
   JYC 加载条 · 小老鼠追奶酪  (v4.0)
   ---------------------------------------------------------
   零素材：老鼠与奶酪全部由 CSS 绘制（本项目正被图片体积困扰，
   加载动画自己再引入图片就是自打嘴巴）。
   结构：.jml > .jml-head + .jml-track(.jml-fill/.jml-runner/.jml-cheese) + .jml-sub
   进度靠自定义属性 --p（0~1）驱动，JS 每帧只写一个变量。
   ========================================================= */

.jml {
  --p: 0;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  font-family: 'Noto Sans SC', sans-serif;
  user-select: none;
}

/* ---------- 头部：文案 + 百分比 ---------- */
.jml-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 7px;
}
.jml-tip {
  font-size: 12.5px; color: #d6c8f2; letter-spacing: .02em;
  animation: jmlTipIn .35s ease;
}
@keyframes jmlTipIn { from { opacity: 0; transform: translateY(3px); } }
.jml-pct {
  font-family: Rajdhani, sans-serif; font-size: 16px; font-weight: 700;
  color: var(--gold, #f5c451);
  text-shadow: 0 0 12px rgba(245, 196, 81, .5);
  font-variant-numeric: tabular-nums;
}

/* ---------- 轨道：地板缝 ---------- */
.jml-track {
  position: relative; height: 34px;
  border-radius: 9px; overflow: hidden;
  border: 1px solid rgba(245, 196, 81, .3);
  background:
    linear-gradient(180deg, rgba(52, 33, 15, .95), rgba(16, 10, 5, .98));
  box-shadow:
    inset 0 3px 7px rgba(0, 0, 0, .8),
    inset 0 -1px 0 rgba(255, 224, 170, .14);
}
/* 木地板纹理 */
.jml-track::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg,
    transparent 0 26px, rgba(0, 0, 0, .35) 26px 28px);
  opacity: .55;
}
/* 地面线：老鼠跑在这条线上 */
.jml-track::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 3px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 224, 170, .3) 12%, rgba(255, 224, 170, .3) 88%, transparent);
}

.jml-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: calc(var(--p) * 100%);
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .12) 0 8px, transparent 8px 18px),
    linear-gradient(90deg, rgba(168, 85, 247, .5), rgba(245, 196, 81, .68));
  box-shadow: 0 0 16px rgba(245, 196, 81, .45);
}
.jml-fill::after {
  content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 2px;
  background: #fff6d8; box-shadow: 0 0 10px 2px rgba(255, 240, 200, .8);
}

/* ---------- 奔跑体（老鼠 + 尘土） ---------- */
.jml-runner {
  position: absolute; bottom: 3px;
  left: calc(var(--p) * (100% - 76px));
  display: flex; align-items: flex-end;
  z-index: 3;
}

/* ---------- 小老鼠（纯 CSS，侧视朝右） ---------- */
.jml-mouse { position: relative; width: 42px; height: 26px; }
.jml-mouse i { position: absolute; display: block; }

.m-body {
  left: 8px; top: 8px; width: 22px; height: 14px;
  border-radius: 56% 74% 62% 48% / 66% 72% 52% 44%;
  background: linear-gradient(162deg, #ded3c7 0%, #bcab9c 38%, #93816f 72%, #6b5b4d 100%);
  box-shadow: inset -2px -2px 4px rgba(0, 0, 0, .34), inset 2px 2px 3px rgba(255, 250, 240, .4);
}
.m-head {
  left: 24px; top: 9px; width: 13px; height: 13px;
  border-radius: 52% 62% 48% 56%;
  background: linear-gradient(158deg, #e6dcd1 0%, #c3b2a3 45%, #8d7b6a 100%);
  box-shadow: inset -1px -1px 3px rgba(0, 0, 0, .3);
}
.m-ear {
  left: 23px; top: 3px; width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 44% 56%, #f0b9c4 0 38%, #c9a595 40%, #9c8474 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.m-eye {
  left: 31px; top: 12.5px; width: 3.4px; height: 3.4px; border-radius: 50%;
  background: #241a12;
  box-shadow: .8px -.8px 0 .2px rgba(255, 255, 255, .75);
}
.m-nose {
  left: 36px; top: 16px; width: 4.6px; height: 3.6px; border-radius: 50%;
  background: #f09ab0; box-shadow: 0 0 3px rgba(240, 154, 176, .7);
}
/* 胡须 */
.m-nose::after {
  content: ""; position: absolute; left: 2px; top: -1px; width: 9px; height: 5px;
  border-top: 1px solid rgba(255, 244, 225, .55);
  border-bottom: 1px solid rgba(255, 244, 225, .4);
  transform: rotate(-6deg);
}
.m-tail {
  left: 0; top: 7px; width: 15px; height: 12px;
  border: 2px solid #a89383;
  border-color: transparent transparent #a89383 #a89383;
  border-radius: 0 0 0 15px;
  transform-origin: 100% 50%;
  transform: rotate(-12deg);
}
.m-leg {
  bottom: 0; width: 4px; height: 7px; border-radius: 3px 3px 2px 2px;
  background: linear-gradient(180deg, #a08d7c, #6d5b4c);
  transform-origin: 50% 0%;
}
.m-leg.a { left: 12px; transform: rotate(20deg); }
.m-leg.b { left: 21px; transform: rotate(-20deg); }

/* 尘土：绝对定位在奔跑体左侧，永远扬在老鼠身后 */
.jml-dust { position: absolute; left: -2px; bottom: 1px; width: 0; height: 0; }
.jml-dust::before, .jml-dust::after {
  content: ""; position: absolute; bottom: 0; border-radius: 50%;
  background: rgba(226, 208, 178, .38); opacity: 0;
}
.jml-dust::before { left: -8px; width: 7px; height: 7px; }
.jml-dust::after  { left: -16px; width: 5px; height: 5px; }

/* ---------- 奔跑状态 ---------- */
.jml.is-run .jml-mouse { animation: jmlBob .24s linear infinite; }
.jml.is-run .m-leg.a   { animation: jmlLegA .24s linear infinite; }
.jml.is-run .m-leg.b   { animation: jmlLegB .24s linear infinite; }
.jml.is-run .m-tail    { animation: jmlTail .34s ease-in-out infinite; }
.jml.is-run .jml-dust::before { animation: jmlDust .46s linear infinite; }
.jml.is-run .jml-dust::after  { animation: jmlDust .46s linear .17s infinite; }
@keyframes jmlBob  { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2.5px); } }
@keyframes jmlLegA { 0%, 100% { transform: rotate(26deg); } 50% { transform: rotate(-26deg); } }
@keyframes jmlLegB { 0%, 100% { transform: rotate(-26deg); } 50% { transform: rotate(26deg); } }
@keyframes jmlTail { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(8deg); } }
@keyframes jmlDust {
  0%   { opacity: .5; transform: translate(0, 0) scale(.5); }
  100% { opacity: 0;  transform: translate(-13px, -6px) scale(1.5); }
}
/* 停滞时：抽鼻子嗅探 */
.jml:not(.is-run):not(.is-done) .m-head { animation: jmlSniff 1.1s ease-in-out infinite; }
.jml:not(.is-run):not(.is-done) .m-ear  { animation: jmlEar 1.7s ease-in-out infinite; }
@keyframes jmlSniff { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(1.6px); } }
@keyframes jmlEar   { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-13deg); } }

/* ---------- 奶酪 ---------- */
.jml-cheese {
  position: absolute; right: 5px; bottom: 3px; z-index: 2;
  width: 30px; height: 23px;
  clip-path: polygon(0 100%, 100% 100%, 100% 8%);
  background: linear-gradient(152deg, #fff0ae 0%, #ffd254 40%, #eaa917 72%, #b47c07 100%);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6));
  animation: jmlCheese 1.7s ease-in-out infinite;
}
@keyframes jmlCheese {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-3px) rotate(-4deg); }
}
.c-hole {
  position: absolute; border-radius: 50%;
  background: #a5710a;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 235, 160, .25);
}
.c-hole.h1 { right: 4px;  bottom: 4px;  width: 6px;   height: 6px; }
.c-hole.h2 { right: 13px; bottom: 3px;  width: 4.5px; height: 4.5px; }
.c-hole.h3 { right: 5px;  bottom: 12px; width: 4px;   height: 4px; }

/* ---------- 收尾：追到了 ---------- */
.jml.is-done .jml-cheese { animation: jmlChomp .55s cubic-bezier(.3, 1.4, .5, 1) forwards; }
@keyframes jmlChomp {
  0%   { transform: scale(1) rotate(0deg); }
  32%  { transform: scale(1.28) rotate(-12deg); }
  100% { transform: scale(.15) rotate(24deg); opacity: 0; }
}
.jml.is-done .jml-mouse { animation: jmlHop .55s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes jmlHop {
  0%   { transform: translateY(0) scale(1); }
  38%  { transform: translateY(-11px) scale(1.14); }
  100% { transform: translateY(0) scale(1); }
}
.jml.is-done .jml-tip { color: #ffe6ab; font-weight: 700; }
.jml.is-done .jml-fill { background: linear-gradient(90deg, #a855f7, #f5c451 62%, #fff3cd); }

/* ---------- 底部：已搬运 N / M ---------- */
.jml-sub {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 6px; font-size: 11px; color: #9d8fbe;
  font-variant-numeric: tabular-nums;
}
.jml-sub b { color: #c9b6ee; font-family: Rajdhani, sans-serif; font-size: 12.5px; margin-left: 5px; }

/* ---------- 变体 A：遮罩（盖在某个容器 / 全屏上） ---------- */
.jml-host { position: relative; }
/* ⚠️ 不能垂直居中：游戏面板经常比视口更高，居中会把加载条推到折叠线以下
   （截图实测踩到过——遮罩在、条看不见）。改为靠上定位，永远在首屏。 */
.jml-mask {
  position: absolute; inset: 0; z-index: 30; overflow: hidden;
  display: flex; align-items: flex-start; justify-content: center; padding: 22px;
  background: radial-gradient(ellipse at 50% 50%, rgba(22, 12, 40, .88), rgba(3, 2, 8, .95));
  backdrop-filter: blur(6px);
  animation: fadeIn .2s ease;
  border-radius: inherit;
}
.jml-mask > .jml { margin-top: clamp(18px, 11vh, 96px); }
.jml-mask.is-full { position: fixed; z-index: 95; align-items: center; }
.jml-mask.is-full > .jml { margin-top: 0; }
.jml-mask.is-out { animation: jmlMaskOut .34s ease forwards; }
@keyframes jmlMaskOut { to { opacity: 0; visibility: hidden; } }

/* ---------- 变体 B：细条（弹窗顶部内联） ---------- */
.jml.is-slim { max-width: none; margin-bottom: 14px; }
.jml.is-slim .jml-track { height: 26px; }
.jml.is-slim .jml-mouse { transform-origin: bottom left; scale: .78; }
.jml.is-slim .jml-cheese { width: 24px; height: 18px; }
.jml.is-slim .jml-runner { left: calc(var(--p) * (100% - 64px)); }
.jml.is-slim .jml-sub { display: none; }

/* ---------- 变体 C：入场页 ----------
   ⚠️ #entrance 是 position:fixed 的定高 flex 容器且 justify-content:center，
   多塞进去的任何高度都会把底部的进入按钮挤出视口（截图实测踩到过）。
   所以入场变体本身要瘦，并在加载期间同步压缩 logo 与各段间距，加载完自动还原。 */
.jml.is-entry { max-width: 340px; margin: 14px auto 0; }
.jml.is-entry .jml-sub { display: none; }
.jml.is-entry .jml-track { height: 28px; }
.jml.is-entry .jml-runner { left: calc(var(--p) * (100% - 66px)); }
.jml.is-entry .jml-mouse { scale: .84; transform-origin: bottom left; }
.jml.is-entry .jml-cheese { width: 26px; height: 20px; }

/* ⚠️ 修既存缺陷：#entrance 是 column flex，子项默认 flex-shrink:1，
   内容一超过视口高度，进入按钮就被"压扁"，而它自带 overflow:hidden，
   于是按钮文字被从下方裁掉（1280×800 下必现，加载条只是把它放大了）。
   解法：子项禁止压缩 + 容器可滚动，并用首尾 auto 外边距保住「够高时仍居中」。 */
#entrance { overflow-y: auto; overscroll-behavior: contain; justify-content: flex-start; }
#entrance > * { flex-shrink: 0; }
#entrance > :first-child { margin-top: auto; }
#entrance > :last-child { margin-bottom: auto; }

/* 入场页高度自适应：实测原始内容总高 1086px，
   在 800px 视口下主 CTA「钻进鼠界」会掉到折叠线以下 —— 这是转化关键位，必须在首屏。
   按视口高度分档收紧，够高时完全不生效。 */
#entrance .entrance-logo { transition: width .45s ease; }
@media (max-height: 940px) {
  #entrance .entrance-logo   { width: min(38vw, 236px); }
  #entrance .entrance-tag    { margin-bottom: 6px; }
  #entrance .entrance-title  { margin-top: 6px; }
  #entrance .entrance-slogan { margin-top: 10px; margin-bottom: 8px; }
  #entrance .entrance-chips  { margin-top: 12px; }
  #entrance .entrance-cast   { margin-top: 10px; }
  #entrance .entrance-cast img { width: 60px; height: 94px; }
  #entrance .enter-btn       { margin-top: 14px; }
  #entrance .entrance-meta   { margin-top: 14px; }
  #entrance .seed-pub        { margin-top: 8px; }
  #entrance .legal-note      { margin-top: 10px; }
}
@media (max-height: 740px) {
  #entrance .entrance-logo   { width: min(30vw, 176px); }
  #entrance .entrance-title  { font-size: clamp(26px, 5vw, 38px); }
  #entrance .entrance-cast img { width: 50px; height: 78px; }
  #entrance .e-chip          { padding: 5px 12px; font-size: 11.5px; }
}
/* 极矮视口（横屏手机等）：优先保 CTA，装饰性角色预览让位 */
@media (max-height: 640px) {
  #entrance .entrance-logo  { width: min(24vw, 132px); }
  #entrance .entrance-title { font-size: 30px; }
  #entrance .entrance-cast  { display: none; }
  #entrance .seed-pub       { display: none; }
}
/* 加载期间再压一档，把加载条的高度让出来 */
#entrance.has-loader .entrance-logo { width: min(32vw, 200px); }
#entrance.has-loader .entrance-chips { margin-top: 10px; }
#entrance.has-loader .entrance-cast { margin-top: 8px; }
#entrance.has-loader .enter-btn { margin-top: 12px; }

.enter-btn.is-loading { opacity: .72; }
.enter-btn.is-ready { animation: jmlReady .9s ease; }
@keyframes jmlReady {
  0%   { box-shadow: 0 0 0 0 rgba(245, 196, 81, .7); }
  100% { box-shadow: 0 0 0 22px rgba(245, 196, 81, 0); }
}

/* ---------- 变体 D：盲盒蓄力（放在保险箱下方） ---------- */
.jml.is-vault {
  position: absolute; left: 50%; bottom: -58px; transform: translateX(-50%);
  width: 300px; z-index: 4;
}
.jml.is-vault .jml-sub { display: none; }
.gc-fx.ph-burst .jml.is-vault,
.gc-fx.ph-cards .jml.is-vault,
.gc-fx.ph-skip .jml.is-vault { opacity: 0; transition: opacity .25s ease; pointer-events: none; }

/* ---------- 响应式 / 降低动效 ---------- */
@media (max-width: 560px) {
  .jml { max-width: 100%; }
  .jml.is-vault { width: min(84vw, 300px); }
}
@media (prefers-reduced-motion: reduce) {
  .jml.is-run .jml-mouse, .jml.is-run .m-leg, .jml.is-run .m-tail,
  .jml-cheese, .jml .m-head, .jml .m-ear,
  .jml.is-run .jml-dust::before, .jml.is-run .jml-dust::after { animation: none !important; }
  .jml.is-done .jml-cheese { opacity: 0; transition: opacity .2s; }
}
