/* Diaam design tokens: the one colour sheet of the whole site.
 * 
 * Served by the hub gateway at /theme.css, and linked by every page of every
 * app before its own styles.css:
 *
 *     <link rel="stylesheet" href="/theme.css" />
 *     <link rel="stylesheet" href="styles.css" />
 *
 * App stylesheets never write a colour literal: they only use the tokens
 * below. So to recolour the whole site, change --brand here, once, save, and
 * reload the page: this folder is bind-mounted into the gateway
 * (Hub/docker-compose.yml), so nothing needs rebuilding or restarting.
 *
 * PublicApi is standalone (not behind the gateway), so it gets this very file
 * bind-mounted next to its own pages; see PublicApi/docker-compose.yml. That
 * one is a single-file mount: if an edit does not show there, restart its
 * frontend (`docker compose restart frontend` from PublicApi/).
 *
 * ---------------------------------------------------------------------------
 * How it works
 *
 * Everything below is derived from the seeds in SECTION 1 with color-mix():
 * the ramps are mixes toward --paper-pole (lighter) or --ink-pole (darker),
 * even the greys carry a --tint share of the brand, so a new brand hue pulls
 * the whole site with it instead of leaving green-grey borders behind.
 *
 * The mixes are done `in srgb` on purpose: that is plain channel
 * interpolation, which is what the hand-picked palette this replaces was
 * built with, so the steps land on the shades the apps had before.
 */

