/* home.css —— ★ v3.0.0：家园系统样式（场景 / 家具伪3D / 家具栏 / 仓库 / 重量感动画） */

/* ===== 房间容器：虚拟坐标系 1280×720，aspect-ratio 锁比例居中 contain ===== */
#screen-home { background: #2e2440; }
.home-room-wrap {
  position: absolute; left: 0; right: 0; top: 0; bottom: 118px;
  display: flex; align-items: center; justify-content: center;
}
.home-room {
  position: relative;
  aspect-ratio: 1280 / 720;
  width: min(100%, calc((100vh - 118px) * 1280 / 720));
  max-width: 100%; max-height: 100%;
  background: #f7d9e6 center / cover no-repeat;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  overflow: hidden;
}

/* ===== 家具（伪 3D） ===== */
.hm-furn-layer, .hm-worker-layer { position: absolute; inset: 0; }
.hm-furn {
  position: absolute;
  cursor: grab;
  touch-action: none;
}
.hm-furn:active { cursor: grabbing; }
.hm-furn-img {
  position: absolute; inset: 0;
  background: center bottom / contain no-repeat;
  will-change: transform;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .12));
}
/* 接地椭圆阴影（程序生成——素材不画阴影） */
.hm-shadow {
  position: absolute; left: 50%; bottom: -4%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(60, 30, 60, .38) 0%, rgba(60, 30, 60, 0) 70%);
  transition: transform .15s, opacity .15s;
}
/* 拖起：原元素半透明、阴影缩小变淡（幽灵上浮产生高度感） */
.hm-furn.hm-lifted { opacity: .22; }
.hm-furn.hm-lifted .hm-shadow { transform: translateX(-50%) scale(.68); opacity: .45; }
/* 落地挤压回弹（重量感关键帧） */
.hm-furn.hm-landing .hm-furn-img { animation: hmSquash .26s ease-out; }
@keyframes hmSquash {
  0% { transform-origin: 50% 100%; transform: scaleY(1); }
  38% { transform-origin: 50% 100%; transform: scaleY(.9) scaleX(1.07); }
  100% { transform-origin: 50% 100%; transform: scaleY(1); }
}
/* 无处可放弹回红闪 */
.hm-furn.hm-flash .hm-furn-img { animation: hmFlash .45s ease-out; }
@keyframes hmFlash {
  0%, 100% { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .12)); }
  30%, 70% { filter: drop-shadow(0 0 8px #ff5252) saturate(1.6); }
}
/* 重物落地震屏（房间容器微位移） */
.home-room.hm-shake { animation: hmShake .24s ease-out; }
@keyframes hmShake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2.5px, 1.5px); }
  50% { transform: translate(2.5px, -1px); }
  75% { transform: translate(-1.5px, -1.5px); }
}
/* 尘土粒子 */
.hm-dust {
  position: absolute; z-index: 300;
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle, rgba(214, 188, 160, .85) 0%, rgba(214, 188, 160, 0) 70%);
  pointer-events: none;
  animation: hmDust .6s ease-out forwards;
}
@keyframes hmDust {
  0% { transform: translate(0, 0) scale(.6); opacity: .95; }
  100% { transform: translate(var(--dx, 0), var(--dy, -10px)) scale(1.5); opacity: 0; }
}
/* 拖拽幽灵（fixed，跟随+倾斜由 JS 控制 transform） */
.hm-drag-ghost {
  position: fixed; z-index: 99999;
  background: center bottom / contain no-repeat;
  pointer-events: none;
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, .3));
}

/* ===== 打扫史莱姆（复用 .p-slime 基类——基类作用域在 .paradise-area，家园内补齐） ===== */
.hm-worker-layer .p-slime.hm-worker {
  position: absolute;
  width: 70px; height: 70px;
  background-repeat: no-repeat; background-position: center; background-size: contain;
  cursor: pointer;
  transition: left 2.4s ease-in-out, top 2.4s ease-in-out; /* 游走平滑 */
  /* z-index 由 JS 按虚拟 y 动态设置（100+vy，与家具同一画家算法） */
}
/* ★ v3.1.0：史莱姆公主（家园常驻，下 1/3 活动区含黑色区域缓步游走） */
.hm-worker-layer .hm-princess {
  position: absolute;
  width: 90px; height: 90px;
  background-repeat: no-repeat; background-position: center bottom; background-size: contain;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .35));
  cursor: pointer;
  transition: left 2.4s ease-in-out, top 2.4s ease-in-out; /* 游走平滑 */
}
.hm-worker-layer .p-word {
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, 4px);
  font-family: var(--font-en); font-size: 14px; font-weight: bold; color: #5a3d5a;
  white-space: nowrap; pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
