/* The top player strip: one stone frame per player, with a readable dark centre. */
#wb-ui > #wb-heroes {
  --wb-player-gold: #e9d2a0;
  top: 6px;
  left: 50%;
  right: auto;
  width: min(1800px, calc(100% - 24px));
  transform: translateX(-50%);
  display: flex;
  justify-content: safe center;
  gap: 6px;
  align-items: stretch;
  padding: 0;
  overflow: visible;
}

#wb-heroes button.wb-hero {
  flex: 0 1 calc((100% - 42px) / 8);
  display: grid !important;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-rows: 32px 24px;
  gap: 4px 7px !important;
  width: auto !important;
  min-width: 0;
  height: 78px;
  min-height: 78px !important;
  padding: 4px !important;
  box-sizing: border-box;
  /* The shared diamond-riveted silver frame on the dark stone tile (owner, 2026-11-18), as on the recruitment board,
     Garrison and preparation panel (recruitment-board.css, dialog-frames.css), scaled for a 78px frame: slices of
     115 px shown at 30 px, 3 px outside the box. Border 5 + padding 4 keeps the old 9 px inset, so nothing moves. */
  border: 5px solid transparent !important;
  border-image: var(--wb-kit-frame) 115 / 30px / 3px stretch !important;
  background: linear-gradient(#ffffff06, #00000030), var(--wb-kit-stone) 0 0/256px 256px repeat, #1b1713 !important;
  background-clip: border-box !important;
  border-radius: 0;
  color: #eee5d5;
  text-align: left;
  align-items: center;
  box-shadow: 0 3px 10px #0006;
  outline: none;
  isolation: isolate;
}

#wb-heroes button.wb-hero:hover {
  background: linear-gradient(#ffffff10, #00000020), var(--wb-kit-stone) 0 0/256px 256px repeat, #221d18 !important;
  box-shadow: inset 0 0 0 1px #d9c29150, 0 3px 12px #0007;
  outline: none;
}

#wb-heroes button.wb-hero:focus-visible {
  outline: 2px solid #f0d99d;
  outline-offset: 2px;
}

#wb-heroes button.wb-hero.wb-you {
  box-shadow: inset 0 0 0 1px #e3c89190, 0 3px 12px #0007;
}

#wb-heroes button.wb-hero.wb-opponent {
  box-shadow: inset 0 0 0 1px #b8785c80, 0 3px 10px #0006;
  outline: none;
}

/* Each player's crest is round under the gold crest ring, like the faction crest in a card's top-right corner
   (owner, 2026-11-18; card-frames.css .wb-card-crest). The art shows inside the ring's 41% opening; a framed 64px
   emblem is zoomed by faction-emblems.css, so the circle is divided by that zoom and its silver square never shows. */
#wb-heroes .wb-hero-icon {
  display: block;
  width: 32px;
  height: 32px;
  box-sizing: border-box;
  border: 0;
  border-radius: 50%;
  background: none;
  box-shadow: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .7));
}

#wb-heroes .wb-hero-icon > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: circle(calc(41% / var(--wb-emblem-zoom, 1)) at 50% 50%);
}

#wb-heroes .wb-hero-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url('./skin/faction-crest-ring.png') center/100% 100% no-repeat;
  pointer-events: none;
}

#wb-heroes :is(.wb-hero-icon, .wb-hero-identity, .wb-hero-vitals) {
  position: relative;
  z-index: 1;
}

#wb-heroes .wb-hero-identity { min-width: 0; align-self: center; }
#wb-heroes .wb-hero-name {
  display: block;
  font: 400 12px/15px WarbandFriz, Georgia, serif;
  color: var(--wb-player-gold);
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

#wb-heroes .wb-hero-player {
  display: block;
  margin-top: 2px;
  font: 11px/13px Arial, sans-serif !important;
  color: #d3cabe;
  text-shadow: 0 1px #0008;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

/* Player health is a slim bar (hero-health-bar.mjs): a recessed track, a fill with a gentle top-to-bottom gradient whose
   tone follows health (deep green, gold, red), and the number at the bar's end. Hero Level sits underneath. */
#wb-heroes .wb-hero-vitals {
  --wb-hero-bar-height: 7px;
  --wb-hero-number-space: 30px;
  grid-column: 1 / -1;
  height: 24px;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding-top: 13px;
  box-sizing: border-box;
  white-space: nowrap;
}

/* The sanitized inline fraction and tones come from current player health, not decoration. */
#wb-heroes .wb-hero-vitals::before,
#wb-heroes .wb-hero-vitals::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 0;
  height: var(--wb-hero-bar-height);
  box-sizing: border-box;
  border-radius: 4px;
  pointer-events: none;
}

#wb-heroes .wb-hero-vitals::before {
  width: calc(100% - var(--wb-hero-number-space));
  background: linear-gradient(#0c0a08, #1c1814);
  box-shadow: inset 0 1px 2px #000c, 0 0 0 1px #c8aa6e26, 0 1px #ffffff0d;
}

