/**
 * Diablo IV mercenaries stylesheet.
 * Author: vlad1116
 * Website: https://arpg-life.ru
 * Version: 0.5.0
 *
 * Shared by the admin builder (interactive) and the public planner
 * (read-only) — both render the same markup from assets/js/mercenaries.js.
 * Depends on class-mechanics.css being loaded first: mercenaries.js emits
 * .d4cm-panel/.d4cm-title/.d4cm-description/.d4cm-placeholder/.d4cm-empty/
 * .d4cm-option/.d4cm-tooltip directly, reusing that stylesheet's rules and
 * CSS variables wholesale (including the shared click-to-toggle tooltip
 * card) — this file only adds the planner-style roster row (hired /
 * reinforcement slots with pop-up lists, at the end of this file) and the
 * hired mercenary's tree canvas (SVG lines + absolutely-positioned nodes —
 * same technique as skill-tree.css's .d4st-* rules, trimmed to what a small
 * fixed-size non-zoomable diagram needs).
 */

/* Hired mercenary's tree canvas — a small fixed-size (see
   tools/build_mercenaries.py's LAYOUT_WIDTH/LAYOUT_HEIGHT) diagram, so
   unlike skill-tree.css's .d4st-canvas-viewport there is no zoom/pan
   scaffolding here; the whole tree is always visible at once.
   .d4mc-tree-fit is the fit-to-width wrapper: its max-width is the layout
   width and touch-sheet.js's fitTrees() scales the inner .d4mc-tree with
   transform: scale() (never above 1) and sets the wrapper's height to
   match, so on a phone the whole tree shrinks instead of being cut off.
   Without JS the wrapper just clips at its box. */

.d4mc-tree-fit {
  position: relative;
  width: 100%;
  margin: 0 auto 20px;
  overflow: hidden;
}

.d4mc-tree {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.d4mc-tree-lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.d4mc-tree-line {
  stroke-width: 2;
  transition: stroke .2s ease;
}

.d4mc-tree-line.is-inactive {
  stroke: rgba(130, 105, 68, .28);
  stroke-dasharray: 4 4;
}

.d4mc-tree-line.is-active {
  stroke: var(--d4cm-gold);
  stroke-width: 3;
  filter: drop-shadow(0 0 4px rgba(232, 185, 113, .55));
}

.d4mc-tree-nodes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.d4mc-tree-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  outline: none;
  transition: transform .15s ease, filter .15s ease, opacity .15s ease;
}

.d4mc-tree-node:hover:not(:disabled) {
  transform: translate(-50%, -50%) scale(1.1);
}

.d4mc-tree-node:disabled {
  cursor: default;
}

.d4mc-tree-node.is-locked {
  opacity: .3;
  filter: grayscale(1);
}

.d4mc-tree-node.is-available {
  opacity: .8;
}

.d4mc-tree-node.is-selected {
  opacity: 1;
}

.d4mc-tree-node__frame {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #14110d;
}

.d4mc-tree-node__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Root/innate — always shown as the mercenary's own always-active
   special ability, larger and never clickable. */
.d4mc-tree-node--root {
  cursor: default;
}

.d4mc-tree-node--root .d4mc-tree-node__frame {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid #8a6bc9;
  box-shadow: 0 0 12px rgba(138, 107, 201, .45);
}

/* Active skills (branch primary + secondaries) — square, matching
   skill-tree.css's .d4st-node--active convention. */
.d4mc-tree-node--active .d4mc-tree-node__frame {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  border: 2px solid #57442d;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, .8);
}

.d4mc-tree-node--active.is-selected .d4mc-tree-node__frame {
  border-color: var(--d4cm-gold);
  box-shadow: 0 0 12px rgba(232, 185, 113, .45), inset 0 0 6px rgba(255, 222, 153, .3);
}

/* Passive modifiers — circle, smaller. */
.d4mc-tree-node--passive .d4mc-tree-node__frame {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #503d28;
}

.d4mc-tree-node--passive.is-selected .d4mc-tree-node__frame {
  border-color: var(--d4cm-gold);
  box-shadow: 0 0 10px rgba(232, 185, 113, .4);
}

/* Connector — a pure routing waypoint with no skill of its own (see
   build_layout()'s docblock), drawn as a small diamond like
   skill-tree.css's .d4st-category-diamond. */
.d4mc-tree-node--connector {
  width: 12px;
  height: 12px;
  background: #241c14;
  border: 1px solid #785a33;
  transform: translate(-50%, -50%) rotate(45deg);
}

.d4mc-tree-node--connector.is-active {
  border-color: var(--d4cm-gold);
  box-shadow: 0 0 6px rgba(232, 185, 113, .5);
}


