/* paperdoll.css — Ultrastation W3: read-only equipment paper-doll panel.
 *
 * Self-contained panel that appears when ultra_panel.equipment is present
 * in the viewer-state payload and the GHELMYON_FEATURE_ULTRASTATION flag is
 * on. Hidden (display:none) when the flag is off — byte-identical play.
 *
 * Layout: a centred humanoid figure surrounded by equipment-slot cells.
 * Under-layer slots (head_under / chest_under / legs_under / feet_under) and
 * wearable-bag slots (back / belt_pouch / satchel) are grouped in a compact
 * "layers" and "carried" sub-cluster below the main figure.
 *
 * No drag-drop. No equip/unequip. Read-only v1.
 */

/* =========================================================================
 * Container + panel chrome
 * ========================================================================= */

#paperdoll-panel {
  display: none;               /* shown only when ultra_panel arrives */
  flex-direction: column;
  align-items: center;
  padding: 8px 6px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  user-select: none;
  font-family: inherit;
  font-size: 11px;
  color: #c8c8c8;
  /* equip-fit: fill the (resizable) sidebar panel + become a query container so
     the paperdoll scales to the PANEL width, not the browser window. Replaces
     the old fixed min-width:220 which overflowed a narrower sidebar. */
  width: 100%;
  min-width: 0;
  max-width: 100%;
  container-type: inline-size;
  overflow: hidden;
  gap: 6px;
}

#paperdoll-panel.pd-visible {
  display: flex;
}

#paperdoll-title {
  font-size: 12px;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

/* #9: aggregate gear-score line under the Equipment title. */
#paperdoll-gear-score {
  font-size: 11px;
  color: #b9b9c6;
  margin-bottom: 4px;
}
#pd-gear-score-value {
  font-weight: bold;
  color: var(--accent);
}

/* =========================================================================
 * Main body grid — figure in the centre column, slots flanking it.
 *
 * Three-column layout: left | figure | right
 *   left  — off-hand / arms / ring_1 / ring_2
 *   centre— head, shoulders, chest, legs, feet (stacked) + figure silhouette
 *   right — weapon / hands / necklace / trinket_1 / trinket_2
 * ========================================================================= */

#paperdoll-body {
  display: grid;
  /* left: 52px | figure: 72px | right: 52px */
  grid-template-columns: 52px 72px 52px;
  grid-template-rows: auto;
  gap: 4px;
  align-items: start;
}

#pd-col-left,
#pd-col-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#pd-col-centre {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* =========================================================================
 * Humanoid silhouette (pure CSS; no image required)
 * ========================================================================= */

#pd-figure {
  width: 44px;
  height: 88px;
  position: relative;
  margin: 4px auto;
  pointer-events: none;
}

/* head circle */
#pd-figure::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(180, 180, 200, 0.22);
  background: rgba(100, 100, 130, 0.12);
}

/* body + legs shaft */
#pd-figure::after {
  content: "";
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 60px;
  border: 1px solid rgba(180, 180, 200, 0.22);
  background: rgba(100, 100, 130, 0.08);
  border-radius: 3px 3px 0 0;
  clip-path: polygon(
    20% 0%, 80% 0%,           /* shoulders */
    100% 6%,                  /* arm attach */
    100% 46%,                 /* arm base */
    80% 46%,                  /* hip R */
    80% 100%,                 /* leg R */
    65% 100%,                 /* inner leg R */
    65% 55%,                  /* crotch R */
    35% 55%,                  /* crotch L */
    35% 100%,                 /* inner leg L */
    20% 100%,                 /* outer leg L */
    20% 46%,                  /* hip L */
    0% 46%,                   /* arm base L */
    0% 6%                     /* arm attach L */
  );
}

/* =========================================================================
 * Slot cells
 * ========================================================================= */

.pd-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 48px;
  min-height: 48px;
  background: rgba(13, 21, 37, 0.70);
  border: 1px solid rgba(51, 51, 68, 0.80);
  border-radius: 3px;
  cursor: default;
  position: relative;
  transition: border-color 0.15s;
  overflow: hidden;
}

