/**
 * Commander paper-doll compositor styles (combat stand + DEV dress-up).
 * Spec: docs/features/.../commander-paper-doll/
 */

.cpd-host {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cpd-root {
  position: absolute;
  inset: 0;
  transform-origin: center bottom;
}

.cpd-root--mirror {
  transform: scaleX(-1);
}

.cpd-layer,
.cpd-arm-group,
.cpd-arm-pivot,
.cpd-arm-art,
.cpd-arm-sleeve,
.cpd-weapon {
  position: absolute;
  box-sizing: border-box;
  pointer-events: none;
}

.cpd-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.cpd-img--gear {
  object-fit: contain;
}

/* Full-root layers so % sizes resolve against the figure; shoulder = transform-origin. */
.cpd-arm-group,
.cpd-arm-pivot {
  inset: 0;
  width: auto;
  height: auto;
  z-index: 5;
}

.cpd-layer--rear_cape {
  z-index: 1;
}
.cpd-layer--base_body {
  z-index: 2;
}
.cpd-layer--boots {
  z-index: 3;
}
.cpd-layer--torso_armor {
  z-index: 4;
}
.cpd-layer--front_cape {
  z-index: 6;
}
.cpd-layer--hair {
  z-index: 7;
}
.cpd-layer--helmet {
  z-index: 8;
}

/* Weapon sits under arm art (DOM order); do not elevate with z-index. */
.cpd-arm-art,
.cpd-arm-sleeve {
  z-index: 2;
}
.cpd-weapon {
  z-index: 1;
}

/* Combat stand: paper-doll replaces static portrait image */
.combat-commander-portrait--paperdoll {
  overflow: visible;
  aspect-ratio: 3 / 4;
  /*
   * Full-body doll: ~0.72 of tile width so height stays near one row (not a giant).
   * Size the layout box itself (no bottom-origin scale) so the figure sits under the
   * HP bar and the stand’s row centering tracks the painted body.
   */
  width: calc(var(--combat-side-sprite-size, 100%) * 0.72);
  max-width: 100%;
  background: transparent;
}

.combat-commander-portrait--paperdoll .combat-commander-portrait__img {
  display: none !important;
}

/* Surround blend on the composed figure (same tokens as static commander img). */
.combat-commander-portrait--paperdoll .cpd-mount {
  position: absolute;
  inset: 0;
  z-index: 1;
  filter: var(
    --combat-commander-contact-shadow,
    drop-shadow(0 calc(var(--gs-u-h) * 0.08) calc(var(--gs-u-h) * 0.18) rgba(0, 0, 0, 0.4))
      drop-shadow(0 calc(var(--gs-u-h) * 0.28) calc(var(--gs-u-h) * 0.55) rgba(0, 0, 0, 0.38))
  );
}

@media (prefers-reduced-motion: reduce) {
  .cpd-arm-pivot {
    transition: none;
  }
}
