/* ============================================================
   VYNDR — FUTURES MOVEMENT color/label (Wave 2B, Offseason Hub).

   The color contract for a futures selection's price movement. HONESTY RULE:
   futures are TRACKED, not model-graded — a movement is only ever shown when
   the backend actually supplies a `move` (never fabricated). The color space
   is deliberately narrow and NEVER red:
     • shortening → the market moved TOWARD the selection  → green (value/steam)
     • drifting   → the market moved AWAY                   → amber (caution)
     • flat / absent → no movement to report               → dim (say less)
   Red is reserved system-wide for settled-negative outcomes; a futures drift
   is NOT a miss, so it must never render red.

   CommonJS so the .tsx surface imports it (allowJs) AND Jest exercises it.
   ============================================================ */

// Canonical move → CSS custom-property token. No branch returns the red
// (--miss) token — a normal drift is caution (amber), never a miss.
const MOVE_COLOR = {
  shortening: 'var(--g-a)', // green — toward the selection (value)
  drifting: 'var(--amber)', // amber — away from the selection (caution)
  flat: 'var(--text-2)',    // dim — no movement
};

/** moveColor(move) — the token for a move, defaulting to dim for flat/absent. */
function moveColor(move) {
  const m = String(move || '').toLowerCase();
  return MOVE_COLOR[m] || MOVE_COLOR.flat;
}

/** moveLabel(move) — a short mono glyph+word, or '' when there is no move. */
function moveLabel(move) {
  const m = String(move || '').toLowerCase();
  if (m === 'shortening') return '▼ SHORTENING';
  if (m === 'drifting') return '▲ DRIFTING';
  if (m === 'flat') return '— FLAT';
  return '';
}

module.exports = { MOVE_COLOR, moveColor, moveLabel };
