/* ============================================
   StreamSprite — Stat Bar Styles (V3)
   Per-stat colors via --stat-color CSS variable
   ============================================ */

.stat-bar {
  width: var(--bar-width);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--bar-radius);
  overflow: hidden;
  position: relative;
  height: var(--bar-height);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Slide-in from below */
.stat-bar.entering {
  animation: barSlideIn 0.5s ease forwards;
}

@keyframes barSlideIn {
  0%   { opacity: 0; transform: translateX(-20px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* Slide-out */
.stat-bar.exiting {
  animation: barSlideOut 0.5s ease forwards;
}

@keyframes barSlideOut {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(-20px); }
}

/* Fill bar — uses per-stat color via CSS variable */
.stat-bar__fill {
  height: 100%;
  border-radius: var(--bar-radius);
  transition: width 0.8s cubic-bezier(0.25, 0.8, 0.25, 1),
              background-color 0.6s ease,
              filter 0.6s ease;
  position: relative;
  min-width: 0;

  /* Default: full brightness, stat's own color */
  background: linear-gradient(90deg,
    var(--stat-color, #4ade80),
    color-mix(in srgb, var(--stat-color, #4ade80), white 20%)
  );
  box-shadow: 0 0 10px color-mix(in srgb, var(--stat-color, #4ade80), transparent 70%);
}

/* Level-based modifiers — desaturate + darken as stat depletes */
.stat-bar__fill[data-level="mid"] {
  filter: saturate(0.7) brightness(0.85);
}

.stat-bar__fill[data-level="low"] {
  filter: saturate(0.4) brightness(0.65);
}

.stat-bar__fill[data-level="critical"] {
  filter: saturate(0.2) brightness(0.5);
  animation: barPulse 1s ease-in-out infinite;
}

@keyframes barPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* Label overlay */
.stat-bar__label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 2;
}

.stat-bar__label-name {
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.stat-bar__label-value {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

/* Replenish flash effect */
.stat-bar.replenish-flash .stat-bar__fill {
  animation: flashGlow 0.6s ease;
}

@keyframes flashGlow {
  0%   { filter: brightness(1); }
  30%  { filter: brightness(1.8); }
  100% { filter: brightness(1); }
}
