You are a Python developer. Write a script that uses PRAW to fetch top posts from a specified subreddit. The script must: 1) Accept subreddit name and time filter (day, week, month), 2) Extract title, score, URL, comments, 3) Save to CSV, 4) Handle rate limits, 5) Use environment variables for API keys, 6) Log progress, 7) Include error handling. Add comments.