/*
 * The body figure (benefit-figure.js). Colours come from the page through
 * five variables, so the stats page and the website each keep their own:
 *   --bf-accent  the numbers, the glow behind each picture
 *   --bf-ink     text
 *   --bf-dim     secondary text
 *   --bf-rule    borders and underlines
 *   --bf-bg      the cards' surface
 * Shared with the website (docs/), copied there by scripts/sync-site-figure.js.
 */

.bf {
  color: var(--bf-ink);
}

.bf-empty {
  margin: 0 0 0.75rem;
  color: var(--bf-dim);
  font-style: italic;
}

.bf-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
  gap: 0.9rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.bf-card {
  display: flex;
  flex-direction: column;
  background: var(--bf-bg);
  border: 1px solid var(--bf-rule);
  border-radius: 12px;
  overflow: hidden;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bf-card:hover,
.bf-card:focus {
  border-color: var(--bf-accent);
  box-shadow: 0 0 0 1px var(--bf-accent);
}

/* ── The picture: three stacked layers ── */

.bf-stage {
  position: relative;
  aspect-ratio: 6 / 5;
  background: radial-gradient(110% 85% at 50% 40%,
    color-mix(in srgb, var(--bf-accent) 9%, var(--bf-bg)) 0%, var(--bf-bg) 72%);
}

.bf-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* At rest the warm place stays marked, softer: it was spared, not hurt. */
.bf-heat { opacity: 0.6; transition: opacity 0.3s ease; }

.bf-ring { transition: filter 0.2s ease; }

.bf-card:hover .bf-heat,
.bf-card:focus .bf-heat {
  opacity: 1;
}

.bf-card:hover .bf-ring,
.bf-card:focus .bf-ring {
  filter: drop-shadow(0 0 6px var(--bf-accent));
}

/* ── Played in a loop: warm first, the ring arrives, the warmth fades;
      then the ring lets go and the warmth comes back, and again ── */

.bf-play .bf-heat {
  animation: bf-cool 3s ease-in-out infinite both;
}

.bf-play .bf-ring {
  animation: bf-arrive 3s infinite both;
}

.bf-play .bf-card:nth-child(2) .bf-layer { animation-delay: 0.25s; }
.bf-play .bf-card:nth-child(3) .bf-layer { animation-delay: 0.5s; }

/* Stopped, each picture holds where it was. */
.bf-paused .bf-layer {
  animation-play-state: paused;
}

/* A card under the pointer or the focus shows its marked state, still. */
.bf-play .bf-card:hover .bf-layer,
.bf-play .bf-card:focus .bf-layer {
  animation: none;
}

@keyframes bf-arrive {
  0%   { opacity: 0; transform: scale(1.5);
         animation-timing-function: cubic-bezier(0.2, 0.8, 0.3, 1.2); }
  9%   { opacity: 1; transform: scale(1); }
  78%  { opacity: 1; transform: scale(1); animation-timing-function: ease-in; }
  90%  { opacity: 0; transform: scale(1.5); }
  100% { opacity: 0; transform: scale(1.5); }
}

@keyframes bf-cool {
  0%   { opacity: 1; }
  4%   { opacity: 1; }
  26%  { opacity: 0.6; }
  80%  { opacity: 0.6; }
  92%  { opacity: 1; }
  100% { opacity: 1; }
}

/* ── Stop / play ── */

.bf-controls {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 0.5rem;
}

.bf-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--bf-dim);
  background: var(--bf-bg);
  border: 1px solid var(--bf-rule);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.bf-toggle:hover,
.bf-toggle:focus-visible {
  color: var(--bf-ink);
  border-color: var(--bf-accent);
  outline: none;
}

.bf-toggle-icon {
  width: 0.7rem;
  height: 0.7rem;
  fill: currentColor;
}

/* ── The text ── */

.bf-text {
  padding: 0.75rem 0.9rem 0.9rem;
  border-top: 1px solid var(--bf-rule);
}

.bf-row-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bf-dim);
}

.bf-value {
  font-size: 0.95rem;
  line-height: 1.35;
}

.bf-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--bf-accent);
  font-variant-numeric: tabular-nums;
}

.bf-extra,
.bf-today {
  font-size: 0.82rem;
  color: var(--bf-dim);
}

.bf-today {
  color: var(--bf-accent);
  font-weight: 600;
}

.bf-why {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--bf-dim);
}

.bf-why a,
.bf-how a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--bf-rule);
  text-underline-offset: 2px;
}

.bf-how {
  margin-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--bf-dim);
}

.bf-how summary {
  cursor: pointer;
}

.bf-how ul {
  margin: 0.4rem 0 0;
  padding-inline-start: 1.1rem;
}

@media (prefers-reduced-motion: reduce) {
  .bf-play .bf-heat,
  .bf-play .bf-ring {
    animation: none;
  }

  .bf-controls {
    display: none;
  }
}
