/* ──────────────────────────────────────────────────────────────────────────
 * Fund progress bar — the noticeboard's fundraising thermometer.
 *
 * The bar is always green, whatever colour the notice itself is: money raised
 * reads the same on every card, and it stands out against the accent colour of
 * the band above it. The whole filled length glows, with a sheen sweeping
 * across it. Two rules keep this cheap on low-end phones:
 *
 *   1. Nothing animates until the card is open. The bar only exists inside a
 *      notice's expanded body, and the animations hang off .is-expanded, so a
 *      board of collapsed notices costs nothing at all.
 *   2. The looping effects only touch transform and opacity. The glow is a
 *      static box-shadow whose opacity breathes — the shadow itself never
 *      animates, so nothing repaints per frame.
 *   3. A fund with nothing raised yet animates nothing at all — see .is-empty.
 *
 * Colours use rgb(... / α) rather than color-mix() so the effect survives the
 * pre-Chrome-111 WebViews that application.css already carries a fallback for.
 * ────────────────────────────────────────────────────────────────────────── */

.fund {
  /* Bright green, right-to-left like the card bands: --fund-from is the richer
     stop on the right, --fund-to the deeper one on the left. */
  --fund-from: #2fd25f;
  --fund-to: #14a04c;
  --fund-glow: 47 210 95; /* --fund-from as an "r g b" triple */

  --fund-a1: 0.78; /* tight inner glow  */
  --fund-a2: 0.44; /* wide outer bloom  */

  display: flex;
  flex-direction: column;
  gap: 0.5625rem;
}

[data-theme="dark"] .fund {
  --fund-a1: 1;
  --fund-a2: 0.62;
}

/* Overflow stays visible so the halo can bloom past the bar. Nothing else
   escapes: the fill is never wider than the track, and it clips its own
   children. */
.fund-track {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.13);
  overflow: visible;
}

[data-theme="dark"] .fund-track {
  background: rgb(0 0 0 / 0.32);
}

.fund-halo,
.fund-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 999px;
}

/* Sits behind the fill, matching its geometry exactly, so the glow belongs to
   the whole bar rather than pooling at the leading edge. */
.fund-halo {
  box-shadow:
    0 0 8px -1px rgb(var(--fund-glow) / var(--fund-a1)),
    0 0 22px 2px rgb(var(--fund-glow) / var(--fund-a2));
  will-change: opacity;
}

.fund-fill {
  overflow: hidden;
  background-image: linear-gradient(to left, var(--fund-from) 0%, var(--fund-to) 100%);
}

/* A static sliver of gloss along the top edge, for a little dimension. */
.fund-fill::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgb(255 255 255 / 0.2) 0%,
    rgb(255 255 255 / 0.05) 45%,
    rgb(255 255 255 / 0) 70%
  );
}

/* Clipped by .fund-fill, so the sheen only ever crosses the coloured part. */
.fund-sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    rgb(255 255 255 / 0) 36%,
    rgb(255 255 255 / 0.4) 50%,
    rgb(255 255 255 / 0) 64%
  );
  transform: translateX(-100%);
  will-change: transform;
}

/* Everything switches on when the card opens — including for auto-expand
   notices, whose card controller sets .is-expanded as soon as it connects. */
.is-expanded .fund-fill {
  animation: fund-fill 1150ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.is-expanded .fund-halo {
  animation:
    fund-fill 1150ms cubic-bezier(0.22, 1, 0.36, 1) forwards,
    fund-breathe 2.9s ease-in-out infinite;
}

.is-expanded .fund-sheen {
  animation: fund-sweep 2.6s ease-in-out infinite;
}

/* Nothing raised yet. There is no fill to grow and nothing for the sheen to
   sweep across, and a zero-width halo would still cast its glow as a smudge at
   the left end of the track — so the whole effect switches off and the bar sits
   there as a plain empty pill. Higher specificity than the .is-expanded rules
   above, so it wins wherever it appears. */
.fund.is-empty .fund-fill,
.fund.is-empty .fund-halo,
.fund.is-empty .fund-sheen {
  animation: none;
  will-change: auto;
}

.fund.is-empty .fund-halo {
  box-shadow: none;
}

@keyframes fund-fill {
  from { width: 0; }
  to   { width: var(--fund-pct); }
}

@keyframes fund-breathe {
  0%, 100% { opacity: 0.62; }
  50%      { opacity: 1; }
}

@keyframes fund-sweep {
  0%        { transform: translateX(-100%); }
  62%, 100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .is-expanded .fund-fill,
  .is-expanded .fund-halo {
    animation: none;
    width: var(--fund-pct);
  }

  .is-expanded .fund-sheen {
    animation: none;
  }
}
