"""Mood modes — the humane front door over the topic/flavor taxonomy.

A reader thinks "I want wonder," not "animals/discovery". Each mood resolves to
a filter preset (include_topics / include_flavors / a cortisol ceiling) that the
feed already understands via FilterPrefs. Topic/flavor remain available as the
secondary "browse more precisely" controls; moods don't replace them.

Single source of truth so the website and any future companion app agree.
"""

from __future__ import annotations

# "today" is special: it has no filter — it's the daily brief view.
MOODS: list[dict] = [
    {
        "key": "today",
        "label": "Today",
        "description": "The day's five good things.",
        "filter": {},
    },
    {
        "key": "wonder",
        "label": "Wonder",
        "description": "Awe and discovery.",
        "filter": {"include_topics": ["science", "animals", "culture"], "include_flavors": ["discovery"]},
    },
    {
        "key": "people-helping",
        "label": "People Helping",
        "description": "Community, kindness, and repair.",
        "filter": {"include_topics": ["community"], "include_flavors": ["solution", "feelgood"]},
    },
    {
        "key": "solutions",
        "label": "Solutions",
        "description": "Problems being solved.",
        "filter": {
            "include_topics": ["environment", "community", "health"],
            "include_flavors": ["solution", "breakthrough"],
        },
    },
    {
        "key": "light",
        "label": "Light Only",
        "description": "Just the gentle stuff.",
        "filter": {"include_flavors": ["feelgood", "discovery"], "max_cortisol": 2},
    },
    {
        "key": "grounded",
        "label": "Grounded",
        "description": "Useful, calm perspective.",
        "filter": {"include_flavors": ["perspective", "solution"]},
    },
]

_BY_KEY = {m["key"]: m for m in MOODS}


def mood_filter(key: str) -> dict:
    """Return the filter preset for a mood key (empty dict if unknown/today)."""
    mood = _BY_KEY.get(key)
    return dict(mood["filter"]) if mood else {}
