/* Initiative Tracker Specific Styles */

/* Initiative Bar */
.initiative-bar {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  width: 100%;
  max-width: 98vw;
  flex-wrap: nowrap;
  gap: 1.5rem;
  padding: 115px 80px 100px 80px;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
}

.initiative-bar::-webkit-scrollbar {
  display: none;
}

/* Character Portraits */
.character-portrait {
  width: var(--portrait-width);
  height: var(--portrait-height);
  flex-shrink: 0;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-primary);
  background-color: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  font-weight: bold;
  font-size: 1em;
  text-align: center;
  padding: 0 10px var(--spacing-xl) 10px;
  position: relative;
  overflow: visible;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-slow);
  opacity: 1;
  filter: brightness(0.5);
}

.character-portrait.has-bg {
  color: var(--text-primary);
  text-shadow: 1px 2px 6px #111, 0px 0px 8px #000;
  background-size: cover;
  background-position: center;
}

.character-portrait.current.active-card {
  transform: scale(1.12);
  z-index: 2;
  border-color: var(--color-primary);
  box-shadow: 0 0 10px var(--shadow-gold), 0 2px 16px var(--shadow-gold-strong);
}

.active-card {
  filter: brightness(1);
}

.character-portrait .character-name {
  position: absolute;
  left: 0;
  bottom: -10px;
  width: 100%;
  z-index: 999;
  font-size: 15px;
  text-align: center;
}

/* Dice Roll Display */
.dice-roll {
  position: absolute;
  top: -56px;
  margin-left: 50%;
  background-image: url(../images/dice.png);
  background-position: center center;
  background-size: contain;
  background-repeat: no-repeat;
  text-shadow: 1px 1px var(--color-gold);
  color: black;
  width: 90px;
  height: 90px;
  padding: 37px 0px 0px 0px;
  left: -45px;
  text-align: center;
  z-index: 1000;
}

.btn-dice {
  background-image: url(../images/dice.png);
  background-position: center center;
  background-size: contain;
  background-repeat: no-repeat;
  text-shadow: 1px 1px var(--color-gold);
  color: black;
  width: 60px;
  height: 60px;
  padding: 6px 0px 0px 0px;
  text-align: center;
}

.roll-selector {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: url('../images/dice.png') center center/cover, #232323;
  border: 2px solid #666;
  font-size: 1.5em;
  color: #ffe066;
  font-weight: bold;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
  margin-right: var(--spacing-xs);
}

.roll-selector:hover, .roll-selector:active {
  background: url('../images/dice.png') center center/cover, #111;
}

.roll-selector span {
  text-shadow: 0 1px 3px #111;
  position: relative;
  z-index: 2;
  pointer-events: none;
}

/* Death Overlay */
.character-portrait .death-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 10, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 1;
  transition: opacity var(--transition-slow);
  cursor: pointer;
  border-radius: 23px;
}

.character-portrait .death-overlay .big-skull img {
  width: 300px;
}

/* Damage Overlay */
.damage-overlay {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 0; /* will fill dynamically */
  background-image: url('../images/blood.png');
  background-size: cover;
  background-position: top;
  opacity: 1;
  pointer-events: none;
  transition: height var(--transition-normal);
  border-radius: 1.5em;
  z-index: 0;
  border-top: 3px solid rgba(166, 0, 15, 1);
}

/* Power-up and Gem Overlays */
.power-up-overlay {
  position: absolute;
  bottom: -53px;
  width: 100%;
  height: 130px;
  background-image: url('../images/red-name-plate.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 101;
}

.gem-overlay {
  position: absolute;
  bottom: -53px;
  width: 100%;
  height: 130px;
  background-image: url('../images/name-plate.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 100;
  cursor: pointer;
  transition: filter var(--transition-fast);
}

.dice-overlay {
  position: absolute;
  top: -65px;
  width: 250px;
  height: 90px;
  background-image: url('../images/top-border.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 11;
}

/* Condition Overlays */
.condition-overlays {
  display: flex;
  flex-direction: column;
  z-index: 1;
  pointer-events: none;
  text-shadow: none;
  position: absolute;
  bottom: 80px;
  left: 0;
  width: 100%;
  height: auto;
}

.condition-badge {
  color: var(--text-primary);
  display: block;
  pointer-events: auto;
  position: relative;
  margin: 1px auto;
  width: 80%;
  font-size: var(--font-sm);
  padding: 6px 12px;
  border-radius: 20px;
}

.badge-remove {
  position: absolute;
  right: 20px;
  top: 3px;
  font-size: 16px;
  text-shadow: 1px 2px 6px #111, 0px 0px 8px #000;
  color: var(--text-primary) !important;
  cursor: pointer;
  opacity: 0.5;
}

/* Initiative Controls */
#initiativeControls {
  position: fixed;
  bottom: 0px;
  left: 0px;
  width: 100%;
  height: 80px;
  display: none;
}

#initiativeOverlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 25, 26, 0.78);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

#initiativeOverlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Animations */
@keyframes pulse-pop {
  0% {
    transform: scale(0.7);
    opacity: 0.5;
    box-shadow: 0 0 0 #ffe06600;
  }
  40% {
    transform: scale(1.18);
    opacity: 1;
    box-shadow: 0 0 18px #ffe066;
  }
  70% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 0 #ffe06600;
  }
}

.character-portrait.just-added {
  animation: pulse-pop 0.6s cubic-bezier(.57, 1.64, .41, .87);
  z-index: 10 !important;
}

@keyframes shortlistPulse {
  0% {
    border: 1px solid var(--color-primary);
    box-shadow: 0 0 4px var(--shadow-gold), 0 1px 7px var(--shadow-gold-strong);
    opacity: 1;
  }
  50% {
    border: 2px solid #ffc857;
    box-shadow: 0 0 10px #ffd470cc, 0 2px 10px #b18c3e;
    opacity: 0.95;
  }
  100% {
    border: 1px solid var(--color-primary);
    box-shadow: 0 0 4px var(--shadow-gold), 0 1px 7px var(--shadow-gold-strong);
    opacity: 1;
  }
}

.monster-search-result.highlight .monster-card {
  animation: shortlistPulse 1.1s infinite;
  user-select: none;
  transition: border var(--transition-normal), box-shadow var(--transition-normal);
}

@keyframes addedGlow {
  0% {
    box-shadow: 0 0 0 0 #f9e79f;
  }
  50% {
    box-shadow: 0 0 18px 8px #f9e79f;
  }
  100% {
    box-shadow: 0 0 0 0 #f9e79f;
  }
}

.monster-card.added-animate {
  animation: addedGlow 1.2s;
}

/* Input Flash Effect */
input.flash {
  background: #234 !important;
  box-shadow: 0 0 8px #ffe066, 0 0 3px #111;
  transition: background var(--transition-normal);
}
