/* dex-home.css - 图鉴的主页集成（index.html）
 * ① 图鉴入口 FAB（播放器正上方）
 * ② 主页展示层：配置进来的收集物（空中漂浮）与角色（地板跑步/原地弹跳）
 * ③ 配置模式（?arrange=1）：隐藏主页其它 UI，槽位 + 待选托盘
 * 设计语言与 landing.css 一致：3~4px 墨描边、硬阴影、胶囊标签
 */

:root {
  --dex-ink: #1d1d1d;
  --dex-miku: #39C5BB;
  --dex-yellow: #FFD93D;
}

/* ==================== ① 图鉴入口 FAB ====================
   播放器 FAB：right:18px / bottom:86px / 56px（竖屏 bottom:126px）
   图鉴 FAB 48px 居中置于其正上方，留 12px 间距 */
.dex-fab {
  position: fixed;
  right: 22px;
  bottom: 154px;
  z-index: 60;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 4px solid var(--dex-ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--dex-ink);
  font-size: 20px;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.dex-fab:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--dex-ink);
}

.dex-fab-label {
  position: absolute;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 9px;
  background: #fff;
  border: 2px solid var(--dex-ink);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

/* ==================== ② 主页展示层 ==================== */
.dex-home-layer {
  position: fixed;
  inset: 0;
  z-index: 1;            /* 与 .landing 同层：低于广告牌(2)与播放器(60) */
  pointer-events: none;  /* 纯展示，不挡任何点击 */
  overflow: hidden;
}

/* 空中收集物：上下轻浮动（不再满屏漂移） */
.dex-float {
  position: absolute;
  animation: dexBob 2.8s ease-in-out infinite alternate;
}

.dex-float img {
  display: block;
  width: 44px;
  filter: drop-shadow(2px 2px 0 rgba(29, 29, 29, 0.2));
}

/* 无图条目（猫の条）的占位气泡 */
.dex-float .dex-q {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.85);
  border: 3px solid var(--dex-ink);
  border-radius: 14px;
  font-size: 20px;
  font-weight: 900;
  color: #B9B5AA;
}

/* 5 个空中槽位预置点（避开标题与右侧 FAB 区） */
.dex-float.f1 { top: 9%;  left: 6%;  animation-delay: -0.4s; }
.dex-float.f2 { top: 16%; right: 10%; animation-delay: -1.3s; }
.dex-float.f3 { top: 27%; left: 14%; animation-delay: -2.1s; }
.dex-float.f4 { top: 7%;  right: 36%; animation-delay: -0.9s; }
.dex-float.f5 { top: 24%; right: 28%; animation-delay: -1.8s; }

@keyframes dexBob {
  from { margin-top: 0; }
  to   { margin-top: -12px; }
}

/* 地板角色（脚底贴着砖块地面，地面高 78px） */
.dex-char {
  position: absolute;
  bottom: 72px;
}

.dex-char img {
  display: block;
  filter: drop-shadow(2px 3px 0 rgba(29, 29, 29, 0.15));
}

/* 跑步型：从左跑到右循环（负延迟避免页面打开/截图时刻角色在屏外） */
.dex-char.run img { height: 84px; }
.dex-char.run.r0 { animation: dexRunAcross 11s linear -6s infinite; }
.dex-char.run.r1 { animation: dexRunAcross 15s linear -11s infinite; }
.dex-char.run.r2 { animation: dexRunAcross 19s linear -16s infinite; }

@keyframes dexRunAcross {
  from { transform: translateX(-140px); }
  to   { transform: translateX(105vw); }
}

/* 原地型：在地板上原地弹跳（预置 3 个站位，避开左下广告牌与右侧 FAB） */
.dex-char.hop img { height: 80px; }
.dex-char.hop { animation: dexHop 0.62s ease-in-out infinite; }
.dex-char.hop.h0 { left: 26%; }
.dex-char.hop.h1 { left: 50%; animation-delay: -0.21s; }
.dex-char.hop.h2 { left: 72%; animation-delay: -0.42s; }

@keyframes dexHop {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-14px); }
}

/* ==================== ③ 配置模式（body.arrange） ==================== */
/* 隐藏主页其它 UI：LOGO/开始按钮/底行/播放器 FAB/图鉴 FAB/广告牌/展示层 */
body.arrange .landing,
body.arrange .music-player,
body.arrange .ad-sign,
body.arrange .dex-fab,
body.arrange .dex-home-layer,
body.arrange .link-status {
  display: none !important;
}

/* 砖块地面抬到托盘上方，当作配置模式的地板（托盘高 116px） */
body.arrange .ground { bottom: 116px; }
body.arrange .hill   { bottom: 194px; }

.arrange-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;   /* 容器不挡背景，子元素各自恢复点击 */
  font-family: inherit;
}

