# MTG Python Deckbuilder v4.0.1

## Summary
Major web UI overhaul with Tailwind CSS migration, TypeScript conversion, backend standardization, error handling integration, and testing standards. Includes bug fixes for image cache UI, Scryfall API compatibility, and several deck-building display issues.

## Added
- **Tailwind CSS Migration**: Full CSS rewrite using Tailwind v3 with custom MTG color palette and PostCSS build pipeline
- **TypeScript Migration**: Converted `app.js` and `components.js` to TypeScript with shared type definitions; Docker build compiles automatically
- **Component Library**: Reusable UI component system with macros, partial templates, and living docs at `/docs/components`
- **Card Image Caching**: Optional local image cache (`CACHE_CARD_IMAGES=1`); graceful fallback to Scryfall API
- **Intelligent Synergy Builder**: Analyze multiple builds to create an optimized "best-of" deck with frequency/rank/tag scoring
- **Backend Standardization**: Response builders, telemetry decorators, modular route organization, service layer, and validation framework
- **Error Handling Integration**: Typed domain exceptions mapped to correct HTTP status codes; HTMX requests get HTML error fragments
- **Testing Standards**: Developer guide (`docs/web_backend/testing.md`) and reusable base classes (`base_test_cases.py`)
- **Template Validation Tests**: Automated Jinja2/HTML structure and accessibility regression tests

## Changed
- Inline JavaScript cleanup (~230 lines of legacy card hover code removed)
- JavaScript extracted to TypeScript modules (`cardHover.ts`, `cardImages.ts`)
- Docker build optimized with hot reload for templates and static files
- Test suite consolidated from 148 files to 87 (41% reduction, 100% pass rate maintained)
- Templates modernized to use component system

## Removed
- **Permalink Feature**: Removed permalink generation and restoration; users can still export decks (CSV/TXT/JSON) or use headless configs

## Fixed
- **Image Cache Status UI**: Setup page spinner stuck on "Checking…" after a failed download; error state now shown with failure message
- **Scryfall Bulk Data API**: HTTP 400 error fixed by adding required `Accept: application/json` header
- **Deck Summary Display**: Card images and names now display correctly in List and Thumbnails views
- **Multi-Copy Package Detection**: Multi-copy panel now correctly appears based on commander and theme tags
- **Card Data Auto-Refresh**: Stale cached data resolved; raw parquet deleted before fresh download
- **Template Quality**: Duplicate IDs, erroneous block tags, and HTMX fragment structure issues resolved
- **CommanderValidationError**: Fixed `TypeError` when subclasses passed `code` kwarg to parent `__init__`

## For Users
- Cleaner, faster, more consistent web UI
- Optional card image caching for offline-faster browsing
- Deck analysis across multiple builds with synergy scoring
- More reliable JavaScript behavior across themes (system/light/dark)

## Infrastructure
- Tailwind + PostCSS build pipeline integrated into Docker
- TypeScript compilation in Docker image build
- Backend: service registry, validation models, standardized response shapes
- New docs: `docs/web_backend/error_handling.md`, `docs/web_backend/testing.md`, `docs/web_backend/route_patterns.md`