/* Fonts, self-hosted (html/fonts, SIL Open Font License, see the OFL-*.txt
 * files there) rather than loaded from Google Fonts: a page that links
 * fonts.googleapis.com sends every visitor's IP address to Google, a
 * transfer outside the EU that GDPR would require us to justify. One variable
 * file per family and subset covers every weight the site uses. The URLs are
 * absolute, so they resolve to the gateway from every app under /apps/. */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/dm-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/dm-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/manrope-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/manrope-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* === SECTION 1: THE SEEDS — this is the part you edit ================== */

  /* The brand colour. Buttons, links, active states, and the hue that tints
     every grey on the site. Changing this line recolours everything. */
  --brand: #1f4764; /* bleu pétrole, the action colour of Diaam-Questionnaire */

  /* How much of the brand bleeds into the greys (text, borders, surfaces).
     0% gives dead neutral greys, 30% the softly tinted ones the site uses,
     50%+ makes the whole page visibly coloured. */
  --tint: 0%;

  /* The two poles every ramp is mixed toward: the lightest surface and the
     darkest ink. Swapping them is what a dark theme would do. They are named
     -pole because every other token is derived from them: an app that
     redefined one would move the whole palette with it. */
  --paper-pole: #ffffff;
  --ink-pole: #282622;

  /* Status colours, kept independent of the brand on purpose: a red that
     follows the brand hue stops reading as "danger". Each one is a mid tone;
     its wash, border and text shades are derived from it in SECTION 3. */
  --danger: #a64136;
  --warn: #b5862f;
  --info: #3a6787;
  /* Jaune de signalisation: only on labels and plates, never on actions. */
  --signal: #f9a800;
  --signal-soft: #fff3d1;

  /* === SECTION 2: NEUTRALS ============================================== */

  /* Darkest text tone: the ink pole, pulled --tint of the way to the brand.
     The whole grey ramp is a mix of this with --paper-pole, so the greys are never
     dead grey and never fight the brand. */
  --ink: #282622;

  --n-900: #282622;
  --n-700: #45423c;
  --n-600: #57534c;
  --n-500: #6d6860;
  --n-400: #8f897e;
  --n-300: #c9c4ba;
  --n-200: #e0ddd6;
  --n-100: #efede8;
  --n-50: #f8f7f4; /* papier chaud: the page */
  --n-0: var(--paper-pole);

  /* === SECTION 3: RAMPS ================================================= */

  /* Brand, from the faintest wash to the deepest ink. 500 is --brand itself:
     everything lighter is mixed toward --paper-pole, everything darker toward
     --ink-pole. */
  --brand-50: #eef3f7;
  --brand-100: #d9e5ee;
  --brand-200: #b5cbdb;
  --brand-300: #87a8c0;
  --brand-400: #5a84a2;
  --brand-500: var(--brand);
  --brand-600: #183a52;
  --brand-700: #132e41;

  /* Status ramps: -50 is the panel wash, -200 its border, -500 the mark or
     badge, -700 the text (dark enough to read on its own wash). */
  --danger-50: color-mix(in srgb, var(--danger) 8%, var(--paper-pole));
  --danger-200: color-mix(in srgb, var(--danger) 38%, var(--paper-pole));
  --danger-500: var(--danger);
  --danger-700: color-mix(in srgb, var(--danger) 70%, var(--ink-pole));

  --warn-50: color-mix(in srgb, var(--warn) 8%, var(--paper-pole));
  --warn-100: color-mix(in srgb, var(--warn) 25%, var(--paper-pole));
  --warn-200: color-mix(in srgb, var(--warn) 51%, var(--paper-pole));
  --warn-500: var(--warn);
  --warn-700: color-mix(in srgb, var(--warn) 62%, var(--ink-pole));

  --info-50: color-mix(in srgb, var(--info) 5%, var(--paper-pole));
  --info-100: color-mix(in srgb, var(--info) 14%, var(--paper-pole));
  --info-200: color-mix(in srgb, var(--info) 28%, var(--paper-pole));
  --info-500: var(--info);
  --info-700: color-mix(in srgb, var(--info) 68%, var(--ink-pole));

  /* === SECTION 4: ROLES ================================================= */
  /* What app stylesheets actually use. A rule should name the job
     (--text-muted, --surface-raised), not a step of a ramp, so that
     retuning a ramp cannot change what a colour means. */

  /* Surfaces */
  --canvas: var(--n-50); /* the page itself */
  --canvas-glow: var(--canvas); /* flat page, no corner wash */
  --surface: var(--n-0); /* cards, panels, rows */
  --surface-sunken: var(--n-100); /* inputs, wells, code blocks */
  --surface-hover: var(--brand-50); /* a row or card under the pointer */
  --surface-selected: var(--brand-100); /* the chosen row, the active tab */

  /* Text */
  --text: var(--n-900); /* body copy and headings */
  --text-strong: var(--n-900);
  --text-secondary: var(--n-600); /* labels, table headers, meta lines */
  --text-muted: var(--n-500); /* hints, timestamps, placeholders */
  --text-faint: var(--n-400); /* disabled, watermarks, empty states */
  --text-on-brand: var(--n-0); /* on a --brand-500/600 fill */
  --text-link: var(--brand-600);

  /* Lines */
  --line: var(--n-200); /* the default border */
  --line-strong: var(--n-300); /* dividers that must be seen */
  --line-soft: color-mix(in srgb, var(--ink) 9%, transparent); /* hairline over a wash */
  --line-brand: var(--brand-300); /* border of a brand-tinted panel */
  --grid: var(--brand-100); /* table rules, dotted guides */

  /* Interactive */
  --accent: var(--brand-500);
  --accent-hover: var(--brand-600);
  --accent-soft: var(--brand-100); /* ghost-button fill, soft badge */
  --accent-strong: var(--brand-700);
  --on-accent: var(--n-0);
  --focus: var(--brand-500); /* focus ring */

  /* Veils: borders and fills *inside* a brand-filled element, where a token
     from the ramps would not show. */
  --veil-light: color-mix(in srgb, var(--paper-pole) 22%, transparent);
  --veil-light-strong: color-mix(in srgb, var(--paper-pole) 35%, transparent);

  /* Elevation. The shadow is a deep brand green rather than black: a black
     shadow over a tinted page reads as dirt. */
  --shadow-color: var(--brand-700);
  --shadow-xs: 0 1px 3px color-mix(in srgb, var(--shadow-color) 7%, transparent);
  --shadow-sm: 0 3px 10px color-mix(in srgb, var(--shadow-color) 5%, transparent);
  --shadow-md: 0 10px 24px color-mix(in srgb, var(--shadow-color) 10%, transparent);
  --shadow-lg: 0 14px 40px color-mix(in srgb, var(--shadow-color) 8%, transparent);
  /* A dialog lifted clear of the page behind it. */
  --shadow-dialog: 0 24px 60px color-mix(in srgb, var(--ink) 22%, transparent);

  /* Full-screen dim behind a dialog. */
  --scrim: color-mix(in srgb, var(--ink) 35%, transparent);

  /* === SECTION 5: OLDER NAMES ============================================ */
  /* The names the app stylesheets already used before the tokens were
     centralised here, so their rules did not all have to be rewritten. They
     are aliases, not a second palette: prefer the roles above in new CSS.
     --green is the one to watch — it is the brand, whatever hue --brand is,
     so a blue site still has rules reading `color: var(--green)`. */

  --green: var(--brand-500);
  --green-dark: var(--brand-600);
  --green-soft: var(--brand-100);
  --muted: var(--text-muted);
  --amber: var(--warn-700);
  --amber-line: var(--warn-200);
  --amber-soft: var(--warn-50);
  --danger-line: var(--danger-200);
  --danger-soft: var(--danger-50);
  /* Card background. The seed is --paper-pole: never redeclare that one. */
  --paper: var(--surface);

  /* Typography and spacing are shared too: an app that linked only its own
     stylesheet would otherwise re-declare them. */
  /* Small radii: controls 6 px, cards and tiles 10 px. */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  font-family: 'Archivo', 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
