/**
 * Tiny corner footer pinned to the bottom-right of the main column.
 * Renders "Built with hubris • <year in roman numerals>", refreshed
 * once per page load.
 */

const ROMAN_PAIRS: [number, string][] = [
  [1000, 'M'],
  [900, 'CM'],
  [500, 'D'],
  [400, 'CD'],
  [100, 'C'],
  [90, 'XC'],
  [50, 'L'],
  [40, 'XL'],
  [10, 'X'],
  [9, 'IX'],
  [5, 'V'],
  [4, 'IV'],
  [1, 'I'],
]

function toRoman(n: number): string {
  let result = ''
  for (const [value, symbol] of ROMAN_PAIRS) {
    while (n >= value) {
      result += symbol
      n -= value
    }
  }
  return result
}

export function AppFooter() {
  const year = new Date().getFullYear()
  return (
    <div className="pointer-events-none absolute bottom-2 right-3 z-10 text-[10px] text-text-faint">
      <span className="pointer-events-auto">
        Built with hubris • {toRoman(year)}
      </span>
    </div>
  )
}
