/* Workshop Jewelry Box — Rue-access Building notes */

/* Brand + jewelry — jewelry hangs on the topbar gold line on purpose (charm on the rail) */
.wj-brand-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 9;
  min-width: 0;
  overflow: visible;
}

/* Top bar charm: sits on the border line, label is title-only (no text under the rule) */
.wj-prop {
  position: relative;
  left: auto;
  bottom: auto;
  z-index: 9;
  width: 56px;
  height: 48px;
  margin: 0 2px -10px 6px;
  flex-shrink: 0;
  align-self: flex-end;
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}
.wj-prop[hidden] { display: none !important; }
.wj-prop:focus-visible {
  outline: 2px solid #C8962A;
  outline-offset: 4px;
}

.wj-stool {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  width: 48px;
  height: 12px;
  background: linear-gradient(180deg, #5a3d22 0%, #3a2514 100%);
  border-radius: 6px 6px 3px 3px;
  border: 1px solid rgba(200, 150, 42, 0.35);
}
.wj-stool::before,
.wj-stool::after {
  content: '';
  position: absolute;
  top: 11px;
  width: 4px;
  height: 8px;
  background: #2a1a0e;
  border-radius: 2px;
}
.wj-stool::before { left: 8px; }
.wj-stool::after { right: 8px; }

.wj-box {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: 40px;
  height: 30px;
  perspective: 90px;
  background: linear-gradient(160deg, #2a1840 0%, #1a0f28 55%, #3d2458 100%);
  border: 1.5px solid #C8962A;
  border-radius: 5px 5px 3px 3px;
  box-shadow: inset 0 0 10px rgba(233, 194, 90, 0.15);
  overflow: visible;
}
.wj-box-lid {
  position: absolute;
  top: -5px;
  left: 3px;
  right: 3px;
  height: 8px;
  background: linear-gradient(180deg, #4a2d6e, #2a1840);
  border: 1px solid rgba(200, 150, 42, 0.55);
  border-radius: 3px 3px 0 0;
}

/* Fairy: yaw spin in 3D (not flat 2D cartwheel) */
.wj-fairy {
  position: absolute;
  left: 50%;
  top: 3px;
  width: 16px;
  height: 24px;
  margin-left: -8px;
  transform-origin: 50% 70%;
  transform-style: preserve-3d;
  animation: wj-spin3d 4.8s linear infinite;
}
.wj-fairy-body {
  position: absolute;
  left: 4px;
  top: 7px;
  width: 8px;
  height: 12px;
  background: linear-gradient(180deg, #f3d6e8, #c89bc0);
  border-radius: 4px 4px 2px 2px;
  backface-visibility: visible;
}
.wj-fairy-head {
  position: absolute;
  left: 3px;
  top: 1px;
  width: 10px;
  height: 10px;
  background: #f6e6d8;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(255, 220, 240, 0.7);
}
.wj-fairy-skirt {
  position: absolute;
  left: 0;
  top: 14px;
  width: 16px;
  height: 9px;
  background: radial-gradient(ellipse at top, #e8b4d4, #9a5a8a);
  border-radius: 0 0 50% 50%;
}
.wj-fairy-wing {
  position: absolute;
  top: 8px;
  width: 9px;
  height: 7px;
  background: rgba(233, 220, 255, 0.55);
  border-radius: 50% 50% 40% 40%;
  transform-origin: center center;
}
.wj-fairy-wing.left {
  left: -4px;
  transform: rotate(-18deg);
  animation: wj-wing-l 0.55s ease-in-out infinite alternate;
}
.wj-fairy-wing.right {
  right: -4px;
  transform: rotate(18deg);
  animation: wj-wing-r 0.55s ease-in-out infinite alternate;
}

@keyframes wj-spin3d {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}
@keyframes wj-wing-l {
  from { transform: rotate(-18deg) scaleX(1); }
  to { transform: rotate(-28deg) scaleX(0.85); }
}
@keyframes wj-wing-r {
  from { transform: rotate(18deg) scaleX(1); }
  to { transform: rotate(28deg) scaleX(0.85); }
}

@media (prefers-reduced-motion: reduce) {
  .wj-fairy {
    animation: none;
    transform: none;
  }
  .wj-fairy-wing.left,
  .wj-fairy-wing.right {
    animation: none;
  }
}

.wj-prop-label {
  /* Label lives in title/aria only — hanging text under the gold rule looked broken */
  display: none !important;
}

/* Grown jewelry box (prop transformed large) */
.wj-flyout {
  position: absolute;
  left: 50%;
  top: 8%;
  z-index: 96;
  width: min(420px, 94%);
  max-height: min(78vh, 620px);
  display: flex;
  flex-direction: column;
  color: #e8d9ba;
  font-size: 0.78rem;
  transform: translate(-50%, 12px) scale(0.42);
  transform-origin: 20% 0%;
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease;
  background:
    linear-gradient(165deg, #3a2460 0%, #1a0f28 42%, #2a1840 78%, #120a1c 100%);
  border: 2px solid #C8962A;
  border-radius: 14px 14px 10px 10px;
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.55),
    inset 0 0 40px rgba(233, 194, 90, 0.08),
    inset 0 1px 0 rgba(255, 230, 180, 0.12);
  overflow: hidden;
}
.wj-flyout[hidden] { display: none !important; }
.wj-flyout.is-open {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.wj-box-shell {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.wj-box-shell-lid {
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 18px;
  background: linear-gradient(180deg, #5a3a82, #2a1840);
  border: 1px solid rgba(200, 150, 42, 0.55);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transform-origin: top center;
  transition: transform 0.35s ease;
}
.wj-flyout.is-open .wj-box-shell-lid {
  transform: perspective(240px) rotateX(-28deg) translateY(-2px);
}
.wj-box-shell-hinge {
  position: absolute;
  top: 16px;
  left: 12%;
  right: 12%;
  height: 1px;
  background: rgba(200, 150, 42, 0.35);
}
.wj-box-shell-fairy {
  position: absolute;
  right: 18px;
  top: 28px;
  width: 22px;
  height: 32px;
  transform-style: preserve-3d;
  animation: wj-spin3d 5.2s linear infinite;
  opacity: 0.85;
}

.wj-flyout-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 22px 14px 10px;
  border-bottom: 1px solid rgba(200, 150, 42, 0.28);
  font-family: Cinzel, Georgia, serif;
  font-size: 0.92rem;
  color: #e8bd4f;
  letter-spacing: 0.04em;
}
.wj-flyout-head-actions {
  display: inline-flex;
  gap: 6px;
}
.wj-flyout-head button,
.wj-icon-btn {
  border: 1px solid rgba(200, 150, 42, 0.4);
  background: rgba(20, 12, 28, 0.85);
  color: #e8d9ba;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.wj-flyout-body {
  position: relative;
  z-index: 1;
  overflow: auto;
  padding: 12px 14px 16px;
  flex: 1;
}

.wj-fade-in {
  animation: wj-fade-in 0.45s ease both;
}
@keyframes wj-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.wj-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.wj-action {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(200, 150, 42, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(8, 6, 14, 0.55);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.wj-action:hover {
  border-color: #C8962A;
  background: rgba(40, 28, 60, 0.65);
  transform: translateY(-1px);
}
.wj-action-admin {
  border-color: rgba(200, 150, 42, 0.55);
  background: linear-gradient(135deg, rgba(60, 40, 20, 0.45), rgba(20, 12, 28, 0.55));
}
.wj-action-kicker {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #C8962A;
  margin-bottom: 4px;
}
.wj-action strong {
  display: block;
  font-size: 0.95rem;
  color: #F6F4EC;
}
.wj-action-blurb {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: #9EA39F;
}

.wj-slip-tile {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(200, 150, 42, 0.45);
  background: linear-gradient(160deg, #3a2460, #1a0f28);
  color: #e8bd4f;
  font: 700 0.85rem/1 Cinzel, Georgia, serif;
  letter-spacing: 0.04em;
}
.wj-slip-tile.lg {
  width: 52px;
  height: 52px;
  font-size: 1.05rem;
}

.wj-org-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.wj-org-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(200, 150, 42, 0.28);
  border-radius: 10px;
  background: rgba(8, 6, 14, 0.55);
  cursor: grab;
}
.wj-org-row.is-dragging { opacity: 0.55; }
.wj-org-handle {
  color: #8a8070;
  font-size: 1rem;
  cursor: grab;
  user-select: none;
}
.wj-org-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.wj-org-meta strong {
  color: #F6F4EC;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wj-org-meta small {
  color: #9EA39F;
  font-size: 0.65rem;
}
.wj-org-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}
.wj-org-btns .wj-btn {
  padding: 4px 8px;
  font-size: 0.65rem;
}

.wj-detail-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 12px 0 10px;
}
.wj-slip-body {
  white-space: pre-wrap;
  line-height: 1.45;
  color: #c8c2b4;
  font-size: 0.78rem;
  margin: 8px 0 12px;
}

@media (prefers-reduced-motion: reduce) {
  .wj-flyout {
    transition: none;
  }
  .wj-fade-in { animation: none; }
  .wj-box-shell-fairy { animation: none; }
}

.wj-lead {
  margin: 0 0 10px;
  color: #9EA39F;
  font-size: 0.72rem;
  line-height: 1.4;
}

.wj-form label {
  display: block;
  font-size: 0.65rem;
  color: #C8962A;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 8px 0 4px;
}
.wj-form input,
.wj-form textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid rgba(200, 150, 42, 0.3);
  background: rgba(3, 6, 5, 0.75);
  color: #F6F4EC;
  padding: 8px 10px;
  font: inherit;
}
.wj-form textarea {
  min-height: 72px;
  resize: vertical;
}
.wj-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.wj-btn {
  border: 1px solid rgba(200, 150, 42, 0.45);
  background: rgba(28, 24, 14, 0.9);
  color: #C8962A;
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
}
.wj-btn.primary {
  background: linear-gradient(180deg, #3a2e14, #1a1408);
  color: #fff;
  border-color: #C8962A;
}
.wj-btn.danger {
  color: #e07070;
  border-color: rgba(224, 112, 112, 0.45);
}

.wj-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wj-slip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  border: 1px solid rgba(200, 150, 42, 0.28);
  background: rgba(12, 10, 18, 0.85);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  color: inherit;
}
.wj-slip:hover {
  border-color: rgba(200, 150, 42, 0.55);
  background: rgba(28, 20, 40, 0.95);
}
.wj-slip-copy { min-width: 0; flex: 1; }
.wj-slip-title {
  margin: 0 0 4px;
  font-weight: 700;
  color: #F6F4EC;
  font-size: 0.82rem;
}
.wj-slip-meta {
  margin: 0;
  font-size: 0.65rem;
  color: #9EA39F;
}
.wj-slip-preview {
  margin: 6px 0 0;
  font-size: 0.72rem;
  color: #c8c2b4;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wj-empty {
  margin: 12px 0 0;
  color: #9EA39F;
  font-size: 0.72rem;
  font-style: italic;
}

.wj-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.wj-msg {
  margin-top: 8px;
  font-size: 0.72rem;
}
.wj-msg.err { color: #e07070; }
.wj-msg.ok { color: #5dcea0; }

body.wj-on .wj-prop { display: block; }

/* ── Jewelry box files — STATE:JEWELRY-ROOM-BOX-20260805 (stage 3) ──────────
 *
 * An image slip shows the picture where a document slip shows its initials, so
 * a room box reads as a small gallery. Same footprint either way — the tiles
 * stay on the same grid whichever kind of slip they hold.
 */
.wj-slip-tile--img {
  object-fit: cover;
  background: #1a0f28;
}

.wj-upload {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.7rem;
  border: 1px dashed rgba(200, 150, 42, 0.35);
  border-radius: 10px;
  background: rgba(26, 15, 40, 0.4);
}

/* The real input is hidden and driven by its label: file inputs cannot be
 * styled to match the house, but a label is a legitimate control for one. */
.wj-upload__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.wj-upload__btn {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border: 1px solid rgba(200, 150, 42, 0.5);
  border-radius: 8px;
  background: linear-gradient(160deg, #3a2460, #1a0f28);
  color: #e8bd4f;
  font: 600 0.8rem/1.2 Cinzel, Georgia, serif;
  cursor: pointer;
}

.wj-upload__btn:hover { border-color: rgba(200, 150, 42, 0.85); }
.wj-upload__input:focus-visible + .wj-upload__hint,
.wj-upload__input:focus-visible ~ .wj-upload__btn { outline: 2px solid #e8bd4f; }

.wj-upload__hint {
  margin: 0.4rem 0 0;
  color: rgba(232, 189, 79, 0.65);
  font-size: 0.7rem;
  line-height: 1.35;
}

/* ── Place mode — STATE:JEWELRY-ROOM-BOX-20260805 ───────────────────────────
 * The box lists a slip and a Place button side by side. Placement is a click,
 * not a drag, mirroring the wall signs (beginDropMode / onDropPlace). */
.wj-slip-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.wj-slip-row > .wj-slip { flex: 1 1 auto; min-width: 0; }

.wj-slip-place {
  flex: 0 0 auto;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(200, 150, 42, 0.5);
  background: linear-gradient(160deg, #3a2460, #1a0f28);
  color: #e8bd4f;
  font: 600 0.72rem/1 Cinzel, Georgia, serif;
  cursor: pointer;
  white-space: nowrap;
}

.wj-slip-place:hover { border-color: rgba(200, 150, 42, 0.9); }

/* The ghost trails the cursor while placement is armed, so it is obvious the
 * next click does something. Never eats the click — pointer-events must stay
 * off or the ghost itself would be the click target. */
.wj-place-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid rgba(200, 150, 42, 0.7);
  background: rgba(26, 15, 40, 0.95);
  color: #e8bd4f;
  font: 600 0.72rem/1.2 Inter, system-ui, sans-serif;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

body.wj-placing #scene { cursor: crosshair; }