.pd-slot:hover {
  border-color: rgba(233, 69, 96, 0.60);
  z-index: 1;
}

/* A slot that has an item equipped */
.pd-slot.pd-filled {
  border-color: rgba(100, 130, 180, 0.55);
  background: rgba(20, 30, 55, 0.80);
}

.pd-slot.pd-filled:hover {
  border-color: var(--accent);
}

/* Slot label (small, below icon) */
.pd-slot-label {
  font-size: 9px;
  color: rgba(160, 160, 180, 0.65);
  text-align: center;
  padding: 0 2px 2px;
  line-height: 1.2;
  word-break: break-word;
  max-width: 46px;
}

.pd-slot.pd-filled .pd-slot-label {
  color: rgba(200, 210, 230, 0.80);
}

/* =========================================================================
 * Slot icon / glyph
 * ========================================================================= */

.pd-slot-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

/* Item icon image */
.pd-slot-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 2px;
}

/* Fallback glyph when no icon image available */
.pd-slot-glyph {
  font-size: 18px;
  line-height: 1;
  opacity: 0.28;
}

.pd-slot.pd-filled .pd-slot-glyph {
  opacity: 0.70;
}

/* =========================================================================
 * Sub-cluster: under-layers + bags
 * ========================================================================= */

#pd-sub-clusters {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.pd-cluster-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pd-cluster-label {
  font-size: 9px;
  color: rgba(140, 140, 160, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding-left: 2px;
}

.pd-cluster-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Sub-cluster slots are slightly smaller to save space */
.pd-cluster-slots .pd-slot {
  width: 44px;
  min-height: 44px;
}

.pd-cluster-slots .pd-slot-icon {
  width: 28px;
  height: 28px;
}

.pd-cluster-slots .pd-slot-icon img {
  width: 24px;
  height: 24px;
}

.pd-cluster-slots .pd-slot-glyph {
  font-size: 16px;
}

/* Quiver / instrument row (ranged + musical) */
#pd-cluster-misc .pd-slot {
  width: 44px;
  min-height: 44px;
}

/* =========================================================================
 * Tooltip trigger cursor (hover/click handled by item_tooltip.js)
 * ========================================================================= */

.pd-slot[data-item-id] {
  cursor: help;
}

/* =========================================================================
 * Reduced motion / accessibility
 * ========================================================================= */

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

/* =========================================================================
 * equip-fit: container queries scale the paperdoll to the PANEL width.
 * The sidebar is independently resizable, so we query the panel (container-
 * type: inline-size above), NOT the viewport. At full width it looks as before;
 * it steps down gracefully as the panel narrows so it always fits its tab.
 * ========================================================================= */
@container (max-width: 212px) {
  #paperdoll-body { grid-template-columns: 46px 62px 46px; }
  .pd-slot { width: 44px; }
  .pd-slot-icon { width: 28px; height: 28px; }
  .pd-slot-icon img { width: 24px; height: 24px; }
}
@container (max-width: 184px) {
  #paperdoll-body { grid-template-columns: 40px 54px 40px; gap: 3px; }
  .pd-slot { width: 38px; min-height: 44px; }
  .pd-slot-label { font-size: 8px; }
  .pd-slot-icon { width: 24px; height: 24px; margin-top: 3px; }
  .pd-slot-icon img { width: 20px; height: 20px; }
  #pd-figure { width: 38px; height: 76px; }
  .pd-cluster-slots .pd-slot,
  #pd-cluster-misc .pd-slot { width: 38px; }
}
@container (max-width: 156px) {
  #paperdoll-body { grid-template-columns: 34px 46px 34px; gap: 2px; }
  .pd-slot { width: 32px; min-height: 40px; }
  .pd-slot-label { font-size: 7px; line-height: 1.1; }
  .pd-slot-icon { width: 20px; height: 20px; }
  .pd-slot-icon img { width: 18px; height: 18px; }
  .pd-slot-glyph { font-size: 14px; }
  #pd-figure { width: 32px; height: 64px; }
  .pd-cluster-slots .pd-slot,
  #pd-cluster-misc .pd-slot { width: 32px; }
}
