/* Selected-instance HP control (DESIGN; hpctl.js). Load after hud31.css. A compact dark-red glass popover that sits on
   the unit panel's HP bar INSIDE the console region (so __hudCheck sees no escaping control): above the console's own
   panels (z 6 in .r-console), always below the modal layer (.r-modal is z 40, outside the bottom frame). It inherits
   the HUD scale (the frame's zoom). Type floor: 11 px. */

/* ---------- the unit panel's HP bar as the handle (only when live.js passes onHp) ---------- */
.u-bar.hp.hp-edit { cursor: pointer; }
.u-bar.hp.hp-edit:hover, .u-bar.hp.hp-edit.on, .u-bar.hp.hp-edit:focus-visible { outline: none; box-shadow: 0 0 0 1px var(--red), 0 0 9px rgba(255,42,18,.5); }
.u-bar.hp .hp-aff { position: absolute; right: 4px; top: 0; z-index: 1; pointer-events: none; font-family: var(--label); font-style: normal; font-size: 11px; line-height: 16px;
  letter-spacing: .06em; color: var(--hot); text-shadow: 0 1px 2px #000, 0 0 3px #000; opacity: .72; }
.u-bar.hp.hp-edit:hover .hp-aff, .u-bar.hp.hp-edit.on .hp-aff { opacity: 1; color: #fff; }

/* ---------- popover ---------- */
.hpctl { position: absolute; z-index: 6; box-sizing: border-box; display: flex; flex-direction: column; gap: 5px; padding: 6px 8px 7px; pointer-events: auto;
  color: var(--hot); font-family: var(--mono); font-size: 11px; line-height: 1.3; text-align: left; outline: none;
  background: linear-gradient(180deg, rgba(52,13,7,.95) 0%, rgba(22,6,4,.96) 55%, rgba(8,3,2,.97) 100%);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid #6a1e12; border-top: 2px solid var(--red);
  box-shadow: 0 0 0 1px #000, 0 10px 24px rgba(0,0,0,.75), 0 0 18px rgba(255,42,18,.18), inset 0 1px 0 rgba(255,190,170,.08), inset 0 0 22px rgba(255,42,18,.07); }
.hpctl[hidden], .hpctl [hidden] { display: none !important; }

.hp-head { display: flex; align-items: center; gap: 6px; min-height: 18px; }
.hp-ttl { flex: none; font-family: var(--label); font-weight: 400; font-size: 11px; letter-spacing: .1em; color: var(--red); text-shadow: 0 0 6px rgba(255,42,18,.45); }
.hp-mock { flex: none; font-style: normal; font-family: var(--label); font-size: 11px; letter-spacing: .08em; line-height: 14px; padding: 0 4px;
  color: #000; background: var(--warn); }                    /* practice universe, as the MOCK DATA chip top-right */
.hp-who { flex: 1 1 auto; min-width: 0; font-size: 11px; color: var(--esp-hot); overflow-wrap: anywhere; }
.hp-who b { font-family: var(--label); font-weight: 400; letter-spacing: .04em; color: var(--hot); }
.hp-who .hp-ret { font-style: normal; font-family: var(--label); font-size: 11px; letter-spacing: .06em; color: #000; background: var(--warn); padding: 0 4px; }
.hp-x { flex: none; width: 20px; height: 18px; padding: 0; display: grid; place-items: center; cursor: pointer; color: var(--hot); background: #0a0403; border: 1px solid #4a1a10; }
.hp-x:hover, .hp-x:focus-visible { outline: none; color: #fff; border-color: var(--red); }

.hp-now { display: flex; align-items: baseline; gap: 8px; min-height: 20px; }
.hp-num { flex: none; font-size: 13px; font-weight: 600; color: var(--hp-hi); letter-spacing: .02em; }
.hp-num b { font-size: 16px; color: #fff; text-shadow: 0 0 8px rgba(255,59,31,.55); }
.hp-src, .hp-state { flex: none; font-style: normal; font-family: var(--label); font-size: 11px; letter-spacing: .08em; color: var(--trim); }
.hp-state { margin-left: auto; color: var(--esp-hot); }
.hp-state.dead { color: var(--warn); }

.hp-row { display: flex; gap: 4px; height: 26px; }
.hp-in { flex: 0 0 86px; width: 86px; min-width: 0; box-sizing: border-box; height: 26px; padding: 0 6px; margin: 0;
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: #fff; background: #060202; border: 1px solid #5a2216; border-radius: 0; box-shadow: inset 0 0 8px #000; }
.hp-in::placeholder { color: #8a5a4e; font-weight: 400; font-size: 11px; }
.hp-in { -moz-appearance: textfield; appearance: textfield; }                       /* no grey native spinner in the red glass */
.hp-in::-webkit-inner-spin-button, .hp-in::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.hp-in:focus { outline: none; border-color: var(--red); box-shadow: inset 0 0 8px #000, 0 0 0 1px var(--red), 0 0 10px rgba(255,42,18,.35); }
.hp-in:disabled { opacity: .45; cursor: not-allowed; }
.hpctl .hp-b { flex: 1 1 auto; min-width: 0; height: 26px; padding: 0 6px; margin: 0; cursor: pointer; white-space: nowrap;
  font-family: var(--label); font-size: 11px; letter-spacing: .08em; color: var(--hot);
  background: linear-gradient(180deg, #3a160a, #120604); border: 1px solid #6a2a18; border-radius: 0; box-shadow: inset 0 1px 0 rgba(255,200,170,.07); }
.hpctl .hp-b:hover:not(:disabled), .hpctl .hp-b:focus-visible { outline: none; border-color: var(--red); color: #fff; box-shadow: 0 0 8px rgba(255,42,18,.4); }
.hpctl .hp-b:disabled { opacity: .42; cursor: not-allowed; filter: grayscale(.5); }
.hpctl .hp-b.revive:hover:not(:disabled), .hpctl .hp-b.armed:hover:not(:disabled) { color: #000; }
.hpctl .hp-b[data-hpop="set"] { flex: 0 0 auto; color: #000; background: linear-gradient(180deg, #ff5a3c, var(--red) 55%, #a01404); border-color: #ff8a70; }
.hpctl .hp-b[data-hpop="set"]:hover:not(:disabled) { color: #000; }
.hpctl .hp-b.kill { color: var(--red); border-color: var(--red); background: linear-gradient(180deg, #2a0804, #0a0201); }
.hpctl .hp-b.revive { color: #140c05; border-color: #f2d898; background: linear-gradient(180deg, #e6c47a, #9c7a3c); }
.hpctl .hp-b.armed { color: #000; background: var(--red); border-color: #ffb199; animation: hp-armed .45s ease-in-out infinite alternate; }
.hpctl .hp-b.revive.armed { background: #f2d898; border-color: #fff3d0; }
@keyframes hp-armed { from { box-shadow: 0 0 0 0 rgba(255,42,18,.7); } to { box-shadow: 0 0 12px 2px rgba(255,42,18,.85); } }

.hp-msg, .hp-why { margin: 0; font-size: 11px; line-height: 15px; overflow-wrap: anywhere; }
.hp-msg { min-height: 15px; color: var(--hot); }
.hp-msg.hint { color: #a08070; }
.hp-msg.busy { color: var(--esp-hot); }
.hp-msg.busy::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; vertical-align: 1px; background: var(--esp); animation: hp-blink .6s steps(2) infinite; }
.hp-msg.ok { color: #f2d898; font-weight: 600; }
.hp-msg.err { color: var(--warn); }
.hp-msg.armed { color: var(--red); font-family: var(--label); letter-spacing: .06em; }
.hp-why { font-family: var(--label); letter-spacing: .06em; color: var(--warn); }
@keyframes hp-blink { 50% { opacity: 0; } }

/* small consoles (the frame narrows below ~1100 px wide): tighter row, same type floor */
@media (max-width: 1100px) {
  .hpctl { padding: 5px 6px 6px; gap: 4px; }
  .hp-in { flex-basis: 70px; width: 70px; }
  .hpctl .hp-b { padding: 0 4px; letter-spacing: .04em; }
}
/* short windows (1280 × 660 and below): the popover may sit a little higher on the HP bar; keep it compact */
@media (max-height: 700px) {
  .hpctl { gap: 4px; padding-top: 5px; padding-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .hpctl .hp-b.armed, .hp-msg.busy::before { animation: none; }
}
