/* Interface « Synthèse » : jetons. Seul fichier de l'interface autorisé à contenir des couleurs littérales (comme les blocs de thème d'app.css).
   Il redéfinit les NOMS de variables déjà utilisés par tous les écrans : ceux-ci se recolorent sans être touchés. La couleur d'accent de la société
   (--accent*) n'est PAS redéfinie ici : apparence.js la pose avec ses garanties de contraste. Spécificité >= 0,2,0 pour passer devant app.css. */

@property --v5-ah { syntax: '<number>'; inherits: true; initial-value: 255; }
@property --v5-fc { syntax: '<number>'; inherits: true; initial-value: 1; }

/* ── Sombre (défaut) ─────────────────────────────────────── */
:root[data-interface="synthese"],
:root[data-interface="synthese"][data-theme="dark"] {
  color-scheme: dark;
  /* teinte du fond (une par rubrique) et intensité (1 = franc ; réduite hors accueil en mode « Accueil seulement ») */
  --v5-ah: 255;
  --v5-fc: 1;
  transition: --v5-ah .9s cubic-bezier(.4, 0, .2, 1), --v5-fc .9s cubic-bezier(.4, 0, .2, 1);

  --bg:       oklch(16.5% calc(.075 * var(--v5-fc) * var(--v5-pc, 1)) var(--v5-ah));
  --surface:  oklch(21.5% calc(.06 * var(--v5-fc) * var(--v5-pc, 1)) var(--v5-ah));
  --surface2: oklch(32% calc(.056 * var(--v5-fc) * var(--v5-pc, 1)) var(--v5-ah));
  --v5-fenetre: oklch(26.5% calc(.058 * var(--v5-fc) * var(--v5-pc, 1)) var(--v5-ah));
  --fg:       oklch(96% .008 var(--v5-ah));
  --muted:    oklch(79% .025 var(--v5-ah));
  --border:   rgb(255 255 255 / .1);
  --border-in: oklch(68% .03 var(--v5-ah));
  --field:    color-mix(in oklab, var(--bg) 70%, var(--surface));
  --navy:     var(--surface);
  --success:  oklch(81% .13 155);   --success-t: oklch(81% .13 155);
  --orange:   oklch(84% .12 80);    --orange-t:  oklch(84% .12 80);
  --danger:   oklch(77% .14 25);    --danger-t:  oklch(77% .14 25);
  --blue:     oklch(81% .09 245);   --blue-t:    oklch(81% .09 245);
  --retard-t: var(--danger);
  --e-2: 0 8px 20px -12px rgb(0 0 0 / .6);
  --e-3: 0 18px 40px -18px rgb(0 0 0 / .65);
  --e-4: 0 24px 60px -16px rgb(0 0 0 / .7);
  --v5-halo:  oklch(58% calc(.19 * var(--v5-pc, 1)) var(--v5-ah) / .34);
  --v5-halo2: oklch(60% calc(.16 * var(--v5-pc, 1)) calc(var(--v5-ah) + 50) / .22);
  --v5-trait: rgb(255 255 255 / .16);
  --v5-voile: rgb(0 0 0 / .5);
}

/* ── Clair ───────────────────────────────────────────────── */
:root[data-interface="synthese"][data-theme="light"] {
  color-scheme: light;
  --bg:       oklch(93.5% calc(.035 * var(--v5-fc) * var(--v5-pc, 1)) var(--v5-ah));
  --surface:  oklch(98.2% calc(.012 * var(--v5-fc) * var(--v5-pc, 1)) var(--v5-ah));
  --surface2: oklch(95% calc(.02 * var(--v5-fc) * var(--v5-pc, 1)) var(--v5-ah));
  --v5-fenetre: oklch(99.7% .004 var(--v5-ah));
  --fg:       oklch(21% .03 var(--v5-ah));
  --muted:    oklch(41% .03 var(--v5-ah));
  --border:   rgb(20 30 60 / .12);
  --border-in: oklch(50% .03 var(--v5-ah));
  --field:    var(--v5-fenetre);
  --navy:     var(--surface);
  --success:  oklch(40% .12 155);   --success-t: oklch(40% .12 155);
  --orange:   oklch(46% .11 65);    --orange-t:  oklch(46% .11 65);
  --danger:   oklch(47% .18 25);    --danger-t:  oklch(47% .18 25);
  --blue:     oklch(42% .13 255);   --blue-t:    oklch(42% .13 255);
  --retard-t: var(--danger);
  --e-2: 0 8px 20px -14px rgb(30 40 80 / .3);
  --e-3: 0 14px 32px -16px rgb(30 40 80 / .3);
  --e-4: 0 24px 60px -18px rgb(30 40 80 / .4);
  --v5-halo:  oklch(80% calc(.12 * var(--v5-pc, 1)) var(--v5-ah) / .42);
  --v5-halo2: oklch(82% calc(.1 * var(--v5-pc, 1)) calc(var(--v5-ah) + 50) / .3);
  --v5-trait: rgb(20 30 60 / .2);
  --v5-voile: rgb(20 30 60 / .36);
}

