/*
 * Design tokens — THE one source (kit Directive 17). No inline hex anywhere else.
 *
 * Direction: "Night grid", soft and big (round two). Canon: saturated accents on SMALL areas over a
 * near-neutral, gridded ground (design-canon-colour.md). The ground is cool
 * paper; the frame of the app (header, sign-in picture) is night navy with one
 * electric line of signal. --color-link is reserved for links ONLY — a violet
 * that is neither the blue accent nor any status colour, so color = meaning
 * stays unambiguous. Header navigation is a link too: on night it wears
 * --color-night-link, the same violet lifted so it reads on navy. Keyboard
 * focus has its own token, --color-focus, so the ring is never the accent.
 *
 * Round two (the owner's decisions): everything pressable is SOFT (tinted
 * pills, rounded fields) and the pages are BIG: a picture band behind every
 * page title, a photograph on the sign-in pages. Pictures are covered by the
 * --shade-* overlays below; those and the shadows are the only values in the
 * product that are not plain hex, and they live here like every other.
 *
 * Three kinds of line, never mixed up:
 *   --color-rule            a hairline between things (decorative, any contrast)
 *   --color-control-border  the edge of something you press or type in (>= 3:1)
 *   --color-night-control   the same, for the buttons in the night header
 *
 * Contrast, WCAG 2.1 relative luminance, computed by tools/contrast.py from
 * the values below (ratios are floored, never rounded up). TEXT needs 4.5,
 * EDGE / FOCUS / GLYPH need 3.0. Re-run the script after changing any value.
 *
 *   pair                                                                light   dark  needs
 *   TEXT ink on bg (body)                                               16.34  15.20  4.5
 *   TEXT ink on surface (cards, board lane)                             14.91  13.31  4.5
 *   TEXT ink on field (inputs, quiet buttons, board cards)              17.39  16.09  4.5
 *   TEXT muted on bg (meta lines, notes)                                 6.57   7.84  4.5
 *   TEXT muted on surface                                                5.99   6.87  4.5
 *   TEXT muted on field (board card meta)                                6.99   8.30  4.5
 *   TEXT link on bg                                                      6.40   9.35  4.5
 *   TEXT link on surface                                                 5.84   8.18  4.5
 *   TEXT link on field (board card name)                                 6.80   9.89  4.5
 *   TEXT link on open tint (tick-many banner)                            5.73   7.16  4.5
 *   TEXT link on working tint (waiting banner)                           5.97   7.58  4.5
 *   TEXT accent-ink on accent (primary button, skip link)                6.64   7.70  4.5
 *   TEXT accent-ink on accent-hover                                      8.77   9.69  4.5
 *   TEXT danger on bg (trouble)                                          6.14   8.24  4.5
 *   TEXT danger on surface (trouble in a card)                           5.60   7.22  4.5
 *   TEXT ink on open tint (chip, banner)                                14.64  11.65  4.5
 *   TEXT ink on working tint (chip, banner)                             15.27  12.33  4.5
 *   TEXT ink on won tint (chip, message)                                15.02  11.37  4.5
 *   TEXT ink on lost tint (chip)                                        14.52  12.00  4.5
 *   TEXT ink on do-not-contact tint (chip, error)                       14.51  12.32  4.5
 *   TEXT night-ink on night (brand, nav, panel line)                    16.11  17.29  4.5
 *   TEXT night-muted on night (name, panel caption)                      9.08   9.75  4.5
 *   EDGE control-border on bg                                            4.44   4.39  3.0
 *   EDGE control-border on surface                                       4.05   3.84  3.0
 *   EDGE control-border against its own field fill                       4.72   4.65  3.0
 *   EDGE control-border on open tint                                     3.98   3.36  3.0
 *   EDGE control-border on working tint                                  4.15   3.56  3.0
 *   EDGE primary button (accent) on bg                                   6.24   7.54  3.0
 *   EDGE primary button on surface                                       5.69   6.60  3.0
 *   EDGE primary button on working tint                                  5.83   6.12  3.0
 *   EDGE primary button on open tint                                     5.59   5.78  3.0
 *   EDGE header button border on night                                   5.15   5.09  3.0
 *   FOCUS ring on bg                                                    15.66  16.98  3.0
 *   FOCUS ring on surface                                               14.29  14.87  3.0
 *   FOCUS ring on field                                                 16.66  17.97  3.0
 *   FOCUS ring on working tint                                          14.63  13.77  3.0
 *   FOCUS ring on open tint                                             14.03  13.01  3.0
 *   FOCUS signal ring on night (header)                                  7.08   7.59  3.0
 *   TEXT night on signal (skip link)                                     7.08   7.59  4.5
 *   FOCUS night-ink ring on night (skip link)                           16.11  17.29  3.0
 *   EDGE skip link fill on night                                         7.08   7.59  3.0
 *   TEXT night-link on night (header navigation)                        11.95  12.83  4.5
 *   TEXT night-ink on night-raised (hovered header button)              13.30  14.75  4.5
 *   TEXT link on won tint (message)                                      5.88   6.99  4.5
 *   TEXT link on do-not-contact tint (error message)                     5.68   7.58  4.5
 *   TEXT muted on field (placeholder)                                    6.99   8.30  4.5
 *   TEXT muted on surface (paused card)                                  5.99   6.87  4.5
 *   TEXT ink on surface (paused card)                                   14.91  13.31  4.5
 *   EDGE board card rail open: accent on field                           6.64   7.98  3.0
 *   EDGE board card rail working: warn on field                          5.81  10.96  3.0
 *   EDGE board card rail won: ok on field                                5.34  10.51  3.0
 *   EDGE board card rail lost: muted on field                            6.99   8.30  3.0
 *   EDGE board card rail do-not-contact: danger on field                 6.53   8.73  3.0
 *   GLYPH open chip mark: accent on open tint                            5.59   5.78  3.0
 *   GLYPH working chip mark: warn on working tint                        5.10   8.40  3.0
 *   GLYPH won chip mark: ok on won tint                                  4.61   7.43  3.0
 *   GLYPH lost chip mark: muted on lost tint                             5.83   6.19  3.0
 *   GLYPH do-not-contact mark: danger on its tint                        5.45   6.68  3.0
 *   GLYPH board rail open: accent on surface                             5.69   6.60  3.0
 *   GLYPH board rail working: warn on surface                            4.99   9.07  3.0
 *   GLYPH board rail won: ok on surface                                  4.58   8.69  3.0
 *   GLYPH board rail lost: muted on surface                              5.99   6.87  3.0
 *   GLYPH board rail do-not-contact: danger on surface                   5.60   7.22  3.0
 *   GLYPH current-page bar: signal on night                              7.08   7.59  3.0
 *   GLYPH title bar / section tick / timeline node: accent on bg         6.24   7.54  3.0
 *   GLYPH banner edge: warn on bg                                        5.46  10.36  3.0
 *   GLYPH ok edge: ok on bg                                              5.02   9.93  3.0
 *   GLYPH error edge: danger on bg                                       6.14   8.24  3.0
 *   GLYPH mark tile: signal on night                                     7.08   7.59  3.0
 *   GLYPH mark letter: night on signal                                   7.08   7.59  3.0
 *   GLYPH empty/404 drawing line: control-border on bg                   4.44   4.39  3.0
 *   TEXT soft-ink on soft (quiet button)                                 8.35   9.43  4.5
 *   TEXT soft-ink on soft-hover                                          7.40   7.89  4.5
 *   TEXT soft-ink on soft-press                                          6.33   6.13  4.5
 *   TEXT accent-ink on accent-press (pressed primary)                   11.70   5.80  4.5
 *   EDGE soft-edge on bg (quiet button outline)                          3.87   4.69  3.0
 *   EDGE soft-edge on surface                                            3.53   4.10  3.0
 *   EDGE soft-edge on card                                               4.12   4.41  3.0
 *   EDGE soft-edge on working tint                                       3.62   3.80  3.0
 *   EDGE soft-edge on open tint                                          3.47   3.59  3.0
 *   EDGE soft-edge against its own fill                                  3.47   3.83  3.0
 *   EDGE control-border on card                                          4.72   4.13  3.0
 *   EDGE control-border against field-rest (field at rest)               4.24   4.17  3.0
 *   EDGE accent against field (focused field)                            6.64   7.98  3.0
 *   TEXT ink on field-rest (typed text)                                 15.60  14.46  4.5
 *   TEXT muted on field-rest (placeholder)                               6.27   7.46  4.5
 *   TEXT ink on card                                                    17.39  14.29  4.5
 *   TEXT muted on card                                                   6.99   7.38  4.5
 *   TEXT link on card                                                    6.80   8.79  4.5
 *   TEXT link-hover on bg                                                9.82  13.10  4.5
 *   TEXT link-hover on card                                             10.45  12.32  4.5
 *   TEXT link-hover on surface                                           8.96  11.48  4.5
 *   TEXT link-hover on working tint                                      9.18  10.63  4.5
 *   TEXT link-hover on open tint                                         8.80  10.04  4.5
 *   TEXT danger on card                                                  6.53   7.75  4.5
 *   TEXT off-ink on off-bg (switched-off control)                        4.91   6.25  4.5
 *   EDGE off-edge on bg (switched-off outline)                           3.36   3.81  3.0
 *   EDGE off-edge on card                                                3.57   3.58  3.0
 *   FOCUS ring on card                                                  16.66  15.96  3.0
 *   FOCUS ring on soft (quiet button)                                   14.06  13.89  3.0
 *   GLYPH tick: accent-ink on accent                                     6.64   7.70  3.0
 *   GLYPH ticked box: accent on card                                     6.64   7.09  3.0
 *   GLYPH section bar / timeline node: accent on card                    6.64   7.09  3.0
 *   GLYPH chip mark on card: warn                                        5.81   9.74  3.0
 *   GLYPH chip mark on card: ok                                          5.34   9.33  3.0
 *   TEXT night-ink on night-soft (current page pill, band button)       11.48  12.35  4.5
 *   TEXT night-link on night-soft (current page pill)                    8.52   9.16  4.5
 *   TEXT night-link on night-raised (hovered nav pill)                   9.86  10.94  4.5
 *   TEXT night-ink on night-press (pressed band button)                  8.62   9.48  4.5
 *   TEXT night on signal (primary button on a band)                      7.08   7.59  4.5
 *   TEXT night on signal-2 (the same, hovered)                          10.71  11.50  4.5
 *   EDGE night-control against night-soft (band button)                  3.67   3.63  3.0
 *   EDGE night-control on night-raised                                   4.25   4.34  3.0
 *   TEXT night-off on night (switched-off band button)                   5.94   6.38  4.5
 *   TEXT mark-ink on mark 1..6 (a person's letters, lowest of the six)   5.31   8.45  4.5
 *   GLYPH mark 1..6 on card (a person's mark, lowest of the six)         5.31   7.78  3.0
 *   GLYPH mark 1..6 on bg                                                4.99   8.28  3.0
 *   GLYPH mark 1..6 on surface                                           4.55   7.25  3.0
 *   GLYPH mark 1..6 on open tint (a chosen person, a painted row)        4.47   6.34  3.0
 *
 *   watermark (ink at 11%) on bg                 light: 1.24:1 against the ground; ink text crossing it keeps 13.13:1
 *   watermark (ink at 11%) on surface            light: 1.24:1 against the ground; ink text crossing it keeps 12.01:1
 *   watermark (ink at 11%) on field              light: 1.25:1 against the ground; ink text crossing it keeps 13.93:1
 *   watermark (ink at 11%) on card               light: 1.25:1 against the ground; ink text crossing it keeps 13.93:1
 *   watermark (ink at 11%) on status-working-bg  light: 1.24:1 against the ground; ink text crossing it keeps 12.28:1
 *   watermark (ink at 11%) on bg                 dark : 1.32:1 against the ground; ink text crossing it keeps 11.50:1
 *   watermark (ink at 11%) on surface            dark : 1.35:1 against the ground; ink text crossing it keeps 9.86:1
 *   watermark (ink at 11%) on field              dark : 1.27:1 against the ground; ink text crossing it keeps 12.63:1
 *   watermark (ink at 11%) on card               dark : 1.34:1 against the ground; ink text crossing it keeps 10.68:1
 *   watermark (ink at 11%) on status-working-bg  dark : 1.37:1 against the ground; ink text crossing it keeps 9.03:1
 */