.arrange-root[hidden] { display: none; }

.arrange-root > * { pointer-events: auto; }

/* 顶部栏：只剩 取消 / 完成 ✓ */
.ar-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.ar-btn {
  min-height: 44px;
  padding: 7px 18px;
  background: #fff;
  color: var(--dex-ink);
  border: 3px solid var(--dex-ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--dex-ink);
  font-size: 14px;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.ar-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--dex-ink);
}

.ar-btn.done { background: var(--dex-yellow); }

.ar-title {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(29, 29, 29, 0.45);
  pointer-events: none;
}

/* 槽位分组标签（收集物槽 n/5、角色槽 n/3） */
.ar-label {
  position: absolute;
  z-index: 3;
  padding: 3px 12px;
  background: #fff;
  border: 2px solid var(--dex-ink);
  border-radius: 999px;
  box-shadow: 2px 2px 0 var(--dex-ink);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.ar-label.air { top: 11%; left: 4.4%; }
/* 类名用 ground-label 而非 ground：避免被 body.arrange .ground（砖块地面抬升规则）误伤 */
.ar-label.ground-label { bottom: 268px; left: 4%; }

/* 虚线槽位 */
.ar-slot {
  position: absolute;
  z-index: 3;
  border: 3px dashed rgba(29, 29, 29, 0.55);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ar-slot img {
  max-width: 86%;
  max-height: 86%;
  display: block;
}

.ar-slot .plus {
  font-size: 30px;
  font-weight: 900;
  color: rgba(29, 29, 29, 0.4);
}

/* 已放入的槽位：实线白底 */
.ar-slot.filled {
  border-style: solid;
  border-color: var(--dex-ink);
  background: #fff;
  box-shadow: 3px 3px 0 var(--dex-ink);
}

/* 有选中待放物品时，可接收的槽位高亮成初音青 */
.ar-slot.can-drop {
  border-color: var(--dex-miku);
  background: rgba(217, 244, 242, 0.65);
}

/* 移除按钮（44×44 触控目标） */
.ar-remove {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 44px;
  height: 44px;
  background: #fff;
  border: 3px solid var(--dex-ink);
  border-radius: 50%;
  font-size: 15px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--dex-ink);
}

/* 空中收集物槽：竖屏 3+2 两行错位 */
.ar-slot.air-1 { top: 15%; left: 4.4%;  width: 84px; height: 84px; }
.ar-slot.air-2 { top: 15%; left: 41.6%; width: 84px; height: 84px; }
.ar-slot.air-3 { top: 15%; left: 77.2%; width: 84px; height: 84px; }
.ar-slot.air-4 { top: 29%; left: 20%;   width: 84px; height: 84px; }
.ar-slot.air-5 { top: 29%; left: 56%;   width: 84px; height: 84px; }

/* 地板角色槽：3 个，脚踩地板线 */
.ar-slot.ground-1 { bottom: 146px; left: 4%;    width: 112px; height: 112px; }
.ar-slot.ground-2 { bottom: 146px; left: 36.5%; width: 112px; height: 112px; }
.ar-slot.ground-3 { bottom: 146px; left: 69%;   width: 112px; height: 112px; }

/* 底部待选托盘 */
.ar-tray {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 116px;
  background: #fff;
  border-top: 4px solid var(--dex-ink);
  display: flex;
  flex-direction: column;
}

.ar-tray-hint {
  padding: 5px 12px 2px;
  font-size: 10px;
  font-weight: 900;
  color: #7c7668;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.ar-tray-row {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 2px 12px 8px;
  overflow-x: auto;
}

.ar-empty {
  padding: 0 12px;
  font-size: 12px;
  font-weight: 900;
  color: #a09b8f;
  align-self: center;
}

/* 托盘里的待选物品（整个 66px 宽列都是点击目标，≥44） */
.ar-pick {
  flex: none;
  width: 66px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  padding: 6px 0 0;
  font-family: inherit;
}

.ar-pick .ic {
  width: 52px;
  height: 52px;
  background: var(--tbg, #EAF7F5);
  border: 3px solid var(--dex-ink);
  border-radius: 14px;
  box-shadow: 2px 2px 0 var(--dex-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: #B9B5AA;
}

.ar-pick .ic img {
  max-width: 44px;
  max-height: 44px;
  display: block;
}

.ar-pick .nm {
  margin-top: 3px;
  font-size: 9px;
  font-weight: 900;
  color: var(--dex-ink);
  max-width: 66px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 选中态：青框高亮 + 微微放大 */
.ar-pick.selected .ic {
  border-color: var(--dex-miku);
  box-shadow: 3px 3px 0 var(--dex-miku);
  transform: scale(1.08);
}

/* 已放置：变暗 + 角标 */
.ar-pick.placed .ic { opacity: 0.45; }

.ar-pick .placed-tag {
  position: absolute;
  top: 0;
  right: -2px;
  z-index: 2;
  padding: 1px 6px;
  background: var(--dex-miku);
  color: #fff;
  border: 2px solid var(--dex-ink);
  border-radius: 999px;
  font-size: 8px;
  font-weight: 900;
}

/* 类型小标签：收集物 / 跑步 / 原地 */
.ar-pick .mv {
  position: absolute;
  top: 0;
  left: -2px;
  z-index: 2;
  padding: 1px 5px;
  background: var(--dex-yellow);
  border: 2px solid var(--dex-ink);
  border-radius: 999px;
  font-size: 7px;
  font-weight: 900;
  white-space: nowrap;
}

.ar-pick .mv.mv-item { background: #D9F4F2; }

/* 提示 toast（超上限/槽位类型不符等） */
.ar-toast {
  position: absolute;
  left: 50%;
  bottom: 128px;
  transform: translateX(-50%) translateY(8px);
  z-index: 9;
  padding: 8px 16px;
  background: var(--dex-yellow);
  border: 3px solid var(--dex-ink);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--dex-ink);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.ar-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==================== 响应式 ==================== */
/* 竖屏：砖块地面加高到 108px（landing.css 同款），角色与 FAB 同步抬升 */
@media (orientation: portrait) {
  .dex-fab { bottom: 194px; }   /* 播放器 FAB 竖屏 bottom:126px 的正上方 */
  .dex-char { bottom: 104px; }
  body.arrange .hill { bottom: 224px; }   /* 116 托盘 + 108 地面 */
}

/* 矮横屏：展示物缩小，配置模式整体压缩（托盘 84px、槽位一行排开） */
@media (max-height: 520px) {
  .dex-fab {
    width: 40px;
    height: 40px;
    right: 17px;
    bottom: 138px;
    border-width: 3px;
    font-size: 16px;
  }
  .dex-fab-label { bottom: 43px; font-size: 9px; }

  .dex-float img { width: 30px; }
  .dex-float .dex-q { width: 30px; height: 30px; font-size: 14px; border-width: 2px; border-radius: 10px; }
  .dex-float.f1 { top: 5%;  left: 4%; }
  .dex-float.f2 { top: 8%;  right: 6%; }
  .dex-float.f3 { top: 18%; left: 10%; }
  .dex-float.f4 { top: 5%;  right: 28%; }
  .dex-float.f5 { top: 16%; right: 20%; }

  .dex-char.run img { height: 56px; }
  .dex-char.hop img { height: 52px; }

  body.arrange .ground { bottom: 84px; }
  body.arrange .hill   { bottom: 162px; }

  .ar-top { padding: 6px 10px; }
  .ar-btn { min-height: 40px; padding: 4px 14px; font-size: 12px; border-width: 2px; }
  .ar-title { font-size: 12px; }

  /* 空中 5 槽横屏排一行 */
  .ar-slot.air-1 { top: 25%; left: 5%;    width: 50px; height: 50px; }
  .ar-slot.air-2 { top: 25%; left: 26.3%; width: 50px; height: 50px; }
  .ar-slot.air-3 { top: 25%; left: 47.4%; width: 50px; height: 50px; }
  .ar-slot.air-4 { top: 25%; left: 68.6%; width: 50px; height: 50px; }
  .ar-slot.air-5 { top: 25%; left: 89.7%; width: 50px; height: 50px; }
  .ar-label.air { top: 15%; left: 5%; font-size: 9px; padding: 2px 8px; }

  .ar-slot.ground-1 { bottom: 92px; left: 18%; width: 76px; height: 76px; }
  .ar-slot.ground-2 { bottom: 92px; left: 44%; width: 76px; height: 76px; }
  .ar-slot.ground-3 { bottom: 92px; left: 70%; width: 76px; height: 76px; }
  .ar-label.ground-label { bottom: 176px; left: 18%; font-size: 9px; padding: 2px 8px; }

  .ar-slot .plus { font-size: 20px; }
  .ar-remove { width: 34px; height: 34px; font-size: 11px; top: -10px; right: -10px; border-width: 2px; }

  .ar-tray { height: 84px; }
  .ar-tray-hint { padding: 3px 10px 0; font-size: 9px; }
  .ar-tray-row { padding: 2px 10px 6px; gap: 6px; }
  .ar-pick { width: 54px; min-height: 62px; padding-top: 4px; }
  .ar-pick .ic { width: 40px; height: 40px; border-width: 2px; border-radius: 10px; font-size: 15px; }
  .ar-pick .ic img { max-width: 34px; max-height: 34px; }
  .ar-pick .nm { font-size: 8px; margin-top: 1px; max-width: 54px; }

  .ar-toast { bottom: 94px; font-size: 11px; padding: 6px 12px; }
}
