# Session heatmap API colors

## Intent

Render dashboard session heatmap cells using the upstream `cells[].color` from the heatmap response, alongside the existing session counts and time/day grid. The average heatmap period selector advances in three-month windows to match the upstream average period.

## Goals and constraints

- Treat each upstream cell color as authoritative; do not use the current client palette as a fallback.
- Require and validate six-digit hex colors for weekly and average heatmap cells.
- Keep the existing endpoints, week navigation, values, and grid layout. Remove the client-palette legend because it would no longer describe the rendered colors.
- Derive readable text contrast from each cell's background color; do not substitute a background palette.
- Keep the weekly selector in one-week steps. Move the average selector in three-calendar-month steps and show boundaries derived from the selected period start.
- The average selector and subtitle follow the selected UI period start even when the endpoint returns a different rolling data window, as directed by the user.
- Send the average period start through the existing upstream `week_start` parameter; accept `average_session_period_start` in the dashboard URL and read the legacy `average_session_week_start` value for compatibility.

## Non-goals

- Redesigning the dashboard or changing the weekly heatmap period/query behavior.
- Changing the response values or colors upstream.

## Approaches

- Keep the current client palette: simple, but ignores the upstream color field.
- Use upstream colors as the only cell backgrounds: selected because it follows the supplied response contract and the user's direction. Invalid/missing colors fail parsing instead of falling back.
- Use upstream colors with the current palette as fallback: rejected at the user's direction.

## Implementation calls

- Require colors for both endpoints; the supplied weekly and average responses include a color for every cell.
- Derive the average selector label from the API response period when data is available; otherwise calculate the three-month range from the selected start date.
- Continue deriving cell text and accessible descriptions from the session count and slot/day labels.