:root {
  /* What the browser draws itself — tick-boxes, the arrow and list of a
     select, the date picker, scrollbars — follows the theme too. Light here;
     the dark block below says dark. (Dark is only ever chosen by
     html[data-theme="dark"]: the script at the top of the layout sets that
     before the first paint, from the saved choice or the system setting.) */
  color-scheme: light;

  /* Ground & ink (light): cool paper, blue-black ink */
  --color-bg: #f6f8fb;
  --color-surface: #e9eef5;
  --color-field: #ffffff;          /* inside of inputs and quiet buttons */
  --color-ink: #0f1a2e;
  --color-muted: #4c5a70;
  --color-rule: #cfd8e3;           /* hairlines between things — not a control edge */
  --color-control-border: #66748c; /* the edge of anything you can press or type in (3:1) */

  /* Brand accent — small areas only (buttons, active states, key highlights) */
  --color-accent: #1d4fd8;
  --color-accent-hover: #153fb3;
  --color-accent-ink: #ffffff;

  /* Dedicated link color — links only, nowhere else */
  --color-link: #7a2bd0;

  /* Keyboard focus: its own colour, so the ring never melts into a blue
     button. Night ink in light, near-white in dark; signal on the header. */
  --color-focus: #101c3f;

  /* Status */
  --color-ok: #0c7a55;
  --color-warn: #955600;
  --color-danger: #b3261e;

  /* Status chips: a pale ground under the word; the word stays in ink */
  --color-status-open-bg: #e3ecfd;
  --color-status-working-bg: #fbefd8;
  --color-status-won-bg: #dff3ea;
  --color-status-lost-bg: #e7ebf0;
  --color-status-dnc-bg: #fbe6e3;
  /* My calendar (ledger D228): booking hours shaded; a call and a follow-up told apart by their edge; busy time
     blocked out (ledger D253) a grey edge on a grey ground */
  --color-cal-open: #e2f2ea;
  --color-cal-call: #1d4fd8;
  --color-cal-follow: #955600;
  --color-cal-busy: #5f6b7a;
  --color-cal-busy-bg: #eef0f3;

  /* Soft controls (round two). A quiet button is a tinted pill: fill, a
     stronger fill under the pointer, a deeper one while pressed; its words in
     --color-soft-ink; its edge (still 3:1, so the pill is findable without
     its fill) in --color-soft-edge. A field rests on --color-field-rest and
     turns to --color-field when it has the keyboard. */
  --color-soft: #e4ecfd;
  --color-soft-hover: #d2dffb;
  --color-soft-press: #bdcff7;
  --color-soft-ink: #163a9c;
  --color-soft-edge: #5878d8;
  --color-field-rest: #eef3fb;
  --color-accent-press: #0f2f8a;
  --color-halo: #c5d5fa;           /* the soft ring round a hovered primary button or a focused field */
  --color-link-hover: #54189f;
  /* Switched off: flat, dashed, no tint. Still readable. */
  --color-off-bg: #e6e9ee;
  --color-off-ink: #586479;
  --color-off-edge: #7d889b;
  /* Card on the page: where lists, facts and forms sit. Plain, never a picture. */
  --color-card: #ffffff;
  --shadow-card: 0 1px 2px rgba(15, 26, 46, 0.06), 0 6px 20px rgba(15, 26, 46, 0.07);
  --shadow-raised: 0 2px 4px rgba(15, 26, 46, 0.10), 0 12px 32px rgba(15, 26, 46, 0.14);

  /* A person's mark on the Assign screen: two letters of their name on one
     of five SHAPES in one of these six colours. The shape and the letters
     tell people apart; the colour only helps, and is never the one thing
     that does. Each is 3:1 or better on every ground a mark sits on, and
     its letters (--color-mark-ink) 4.5:1 on it. Nothing else wears them. */
  --color-mark-1: #1f5fbf;
  --color-mark-2: #a34a00;
  --color-mark-3: #0b7a5c;
  --color-mark-4: #a3247f;
  --color-mark-5: #6b6100;
  --color-mark-6: #4a5d75;
  --color-mark-ink: #ffffff;

  /* Night: the header, and the picture panel of the sign-in and error pages.
     Night in BOTH themes — it is the app's frame, not a working surface. */
  --color-night: #0a1230;
  --color-night-raised: #18234c;   /* an unlit cell in the picture */
  --color-night-line: #131d44;     /* the fine grid drawn on night */
  --color-night-rule: #2c3b70;     /* traces and hairlines on night */
  --color-night-control: #7486bd;  /* the edge of a header button (3:1) */
  --color-night-ink: #eaf0ff;
  --color-night-muted: #a9b6d9;
  --color-night-link: #d9c8ff;     /* the link colour as it reads on night: header navigation */
  --color-signal: #57a3ff;         /* the electric line: current page, focus on night */
  --color-signal-2: #3ddbd0;       /* its second, cooler voice */
  --color-spark: #ffb648;          /* one warm point of light, used once per picture */
  --color-urgent: #ff5a4f;         /* Lead Response's count of replies not opened (ledger D302, D304): night header only, --color-night text, 5.98:1 */

  --color-night-soft: #1b2d63;     /* the pill under the current page in the header; a band button at rest */
  --color-night-press: #283f84;    /* the same, pressed */
  --color-night-off: #8792b3;      /* a switched-off button's words on night */

  /* Pictures. Night laid over a picture so words on it keep their contrast:
     the band behind a page title (strong where the title can be, lighter
     toward the far edge) and the photograph on the sign-in pages (strong at
     the top and bottom where the two lines of words sit, clear in between).
     Measured on the rendered pixels by tools/band_contrast.py. */
  --shade-band-strong: rgba(6, 10, 24, 0.77);
  --shade-band-light: rgba(6, 10, 24, 0.12);
  --shade-band-phone: rgba(6, 10, 24, 0.72);
  --shade-photo-edge: rgba(6, 10, 24, 0.82);
  --shade-photo-mid: rgba(6, 10, 24, 0.10);
  --shade-text: 0 1px 2px rgba(6, 10, 24, 0.9);  /* a hairline of shadow under words on a picture */

  /* A QR code must sit on white in BOTH themes or phone cameras miss it.
     Deliberately not overridden in the dark block below. */
  --color-qr-ground: #ffffff;

  /* Type — generous default (kit Directive 18) */
  --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --text-base: 1.125rem; /* 18px at browser default */
  --leading: 1.6;

  /* Space & shape — 4px grid */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --radius: 0.75rem;               /* fields, small cards */
  --radius-chip: 999px;            /* pills: buttons, chips, nav */
  --radius-card: 1rem;
  --radius-panel: 1.25rem;
  --text-h1: clamp(2.1rem, 1.5rem + 2.4vw, 3.25rem);
  --text-h2: 1.5rem;
  --text-h3: 1.2rem;
  --page-w: 56rem;                 /* the reading column */
  --gutter: 1.5rem;
  --touch: 2.75rem;                /* nothing pressable is shorter than this */
  --grid-step: 1.5rem;             /* the pitch of the fine grid on night */
  --focus-ring: 3px solid var(--color-focus);
}

