/*
 * PICMAN : jetons de la charte « Ciel du Pic » (docs/UI.md § 3 et § 9).
 *
 * 1. Charte : copie à l'identique de la couche « tokens » de
 *    forums.cvvm.fr/styles/cvvm2/theme/stylesheet.css (couleurs, formes, police).
 *    Ne jamais modifier ces valeurs dans PICMAN seul.
 * 2. Couche sémantique PICMAN : ce que la charte ne couvre pas (remplissages des
 *    actions colorées, survol, masque, infobulle, densité), toujours dérivé de la charte.
 * 3. Compatibilité : les deux variables de Saga que lit encore components.css de
 *    PrimeFaces, remappées sur la charte.
 *
 * Le sombre ne s'applique qu'à l'écran : l'impression garde la palette claire.
 */

/* ---------- 1. Charte, clair ---------- */
:root {
	color-scheme: light;

	--blue: #0c53a1;
	--blue-deep: #0a3e78;
	--navy: #082f5c;
	--sky: #1f66b8;
	--sky-light: #42ace2;
	--blue-soft: #eaf2fb;
	--blue-mist: #f4f8fd;
	--blue-line: #d3e2f3;

	--green: #458031;
	--green-deep: #35682a;
	--green-soft: #eef5ea;
	--amber: #e8a13c;
	--amber-ink: #8a5a10;
	--amber-soft: #fdf6e7;
	--red: #c0392b;
	--red-soft: #fdeeee;
	--violet: #7d5ba6;

	--ink: #1c2733;
	--slate: #46525f;
	--muted: #5f6b79;
	--line: #e2e8f0;
	--line-strong: #c9d3df;
	--paper: #ffffff;
	--paper-2: #f9fbfd;
	--ground: #f6f8fb;
	--field-bg: #fbfcfe;
	--code-bg: #f0f4f9;
	--code-ink: #24466e;
	--code-shadow: rgba(8, 47, 92, 0.18);
	--highlight: #fff3bf;

	--bar-bg: #ffffff;
	--bar-shadow: 0 1px 0 var(--line), 0 6px 20px rgba(8, 47, 92, 0.10);
	--hero-a: #082f5c;
	--hero-b: #0c53a1;
	--hero-c: #1f66b8;
	--hero-halo: rgba(69, 128, 49, 0.24);
	--hero-text: #ffffff;
	--hero-muted: rgba(255, 255, 255, 0.86);
	--hero-line: rgba(255, 255, 255, 0.18);
	--footer-bg: #082f5c;
	--footer-text: #b9cce2;
	--footer-link: #dce9f8;

	--radius: 10px;
	--radius-sm: 8px;
	--radius-xs: 6px;
	--shadow-1: 0 1px 2px rgba(8, 47, 92, 0.06), 0 1px 6px rgba(8, 47, 92, 0.05);
	--shadow-2: 0 4px 14px rgba(8, 47, 92, 0.10), 0 1px 4px rgba(8, 47, 92, 0.06);
	--shadow-float: 0 2px 12px rgba(8, 47, 92, 0.22);
	--grad: linear-gradient(90deg, #0c53a1 0%, #458031 100%);
	--focus-ring: 0 0 0 3px rgba(12, 83, 161, 0.35);
	--btn-bg: #0c53a1;
	--btn-bg-hover: #0a3e78;
	--btn-fg: #ffffff;
	--selection: rgba(12, 83, 161, 0.18);

	--font: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	--font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- 2. Couche sémantique PICMAN, clair ---------- */
:root {
	--violet-soft: #f3eef9;
	--radius-lg: 14px;

	/* Texte posé sur un remplissage coloré (boutons, pastilles pleines) */
	--on-accent: #ffffff;
	--on-warning: #1c2733;

	/* Remplissages des actions : texte blanc lisible (≥ 4,5:1) en clair comme en sombre */
	--fill-primary: var(--btn-bg);
	--fill-primary-hover: var(--btn-bg-hover);
	--fill-primary-active: #082f5c;
	--fill-secondary: #46525f;
	--fill-secondary-hover: #39434e;
	--fill-secondary-active: #2e363f;
	--fill-success: #458031;
	--fill-success-hover: #35682a;
	--fill-success-active: #2b5622;
	--fill-info: #1f66b8;
	--fill-info-hover: #19579e;
	--fill-info-active: #154a87;
	--fill-warning: #e8a13c;
	--fill-warning-hover: #d98f26;
	--fill-warning-active: #c98019;
	--fill-help: #7d5ba6;
	--fill-help-hover: #6a4b8f;
	--fill-help-active: #5a3f7a;
	--fill-danger: #c0392b;
	--fill-danger-hover: #a83224;
	--fill-danger-active: #922b1f;

	/* Texte de la sévérité « info » (boutons outlined et flat) : ciel en clair, bleu en sombre,
	   le ciel sombre n'atteignant pas 4,5:1 sur --paper */
	--info-ink: var(--sky);

	/* États d'interface */
	--hover: color-mix(in srgb, var(--line) 70%, var(--paper));
	--row-hover: var(--blue-mist);
	--entry-bg: var(--blue-mist);
	--focus-color: rgba(12, 83, 161, 0.35);
	--mask: rgb(8 47 92 / 0.42);
	--tooltip-bg: #1c2733;
	--tooltip-ink: #ffffff;

	/* Ombres teintées navy : rgb(var(--shadow-rgb) / alpha) */
	--shadow-rgb: 8 47 92;

	/* Densité : tableaux compacts 36 px (décision du 13/11/2026), confortable 44 px */
	--row-h: 36px;
	--control-h: 36px;
	--text-size: 0.875rem;
	--control-text-size: 0.875rem;

	/* Échelle des couches : contenu < barres de l'application < surcouches PrimeFaces (1000 et +) */
	--z-shell: 900;
	--z-skiplink: 100000;

	/* Gabarit (picman-shell.css). La barre latérale « bleu nuit » est identique en clair et en
	   sombre : ses jetons ne sont pas redéfinis par le mode sombre. */
	--side-w: 248px;
	--rail-w: 72px;
	--topbar-h: 56px;
	--tabbar-h: 64px;
	--side-bg: #082f5c;
	--side-ink: #cfe0f2;
	--side-head: #8fb2d6;
	--side-line: rgb(255 255 255 / 0.12);
	--side-hover: rgb(255 255 255 / 0.08);
	--side-active-bg: rgb(255 255 255 / 0.14);
	--side-active-ink: #ffffff;
	--side-ok: #8fd17a;
	--side-warn: #f5c986;
	--side-focus: #9ccafa;
	--side-switch: rgb(255 255 255 / 0.22);
	--tile-ring: rgb(255 255 255 / 0.16);
	--avatar-a: #1f66b8;
	--avatar-b: #0a3e78;
	--avatar-ink: #ffffff;
}

/* Tactile et petit écran : cibles de 44 px, champs en 16 px (pas de zoom iOS) */
@media screen and (max-width: 767.98px), screen and (pointer: coarse) {
	:root {
		--row-h: 44px;
		--control-h: 44px;
		--control-text-size: 1rem;
	}
}
@media screen and (max-width: 767.98px) {
	:root {
		--text-size: 1rem;
	}
}

/* ---------- 1 et 2. Sombre : choix explicite ---------- */
@media screen {
	:root[data-theme="dark"] {
		color-scheme: dark;

		--blue: #6fb1f5;
		--blue-deep: #9ccafa;
		--navy: #dbe7f4;
		--sky: #4f8fd6;
		--sky-light: #42ace2;
		--blue-soft: #22364e;
		--blue-mist: #1e2a38;
		--blue-line: #2a3d55;

		--green: #7cc95f;
		--green-deep: #86c46b;
		--green-soft: #18261a;
		--amber: #d9a866;
		--amber-ink: #f5c986;
		--amber-soft: #2b2415;
		--red: #ff8a80;
		--red-soft: #2e1a1a;
		--violet: #b9a2d8;

		--ink: #d7dee7;
		--slate: #b4bfcb;
		--muted: #9daab8;
		--line: #334457;
		--line-strong: #43566a;
		--paper: #1d2a3a;
		--paper-2: #243347;
		--ground: #0b1118;
		--field-bg: #111a24;
		--code-bg: #10181f;
		--code-ink: #9cc3ee;
		--code-shadow: rgba(0, 0, 0, 0.7);
		--highlight: #5a4a18;

		--bar-bg: #111820;
		--bar-shadow: 0 1px 0 #2a3747, 0 4px 18px rgba(0, 0, 0, 0.35);
		--hero-a: #05203f;
		--hero-b: #083a72;
		--hero-c: #0f4c8f;
		--hero-halo: rgba(69, 128, 49, 0.28);
		--hero-text: #ffffff;
		--hero-muted: rgba(255, 255, 255, 0.86);
		--hero-line: rgba(255, 255, 255, 0.16);
		--footer-bg: #0c1c2e;
		--footer-text: #b7c8dc;
		--footer-link: #d6e3f2;

		--shadow-1: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 6px rgba(0, 0, 0, 0.25);
		--shadow-2: 0 4px 14px rgba(0, 0, 0, 0.45), 0 1px 4px rgba(0, 0, 0, 0.30);
		--shadow-float: 0 2px 12px rgba(0, 0, 0, 0.50);
		--focus-ring: 0 0 0 3px rgba(111, 177, 245, 0.45);
		--btn-bg: #2a72c4;
		--btn-bg-hover: #3b82d4;
		--btn-fg: #ffffff;
		--selection: rgba(111, 177, 245, 0.25);

		--violet-soft: #2a2236;
		--row-hover: var(--paper-2);
		--entry-bg: var(--blue-soft);
		--info-ink: var(--blue);
		--fill-primary-active: #2364ad;
		--fill-secondary: #536273;
		--fill-secondary-hover: #5f6f81;
		--fill-secondary-active: #485667;
		--focus-color: rgba(111, 177, 245, 0.45);
		--mask: rgb(0 0 0 / 0.6);
		--tooltip-bg: #3a4d63;
		--shadow-rgb: 0 0 0;
	}
}

/* ---------- 1 et 2. Sombre : mode automatique ---------- */
@media screen and (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;

		--blue: #6fb1f5;
		--blue-deep: #9ccafa;
		--navy: #dbe7f4;
		--sky: #4f8fd6;
		--sky-light: #42ace2;
		--blue-soft: #22364e;
		--blue-mist: #1e2a38;
		--blue-line: #2a3d55;

		--green: #7cc95f;
		--green-deep: #86c46b;
		--green-soft: #18261a;
		--amber: #d9a866;
		--amber-ink: #f5c986;
		--amber-soft: #2b2415;
		--red: #ff8a80;
		--red-soft: #2e1a1a;
		--violet: #b9a2d8;

		--ink: #d7dee7;
		--slate: #b4bfcb;
		--muted: #9daab8;
		--line: #334457;
		--line-strong: #43566a;
		--paper: #1d2a3a;
		--paper-2: #243347;
		--ground: #0b1118;
		--field-bg: #111a24;
		--code-bg: #10181f;
		--code-ink: #9cc3ee;
		--code-shadow: rgba(0, 0, 0, 0.7);
		--highlight: #5a4a18;

		--bar-bg: #111820;
		--bar-shadow: 0 1px 0 #2a3747, 0 4px 18px rgba(0, 0, 0, 0.35);
		--hero-a: #05203f;
		--hero-b: #083a72;
		--hero-c: #0f4c8f;
		--hero-halo: rgba(69, 128, 49, 0.28);
		--hero-text: #ffffff;
		--hero-muted: rgba(255, 255, 255, 0.86);
		--hero-line: rgba(255, 255, 255, 0.16);
		--footer-bg: #0c1c2e;
		--footer-text: #b7c8dc;
		--footer-link: #d6e3f2;

		--shadow-1: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 6px rgba(0, 0, 0, 0.25);
		--shadow-2: 0 4px 14px rgba(0, 0, 0, 0.45), 0 1px 4px rgba(0, 0, 0, 0.30);
		--shadow-float: 0 2px 12px rgba(0, 0, 0, 0.50);
		--focus-ring: 0 0 0 3px rgba(111, 177, 245, 0.45);
		--btn-bg: #2a72c4;
		--btn-bg-hover: #3b82d4;
		--btn-fg: #ffffff;
		--selection: rgba(111, 177, 245, 0.25);

		--violet-soft: #2a2236;
		--row-hover: var(--paper-2);
		--entry-bg: var(--blue-soft);
		--info-ink: var(--blue);
		--fill-primary-active: #2364ad;
		--fill-secondary: #536273;
		--fill-secondary-hover: #5f6f81;
		--fill-secondary-active: #485667;
		--focus-color: rgba(111, 177, 245, 0.45);
		--mask: rgb(0 0 0 / 0.6);
		--tooltip-bg: #3a4d63;
		--shadow-rgb: 0 0 0;
	}
}

/* ---------- 3. Compatibilité : variables de Saga lues par components.css de PrimeFaces ---------- */
:root {
	--primary-color: var(--blue);
	--surface-border: var(--line);
}
