module VideoTextGenerator
  def get_usage_roast(count)
    case count
    when 0..10
      "Just getting started"
    when 11..50
      "Casual explorer"
    when 51..100
      "Regular customer"
    when 101..200
      "Frequent flyer"
    when 201..365
      "Daily dedication"
    else
      "Legendary status"
    end
  end

  def get_variety_roast(count)
    case count
    when 0..2
      "Playing it safe"
    when 3..5
      "Branching out"
    when 6..10
      "Adventurous spirit"
    when 11..15
      "Collector mindset"
    else
      "Gotta catch 'em all"
    end
  end

  def get_frequency_roast(days)
    case days
    when 0..30
      "Weekend warrior"
    when 31..90
      "Regular routine"
    when 91..180
      "Consistent commitment"
    when 181..270
      "Almost daily"
    else
      "Living the lifestyle"
    end
  end

  def get_substance_roast(substance, count, rank)
    return "" if rank > 2
    
    base_roasts = {
      0 => "Your ride or die",
      1 => "Solid backup choice",
      2 => "Bronze medal winner",
      3 => "Honorable mention",
      4 => "Made the list"
    }

    substance_specific = {
      # Common substances
      'Cannabis' => ["Your green companion", "Reliable as always", "Classic choice"],
      'Alcohol' => ["Social lubricant supreme", "Liquid courage", "The usual suspect"],
      'Caffeine' => ["Morning motivation", "Productivity fuel", "Legal addiction"],
      'Nicotine' => ["Stress relief stick", "Break time buddy", "Oral fixation"],
      
      # Psychedelics
      'LSD' => ["Mind expansion specialist", "Reality optional", "Cosmic explorer"],
      'Psilocybin' => ["Nature's teacher", "Wisdom seeker", "Fungal friend"],
      'DMT' => ["Breakthrough specialist", "Entity encounter", "Hyperspace traveler"],
      '2C-B' => ["Party psychedelic", "Visual voyage", "Nexus navigator"],
      
      # Stimulants
      'Amphetamine' => ["Focus fuel", "Productivity hack", "Speed demon"],
      'Methamphetamine' => ["Crystal clear", "Go fast juice", "Sleep's enemy"],
      'Methylphenidate' => ["Study buddy", "Academic aid", "Concentration station"],
      'Modafinil' => ["Wakefulness warrior", "Smart drug", "Sleep optional"],
      'Cocaine' => ["Fast lane favorite", "Energy booster", "Quick fix"],
      
      # Empathogens/Entactogens
      'MDMA' => ["Love drug champion", "Empathy enhancer", "Dance floor deity"],
      '3-MMC' => ["Euro favorite", "Meph substitute", "Party powder"],
      '4-MMC' => ["Plant food legend", "Drone pilot", "Meow meow master"],
      
      # Dissociatives
      'Ketamine' => ["K-hole navigator", "Dissociation station", "Wonky wonder"],
      '2-FDCK' => ["K's cousin", "Research chemical", "Novel disso"],
      'Dextromethorphan' => ["Robo warrior", "Plateau climber", "Cough syrup grad"],
      
      # Opioids
      'Kratom' => ["Leaf loyalist", "Natural nod", "Green gold"],
      'O-DSMT' => ["Tramadol 2.0", "Research opioid", "Pain research"],
      'Codeine' => ["Lean legend", "Purple drank", "Mild relief"],
      
      # Benzos/Depressants
      'Alprazolam' => ["Anxiety assassin", "Bar tender", "Panic stopper"],
      'Clonazepam' => ["Chill pill", "Kpin keeper", "Calm collector"],
      'Diazepam' => ["Classic calm", "Mother's helper", "OG benzo"],
      
      # GABAergics
      'Phenibut' => ["Soviet secret", "Social smoothie", "GABA guru"],
      'Gabapentin' => ["Nerve nurturer", "Off-label legend", "Gaba getter"],
      'Pregabalin' => ["Lyrica lover", "Anxiety ally", "Nerve friend"],
      
      # Others
      'GHB' => ["G force", "Date rape drug", "Dose dependent"],
      'Tianeptine' => ["Tricyclic terror", "Gas station gram", "Risky research"]
    }

    # Use substance-specific roast if available, otherwise use rank-based
    specific_roasts = substance_specific[substance]
    if specific_roasts && !specific_roasts.empty?
      specific_roasts.sample
    else
      base_roasts[rank] || "Made an impression"
    end
  end

  def get_time_period_roast(period)
    case period.downcase
    when 'morning'
      "Rise and grind mentality"
    when 'afternoon'
      "Lunch break adventures"
    when 'evening'
      "After work unwind"
    when 'night'
      "Nocturnal creature"
    else
      "Timing is everything"
    end
  end

  def get_peak_month_flavor(month_name)
    month_flavors = {
      'January' => 'New year, new substances',
      'February' => 'Love was in the air... and in your system',
      'March' => 'Spring awakening energy',
      'April' => 'April showers bring May flowers... and substances',
      'May' => 'May the force be with you',
      'June' => 'Summer vibes were strong',
      'July' => 'Independence from sobriety',
      'August' => 'Hot summer nights',
      'September' => 'Back to school, back to substances',
      'October' => 'Spooky season energy',
      'November' => 'Thanksgiving for good times',
      'December' => 'Holiday spirit was high'
    }

    month_flavors[format_month_name(month_name)] || 'What a month'
  end

  def get_hardest_day_flavor(count)
    if count >= 10
      "Someone was having a MOMENT"
    elsif count >= 5
      "You really went for it"
    else
      "A memorable day"
    end
  end

  def get_streak_flavor(substance, days = 0)
    "#{substance} had you in a chokehold"
  end

  def get_route_flavor(route)
    route_flavors = {
      'oral' => 'Classic and reliable',
      'insufflated' => 'Straight to the point',
      'rectal' => 'Taking the scenic route',
      'sublingual' => 'Under the tongue champion',
      'intravenous' => 'Express delivery'
    }

    route_flavors[route.downcase] || 'Your preferred method'
  end

  def get_random_onetime_title
    [
      "Obscure One-Time Uses",
      "The Experimental Phase",
      "One-Hit Wonders",
      "Trial Run Hall of Fame",
      "The 'Never Again' Collection",
      "Single-Serving Substances",
      "The Curiosity Cabinet"
    ].sample
  end

  def get_onetime_roast(substance)
    specific_roasts = {
      # Psychedelics
      "2C-B" => "Too spicy?",
      "2C-B-Fly" => "Wings attached",
      "2C-E" => "Got the message",
      "LSD" => "Tab life",
      "1P-LSD" => "Legal cousin",
      "1cP-LSD" => "Another analogue",
      "1V-LSD" => "Valerie visited",
      "1D-LSD" => "New kid on block",
      "Psilocybin" => "Fungi friend",
      "DMT" => "Met the entities",
      "4-AcO-DMT" => "Synthetic shrooms",
      "5-MeO-DMT" => "The God molecule",
      "Mescaline" => "Desert wisdom",
      "4-HO-MiPT" => "Tryptamine time",
      
      # Dissociatives
      "Ketamine" => "K-hole explorer",
      "2-FDCK" => "2F-Done Correctly",
      "3-HO-PCE" => "Holey moley",
      "3-HO-PCP" => "Triple hop",
      "Dextromethorphan" => "Robo-tripping",
      "DMXE" => "Dexter's lab",
      "Memantine" => "Dissociation station",
      "PCP" => "Wild ride",
      "Methoxetamine" => "MXE memories",
      
      # Stimulants
      "Amphetamine" => "Speed demon",
      "Methamphetamine" => "Breaking bad",
      "Modafinil" => "Wakefulness wizard",
      "Armodafinil" => "R-mode engaged",
      "Methylphenidate" => "Study buddy",
      "Cocaine" => "Snow day",
      "2-FMA" => "Fluorinated focus",
      "NEP" => "Ethyl explorer",
      "a-D2PV" => "Alphabet soup",
      "MDPV" => "Bath salt saga",
      
      # Empathogens
      "MDMA" => "Love everyone mode",
      "3-MMC" => "Meow meow",
      "4-MMC" => "Plant food",
      "2-MMC" => "Meph's cousin",
      "3-CMC" => "Crystal clarity",
      "4-MPD" => "4-wheeling",
      "6-APB" => "Benzo fury",
      "5-MAPB" => "Borax combo",
      
      # Opioids
      "Heroin" => "Dragon chaser",
      "O-DSMT" => "Tramadol's child",
      "Codeine" => "Lean cuisine",
      "Tapentadol" => "Tappy taps",
      "Methadone" => "Maintenance mode",
      "Buprenorphine" => "Sub life",
      "Fentanyl" => "Danger zone",
      "Carfentanil" => "Elephant dose",
      
      # Benzos/GABAergics
      "Alprazolam" => "Bar hopper",
      "Clonazepam" => "Kpin chill",
      "Diazepam" => "Valium vacation",
      "Bromazolam" => "Broma bromance",
      "Clonazolam" => "Blackout city",
      "Flualprazolam" => "Flu season",
      "Phenibut" => "Russian roulette",
      "Gabapentin" => "Gaba gaba hey",
      "Pregabalin" => "Lyrical miracle",
      "Carisoprodol" => "Soma holiday",
      
      # Cannabis
      "Cannabis" => "Green therapy",
      "HHC" => "Legal high",
      "D8-THC" => "Diet weed",
      "THC-O" => "Space weed",
      
      # Natural/Traditional
      "Kratom" => "Leaf life",
      "Kava" => "Island time",
      "Salvia" => "Reality shattered",
      "Nutmeg" => "Kitchen psychonaut",
      "LSA" => "Morning glory",
      "Yohimbine" => "Bark bite",
      
      # Nootropics/Supplements
      "Caffeine" => "Legal speed",
      "L-Theanine" => "Zen mode",
      "Phenylpiracetam" => "Soviet secret",
      "Noopept" => "Brain boost",
      "Modafinil" => "Limitless lite",
      "NAD+" => "Cell fuel",
      "5-HTP" => "Serotonin support",
      
      # Medications
      "Ibuprofen" => "Pain's enemy",
      "Paracetamol" => "Headache helper",
      "Propranolol" => "Beta blocked",
      "Metoprolol" => "Heart keeper",
      "Sildenafil" => "Blue diamond",
      "Tadalafil" => "Weekend warrior",
      "Amoxicillin" => "Infection fighter",
      "Sertraline" => "SSRI squad",
      
      # Novel/RC
      "3-FPM" => "Functional stim",
      "4-FMPH" => "Study aid 2.0",
      "Cyclazodone" => "Pemoline's heir",
      "N-Methyl-Cyclazodone" => "NMC energy",
      "DMAA" => "Pre-workout power",
      "Bromantane" => "Soviet stim",
      
      # Others
      "GHB" => "Dose calculator",
      "GBL" => "G precursor",
      "Tianeptine" => "Risky antidepressant",
      "Etizolam" => "Not worth it",
      "Flubromazepam" => "Half-life hero",
      "MXiPr" => "Disso cousin"
    }
    
    generic_roasts = [
      "Just curious",
      "Not impressed", 
      "One and done",
      "Experimental phase",
      "For science!",
      "Why not?",
      "YOLO moment",
      "Bucket list ✓",
      "Tried it once",
      "Meh experience",
      "Been there",
      "Moving on..."
    ]
    
    specific_roasts[substance] || generic_roasts.sample
  end
end