/* ── Solid CSS 3D furniture ──
   Centred cube: box origin at geometric centre, all 6 faces cover the volume.
   Floor is z=0; box sits with bottom at --bz (never under the pane). */

.placed-item {
  position: absolute;
  cursor: grab;
  box-sizing: border-box;
  z-index: 10;
  touch-action: none;
  pointer-events: auto;
  transform-style: preserve-3d;
  transform: translateZ(1px);
}

.placed-item .pi-shadow {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 12%;
  bottom: 6%;
  border-radius: 45%;
  background: rgba(0, 0, 0, 0.22);
  transform: translateZ(0.3px);
  pointer-events: none;
}

.placed-item .pi-model {
  position: absolute;
  /* size + rotateZ set in JS — whole furniture turns; door stays on same model edge */
  inset: auto;
  margin: 0;
  transform-style: preserve-3d;
  transform-origin: center center;
  pointer-events: auto;
}

/*
  Box footprint from fractions of --pi-w / --pi-d (px on ancestor).
  Centre of box at z = bz + bh/2  →  entire volume is above the floor.
*/
.f3-box {
  position: absolute;
  left: calc(var(--fx) * var(--pi-w));
  top: calc(var(--fy) * var(--pi-d));
  width: calc(var(--fw) * var(--pi-w));
  height: calc(var(--fd) * var(--pi-d));
  transform-style: preserve-3d;
  transform: translateZ(calc(var(--bz) + var(--bh) / 2));
  pointer-events: auto;
}

.f3-face {
  position: absolute;
  box-sizing: border-box;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  cursor: grab;
}

/* Top (+Z) */
.f3-top {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--c-top, #aaa);
  transform: translateZ(calc(var(--bh) / 2));
}

/* Bottom (−Z) — still above floor when bz >= 0 */
.f3-bottom {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--c-side, #666);
  transform: rotateX(180deg) translateZ(calc(var(--bh) / 2));
}

/* Front (+Y in floor space = bottom edge of footprint) */
.f3-front {
  left: 0;
  width: 100%;
  height: var(--bh);
  top: 50%;
  margin-top: calc(var(--bh) / -2);
  background: var(--c-front, #888);
  transform: rotateX(-90deg) translateZ(calc(var(--fd) * var(--pi-d) / 2));
}

/* Back (−Y = top edge of footprint) */
.f3-back {
  left: 0;
  width: 100%;
  height: var(--bh);
  top: 50%;
  margin-top: calc(var(--bh) / -2);
  background: var(--c-side, #666);
  transform: rotateX(90deg) translateZ(calc(var(--fd) * var(--pi-d) / 2));
}

/* Right (+X) */
.f3-right {
  top: 0;
  height: 100%;
  width: var(--bh);
  left: 50%;
  margin-left: calc(var(--bh) / -2);
  background: var(--c-side, #666);
  transform: rotateY(90deg) translateZ(calc(var(--fw) * var(--pi-w) / 2));
}

/* Left (−X) */
.f3-left {
  top: 0;
  height: 100%;
  width: var(--bh);
  left: 50%;
  margin-left: calc(var(--bh) / -2);
  background: var(--c-side, #666);
  transform: rotateY(-90deg) translateZ(calc(var(--fw) * var(--pi-w) / 2));
}

/* Circular disc (fan base) */
.f3-disc .f3-top {
  border-radius: 50%;
}
.f3-disc .f3-bottom {
  border-radius: 50%;
}
.f3-disc .f3-front,
.f3-disc .f3-back,
.f3-disc .f3-left,
.f3-disc .f3-right {
  /* approximate cylinder rim with rounded strip on front only */
  border-radius: 0;
}
.f3-disc .f3-front {
  border-radius: 50% / calc(var(--bh) * 0.5);
}

/* Washer front-load drum — black circle on corridor (front) face */
.f3-washer-drum {
  position: absolute;
  left: 22%;
  width: 56%;
  /* square circle using width of footprint */
  height: calc(var(--pi-w) * 0.5);
  top: auto;
  bottom: 2%;
  margin-left: 0;
  border-radius: 50%;
  box-sizing: border-box;
  background: var(--drum-c, #1a1a1e);
  border: 3px solid var(--rim, #6a7888);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
  transform-origin: center bottom;
  /* stand on front face, vertical to floor */
  transform: translateZ(var(--drum-z, 30px)) rotateX(-90deg) translateZ(calc(var(--pi-d) * 0.06));
  pointer-events: auto;
}
.f3-washer-drum::after {
  content: '';
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: #0d0d10;
}

/*
  Fan head: true circle (diameter from footprint WIDTH so it stays round even on 3×1 items),
  stood vertical with rotateX(-90deg) — perpendicular to the ground, facing front.
*/
.f3-fan-head {
  position: absolute;
  /* diameter = 72% of footprint width → always circular */
  width: calc(var(--pi-w) * 0.72);
  height: calc(var(--pi-w) * 0.72);
  left: calc(50% - var(--pi-w) * 0.36);
  top: calc(50% - var(--pi-w) * 0.36);
  transform-style: preserve-3d;
  transform-origin: center center;
  transform: translateZ(var(--bz, 40px)) rotateX(-90deg);
  pointer-events: auto;
  cursor: grab;
}
.f3-fan-cage,
.f3-fan-blade,
.f3-fan-hub {
  pointer-events: auto;
}
/* Outer circle ring */
.f3-fan-cage {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-sizing: border-box;
  background: rgba(220, 228, 236, 0.28);
  border: 3px solid var(--rim, #3d4a5a);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.f3-fan-cage::before {
  content: '';
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 1.5px solid rgba(61, 74, 90, 0.35);
}
/* 3 leaves — origin at hub, spaced 120° */
.f3-fan-blade {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16%;
  height: 40%;
  margin-left: -8%;
  margin-top: -40%;
  background: var(--blade, #9aabbc);
  border-radius: 45% 45% 30% 30%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  transform-origin: 50% 100%;
  transform: translateZ(2px) rotate(var(--br, 0deg));
}
.f3-fan-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20%;
  height: 20%;
  margin-left: -10%;
  margin-top: -10%;
  border-radius: 50%;
  background: var(--hub, #f0f4f8);
  border: 2px solid var(--rim, #3d4a5a);
  transform: translateZ(4px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4) inset;
}

.pi-label-tag {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateZ(var(--label-z, 48px));
  font-size: 0.5rem;
  font-weight: 800;
  color: #1a1520;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 3;
}

.placed-item.compulsory .pi-label-tag {
  border-color: #f5a623;
  color: #7a4e00;
}

.placed-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
  z-index: 80 !important;
}

.placed-item.dragging .pi-shadow {
  opacity: 0.2;
}

.placed-item .remove-btn,
.placed-item .rotate-btn {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  border: 1px solid #fff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  display: none;
  z-index: 50;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.placed-item .remove-btn {
  bottom: -10px;
  left: -10px;
  background: #e94560;
}

.placed-item .rotate-btn {
  bottom: -10px;
  right: -10px;
  background: #10b981;
}

/* Show controls when hovering the grid cell OR any 3D face/mesh of this item */
.placed-item:hover .remove-btn,
.placed-item:hover .rotate-btn,
.placed-item:focus-within .remove-btn,
.placed-item:focus-within .rotate-btn,
.placed-item .remove-btn:hover,
.placed-item .rotate-btn:hover {
  display: flex;
}
