/**
 * Format a duration in seconds as M:SS (< 1 hour) or H:MM:SS (>= 1 hour).
 * Used by player controls, chapter markers, key moment badges, and chat source cards.
 */
export function formatTime(seconds: number): string {
  const total = Math.floor(seconds);
  const h = Math.floor(total / 3600);
  const m = Math.floor((total % 3600) / 60);
  const s = total % 60;

  if (h > 0) {
    return `${h}:${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`;
  }
  return `${m}:${s.toString().padStart(2, "0")}`;
}
