/* ============================================================
   PREFABLY — DESIGN TOKENS (direction F · Atelier)
   Source unique des couleurs, polices, rayons et espacements : design-f-atelier/DESIGN.md §3 et project/f.css.
   Mode sombre uniquement pour cette refonte (le mode clair viendra plus tard).
   Une seule couleur d'accent : #3ECF8E. Seuls autres usages colorés : avertissement #E8C46A, erreur #FF6961.
   Les anciens noms (--color-*, --text-*, --space-*, --radius-*, --motion-*…) restent définis plus bas pour les
   écrans pas encore refaits ; ils prennent les valeurs F.
   ============================================================ */
:root {
  /* Fonds */
  --f-bg: #0C0D10;        /* fond de l'application */
  --f-stage: #0A0B0D;     /* scène et rail */
  --f-right: #111215;     /* colonne droite (bibliothèque, inspecteur) */
  /* Surfaces */
  --f-card: #141518;
  --f-pj: #15161A;        /* carte projet */
  --f-input: #18191D;
  --f-s2: #1A1B1F;
  --f-sel: #1C1D21;       /* type sélectionné */
  --f-s3: #202126;
  --f-s4: #26272C;        /* boutons secondaires */
  /* Texte */
  --f-text: #F5F5F7;
  --f-text-2: #B6B6BA;
  --f-text-body: #E4E4E7;
  --f-muted: #8E8E94;
  --f-dim: #6E6E74;
  /* Accent unique, avertissement, erreur */
  --f-accent: #3ECF8E;
  --f-accent-12: rgba(62, 207, 142, 0.12);
  --f-accent-18: rgba(62, 207, 142, 0.18);
  --f-warn: #E8C46A;
  --f-warn-bg: #2A2416;
  --f-error: #FF6961;
  /* Bordures */
  --f-line: rgba(255, 255, 255, 0.06);
  --f-line-2: rgba(255, 255, 255, 0.08);
  --f-line-3: rgba(255, 255, 255, 0.1);
  --f-line-4: rgba(255, 255, 255, 0.12);
  /* Polices */
  --f-font-title: 'Manrope', sans-serif;
  --f-font-ui: 'Inter', sans-serif;
  --f-font-mono: 'Geist Mono', monospace;
  --f-font-logo: 'Silkscreen', monospace;
  /* Rayons */
  --f-r-control: 10px;
  --f-r-card: 14px;
  --f-r-big: 22px;
  --f-r-pill: 99px;
  /* Grille de l'application */
  --f-rail-w: 72px;
}

/* Manrope (titres), Geist Mono (coûts, chemins, étiquettes), Silkscreen (logo seul) : polices variables
   Fontsource, auto-hébergées (l'application tourne aussi dans Electron et hors ligne), licences OFL dans /fonts. */
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 200 800; font-display: swap; src: url('/fonts/manrope-latin-wght-normal.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: 200 800; font-display: swap; src: url('/fonts/manrope-latin-ext-wght-normal.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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Geist Mono'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/geist-mono-latin-wght-normal.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: 'Geist Mono'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/geist-mono-latin-ext-wght-normal.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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Silkscreen'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/silkscreen-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Silkscreen'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/silkscreen-latin-700-normal.woff2') format('woff2'); }

