/* Profile charms (include/profile_charms.php, javascript/profile-charms.js)
   A slot is the point a charm is pinned at. The charm's art is a 256×384 canvas drawn at half size,
   offset so the pin's loop (where the chain hangs) sits on that point. */

#bodydiv { position: relative; }

.charm-slot {
  position: absolute;
  z-index: 6;
  width: 0;
  height: 0;
}
.charm-slot[data-slot="top-left"] { left: 40px; top: 50px; }

.charm {
  position: absolute;
  left: -37px;
  top: -71px;
  width: 128px;
  height: 192px;
  pointer-events: none; /* only the drop (.charm-hit) catches the mouse */
}
.charm-chain,
.charm-drop,
.charm-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.charm-chain,
.charm-drop { will-change: transform; }
.charm-layer { user-select: none; }
.charm-hit {
  position: absolute;
  border-radius: 50%;
  pointer-events: auto;
}

/* ---- Picking a charm (only while the profile editor is open) ---- */
.charm-slot-btn {
  display: none;
  position: absolute;
  left: -20px;
  top: -20px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 2px dashed oklch(1 0 0);
  background: oklch(0.46 0.19 270 / 0.45);
  box-shadow: 0 0 0 2px oklch(0.46 0.19 270), 0 4px 12px oklch(0.18 0.01 270 / 0.3);
  z-index: 2;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.pe-open .charm-slot-btn { display: block; }
.charm-slot-btn:hover,
.charm-slot-btn[aria-expanded="true"] {
  background: oklch(0.46 0.19 270 / 0.75);
  transform: scale(1.08);
}
.charm-slot-btn:focus-visible { outline: 3px solid oklch(0.80 0.14 75); outline-offset: 3px; }
/* An empty slot's circle gets a plus so it reads as "add" */
.charm-slot:not(:has(.charm)) .charm-slot-btn::after {
  content: "+";
  color: oklch(1 0 0);
  font: 700 22px/36px Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

.charm-picker {
  position: absolute;
  left: -20px;
  top: 30px;
  z-index: 3;
  width: 240px;
  padding: 12px;
  background: oklch(1 0 0);
  color: oklch(0.18 0.01 270);
  border: 1px solid oklch(0.88 0.008 270);
  border-radius: 10px;
  box-shadow: 0 12px 32px oklch(0.18 0.01 270 / 0.22);
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
}
.charm-picker h3 {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: oklch(0.52 0.015 270);
}
.charm-picker-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.charm-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 6px 4px;
  background: oklch(0.96 0.006 270);
  color: inherit;
  border: 2px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}
.charm-option:hover { border-color: oklch(0.88 0.008 270); }
.charm-option[aria-pressed="true"] { border-color: oklch(0.46 0.19 270); background: oklch(0.46 0.19 270 / 0.08); }
.charm-option:focus-visible { outline: 3px solid oklch(0.80 0.14 75); outline-offset: 1px; }
.charm-option:disabled { opacity: 0.5; }
.charm-thumb {
  position: relative;
  width: 40px;
  height: 60px;
}
.charm-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.charm-thumb-none {
  display: grid;
  place-items: center;
  color: oklch(0.52 0.015 270);
  font-size: 1.5rem;
  font-weight: 400;
}
.charm-option small {
  font-weight: 400;
  color: oklch(0.52 0.015 270);
}
.charm-picker-empty {
  margin: 0;
  color: oklch(0.40 0.015 270);
}
.charm-picker-error {
  margin: 8px 0 0;
  color: oklch(0.4 0.2 25);
  font-size: 0.8125rem;
}
.charm-picker-error:empty { display: none; }

@media (max-width: 768px) {
  .charm-slot[data-slot="top-left"] { left: 32px; top: 42px; }
  .charm { transform: scale(0.8); transform-origin: 37px 71px; }
}

@media (prefers-reduced-motion: reduce) {
  .charm-slot-btn { transition: none; }
}
