"""
EXAMPLE HABITS — written for the USER, not for the developer.

A port of `features/habits/data/mock.js`, which carries the rule and the
reason: the set it replaced was a stress fixture — an untitled habit with no
logs, a title far longer than its column, and a streak of 118 days. Useful for
finding layout faults, wrong as the thing "Fill with example data" hands a
person on their first run.

The rule is **every habit must be one a real person might keep**.

-------------------------------------------------------------------------------
EVERY LOG IS EMPTY, AND THAT IS THE POINT
-------------------------------------------------------------------------------

This set used to ship up to ninety days of ticks per habit, generated by a rule
— three unbroken weeks on the walk, a 22-day best run on lights-out, a
back-filled cold shower. It read beautifully and it was a lie, and it became a
lie that mattered the moment this data stopped being something you opt into
from a menu and became **what a brand-new account is seeded with** (see
`lifey_api/seeding.py`).

A streak is the one number on this page that means "you did this". Handing
somebody a 22-day run they did not earn makes the page's only measurement
worthless on the first screen they ever see, and the first honest thing the app
could do — reset it to zero the moment they touch it — reads as having lost
their data. `Lifey.md` rules out gamification; manufacturing a streak is worse
than a badge, because a badge does not claim to be a record of your life.

So the habits arrive as DEFINITIONS: a name, a schedule, a target, a unit, a
colour and an icon. Everything a habit IS, and nothing about how it has gone.
Every streak reads zero, which is the truth for an account one minute old, and
the first tick a person makes is genuinely their first.

The same rule is why `samples/focus.py` seeds nothing at all: a focus session
has no definition underneath it, so a session record is a measurement and
nothing else.

-------------------------------------------------------------------------------

It still teaches, and the list is here so a row cannot be deleted without
noticing what went with it:

    a plain daily habit                         the walk, lights out
    a target above one, in units                reading, water, morning pages
    set weekdays — a gap is not a miss          strength training
    a weekly quota, any days                    Spanish, the phone call

Deliberately absent: untitled habits and titles long enough to truncate. Those
are still worth testing — type one in.

**ALSO DELIBERATELY ABSENT: AN ARCHIVED HABIT.** The set used to seed one, so
that the archive toggle revealed something. It is the one example row that is
invisible on arrival, so the page opened claiming N habits while the menu
offered to clear N+1, and the row could only be found by somebody who already
knew the feature it was there to teach. Archiving is taught by the row menu
instead, on a habit the user has actually kept. The client's fixture dropped it
at the same time.

**THE FRAME'S OWN DATA IS NOT REPRODUCED.** It shows six habits, every one with
a streak of exactly 30 and a full week of ticks — a screenshot of a perfect
month, which never exercises a single one of the states above.

`HISTORY_DAYS` no longer constrains anything here (the serializer still trims a
log to the 92-day window on write, for logs the user creates). Nothing in this
file writes a log at all.
"""


def _sample(index, **fields):
    row = {
        'id': f'sample-{index}',
        'title': '',
        'notes': '',
        'icon': None,
        'color': None,
        'tags': [],
        'schedule': {'kind': 'daily', 'days': [1, 2, 3, 4, 5], 'timesPerWeek': 3},
        'target': 1,
        'unit': '',
        # EMPTY, ALWAYS. See the docstring — this is the whole change.
        'log': {},
        'archived': False,
        'properties': {},
        'is_sample': True,
    }
    row.update(fields)
    return row


def sample_habits(today=None):
    """
    The example set.

    `today` is accepted and unused, because every other `sample_*` takes it and
    `SampleMixin` is written against one signature. Nothing here is dated: a set
    with no logs has no dates to rot.
    """
    return [
        _sample(
            1,
            title='Walk 30 minutes',
            notes='After lunch, before the afternoon slump. Rain does not count as an excuse.',
            icon='lucide:Footprints',
            color='green',
            tags=['health'],
        ),
        _sample(
            2,
            # THE TARGET IS A FIELD, NOT PART OF THE NAME. The frame calls this
            # "Read 30 pages a day"; here the 30 is the target and `unit` names
            # it, so the cell can show 18/30 and the page can total what was
            # actually read.
            title='Read',
            notes='Paper, not a screen. Ten pages still counts as a partial day.',
            icon='lucide:BookOpen',
            color='violet',
            tags=['mind', 'learning'],
            target=30,
            unit='pages',
        ),
        _sample(
            3,
            title='Strength training',
            notes=(
                'Mon / Wed / Fri only. An empty Tuesday is not a missed day, so the '
                'streak keeps going.'
            ),
            icon='lucide:Dumbbell',
            color='blue',
            tags=['health'],
            schedule={'kind': 'weekdays', 'days': [1, 3, 5], 'timesPerWeek': 3},
        ),
        _sample(
            4,
            title='Drink water',
            notes='Eight glasses. The counter is the point — one tick per glass.',
            icon='lucide:Droplets',
            color='teal',
            tags=['health'],
            # THE HIGHEST TARGET IN THE SET. Eight taps to fill one cell is the
            # case that decides whether a stepper is the right control at all,
            # and whether the cell can still show "5/8" legibly at grid size.
            target=8,
            unit='glasses',
        ),
        _sample(
            5,
            title='Practise Spanish',
            notes=(
                'Three times a week, on whichever days suit. Here the streak counts '
                'weeks, not days.'
            ),
            icon='lucide:Languages',
            color='orange',
            tags=['learning'],
            schedule={'kind': 'weekly', 'days': [1, 2, 3, 4, 5], 'timesPerWeek': 3},
        ),
        _sample(
            6,
            title='Lights out before midnight',
            notes='Missing one night and picking it up the next day is how this is meant to go.',
            icon='lucide:Moon',
            color='pink',
            tags=['health', 'mind'],
        ),
        _sample(
            7,
            title='Morning pages',
            notes='Three pages before the first screen of the day. Weekdays only.',
            icon='lucide:NotebookPen',
            color='amber',
            tags=['mind'],
            schedule={'kind': 'weekdays', 'days': [1, 2, 3, 4, 5], 'timesPerWeek': 3},
            target=3,
            unit='pages',
        ),
        _sample(
            8,
            title='Call someone I have not spoken to in a while',
            notes='Once a week is plenty. A weekly habit with a quota of one.',
            icon='lucide:Phone',
            color='grey',
            tags=['people'],
            schedule={'kind': 'weekly', 'days': [1, 2, 3, 4, 5], 'timesPerWeek': 1},
        ),
    ]