/* ---------- Anciens noms, valeurs F (sombre) ---------- */
:root {
  /* Backgrounds */
  --color-bg: #0C0D10;
  --color-surface: #141518;
  --color-surface-raised: #1A1B1F;
  --color-surface-hover: #1A1B1F;
   --color-surface-active: #202126;
   --color-bg-subtle: rgba(255, 255, 255, 0.03);

  /* Textes */
  --color-text: #F5F5F7;
  --color-text-secondary: #B6B6BA;
  --color-text-muted: #8E8E94; /* 4,9:1 sur blanc, 4,7:1 sur --color-surface-raised (WCAG AA) */
  --color-text-disabled: #6E6E74;
  --color-text-inverse: #0C0D10;

  /* Bordures */
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-strong: rgba(255, 255, 255, 0.12);
  --color-border-subtle: rgba(255, 255, 255, 0.06);

  /* Overlay */
  --color-overlay: rgba(0, 0, 0, 0.7);
  --color-overlay-strong: rgba(0, 0, 0, 0.85);

  /* Accent (principal = noir en light, blanc en dark) */
  --color-accent: #3ECF8E;
  --color-accent-contrast: #0C0D10;
  --color-accent-hover: color-mix(in srgb, #3ECF8E 88%, white);
  --color-accent-active: color-mix(in srgb, #3ECF8E 80%, black);

  /* États fonctionnels (réservés aux cas nécessitant une distinction) */
  --color-success: #3ECF8E;
  --color-success-bg: rgba(62, 207, 142, 0.12);
  --color-success-border: rgba(62, 207, 142, 0.35);
  --color-warning: #E8C46A; /* 5,5:1 sur blanc, 5,2:1 sur --color-warning-bg (WCAG AA) */
  --color-warning-bg: #2A2416;
  --color-warning-border: rgba(232, 196, 106, 0.3);
  --color-danger: #FF6961;
  --color-danger-bg: #3A1414;
  --color-danger-border: #C62828;
  --color-info: #64D2FF;
  --color-info-bg: #0E2440;
  --color-info-border: #1565C0;
  --color-dirty: #FFAB40;
  --color-pink: #F783AC;
  /* Flèche des listes déroulantes (une image ne peut pas suivre currentColor). */
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 12 12'%3E%3Cpath fill='%23D4D4D4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");

  /* Sévérité / statut (couleurs fonctionnelles) */
  --color-severity-critical: #FF6961;
  --color-severity-high: #FF6961;
  --color-severity-medium: #E8C46A;
  --color-status-active: #3ECF8E;
  --color-status-warning: #E8C46A;
   --color-status-attention: #E8C46A;

  /* Couleurs fonctionnelles de l'éditeur de workflow (conservées par A5 §30) */
  --color-edge-inactive: #8A929E;
  --color-edge-done: #7A7F8A;
  --color-port-default: #8A929E;

  /* Couleurs de catégorie des blocs et de type de données (DS-04) : lues par workflow-editor.js */
  --cat-inputs: #7B68C8;
  --cat-workflow: #10B981;
  --cat-unity: #4A90D9;
  --cat-github: #8B949E;
  --cat-notion: #9B9B9B;
  --cat-figma: #A259FF;
  /* Connecteurs ajoutés : couleur de marque, éclaircie si besoin pour un texte noir à 4,5:1. */
  --cat-gitlab: #FC6D26;
  --cat-jira: #2684FF;
  --cat-slack: #36C5F0;
  --cat-discord: #6E79F4;
  --cat-blender: #EA7600;
  --cat-generation: #E8873A;
  --cat-import-export: #3FB27F;
  --cat-variables: #EF4444;
  --cat-other: #8A929E;
  /* Document 8, phase 4: groups of the palette that had no colour of their own. */
  --cat-loops: #14B8C4;
  --cat-text: #D6A31B;
  --cat-math: #E0609E;
  --cat-quality: #8FB339;
  /* Texte posé sur chaque couleur de catégorie (en-tête des blocs) : noir ou blanc,
     celui qui atteint 4,5:1. */
  --cat-inputs-text: #000;
  --cat-workflow-text: #000;
  --cat-unity-text: #000;
  --cat-github-text: #000;
  --cat-notion-text: #000;
  --cat-figma-text: #000;
  --cat-gitlab-text: #000;
  --cat-jira-text: #000;
  --cat-slack-text: #000;
  --cat-discord-text: #000;
  --cat-blender-text: #000;
  --cat-generation-text: #000;
  --cat-import-export-text: #000;
  --cat-variables-text: #000;
  --cat-other-text: #000;
  --cat-loops-text: #000;
  --cat-text-text: #000;
  --cat-math-text: #000;
  --cat-quality-text: #000;
  /* Document 8, phase 3: one hue per family the user sees (texte, nombre, vrai/faux, liste, objet, tout). Whole
     numbers and numbers are one family, so they share a hue; list and object have their own hue AND their own
     shape (workflow-editor.css), so none of the pairs the eye confused (nombre/entier, objet/liste, texte/tout) is left. */
  --type-any: #8E97A5;
  --type-string: #6CB6FF;
  --type-integer: #F1C644;
  --type-number: #F1C644;
  --type-boolean: #F07AAA;
  --type-object: #B58CFF;
  --type-array: #4FD1A5;
  /* Document 10, point 10: the three Unity references, each with its own hue (hues not used above). */
  --type-scene-object: #FB923C;
  --type-prefab: #22D3EE;
  --type-asset: #A3E635;

  /* --- Typographie --- */
  --font-ui: 'Inter', sans-serif;
  --font-display: 'Manrope', sans-serif;
  --font-mono: 'Geist Mono', 'SFMono-Regular', Consolas, monospace;

  /* Échelle typographique (~1.25 ratio) */
  --text-11: 11px;
  --text-12: 12px;
  --text-13: 13px;
  --text-14: 14px;
  --text-15: 15px;
  --text-10: 10px;
  --text-16: 16px;
  --text-19: 19px;
  --text-24: 24px;
  --text-34: 34px;
  --text-48: 48px;
  --text-64: 64px;

  /* Poids */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Hauteurs de ligne */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.6;

  /* --- Espacements (base 4px) --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;
  --space-32: 128px;

  /* --- Rayons --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* --- Ombres (discrètes) --- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.45), 0 8px 16px rgba(0, 0, 0, 0.35);
  --shadow-panel: -4px 0 24px rgba(0, 0, 0, 0.18);

  /* --- Mouvement (Document 2 v2, §7.1) : toute transition et toute animation passe par
     ces jetons (garde-fou : test/phase4-finishing.test.js). Les valeurs changent sous
     html[data-motion="reduced|none"] (voir la fin du fichier). --- */
  --motion-instant: 80ms;   /* appui sur un bouton, coche */
  --motion-fast: 140ms;     /* survol, focus, infobulle, ouverture d'un menu */
  --motion-base: 220ms;     /* menus, panneaux, toasts, changement d'écran */
  --motion-slow: 320ms;     /* tiroir, panneau latéral, défilement du canvas */
  --motion-emphasis: 480ms; /* succès, première apparition, compteurs */
  --motion-exit-fast: 100ms; /* fermeture d'un menu (≈ 30 % plus rapide que l'entrée) */
  --motion-exit: 160ms;     /* fermeture d'une modale, d'un toast */
  --motion-stagger: 20ms;   /* cascade des listes, par élément (12 au plus) */
  /* Boucles : seulement pour les états en cours (chargement, exécution, attente). */
  --motion-loop-spin: 800ms;
  --motion-loop-shimmer: 1.4s;
  --motion-loop-pulse: 1.8s;
  --motion-loop-breathe: 2s;
  --motion-loop-slow: 3s;
  /* Exécution visuelle (§6.2–6.4) */
  --motion-run-lap: 1.6s;       /* un tour de la lumière autour du bloc */
  --motion-run-cascade: 30ms;   /* décalage de la cascade « en attente » */
  --motion-edge-trip: 700ms;    /* trajet de la lumière dans une connexion */
  --ease-standard: cubic-bezier(.2, .7, .3, 1);
  --ease-enter: cubic-bezier(0, 0, .2, 1);
  --ease-exit: cubic-bezier(.4, 0, 1, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  /* Anciens noms (alias de compatibilité) */
  --ease: var(--ease-standard);
  --ease-out: var(--ease-enter);
  --ease-in: var(--ease-exit);
  --dur-fast: var(--motion-fast);
  --dur: var(--motion-base);
  --dur-slow: var(--motion-slow);
  /* Lumière d'exécution : la même couleur tourne autour du bloc puis file dans les connexions. */
  --run-light: #60A5FA;

  /* --- Z-index --- */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-header: 1000;
  --z-modal-backdrop: 2000;
  --z-modal: 2100;
  --z-popover: 3000;
  --z-toast: 4000;

  /* --- Largeurs --- */
  --content-max: 1280px;
  --sidebar-width: 280px;
  --panel-width: 440px;

  /* --- Barre de défilement --- */
  --scrollbar-bg: rgba(255, 255, 255, 0.05);
  --scrollbar-thumb: rgba(255, 255, 255, 0.16);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.26);

  /* --- Hover states --- */
  --color-hover: rgba(255, 255, 255, 0.06);
  --color-active: rgba(255, 255, 255, 0.04);
  --color-accent-hover-bg: rgba(255, 255, 255, 0.2);
  --color-neutral-subtle: rgba(255, 255, 255, 0.08);
  --header-bg: rgba(12, 13, 16, 0.86);

  /* --- Transition par défaut --- */
  --transition: var(--dur) var(--ease);
  --transition-fast: var(--dur-fast) var(--ease);
}

/* --- Alias de compatibilité (pour migration progressive) --- */
:root {
  --paper: var(--color-bg);
  --panel: var(--color-surface);
  --raised: var(--color-surface-raised);
  --ink: var(--color-text);
  --ink-70: var(--color-text-secondary);
  --ink-55: var(--color-text-secondary);
  --ink-35: var(--color-text-muted);
  /* Alias utilisés par workflow-editor.css (n'étaient définis nulle part) */
  --ink-40: var(--color-text-muted);
  --ink-65: var(--color-text-secondary);
  --danger: var(--color-danger);
  --danger-hover: var(--color-severity-critical);
  --link-color: var(--color-info);
  --ink-45: var(--color-text-muted);
  --ink-14: var(--color-border);
  --ink-08: var(--color-border-subtle);

  --s-11: var(--text-11);
  --s-12: var(--text-12);
  --s-13: var(--text-13);
  --s-14: var(--text-14);
  --s-15: var(--text-15);
  --s-10: var(--text-10);
  --s-16: var(--text-16);
  --s-19: var(--text-19);
  --s-24: var(--text-24);
  --s-34: var(--text-34);
  --s-48: var(--text-48);
  --s-64: var(--text-64);

  --radius: var(--radius-md);
}

/* --- Noms du DESIGN.md (direction « E »), alias des tokens sémantiques ci-dessus :
   ils prennent donc la valeur du thème actif (sombre par défaut, clair plus tard).
   `[data-theme]` : un élément qui force son thème (l'éditeur de workflow reste sombre) les résout à nouveau,
   sinon ils hériteraient de la valeur déjà résolue sur :root. --- */
:root, [data-theme] {
  --bg: var(--color-bg);
  --solid: var(--color-surface);
  --solid-2: var(--color-surface-raised);
  --solid-3: var(--color-surface-active);
  --line: var(--color-border);
  --line-2: var(--color-border-strong);
  --t1: var(--color-text);
  --t2: var(--color-text-secondary);
  --t3: var(--color-text-muted);
  --ok: var(--color-success);
  --warn: var(--color-warning);
  --err: var(--color-danger);
  --run: var(--color-info);
  /* Rayons : cartes et panneaux 20, boutons et champs 12–14, pastilles 999. */
  --radius-card: 20px;
  --radius-control: 12px;
  --radius-pill: 999px;
  --control-h: 44px;
}

/* Inter servie par l'application (Document 4, ELE-01) : aucune police
   chargée depuis Internet, rendu identique hors ligne et dans Electron. Polices variables
   (Fontsource 5.3.0), sous-ensembles latin et latin étendu, licences OFL dans /fonts. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations'), url('/fonts/inter-latin-wght-normal.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: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations'), url('/fonts/inter-latin-ext-wght-normal.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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}


:root {
  --icon-sm: 16px;
  --icon-md: 20px;
}


/* Niveau d'animation (§7.3, §7.4) : html[data-motion] est posé dans le <head> par
   js/preferences.js (réglage « Animations », sinon prefers-reduced-motion).
   - « Réduites » : aucune translation, échelle ni secousse ; seuls les fondus (opacité,
     couleurs) de 120 ms au plus restent.
   - « Aucune » : plus aucune animation ni transition.
   Dans les deux cas, les états restent lisibles par la couleur, les badges et le texte. */
html[data-motion="reduced"] {
  --motion-fast: 120ms;
  --motion-base: 120ms;
  --motion-slow: 120ms;
  --motion-emphasis: 120ms;
  --motion-exit-fast: 80ms;
  --motion-exit: 120ms;
  --motion-stagger: 0ms;
}
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after {
  animation: none !important;
  transition-property: opacity, color, background-color, border-color, outline-color, fill, stroke !important;
  scroll-behavior: auto !important;
}
html[data-motion="none"] {
  --motion-instant: 0ms;
  --motion-fast: 0ms;
  --motion-base: 0ms;
  --motion-slow: 0ms;
  --motion-emphasis: 0ms;
  --motion-exit-fast: 0ms;
  --motion-exit: 0ms;
  --motion-stagger: 0ms;
}
html[data-motion="none"] *, html[data-motion="none"] *::before, html[data-motion="none"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* Repli si js/preferences.js n'a pas pu s'exécuter. */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion]) *, html:not([data-motion]) *::before, html:not([data-motion]) *::after {
    animation: none !important;
    transition: none !important;
  }
}