/* ── Teinte du fond par rubrique ─────────────────────────── */
:root[data-interface="synthese"][data-famille="accueil"]      { --v5-ah: calc(255 + var(--v5-dh, 0)); }
:root[data-interface="synthese"][data-famille="patrimoine"]   { --v5-ah: calc(195 + var(--v5-dh, 0)); }
:root[data-interface="synthese"][data-famille="projet"]       { --v5-ah: calc(285 + var(--v5-dh, 0)); }
:root[data-interface="synthese"][data-famille="inventaire"]   { --v5-ah: calc(150 + var(--v5-dh, 0)); }
:root[data-interface="synthese"][data-famille="apres-vente"]  { --v5-ah: calc(35 + var(--v5-dh, 0)); }
:root[data-interface="synthese"][data-famille="savoirs"]      { --v5-ah: calc(330 + var(--v5-dh, 0)); }
/* « Accueil seulement » : hors accueil, fond presque neutre à la teinte de l'accent de la société */
:root[data-interface="synthese"][data-fond="accueil"]:not([data-famille="accueil"]) { --v5-fc: .22; --v5-ah: var(--accent-h, 255); }

/* ── Jetons propres à Synthèse (indépendants du thème) ───── */
:root[data-interface="synthese"] {
  /* typographie : la police à chasse fixe des chiffres devient la police courante (chiffres tabulaires) */
  --font-mono: var(--font-body);
  --v5-t-xs: 12px;
  --v5-t-s: 13px;
  --v5-t-corps: 14.5px;
  --v5-t-m: 15px;
  --v5-t-l: 17px;
  --v5-t-xl: clamp(26px, 2.6vw, 36px);
  --v5-t-chiffre: 36px;
  --v5-poids-fin: 400;
  --v5-poids-moyen: 500;
  --v5-poids-fort: 600;
  /* rayons (remplacent les rayons classiques sur tout l'écran) */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --v5-r-ctl: 12px;
  --v5-r-rond: 999px;
  /* gabarits */
  --v5-ctl-h: 40px;
  --v5-ctl-h-s: 34px;
  --v5-ligne-h: 56px;
  --v5-ico: 20px;
  --v5-ico-s: 17px;
  --v5-ico-l: 30px;
  --v5-pastille: 9px;
  --v5-pal-puce: 36px;
  --v5-pal-l: 56px;
  --v5-flou: 16px;
  --v5-flou-fenetre: 6px;
  --v5-trait-h: 2px;
  --v5-liseret: 2px;
  --v5-decal: 12px;
  --v5-decal-s: 4px;
  /* coque */
  --v5-rail-l: 64px;
  --v5-rail-l-ouvert: 262px;
  --v5-rail-marge: 14px;
  --v5-rail-gouttiere: 22px;
  --v5-barre-h: 62px;
  --v5-tuile-h: 112px;
  --v5-tuile-l: 168px;
  --v5-tuile-h-m: 100px;
  --v5-tuile-l-m: 148px;
  --v5-incl: 4deg;
  --v5-incl-entree: 6deg;
  --v5-profondeur: 90px;
  --v5-tiroir-l: 288px;
  --v5-halo-taille: 70vmax;
  --v5-halo-x1: -20vmax;
  --v5-halo-y1: -30vmax;
  --v5-halo-x2: -25vmax;
  --v5-halo-y2: -35vmax;
  --v5-recul: .985;
  --v5-appui: .97;
  --v5-carte-min: 240px;
  --v5-persp: 900px;
  --v5-rayon: 220px;
  /* mouvement */
  --v5-ease: cubic-bezier(.16, 1, .3, 1);
  --v5-d-court: 150ms;
  --v5-d-moyen: 250ms;
  --v5-d-long: 450ms;
  --v5-d-entree: 220ms;
  --v5-d-descente: 420ms;
  --v5-d-tuile: 260ms;
  --v5-attente-tuile: 80ms;
  --v5-ecart-tuile: 40ms;
  --v5-ease-entree: ease-out;
  --v5-d-halo-1: 46s;
  --v5-d-halo-2: 58s;
  --v5-ecart: 55ms;
  /* ombres de fenêtre, cartes */
  --v5-ombre-carte: 0 1px 0 rgb(255 255 255 / .04) inset;
  /* accent dérivé (jamais redéfini : il vient d'apparence.js) */
  --v5-accent-doux: var(--accent-d);
  /* accent de décor (état actif, sélection) : l'accent de la société en « partout », neutre en « sobres » */
  --v5-deco: var(--accent);
  --v5-deco-doux: var(--accent-d);
  --v5-sur-deco: var(--v5-sur-accent);
  --v5-sur-accent: var(--accent-text, var(--bg));
  /* logo : pastille neutre derrière un logo image */
  --v5-logo-fond: var(--surface2);
  /* couches propres à Synthèse : toutes sous --z-panneau */
  --v5-z-fond: 0;
  --v5-z-coque: 1;
  --v5-z-rail: 40;
  --v5-z-rangee: 45;
  --v5-z-barre: 50;
  --v5-z-lecture: 55;
  --v5-z-tiroir-voile: 1300;
  --v5-z-tiroir: 1400;
  /* registre des types de documents (documents.css, Z.typeDoc) : mêmes noms, teintes de la maquette */
  --td-rapport: var(--v5-type-rapport);
  --td-photo: var(--v5-type-photo);
  --td-plan: var(--v5-type-plan);
  --td-pv: var(--v5-type-rapport);
  --td-devis: var(--v5-type-devis);
  --td-bdc: var(--v5-type-bdc);
  --td-facture: var(--v5-type-facture);
  --td-notice: var(--v5-type-notice);
  --td-bl: var(--v5-type-plan);
  --td-autre: var(--v5-type-notice);
  /* types de fichiers (blocs colorés) : teintes de la maquette */
  --v5-fam-patrimoine: oklch(78% calc(.13 * var(--v5-pf, 1)) calc(195 + var(--v5-dh, 0)));
  --v5-fam-projet: oklch(78% calc(.13 * var(--v5-pf, 1)) calc(285 + var(--v5-dh, 0)));
  --v5-fam-inventaire: oklch(78% calc(.13 * var(--v5-pf, 1)) calc(150 + var(--v5-dh, 0)));
  --v5-fam-apres-vente: oklch(78% calc(.13 * var(--v5-pf, 1)) calc(35 + var(--v5-dh, 0)));
  --v5-fam-savoirs: oklch(78% calc(.13 * var(--v5-pf, 1)) calc(330 + var(--v5-dh, 0)));
  --v5-type-devis: oklch(78% .13 80);
  --v5-type-facture: oklch(78% .11 190);
  --v5-type-rapport: oklch(78% .13 150);
  --v5-type-photo: oklch(78% .11 245);
  --v5-type-plan: oklch(78% .14 50);
  --v5-type-notice: oklch(74% .04 255);
  --v5-type-bdc: oklch(76% .13 305);
}
:root[data-interface="synthese"][data-theme="light"] {
  --v5-fam-patrimoine: oklch(45% calc(.14 * var(--v5-pf, 1)) calc(195 + var(--v5-dh, 0)));
  --v5-fam-projet: oklch(45% calc(.14 * var(--v5-pf, 1)) calc(285 + var(--v5-dh, 0)));
  --v5-fam-inventaire: oklch(45% calc(.14 * var(--v5-pf, 1)) calc(150 + var(--v5-dh, 0)));
  --v5-fam-apres-vente: oklch(45% calc(.14 * var(--v5-pf, 1)) calc(35 + var(--v5-dh, 0)));
  --v5-fam-savoirs: oklch(45% calc(.14 * var(--v5-pf, 1)) calc(330 + var(--v5-dh, 0)));
  --v5-type-devis: oklch(50% .12 70);
  --v5-type-facture: oklch(44% .1 195);
  --v5-type-rapport: oklch(42% .12 150);
  --v5-type-photo: oklch(44% .13 250);
  --v5-type-plan: oklch(48% .14 45);
  --v5-type-notice: oklch(42% .04 255);
  --v5-type-bdc: oklch(44% .15 305);
}

