<?php

namespace App\Domain\Training\Support;

/**
 * One palette for group colours, shared by the schedule builder and every
 * printed sheet.
 *
 * Screen and paper must agree: a coach who learns "our group is the teal one"
 * on the wall board should see the same teal in the app. Two copies of this
 * list would drift the first time either side was edited.
 *
 * Hues are chosen to stay distinguishable in greyscale too, because plenty of
 * academies print these on a mono laser.
 */
final class GroupColor
{
    public const PALETTE = [
        '#1D4ED8', // blue
        '#047857', // emerald
        '#B45309', // amber
        '#B91C1C', // red
        '#6D28D9', // violet
        '#BE185D', // pink
        '#0E7490', // cyan
        '#4D7C0F', // lime
        '#C2410C', // orange
        '#4338CA', // indigo
        '#0F766E', // teal
        '#A21CAF', // fuchsia
        '#0369A1', // sky
        '#15803D', // green
        '#7E22CE', // purple
    ];

    public static function for(int $id): string
    {
        return self::PALETTE[$id % count(self::PALETTE)];
    }

    /**
     * A tint of the group colour for cell backgrounds — dark enough to identify,
     * light enough to keep the text on top above 4.5:1.
     */
    public static function tint(int $id): string
    {
        return self::for($id) . '1A'; // ~10% alpha
    }
}
