:root {
  --amount-current: 0;
  --amount-goal: 0;
  --amount-total: 0%;
  --progress-color: #25B164;
}

/* Screen reader only text (visually hidden but accessible) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.goal-bar {
  width: 100%;
  position: relative;
}

.goal-bar-goal,
.goal-bar-current {
  padding: 1rem;
  position: relative;
  z-index: 2; /* ensure text sits above the progress fill */
}

.goal-bar--content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #eee;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  position: relative;

  /* NEW: create its own blending context so mix-blend-mode behaves predictably */
  isolation: isolate;
}

/* Keep your existing layout */
.goal-bar-current {
  display: flex;
  flex-direction: row-reverse;
}

/* Decorative progress fill */
.progress {
  position: absolute;
  background: var(--progress-color);
  box-shadow: inset 0 0 20px rgba(0,0,0,.16);
  height: 100%;
  animation-name: progress;
  animation-timing-function: ease-in;
  animation-duration: 1s;
  animation-fill-mode: forwards;
  border-radius: 0;
  width: 0;
  z-index: 1;
}

@keyframes progress {
  from { width: 0; }
  to   { width: var(--amount-total); }
}

/* === NEW: Auto-adjust text color over/under the bar ===
   Base the text as white, then let mix-blend-mode: difference
   invert it where the background is light (e.g., #eee). */
.goal-bar-goal--amount,
.goal-bar-goal--title,
.goal-bar-current .goal-bar-goal--amount,
.goal-bar-current .goal-bar-goal--title {
  color: #000;
  mix-blend-mode: difference;
  font-weight: bold;
}

/* Ensure SR-only text does not blend or invert */
.sr-only {
  mix-blend-mode: normal !important;
}