/* ── Palettes (réglage personnel « Palette », Synthèse seulement) ──
   Chaque palette ne fournit que des PARAMÈTRES : --v5-dh (décalage de teinte du fond et des familles), --v5-pc (intensité du fond et des halos), --v5-pf (intensité
   des couleurs de famille), --v5-pa-h / --v5-pa-c (teinte et intensité de l'accent principal). Les couleurs de statut (succès, alerte, erreur) ne sont jamais touchées.
   « nuit » = rendu d'origine : aucune règle d'application (l'accent de la société reste celui de l'application). Les paramètres sont posés sur [data-palette]
   (et non sur la racine) pour que les pastilles de choix de l'écran lisent les leurs. L'accent est dérivé ici avec les garanties de contraste de apparence.js
   (texte d'accent >= 4,5:1 sur les surfaces, texte de bouton >= 4,5:1 sur le dégradé), vérifiées par les tests. */
[data-palette="nuit"]     { --v5-dh: 0;    --v5-pc: 1;   --v5-pf: 1;   --v5-pa-h: 68;  --v5-pa-c: .13; }
[data-palette="emeraude"] { --v5-dh: -90;  --v5-pc: 1;   --v5-pf: 1;   --v5-pa-h: 165; --v5-pa-c: .13; }
[data-palette="cuivre"]   { --v5-dh: -205; --v5-pc: .85; --v5-pf: 1;   --v5-pa-h: 50;  --v5-pa-c: .13; }
[data-palette="violet"]   { --v5-dh: 40;   --v5-pc: 1;   --v5-pf: 1;   --v5-pa-h: 295; --v5-pa-c: .15; }
[data-palette="graphite"] { --v5-dh: 0;    --v5-pc: .12; --v5-pf: .3;  --v5-pa-h: 250; --v5-pa-c: .03; }
[data-palette="corail"]   { --v5-dh: 100;  --v5-pc: .95; --v5-pf: 1;   --v5-pa-h: 355; --v5-pa-c: .14; }
/* aperçu d'une palette (pastille de choix) : fond et accent de la palette portée par l'élément lui-même */
[data-palette] {
  --v5-pal-fond: oklch(28% calc(.075 * var(--v5-pc, 1)) calc(255 + var(--v5-dh, 0)));
  --v5-pal-fond2: oklch(40% calc(.1 * var(--v5-pc, 1)) calc(285 + var(--v5-dh, 0)));
  --v5-pal-accent: oklch(78% var(--v5-pa-c, .13) var(--v5-pa-h, 68));
}
:root[data-interface="synthese"][data-palette]:not([data-palette="nuit"]) {
  --accent-h: var(--v5-pa-h);
}
:root[data-interface="synthese"][data-palette]:not([data-palette="nuit"]):is([data-theme="dark"], :not([data-theme])) {
  --accent: oklch(80% var(--v5-pa-c) var(--v5-pa-h));
  --accent-d: oklch(80% var(--v5-pa-c) var(--v5-pa-h) / .16);
  --accent-hover: oklch(85% var(--v5-pa-c) var(--v5-pa-h));
  --accent-soft: oklch(34% calc(var(--v5-pa-c) * .45) var(--v5-pa-h));
  --accent-grad: linear-gradient(135deg, oklch(76% var(--v5-pa-c) var(--v5-pa-h)), oklch(66% var(--v5-pa-c) var(--v5-pa-h)));
  --accent-text: oklch(16% .03 var(--v5-pa-h));
}
:root[data-interface="synthese"][data-palette]:not([data-palette="nuit"])[data-theme="light"] {
  --accent: oklch(46% var(--v5-pa-c) var(--v5-pa-h));
  --accent-d: oklch(46% var(--v5-pa-c) var(--v5-pa-h) / .1);
  --accent-hover: oklch(41% var(--v5-pa-c) var(--v5-pa-h));
  --accent-soft: oklch(95% calc(var(--v5-pa-c) * .3) var(--v5-pa-h));
  --accent-grad: linear-gradient(135deg, oklch(50% var(--v5-pa-c) var(--v5-pa-h)), oklch(42% var(--v5-pa-c) var(--v5-pa-h)));
  --accent-text: oklch(99% 0 0);
}

/* ── Couleurs « sobres » : la couleur ne reste que sur l'essentiel (statuts, alertes, bouton principal, pastilles de compteur) ──
   Les familles, les types de documents, le fond par rubrique, les halos et les états actifs deviennent neutres. Placé en dernier : à spécificité égale, il l'emporte. */
:root[data-interface="synthese"][data-couleurs="sobres"] {
  --v5-fam-patrimoine: var(--muted);
  --v5-fam-projet: var(--muted);
  --v5-fam-inventaire: var(--muted);
  --v5-fam-apres-vente: var(--muted);
  --v5-fam-savoirs: var(--muted);
  --v5-type-devis: var(--muted);
  --v5-type-facture: var(--muted);
  --v5-type-rapport: var(--muted);
  --v5-type-photo: var(--muted);
  --v5-type-plan: var(--muted);
  --v5-type-notice: var(--muted);
  --v5-type-bdc: var(--muted);
  --v5-ah: var(--accent-h, 255);
  --v5-fc: .22;
  --v5-deco: var(--fg);
  --v5-deco-doux: color-mix(in oklab, var(--fg) 10%, transparent);
  --v5-sur-deco: var(--bg);
}
