/* ===========================================================================
   COLOUR ACROSS THE FRAME (13 Oct 2026, chat FRAME COLOUR, his notes relayed
   by CASE HEADER): every study is in its company's colours, and his lime
   shows only in the Next footer. Tokens only.

   1. Each study's palette, keyed on <html data-study>. Colours come from the
      study's kit (<client>/build/kit.css, read only): Bupa blue, its deep
      blue and the kit's teal; Virgin Australia red. A study with no kit yet
      takes its brand token from tokens.css; his own design system and
      plugin take his lime as their company colour.
        --cs-c      the brand colour       --cs-c-on   words on it
        --cs-c-deep a step deeper          --cs-c-2    the gradient's partner
        --cs-c-text the colour for small marks on the page ground
   2. The lime swap: inside the case study, every frame part but the Next
      footer reads --brand-primary as the study's colour, so the title's
      full stop, the number ticks, Looking back's rule, the deep dive button
      and the chapter rail all turn the company's colour at once.
   3. The numbers band (look A, locked): always the company's colour, never
      the lime gradient. The Colour row's other options (a moving gradient,
      Bupa's bright set), its engine (lime-ground.js, frame-colour.js) and
      the Dark parts row left on 20 Oct (chat FRAME SPLIT, backup
      _before-split-5/): the frame is locked to Plain and no dark parts.
   =========================================================================== */

/* ---- 1. palettes ---- */
:root {
  --cs-c: var(--neutral-850);
  --cs-c-on: var(--neutral-0);
  --cs-c-deep: var(--neutral-900);
  --cs-c-2: var(--neutral-700);
  --cs-c-text: var(--color-text-primary);
}
:root[data-study="bupa"] {
  --cs-c: var(--ext-brand-bupa-blue);
  --cs-c-deep: var(--ext-brand-bupa-blue-dark);
  --cs-c-2: var(--bpk-teal, var(--ext-brand-bupa-blue-dark));
  --cs-c-text: var(--ext-brand-bupa-blue-dark);
  /* the bright set, near Bupa's own (Bupa uses no gradients) */
  --cs-b-light: color-mix(in oklab, var(--ext-brand-bupa-blue) 45%, var(--neutral-0));
  --cs-b-teal: var(--bpk-teal, var(--ext-brand-bupa-blue-dark));
  --cs-b-yellow: var(--ext-brand-wcag-amber);
}
:root[data-study="virgin-australia"] {
  --cs-c: var(--ext-brand-virgin);
  --cs-c-deep: color-mix(in oklab, var(--ext-brand-virgin) 62%, var(--neutral-900));
  --cs-c-2: color-mix(in oklab, var(--ext-brand-virgin) 55%, var(--neutral-900));
  --cs-c-text: var(--ext-brand-virgin);
}
:root[data-study="hcf"] {
  --cs-c: var(--ext-brand-hcf);
  --cs-c-deep: color-mix(in oklab, var(--ext-brand-hcf) 62%, var(--neutral-900));
  --cs-c-2: color-mix(in oklab, var(--ext-brand-hcf) 55%, var(--neutral-900));
  --cs-c-text: var(--ext-brand-hcf);
}
:root[data-study="watchman"] {
  --cs-c: var(--ext-brand-hhf);
  --cs-c-deep: color-mix(in oklab, var(--ext-brand-hhf) 62%, var(--neutral-900));
  --cs-c-2: color-mix(in oklab, var(--ext-brand-hhf) 55%, var(--neutral-900));
  --cs-c-text: var(--ext-brand-hhf);
}
/* small marks on a dark page ground: the brand colour lifted toward white */
[data-theme="dark"] { --cs-c-text: color-mix(in oklab, var(--cs-c) 60%, var(--neutral-0)); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --cs-c-text: color-mix(in oklab, var(--cs-c) 60%, var(--neutral-0)); }
}
/* His own two studies (his design system and his Figma plugin): his lime is
   their company colour, the way Bupa blue is Bupa's (his pick, 13 Oct). Ink
   words on lime, as on his site. */
:root:is([data-study="design-system"], [data-study="token-exporter"]) {
  --cs-c: var(--lime-500);
  --cs-c-on: var(--brand-ink);
  --cs-c-deep: var(--lime-600);
  --cs-c-2: var(--brand-primary-vivid);
  --cs-c-text: var(--lime-500);
}

/* ---- 2. the lime swap: everything but the Next footer ---- */
.cs :is(.cs-part:not(.cs-next), .cs-middle, .cs-wires, .cs-chap),
.cs .csh-list {
  --brand-primary: var(--cs-c-text);
  --brand-spot: var(--cs-c-2);
  --brand-gradient: linear-gradient(135deg in oklab, var(--cs-c) 0%, var(--cs-c-2) 100%);
  --btn-primary-bg: var(--cs-c);
  --btn-primary-fg: var(--cs-c-on);
  --btn-primary-border: var(--cs-c);
  --btn-primary-bg-hover: var(--cs-c-deep);
  --btn-primary-fg-hover: var(--cs-c-on);
  --client-primary: var(--cs-c);
}

/* ---- 3. the numbers band: look A, the company's colour. The selector
   outranks look A's own band rule in looks.css (0,4,0). Look A only: HERO
   MIX locks the numbers to A. ---- */