.hm-worker-layer .work-badge {
  position: absolute; left: 50%; top: -20px; transform: translateX(-50%);
  font-family: var(--font-cn); font-size: 11px; color: #fff;
  background: rgba(139, 108, 178, .85); border-radius: 10px; padding: 2px 8px;
  white-space: nowrap; pointer-events: none;
}
.work-coin {
  position: absolute; right: -6px; top: -10px; width: 30px; height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe98a, #ffb300 70%);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  cursor: pointer; z-index: 20;
  animation: coinBob 1.6s ease-in-out infinite;
}
@keyframes coinBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ===== 底部家具栏 ===== */
.home-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 118px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(46, 36, 64, .55), rgba(46, 36, 64, .92));
  border-top: 2px solid rgba(255, 214, 240, .35);
  z-index: 150;
}
.hm-bar-title {
  font-family: var(--font-cn); font-size: 16px; font-weight: bold; color: #ffd6f0;
  writing-mode: vertical-lr; letter-spacing: 6px;
  border-right: 1px solid rgba(255, 214, 240, .3); padding-right: 10px;
  flex: none;
}
.hm-bar-items {
  flex: 1 1 auto; min-width: 0; height: 92px;
  display: flex; align-items: center; gap: 10px;
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior: contain;
}
.hm-bar-items::-webkit-scrollbar { height: 6px; }
.hm-bar-items::-webkit-scrollbar-thumb { background: rgba(255, 214, 240, .35); border-radius: 3px; }
.hm-bar-empty {
  font-family: var(--font-cn); font-size: 14px; color: rgba(255, 255, 255, .55);
  width: 100%; text-align: center;
}
.hm-bar-tile {
  position: relative; flex: none;
  width: 78px; height: 92px;
  background: rgba(255, 255, 255, .12);
  border: 1.5px dashed rgba(255, 214, 240, .5);
  border-radius: 10px;
  cursor: grab; touch-action: none;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: 4px;
  user-select: none;
}
.hm-bar-tile:active { cursor: grabbing; }
.hm-bar-img {
  position: absolute; inset: 6px 6px 20px;
  background: center / contain no-repeat;
  pointer-events: none;
}
.hm-bar-name {
  font-family: var(--font-cn); font-size: 11px; color: #fff;
  max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: none;
}
.hm-bar-count {
  position: absolute; top: -7px; right: -5px;
  min-width: 20px; height: 20px; line-height: 20px; text-align: center;
  font-family: var(--font-cn); font-size: 12px; font-weight: bold; color: #fff;
  background: #e87b00; border-radius: 10px; padding: 0 5px;
  pointer-events: none;
}
.hm-warehouse-btn { flex: none; font-size: 14px; padding: 10px 16px; }

/* ===== 仓库面板 ===== */
.hm-wh-box { max-width: 480px; text-align: center; }
.hm-wh-tip { font-family: var(--font-cn); font-size: 13px; color: #999; margin: 6px 0 12px; }
.hm-wh-list { max-height: 320px; overflow-y: auto; text-align: left; }
.hm-wh-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border-bottom: 1px solid #f0f0f0;
  cursor: grab; touch-action: none; user-select: none;
}
.hm-wh-img {
  width: 56px; height: 44px; flex: none;
  background: center / contain no-repeat;
}
.hm-wh-info { flex: 1 1 auto; font-family: var(--font-cn); font-size: 14px; color: #333; }
.hm-wh-type {
  margin-left: 8px; font-size: 12px; color: #9b6bff;
  background: rgba(155, 107, 255, .1); border-radius: 8px; padding: 1px 8px;
}
.hm-wh-carry { font-size: 13px; padding: 7px 16px; flex: none; }

/* ===== 家具点击菜单 ===== */
.hm-menu {
  position: absolute; z-index: 9600;
  background: #fff; border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
  padding: 8px; min-width: 140px;
  font-family: var(--font-cn);
}
.hm-menu-title {
  font-size: 13px; font-weight: bold; color: #666;
  text-align: center; padding: 2px 0 6px;
  border-bottom: 1px solid #f0f0f0; margin-bottom: 6px;
}
.hm-menu-btn {
  display: block; width: 100%;
  border: none; background: none; cursor: pointer;
  font-family: var(--font-cn); font-size: 14px; color: #333;
  padding: 8px 10px; border-radius: 8px; text-align: left;
}
.hm-menu-btn:hover { background: #fff3fa; color: #e87b00; }
.hm-menu-cancel { color: #999; }

/* ===== 轻提示 ===== */
#home-toast {
  position: fixed; left: 50%; bottom: 138px; transform: translateX(-50%) translateY(10px);
  z-index: 9800;
  font-family: var(--font-cn); font-size: 14px; color: #fff;
  background: rgba(51, 34, 68, .92);
  border-radius: 20px; padding: 9px 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  max-width: 80vw;
}
#home-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
