/* 铃铛 3D 小屋 · T11 BGM UI
 * owner/visitor 共用。白音符是任务书 §2.0 的硬例外：纯白几何 + 白 bloom，
 * 不含 emoji / 彩色 / 贴图；其余文字与 chip 仍走 §2 色板 / 1px / 低 α。
 *
 * 布局：左下角一行 [音符 28] [1px 细线 8] [2.5cm 歌名窗 94.5px] [BGM][环境]
 * 尺寸：高 30px；2.5cm 歌名窗固定 94.5px，不被父级裁切。
 * surface：house3d-card / house3d-full / room；visitor 阶段由 data-position=absolute 放进 16:9 舞台。
 */
.h3dBgm{
  --h3dBgm-win:94.5px;
  --h3dBgm-h:30px;
  position:fixed;
  left:max(12px, env(safe-area-inset-left));
  bottom:max(14px, env(safe-area-inset-bottom));
  z-index:70;
  display:flex;
  align-items:center;
  height:var(--h3dBgm-h);
  color:#dfe6f2;
  font:600 10.5px/1 system-ui,-apple-system,"PingFang SC","Microsoft YaHei",sans-serif;
  letter-spacing:.3px;
  opacity:0;
  pointer-events:auto;
  -webkit-tap-highlight-color:transparent;
  user-select:none;
  isolation:isolate;
  transition:opacity .32s ease;
}
.h3dBgm[hidden]{display:none!important}
.h3dBgm.is-on{opacity:1}
/* BGM 关：整体渐隐，但仍可点回来；唱机接管时保持可见（唱机还在响）。 */
.h3dBgm.is-bgm-off{opacity:.34;transition-duration:.24s}
/* 2.5D 全屏：让开左下角的壳 HUD（跟随/机位/Hz），不叠在它上面。 */
.h3dBgm[data-surface="house3d-full"]{bottom:calc(112px + env(safe-area-inset-bottom))}
/* 访客/3D 房间：舞台内绝对定位；#visitBotL 由共享样式上移 34px。 */
.h3dBgm[data-position="absolute"]{position:absolute}
/* 2.5D 卡片：落在 #house3dSoundSlot 的流内，不压住下面的串门按钮。 */
.h3dBgm[data-position="inline"]{position:static;left:auto;right:auto;bottom:auto;z-index:auto;opacity:1;transition:none}

