/* ============================================
   pc-tokens.css - PollCheck design system tokens
   Single source of truth for colour, type and party palette.
   Prefix: --pc-*. White default (gb-polls palette).
   Dark mode: overridden under body.dark-mode (slate ramp).
   Party hexes: Wikipedia Index of UK political parties
   meta attributes (fetched 30 Aug 2026). JS mirror:
   js/party-colors.js - keep the two in sync.
   ============================================ */

:root {
    /* Surfaces */
    --pc-bg: #FAFAFA;
    --pc-surface: #FFFFFF;
    --pc-hover-bg: #FAFAFA;
    --pc-tint: #F7F7F7;
    --pc-on-ink: #FFFFFF;

    /* Text ramp */
    --pc-text: #111111;
    --pc-text-body: #333333;
    --pc-text-secondary: #555555;
    /* meta / muted darkened Nov 2026 for WCAG AA (4.5:1 on white, #FAFAFA and
       #F7F7F7): #999 2.8:1 -> #6B6B6B 5.3:1; #AAA 2.3:1 -> #707070 5.0:1 */
    --pc-text-meta: #6B6B6B;
    --pc-text-muted: #707070;

    /* Borders */
    --pc-border: #E0E0E0;
    --pc-border-light: #EEEEEE;
    --pc-border-grid: #F0F0F0;

    /* Semantic */
    --pc-positive: #1F7A1F;        /* was #2A9D2A (3.5:1); 5.4:1 on white */
    --pc-negative: #C0392B;
    --pc-nc: #CCCCCC;
    --pc-accent: #C2410C;          /* fill behind white text (5.2:1) */
    --pc-accent-text: #C2410C;     /* accent used as text: 5.2:1 on white */
    --pc-warning: #876800;         /* was #b08800 (3.3:1); 5.2:1 on white */

    /* Inverted chips / tooltips */
    --pc-tooltip-bg: #1a1a1a;
    --pc-tooltip-text: #ffffff;

    /* Form controls */
    --pc-slider-track: #E0E0E0;

    /* Type */
    --pc-serif: Georgia, "Times New Roman", serif;
    --pc-sans: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

    /* Shape */
    --pc-radius: 0;

    /* Party palette (canonical) */
    --pc-party-con: #0087DC;
    --pc-party-lab: #E41C3E;
    --pc-party-ld: #FAA61A;
    --pc-party-ref: #1EB8D0;
    --pc-party-grn: #02A95B;
    /* SNP deviates from the Wikipedia hex (#FDF38E): too pale on white,
       kept at the swingometer's stronger yellow instead */
    --pc-party-snp: #FFED4A;
    --pc-party-pc: #008672;
    --pc-party-sgn: #00B140;
    --pc-party-alba: #005EB8;
    --pc-party-res: #1B3A6B;
    --pc-party-yp: #7C3AED;
    --pc-party-gyf: #051E40;
    --pc-party-asp: #FF5800;
    --pc-party-ashind: #FFC0CB;
    --pc-on-party-dark: #FFFFFF;   /* text on navy party fills (res, gyf); same in both themes */
    --pc-on-party-light: #111111;  /* text on light party fills (ld, snp); same in both themes */
    --pc-party-ukip: #6D3177;
    --pc-party-ind: #DCDCDC;
    --pc-party-oth: #999999;
    /* US parties (/midterms-2026): Wikipedia meta colours for the
       Democratic (#3333FF) and Republican (#E81B23) parties. US independents
       get a mid purple: Wikipedia's #DCDCDC is too pale for lines and map fills. */
    --pc-party-dem: #3333FF;
    --pc-party-rep: #E81B23;
    --pc-party-usind: #8E6BBF;

    /* Party colour as TEXT (end-of-line labels, party-coloured headers):
       the fill hue darkened just enough for 4.5:1 on every light ground,
       cream included. Fills and swatches keep --pc-party-*. Parties whose
       fill already passes (alba, res, yp, gyf, ukip) point at the fill. */
    --pc-party-con-text: #036FB3;
    --pc-party-lab-text: #D31B3A;
    --pc-party-ld-text: #916316;
    --pc-party-ref-text: #197584;
    --pc-party-grn-text: #067B45;
    --pc-party-snp-text: #756D29;
    --pc-party-pc-text: #027A68;
    --pc-party-sgn-text: #067C30;
    --pc-party-alba-text: var(--pc-party-alba);
    --pc-party-res-text: var(--pc-party-res);
    --pc-party-yp-text: var(--pc-party-yp);
    --pc-party-gyf-text: var(--pc-party-gyf);
    --pc-party-asp-text: #BC4405;
    --pc-party-ukip-text: var(--pc-party-ukip);
    --pc-party-oth-text: #6C6C6C;
    /* Lightness bounds (CIE L*) for party colour on text where the party is
       only known at runtime (--party-color slot): lch(from ... clamp()) keeps
       the hue and pulls L* into the band that reads on this theme's ground. */
    --pc-party-text-lmin: 0;
    --pc-party-text-lmax: 44;

    /* US state supreme courts (/state-supreme-courts): selection methods.
       Not partisan, so deliberately clear of the party blues and reds.
       --pc-court-on is label text on the four dark fills; retention (amber)
       takes --pc-on-party-light. Mirrors css/pc-tokens.css. */
    --pc-court-partisan: #6B3FA0;
    --pc-court-nonpartisan: #0E7C7B;
    --pc-court-retention: #E0A526;
    --pc-court-appointed: #5B6B7F;
    --pc-court-legislative: #8B5A2B;
    --pc-court-on: #FFFFFF;
}

