/*
 * Badge palette — the single place a badge's colour is decided.
 *
 * Views and components never pick a colour: they name a meaning (BadgeKind → <mdb-badge kind="Scale"> or
 * <Badge Kind="...">) and the class for that meaning, defined here, supplies the colour.
 *
 * Two layers:
 *   1. TONES  (--mdb-tone-*)  generic roles built from the site theme's Bootstrap colours, which each site's
 *      [data-theme] block already sets from historic livery colours.
 *   2. MEANINGS (.badge-*)    what a badge represents, mapped to a tone — or, for kinds of model, to a colour of
 *      their own so a kind is never mistaken for a status.
 *
 * PALETTE RULE: every colour comes from the historical rail or bus liveries/branding the sites are built on
 * (see the comments in each site's site.css). New colours are added to a theme block below, named after their
 * source. Hex values for historic colours are approximations of how they are commonly reproduced.
 *
 * Text colours are set explicitly (Bootstrap computes them at build time for its default palette, which is wrong
 * once the theme swaps the colour — e.g. white on BR Rail Grey), and were checked for WCAG AA (4.5:1) contrast.
 */

:root {
    /* Tones — defaults follow whichever theme is active. */
    --mdb-tone-neutral-bg: var(--bs-secondary);   --mdb-tone-neutral-fg: #fff;
    --mdb-tone-info-bg: var(--bs-info);           --mdb-tone-info-fg: #000;
    --mdb-tone-positive-bg: var(--bs-success);    --mdb-tone-positive-fg: #fff;
    --mdb-tone-warning-bg: var(--bs-warning);     --mdb-tone-warning-fg: #000;
    --mdb-tone-negative-bg: var(--bs-danger);     --mdb-tone-negative-fg: #fff;
    --mdb-tone-accent-bg: var(--bs-primary);      --mdb-tone-accent-fg: #fff;
    --mdb-tone-subtle-bg: var(--bs-light);        --mdb-tone-subtle-fg: #212529;

    /* Kinds of model — a theme gives each its own colour; without one they fall back to neutral. */
    --mdb-kind-locomotive-bg: var(--mdb-tone-neutral-bg);  --mdb-kind-locomotive-fg: var(--mdb-tone-neutral-fg);
    --mdb-kind-coach-bg: var(--mdb-tone-neutral-bg);       --mdb-kind-coach-fg: var(--mdb-tone-neutral-fg);
    --mdb-kind-wagon-bg: var(--mdb-tone-neutral-bg);       --mdb-kind-wagon-fg: var(--mdb-tone-neutral-fg);
    --mdb-kind-decoder-bg: var(--mdb-tone-neutral-bg);     --mdb-kind-decoder-fg: var(--mdb-tone-neutral-fg);
    --mdb-kind-spare-bg: var(--mdb-tone-neutral-bg);       --mdb-kind-spare-fg: var(--mdb-tone-neutral-fg);
}

/* ---- Rail theme ---------------------------------------------------------------------------------------------
   Status tones come from the rail theme's Bootstrap colours in site.css (BR Rail Blue, BR Rail Grey, BR Brunswick
   Green, BR Carmine, BR Cream, InterCity Executive Light Blue). */
[data-theme="rail"] {
    --mdb-tone-neutral-fg: #212529;                     /* dark text: white is unreadable on BR Rail Grey */

    /* Kinds of model. Not status colours: red/green/yellow/blue mean Not made/Special/Warning/Accent elsewhere. */
    --mdb-kind-locomotive-bg: var(--bs-primary);        /* BR Rail Blue — the locomotive livery of the modern era */
    --mdb-kind-locomotive-fg: #fff;
    --mdb-kind-coach-bg: #5b3a29;                       /* GWR Chocolate (of Chocolate & Cream) */
    --mdb-kind-coach-fg: var(--bs-warning);             /* BR Cream, the other half of the livery */
    --mdb-kind-wagon-bg: #a04a22;                       /* BR Bauxite — the freight wagon colour */
    --mdb-kind-wagon-fg: #fff;
    --mdb-kind-decoder-bg: #00a4a7;                     /* Docklands Light Railway teal — the driverless, automated railway */
    --mdb-kind-decoder-fg: #000;
    --mdb-kind-spare-bg: #1d1d1b;                       /* Loadhaul black … */
    --mdb-kind-spare-fg: #e8641b;                       /* … and Loadhaul orange */
}

/* ---- Bus theme ----------------------------------------------------------------------------------------------
   Kinds of model are a rail concept; the bus sites have no use for them yet. When they need kinds, add them here
   from bus liveries (London Buses Red, NBC Leaf Green, NBC Poppy Red, Green Line green…). */

/* ---- Meanings ------------------------------------------------------------------------------------------------ */

.badge-scale, .badge-spec,
.badge-status-neutral {
    color: var(--mdb-tone-neutral-fg);
    background-color: var(--mdb-tone-neutral-bg);
}

.badge-finish, .badge-status-info {
    color: var(--mdb-tone-info-fg);
    background-color: var(--mdb-tone-info-bg);
}

.badge-dcc, .badge-special, .badge-new, .badge-condition-new,
.badge-status-positive {
    color: var(--mdb-tone-positive-fg);
    background-color: var(--mdb-tone-positive-bg);
}

.badge-not-made,
.badge-status-negative {
    color: var(--mdb-tone-negative-fg);
    background-color: var(--mdb-tone-negative-bg);
}

.badge-condition-used,
.badge-status-warning {
    color: var(--mdb-tone-warning-fg);
    background-color: var(--mdb-tone-warning-bg);
}

.badge-year, .badge-incomplete {
    color: var(--mdb-tone-warning-fg);
    background-color: var(--mdb-tone-warning-bg);
    border: var(--bs-border-width) solid var(--bs-border-color);
}

.badge-era, .badge-detail {
    color: var(--mdb-tone-subtle-fg);
    background-color: var(--mdb-tone-subtle-bg);
    border: var(--bs-border-width) solid var(--bs-border-color);
}

.badge-caption {
    color: var(--mdb-tone-subtle-fg);
    background-color: var(--mdb-tone-subtle-bg);
    font-size: 1rem;
}

.badge-count,
.badge-status-accent {
    color: var(--mdb-tone-accent-fg);
    background-color: var(--mdb-tone-accent-bg);
}

.badge-kind-locomotive { color: var(--mdb-kind-locomotive-fg); background-color: var(--mdb-kind-locomotive-bg); }
.badge-kind-coach      { color: var(--mdb-kind-coach-fg);      background-color: var(--mdb-kind-coach-bg); }
.badge-kind-wagon      { color: var(--mdb-kind-wagon-fg);      background-color: var(--mdb-kind-wagon-bg); }
.badge-kind-decoder    { color: var(--mdb-kind-decoder-fg);    background-color: var(--mdb-kind-decoder-bg); }
.badge-kind-spare      { color: var(--mdb-kind-spare-fg);      background-color: var(--mdb-kind-spare-bg); }