/* Text-size setting (S/M/L/XL), persisted per device — html[data-textsize] */
html[data-textsize="s"] { font-size: 88.9%; }   /* 16px base */
html[data-textsize="m"] { font-size: 100%; }    /* 18px base (default) */
html[data-textsize="l"] { font-size: 111.1%; }  /* 20px base */
html[data-textsize="xl"] { font-size: 122.2%; } /* 22px base */

/* Dark theme — html[data-theme="dark"]. Not the light theme inverted: the
   ground is a blue-black a step LIGHTER than the night frame, so the header
   still reads as the frame and the page as the desk. */
html[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #0e1526;
  --color-surface: #18213a;
  --color-field: #090e1b;
  --color-ink: #e5ebf6;
  --color-muted: #9eabc2;
  --color-rule: #2a3650;
  --color-control-border: #6e7d9b;
  --color-accent: #6ea8ff;
  --color-accent-hover: #93bdff;
  --color-accent-ink: #08122a;
  --color-link: #cdaaff;
  --color-focus: #f4f7ff;
  --color-ok: #4fd6a0;
  --color-warn: #f6b94a;
  --color-danger: #ff8f85;
  --color-status-open-bg: #152b54;
  --color-status-working-bg: #30270f;
  --color-status-won-bg: #0f3428;
  --color-status-lost-bg: #212a3c;
  --color-status-dnc-bg: #421d1b;
  --color-cal-open: #10301f;
  --color-cal-call: #7fa8ff;
  --color-cal-follow: #f6b94a;
  --color-cal-busy: #aab4c3;
  --color-cal-busy-bg: #232a36;
  --color-soft: #16264a;
  --color-soft-hover: #1d3262;
  --color-soft-press: #26427f;
  --color-soft-ink: #b4cfff;
  --color-soft-edge: #5d7fd0;
  --color-field-rest: #121a2e;
  --color-accent-press: #5590ea;
  --color-halo: #223d78;
  --color-link-hover: #e6d3ff;
  --color-off-bg: #1a2233;
  --color-off-ink: #97a3b9;
  --color-off-edge: #66738d;
  --color-card: #131b30;
  --color-mark-1: #7fb0ff;
  --color-mark-2: #ffab66;
  --color-mark-3: #4fd6b0;
  --color-mark-4: #ff8fd0;
  --color-mark-5: #d9c04a;
  --color-mark-6: #a9bccb;
  --color-mark-ink: #08122a;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-raised: 0 2px 4px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.4);
  --color-night-soft: #18285a;
  --color-night-press: #24397a;
  --color-night: #060a18;
  --color-night-raised: #121b3c;
  --color-night-line: #0d1532;
  --color-night-rule: #26345f;
  --color-night-control: #6f80b4;
  --color-night-ink: #eaf0ff;
  --color-night-muted: #a9b6d9;
  --color-urgent: #ff6b61;  /* 6.59:1 on night (ledger D302) */
}