#wb-heroes .wb-hero-vitals::after {
  width: calc((100% - var(--wb-hero-number-space)) * var(--wb-hero-health-fraction, 0));
  background: linear-gradient(180deg, var(--wb-hero-health-light, #419c46) 0%, var(--wb-hero-health-base, #228c28) 55%, var(--wb-hero-health-dark, #145117) 100%);
  box-shadow: inset 0 1px #ffffff33, 0 0 4px #00000080;
}

#wb-heroes .wb-hero-health {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  width: calc(var(--wb-hero-number-space) - 4px);
  height: 11px;
  font: 400 11px/11px WarbandFriz, Georgia, serif !important;
  color: #f0e6d2;
  text-align: right;
  font-variant-numeric: tabular-nums;
  margin: 0;
  text-shadow: 0 1px 1px #000;
  /* style.css clips every .wb-hero strong; the Soul Stone below the number must stay visible. */
  overflow: visible;
}

#wb-heroes .wb-hero-level { font: 10px/11px Arial, sans-serif !important; color: #c6b79b; }
#wb-heroes .wb-hero-you { display: none; }
/* An armed Soul Stone sits under the health number, at the end of the Hero Level line, while the frame pulses. */
#wb-heroes .wb-hero-soulstone { position: absolute; top: 13px; right: 0; width: 11px; height: 11px; }
/* The entire defeated player frame fades, including its border and crest. */
#wb-heroes button.wb-hero.wb-eliminated { filter: grayscale(1); opacity: .48; }
#wb-heroes button.wb-hero.wb-eliminated .wb-hero-icon { grid-column: 1; grid-row: 1; filter: grayscale(1) brightness(.7); }
#wb-heroes button.wb-hero.wb-eliminated :is(.wb-hero-identity, .wb-hero-vitals) { opacity: .85; }
#wb-heroes .wb-hero-grave { grid-column: 1; grid-row: 1; justify-self: end; align-self: end; position: relative; z-index: 2; width: 16px; height: 16px; margin: 0 -4px -4px 0; filter: drop-shadow(0 1px 1px #000); pointer-events: none; }

/* An armed Soul Stone: the player's frame breathes a soft, deep purple glow until the stone is spent (owner, 2026-11-18;
   darkened the same day).
   The layer covers the brown frame edge and sits under the crest, names and health; client.mjs keeps it on the page clock. */
#wb-heroes button.wb-hero.wb-hero-soulstoned::before {
  content: '';
  position: absolute;
  inset: -4px;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, #7a33bd00 45%, #7a33bd33 100%);
  box-shadow: inset 0 0 0 1px #a865e88c, inset 0 0 12px 2px #8a3ad86b, 0 0 9px 1px #8a3ad885;
  opacity: .3;
  animation: wb-hero-soulstone-pulse 1.4s ease-in-out infinite alternate;
}

@keyframes wb-hero-soulstone-pulse {
  from { opacity: .3; }
  to { opacity: .95; }
}

/* Retain the health-loss pulse, including a visible red surface over the new brown center. */
#wb-heroes button.wb-hero.wb-hero-hit::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #c3342c;
  animation: wb-dialogue-player-hit 1s ease-out;
  opacity: 0;
}

@keyframes wb-dialogue-player-hit {
  0%, 25% { opacity: .68; }
  60% { opacity: .25; }
  100% { opacity: 0; }
}

@media (max-width: 1250px) {
  #wb-ui > #wb-heroes { width: calc(100% - 16px); gap: 4px; }
  #wb-heroes button.wb-hero { grid-template-columns: 28px minmax(0, 1fr); column-gap: 5px !important; }
  #wb-heroes .wb-hero-icon { width: 28px; height: 28px; }
  #wb-heroes .wb-hero-name { font-size: 11px; }
  #wb-heroes .wb-hero-player { font-size: 10px; }
}

@media (max-width: 940px) {
  #wb-ui > #wb-heroes {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: #9a8058 #221b16;
  }
  #wb-heroes button.wb-hero { flex: 0 0 116px; }
}

@media (prefers-reduced-motion: reduce) {
  #wb-heroes button.wb-hero.wb-hero-hit::after { animation: none; opacity: .35; }
  #wb-heroes button.wb-hero.wb-hero-soulstoned::before { animation: none; opacity: .7; }
}

#wb-ui.wb-campaign-active > #wb-heroes > button.wb-hero { flex: 1 1 0; }

/* View Deck: a book on your hero box, and on a teammate's, opens that player's card pool. client.mjs places it in the
   box's top-right corner; the Ready tick moves left beside it. */
#wb-ui#wb-ui #wb-heroes > .wb-hero-deck{position:absolute;z-index:2;display:block;width:24px;height:24px;min-width:0!important;min-height:0!important;margin:0;padding:0!important;border:1px solid #8a6d3a!important;border-image:none!important;border-radius:2px!important;background:#16120f url('./icons/cards/inv_misc_book_09.png') center/cover no-repeat!important;box-shadow:0 1px 3px #000c!important;pointer-events:auto}
#wb-ui#wb-ui #wb-heroes > .wb-hero-deck:is(:hover,:focus-visible){border-color:#f0d58c!important;filter:brightness(1.2);outline:none}
#wb-ui #wb-heroes .wb-has-deck .wb-hero-ready{right:36px}