/* ---------- 音符按钮 ---------- */
.h3dBgmNote{
  flex:0 0 auto; width:28px; height:30px; padding:2px 1px;
  display:grid; place-items:center;
  border:0; background:none; color:#fff; cursor:pointer;
}
.h3dBgmNoteFx{
  position:relative;
  display:grid; place-items:center; width:26px; height:26px;
  transform-origin:50% 50%;
  /* 零半径透明阴影：只为保持与非 beat 帧一致的栅格化，不产生可见光。 */
  filter:drop-shadow(0 0 0 rgba(255,255,255,0));
}
/* beat 只让 SVG 自己的 1px 白线发光：没有径向光点、不缩放、不改布局。 */
.h3dBgmArt{display:grid; place-items:center; width:26px; height:26px; color:#fff; position:relative}
.h3dBgmArt svg{display:block; width:26px; height:26px; overflow:visible; color:#fff}
.h3dBgmArt svg [stroke]{stroke:#fff}
.h3dBgmNote:active .h3dBgmNoteFx{transform:scale(.96)}
.h3dBgm.is-beat .h3dBgmArt svg{animation:h3dBgmLine 120ms ease-out}
.h3dBgmBeam{stroke-opacity:.42}
@keyframes h3dBgmLine{
  0%{filter:drop-shadow(0 0 0 rgba(255,255,255,0))}
  35%{filter:drop-shadow(0 0 1.2px #fff) drop-shadow(0 0 6px rgba(255,255,255,.75))}
  100%{filter:drop-shadow(0 0 0 rgba(255,255,255,0))}
}
/* 2.5D BGM 置灰：beat 不闪（BGM 只在 3D 房间）。 */
.h3dBgm.is-gated .h3dBgmArt svg{animation:none!important;filter:none!important}

/* ---------- 歌名 + 双 chip ---------- */
.h3dBgmBody{
  display:flex; align-items:center; height:30px; min-width:0;
  margin-left:7px; max-width:250px; opacity:1;
  overflow:hidden;
  transition:max-width .22s ease, opacity .18s ease, margin-left .22s ease;
}
.h3dBgm.is-collapsed .h3dBgmBody{max-width:0; margin-left:0; opacity:0; pointer-events:none}
.h3dBgmRule{flex:0 0 auto; width:8px; height:1px; margin-right:7px; background:rgba(223,230,242,.32)}
.h3dBgmTitle{
  flex:0 0 auto; width:var(--h3dBgm-win); height:24px; padding:0;
  display:flex; align-items:center;
  border:0; background:none; color:#dfe6f2; cursor:pointer; text-align:left;
  font:600 10.5px/1 system-ui,-apple-system,"PingFang SC","Microsoft YaHei",sans-serif;
  letter-spacing:.3px; overflow:hidden;
}
.h3dBgmTitle:active{opacity:.72}
.h3dBgmWin{
  display:block; width:var(--h3dBgm-win); height:16px;
  overflow:hidden; position:relative;
}
.h3dBgmTrack{
  display:flex; align-items:center; gap:24px; height:16px;
  width:max-content; transform:translate3d(0,0,0); will-change:transform;
}
.h3dBgmText{display:block; flex:0 0 auto; white-space:nowrap; line-height:16px}
.h3dBgmWin.is-static .h3dBgmTrack{display:block; width:100%; transform:none!important; will-change:auto}
.h3dBgmWin.is-static .h3dBgmText{max-width:100%; overflow:hidden; text-overflow:ellipsis}
.h3dBgmWin.is-static .h3dBgmDup{display:none}
/* 首尾 8px 羽化；只在真正跑 marquee 时打开，短标题不虚边。 */
.h3dBgmWin.is-marquee{
  -webkit-mask-image:linear-gradient(90deg,transparent 0,#000 8px,#000 calc(100% - 8px),transparent 100%);
  mask-image:linear-gradient(90deg,transparent 0,#000 8px,#000 calc(100% - 8px),transparent 100%);
}
.h3dBgmChips{display:flex; align-items:center; gap:4px; flex:0 0 auto; margin-left:7px}
.h3dBgmChip{
  display:flex; align-items:stretch; height:24px; overflow:hidden;
  border-radius:8px;
  background:rgba(9,13,20,.72);
  border:1px solid rgba(111,179,255,.12);
  transition:border-color .2s ease, background .2s ease;
}
.h3dBgmChip.is-on{border-color:rgba(111,179,255,.34);background:rgba(24,36,54,.90)}
.h3dBgmChipMain{
  min-width:0; padding:0 6px; border:0; background:none; color:#7d879b;
  font:600 10px/1 system-ui,-apple-system,"PingFang SC",sans-serif;
  letter-spacing:.3px; cursor:pointer;
}
.h3dBgmChip.is-on .h3dBgmChipMain{color:#cfe2ff}
.h3dBgmChipVol{
  width:16px; padding:0 4px 7px; display:flex; align-items:flex-end; justify-content:center; gap:1px;
  border:0; border-left:1px solid rgba(255,255,255,.06); background:none; cursor:pointer;
}
.h3dBgmChipVol[hidden]{display:none!important}
.h3dBgmChipVol i{display:block; width:1px; border-radius:1px; background:rgba(207,227,255,.18)}
.h3dBgmChipVol i:nth-child(1){height:4px}
.h3dBgmChipVol i:nth-child(2){height:7px}
.h3dBgmChipVol i:nth-child(3){height:10px}
.h3dBgmChipVol i.on{background:rgba(207,227,255,.88)}
.h3dBgmChipMain:active,.h3dBgmChipVol:active{opacity:.7}
.h3dBgmChipMain[disabled]{cursor:default}
.h3dBgmChipMain[disabled]:active{opacity:1}
.h3dBgm3D{display:none}
.h3dBgmNote:focus-visible,.h3dBgmTitle:focus-visible,
.h3dBgmChipMain:focus-visible,.h3dBgmChipVol:focus-visible{
  outline:1px solid rgba(223,230,242,.8); outline-offset:2px;
}
.h3dBgmChipMain:focus-visible,.h3dBgmChipVol:focus-visible{outline-offset:-2px}

/* 2.5D：只保留环境声；没有歌名窗；BGM chip 置灰并标「3D」。 */
.h3dBgm.is-gated .h3dBgmTitle,
.h3dBgm.is-gated .h3dBgmRule{display:none}
.h3dBgm.is-gated .h3dBgmNote{opacity:.42;cursor:default}
.h3dBgm.is-gated .h3dBgmBody{max-width:160px;margin-left:7px}
.h3dBgm.is-gated .h3dBgmChip[data-bus="bgm"]{
  opacity:.62;
  border-color:rgba(111,179,255,.08);
  background:rgba(9,13,20,.46);
}
.h3dBgm.is-gated .h3dBgmChip[data-bus="bgm"] .h3dBgmChipMain{color:#7d879b}
.h3dBgm.is-gated .h3dBgm3D{
  display:inline-block; margin-left:3px; padding:0 3px;
  border:1px solid rgba(207,227,255,.22); border-radius:3px;
  font:600 7px/10px ui-monospace,SFMono-Regular,Consolas,monospace;
  color:#8a93a6; letter-spacing:.3px; vertical-align:1px;
}

/* ---------- 音量（长按 chip / 点 3 根音量条） ---------- */
.h3dBgmVol{
  position:absolute; left:29px; bottom:calc(100% + 8px); z-index:2;
  width:176px; height:36px; padding:0 10px;
  display:flex; align-items:center; gap:8px;
  border-radius:10px;
  background:rgba(9,13,20,.95);
  border:1px solid rgba(111,179,255,.20);
}
.h3dBgmVol[hidden]{display:none!important}
.h3dBgmVolK{flex:0 0 auto; font:600 10px/1 system-ui,sans-serif; color:#8a93a6; letter-spacing:.4px}
.h3dBgmVolN{flex:0 0 20px; text-align:right; font:600 10px/1 ui-monospace,SFMono-Regular,Consolas,monospace;
  color:#dfe6f2; font-variant-numeric:tabular-nums}
.h3dBgmRange{
  flex:1; min-width:0; width:100%; height:16px; margin:0;
  background:transparent; -webkit-appearance:none; appearance:none; cursor:pointer;
}
.h3dBgmRange::-webkit-slider-runnable-track{height:1px;background:rgba(223,230,242,.24)}
.h3dBgmRange::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:8px; height:8px; margin-top:-3.5px;
  border-radius:50%; background:#fff; border:0;
}
.h3dBgmRange::-moz-range-track{height:1px;background:rgba(223,230,242,.24)}
.h3dBgmRange::-moz-range-thumb{width:8px;height:8px;border-radius:50%;background:#fff;border:0}
.h3dBgmRange:focus-visible{outline:1px solid rgba(223,230,242,.8);outline-offset:2px}

/* 3D 房间：BGM UI 高 30px + 底 14px；#visitBotL 按任务书上移 34px。 */
body.bgmUiRoom #visitBotL{bottom:45px}
body.bgmUiRoom #visitClean{bottom:68px}

/* 旧 T3 占位按钮（disabled）与新 BGM UI 重复；有真控件时收起占位，不叠加。 */
body.bgmUiOn #house3dShellSound,
body.bgmUiOn #house3dShellBgm{display:none}

@media (prefers-reduced-motion: reduce){
  .h3dBgm,.h3dBgmBody,.h3dBgmChip{transition:none!important}
  /* 只保留轻微线条发光；不缩放、不旋转、不跑光点。 */
  .h3dBgm.is-beat .h3dBgmArt svg{animation:h3dBgmLineReduced 120ms linear}
  .h3dBgm.is-gated .h3dBgmArt svg{animation:none!important}
  .h3dBgmNoteFx{transform:none!important}
  @keyframes h3dBgmLineReduced{
    0%,100%{filter:none}
    45%{filter:drop-shadow(0 0 1px rgba(255,255,255,.55))}
  }
}