/* ---- Planner-style roster row: "Нанятый" | "Подкрепление" -------------- */
.d4mc-roster {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
}

.d4mc-role {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 10px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--d4cm-line, #2f2e34);
  border-radius: 4px;
}

.d4mc-role__title {
  color: var(--d4cm-muted, #898793);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.d4mc-role__slots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.d4mc-slot-wrap {
  position: relative;
  display: inline-flex;
}

.d4mc-slot {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--d4cm-text, #ececf1);
  font: inherit;
  cursor: pointer;
}

.d4mc-slot:disabled {
  cursor: default;
}

.d4mc-slot__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #15130f;
  border: 1px solid #57442d;
  color: #8f8a80;
  font-size: 20px;
  line-height: 1;
}

.d4mc-slot__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.d4mc-slot:hover:not(:disabled) .d4mc-slot__icon,
.d4mc-slot:focus-visible .d4mc-slot__icon {
  border-color: var(--d4cm-gold, #e8b971);
}

/* portrait — the mercenary's face + name under it */
.d4mc-slot--portrait {
  width: 58px;
}

.d4mc-slot--portrait .d4mc-slot__icon {
  width: 44px;
  height: 44px;
  border-radius: 3px;
}

.d4mc-slot__name {
  max-width: 64px;
  font-size: 11px;
  color: #cfc9bd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* square — reinforcement skill */
.d4mc-slot--square .d4mc-slot__icon {
  width: 36px;
  height: 36px;
  border-radius: 2px;
}

/* diamond — trigger condition */
.d4mc-slot--diamond .d4mc-slot__icon {
  width: 28px;
  height: 28px;
  margin: 5px;
  transform: rotate(45deg);
}

/* contents stay upright inside the rotated diamond */
.d4mc-slot--diamond .d4mc-slot__icon img {
  transform: rotate(-45deg) scale(1.35);
}

.d4mc-slot--diamond .d4mc-slot__plus {
  transform: rotate(-45deg);
}

.d4mc-slot.is-filled .d4mc-slot__icon {
  border-color: #9a7440;
}

/* ---- pop-up lists (open on click, one at a time) --------------------- */
.d4mc-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 230px;
  padding: 4px;
  background: #16140f;
  border: 1px solid #57442d;
  border-radius: 4px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .65);
}

.d4mc-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 6px;
  background: none;
  border: 0;
  border-radius: 3px;
  color: #ddd6c8;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.d4mc-menu__item:hover,
.d4mc-menu__item:focus-visible,
.d4mc-menu__item.is-selected {
  background: rgba(232, 185, 113, .12);
  color: #fff;
}

.d4mc-menu__icon {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  overflow: hidden;
  border: 1px solid #57442d;
  border-radius: 2px;
}

.d4mc-menu__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.d4mc-menu__sep {
  height: 1px;
  margin: 4px 2px;
  background: #3a3226;
}

.d4mc-menu__hint {
  padding: 6px 6px 4px;
  color: #8f8a80;
  font-size: 11px;
  line-height: 1.35;
}

.d4mc-menu__mercs {
  display: grid;
  grid-template-columns: repeat(4, 58px);
  gap: 6px;
}

.d4mc-menu__merc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 2px;
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #cfc9bd;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.d4mc-menu__merc:hover:not(:disabled),
.d4mc-menu__merc.is-selected {
  border-color: var(--d4cm-gold, #e8b971);
}

.d4mc-menu__merc.is-taken {
  opacity: .35;
  cursor: not-allowed;
}

.d4mc-menu__portrait {
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 3px;
}

.d4mc-menu__portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.d4mc-menu__clear {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 5px;
  background: rgba(158, 37, 46, .2);
  border: 1px solid rgba(158, 37, 46, .5);
  border-radius: 3px;
  color: #e5b3b3;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.d4mc-menu__clear:hover {
  background: rgba(158, 37, 46, .35);
}

/* theme-guard:start — generated by tools/theme-guard.mjs, do not edit */
html body .d4mc-tree-node:where(:hover, :focus) { background: transparent; border: none; }
html body .d4mc-tree-node--connector:where(:hover, :focus) { background: #241c14; border: 1px solid #785a33; }
html body .d4mc-slot:where(:hover, :focus) { background: none; border: 0; color: var(--d4cm-text, #ececf1); }
html body .d4mc-menu__item:where(:hover, :focus) { background: none; border: 0; color: #ddd6c8; }
html body .d4mc-menu__merc:where(:hover, :focus) { background: none; border: 1px solid transparent; color: #cfc9bd; }
html body .d4mc-menu__clear:where(:hover, :focus) { background: rgba(158, 37, 46, .2); border: 1px solid rgba(158, 37, 46, .5); color: #e5b3b3; }
/* theme-guard:end */