html:root[data-numbers="plates"] .cs .cs-part.cs-numbers[data-part="numbers"] {
  --cs-num-bg: var(--cs-c);
  --cs-num-fg: var(--cs-c-on);
  position: relative; isolation: isolate;
}
:root[data-numbers="plates"] .cs .cs-numbers .cs-stat-src { opacity: 1; }
:root[data-numbers="plates"] .cs .cs-numbers .cs-stat::before { background: var(--cs-num-fg); }


/* Look A's numerals size to the band, not the window: with both review
   rails open the third number ran off the band at 1280 (13 Oct, chat FRAME
   COLOUR). The list is the container (a stat cannot be one: Virgin's grid
   sizes its stats from their content). Three columns: 11% of the list fits
   "1,714 -> 450" in a third; one column on a phone: 28%. */
:root[data-numbers="plates"] .cs .cs-numbers .cs-stats { container-type: inline-size; }
:root[data-numbers="plates"] .cs .cs-part.cs-numbers .cs-stat-num { font-size: clamp(2.5rem, 11cqi, 7rem); } /* mock-ok: same display ramp as looks.css, sized to the band */
@media (max-width: 767.98px) {
  :root[data-numbers="plates"] .cs .cs-part.cs-numbers .cs-stat-num { font-size: clamp(2.5rem, 28cqi, 6rem); } /* mock-ok: as above, one column */
}

/* The band picks its columns from its own width, not the window (20 Oct 2026,
   chat RAIL SETTLED, BUPA INTAKE FLOW's report): with both review rails open
   at 768 the band is 224px wide and three columns ran 291px off it (45px at
   1024). Under 600px of band the numbers stack, one per row, as on a phone.
   600 clears the widest set today, Bupa's, which needs about 570px.
   The two widths are in rem since 20 Nov 2026 (chat READABILITY FIX), 37.5rem being 600px at the default text size:
   a reader at 200% text gets the stacked numbers until the band is twice as wide, where three columns fit again. */
:root[data-numbers="plates"] .cs .cs-part.cs-numbers { container: cs-band / inline-size; }
@container cs-band (max-width: 37.49875rem) {
  :root[data-numbers="plates"] .cs .cs-part.cs-numbers .cs-stats { grid-template-columns: minmax(0, 1fr); }
  :root[data-numbers="plates"] .cs .cs-part.cs-numbers .cs-stat-num { font-size: clamp(2.5rem, 28cqi, 6rem); } /* mock-ok: the phone's one-column ramp */
}

/* Look A's numbers line up across the band (13 Oct, his note): each part of
   a number (the figure, its label, the change, the badge, the source, a
   note) sits on one shared row, so the badges stay level even when one
   label wraps. Columns size to their words, so a longer label takes a wider
   column and stays on one line while the band has room. A band 600px wide
   and up (was tablet and up, by the window, until 20 Oct); a narrower band
   stacks the numbers, one per row. */
@container cs-band (min-width: 37.5rem) {
  :root[data-numbers="plates"] .cs .cs-part.cs-numbers:where(:not([data-stack])) .cs-stats { grid-template-columns: repeat(3, auto); row-gap: 0; }
  :root[data-numbers="plates"] .cs .cs-part.cs-numbers:where(:not([data-stack])) .cs-stat { display: grid; grid-row: span 6; grid-template-rows: subgrid; row-gap: 0; align-content: start; }
  :root[data-numbers="plates"] .cs .cs-numbers:where(:not([data-stack])) .cs-stat > * { margin: 0; }
  :root[data-numbers="plates"] .cs .cs-numbers:where(:not([data-stack])) .cs-stat-num { grid-row: 1; }
  :root[data-numbers="plates"] .cs .cs-numbers:where(:not([data-stack])) .cs-stat-label { grid-row: 2; margin-top: var(--space-200); text-wrap: balance; }
  :root[data-numbers="plates"] .cs .cs-numbers:where(:not([data-stack])) .cs-change { grid-row: 3; margin-top: var(--space-200); }
  :root[data-numbers="plates"] .cs .cs-numbers:where(:not([data-stack])) .cs-tag { grid-row: 4; margin-top: var(--space-300); justify-self: start; align-self: start; }
  :root[data-numbers="plates"] .cs .cs-numbers:where(:not([data-stack])) .cs-stat-src { grid-row: 5; margin-top: var(--space-200); }
  :root[data-numbers="plates"] .cs .cs-numbers:where(:not([data-stack])) .cs-stat-note { grid-row: 6; margin-top: var(--space-200); }
}
/* A band whose three columns still cannot fit stacks too (20 Nov 2026, chat READABILITY FIX): under a reader's own
   text spacing the columns ran past a band 600 to 640 wide and cut the third figure. study.js measures the list and
   marks the band data-stack; the three-column rules above step aside (their :where() adds no weight) and the list
   takes the one column of the narrower band. The figures keep the size they already have at that window width: the
   one-column ramp under 768, where this happens today. */
:root[data-numbers="plates"] .cs .cs-part.cs-numbers[data-stack] .cs-stats { grid-template-columns: minmax(0, 1fr); }
