const SEASON_START_ISO = '2026-08-10'

export function daysUntil(iso: string): number {
  const target = new Date(`${iso}T00:00:00`)
  const now = new Date()
  const todayMid = new Date(now.getFullYear(), now.getMonth(), now.getDate())
  return Math.round((target.getTime() - todayMid.getTime()) / 86400000)
}

function countdownText(days: number): string {
  if (days > 1) return `${days} days`
  if (days === 1) return '1 day'
  if (days === 0) return 'today'
  return 'now underway'
}

export function useSeasonCountdown() {
  const days = daysUntil(SEASON_START_ISO)
  const cdText = countdownText(days)

  let heroCountdownPrefix = ''
  let heroCountdownBold: string
  if (days > 0) {
    heroCountdownPrefix = 'Season 6 kicks off in'
    heroCountdownBold = cdText
  } else if (days === 0) {
    heroCountdownBold = 'Season 6 kicks off today'
  } else {
    heroCountdownBold = 'Season 6 is underway'
  }

  return { days, cdText, heroCountdownPrefix, heroCountdownBold }
}