/* Dark mode - shared slate ramp (matches gb-polls / p2n / swingometer) */
body.dark-mode {
    --pc-bg: #0f172a;
    --pc-surface: #1e293b;
    --pc-hover-bg: #273548;
    --pc-tint: #243247;
    --pc-on-ink: #0f172a;

    --pc-text: #f8fafc;
    --pc-text-body: #e2e8f0;
    --pc-text-secondary: #cbd5e1;
    --pc-text-meta: #94a3b8;
    --pc-text-muted: #94a3b8;      /* was #64748b (3.1:1 on #1e293b); 5.7:1 */

    --pc-border: #334155;
    --pc-border-light: #3a4a60;
    --pc-border-grid: #2a3548;

    --pc-positive: #4ade80;
    --pc-negative: #f87a7a;        /* was #f87171 (4.49:1 on the #273548 row hover); 4.8:1 */
    --pc-nc: #475569;
    --pc-accent: #C2410C;          /* was #EA580C: white text on it 3.6:1 -> 5.2:1 */
    --pc-accent-text: #FB923C;     /* accent used as text: 6.5:1 on #1e293b */
    --pc-warning: #fbbf24;

    --pc-tooltip-bg: #f8fafc;
    --pc-tooltip-text: #0f172a;

    --pc-slider-track: #4a5a73;

    /* Party colour as text on the slate ground (4.5:1 on #1e293b and the
       #243247 tint): lightened towards the text ink where needed */
    --pc-party-con-text: #43A6E5;
    --pc-party-lab-text: #ED7B90;
    --pc-party-ld-text: #FAA61A;
    --pc-party-ref-text: #1EB8D0;
    --pc-party-grn-text: #22B470;
    --pc-party-snp-text: #FFED4A;
    --pc-party-pc-text: #54ADA1;
    --pc-party-sgn-text: #11B64D;
    --pc-party-alba-text: #6DA3D6;
    --pc-party-res-text: #90A0B8;
    --pc-party-yp-text: #B08BF3;
    --pc-party-gyf-text: #94A0AF;
    --pc-party-asp-text: #FE752D;
    --pc-party-ukip-text: #B296BA;
    --pc-party-oth-text: #9E9E9E;
    --pc-party-text-lmin: 64;
    --pc-party-text-lmax: 100;

    --pc-court-partisan: #A98BDB;
    --pc-court-nonpartisan: #3DBDBA;
    --pc-court-retention: #F2B84B;
    --pc-court-appointed: #94A3B8;
    --pc-court-legislative: #C8925F;
    --pc-court-on: #0f172a;
}

/* Cream surface variant - tool pages that keep the warm ground
   (demographic swingometer, path-to-no10, seat-tracker). Opt in with
   body.pc-cream. Light mode only: dark mode uses the shared slate ramp.
   Text ramp, party colours and semantics stay canonical. */
body.pc-cream:not(.dark-mode) {
    --pc-bg: #F5F0E6;
    --pc-tint: #FAF6EC;
    --pc-hover-bg: #FAF6EC;
    --pc-border: #D8CFBA;
    --pc-border-light: #E6DFCC;
    --pc-border-grid: #EFE9D9;
    --pc-slider-track: #D8CFBA;
    /* the one text-ramp change: muted needs a step more on the cream ground
       (#707070 is 4.4:1 on #F5F0E6; #6B6B6B is 4.7:1) */
    --pc-text-muted: #6B6B6B;
}
