/*
 * FLOWAYZ — HANDOFF TOKEN ALIASES (Sprint 1.1, refonte 2026-04-26)
 *
 * Pont entre le naming handoff (`--bg-canvas`, `--text-primary`, `--r-md`,
 * `--ease-out`, `--motion-mult`, `[data-density]`, `[data-anim]`) et le
 * système existant (themes/accents.css, tokens/design_tokens.css).
 *
 * Stratégie : extend, pas replace. Aucun token existant n'est supprimé.
 * Les nouveaux composants (flowayz.css) consomment ces noms standardisés.
 *
 * Source : handoff/code/tokens.css + handoff/01-design-system.md
 *
 * Import order (cf. application.tailwind.css) :
 *   1. design_tokens.css (existant — palette flowayz, surfaces, shadows base)
 *   2. accents.css (existant — HSL accent system + presets)
 *   3. handoff_aliases.css (CE FICHIER — pont handoff)
 *   4. flowayz.css (composants handoff utilisant ces tokens)
 */

/* =============================================================================
   1. NAMING ALIASES — pointent vers les variables existantes
   ============================================================================= */

:root,
[data-theme="light"],
[data-mode="light"] {
  /* Backgrounds — handoff naming, ALIGNÉS sur la refonte « Bento » (2026-07-23)
     pour que les composants .fz-* suivent la même palette off-white chaud que
     le système design_tokens. --bg-canvas == --bg-primary Bento. */
  --bg-canvas:     #EFECE7;
  --bg-surface:    #FFFFFF;
  --bg-surface-2:  #F4F1EC;
  --bg-elev:       #FFFFFF;
  --bg-sidebar:    #FBFAF8;
  --bg-input:      #FFFFFF;
  --bg-muted:      #ECE7E0;
  --bg-hover:      rgba(23, 24, 29, 0.04);

  /* Texte — handoff naming, aligné sur les 4 niveaux Bento. */
  --text-primary-handoff:   #191B20;
  --text-secondary-handoff: #3B3F47;
  --text-muted-handoff:     #71767F;
  --text-inverse:           #FFFFFF;

  /* Borders — handoff naming, aligné Bento */
  --border-handoff:        rgba(23, 24, 29, 0.09);
  --border-strong-handoff: rgba(23, 24, 29, 0.18);
  --border-faint:          rgba(23, 24, 29, 0.05);

  /* Shadow accent — generic alias (existing has --shadow-coral/teal/navy) */
  --shadow-accent: 0 8px 24px -8px var(--accent);
}

[data-theme="dark"],
[data-mode="dark"],
html.dark {
  /* Aligné sur la refonte « Bento » near-black (2026-07-23). */
  --bg-canvas:     #0B0C0F;
  --bg-surface:    #15181E;
  --bg-surface-2:  #101319;
  --bg-elev:       #1C2027;
  --bg-sidebar:    #08090C;
  --bg-input:      #1C2027;
  --bg-muted:      #1C2027;
  --bg-hover:      rgba(255, 255, 255, 0.06);

  --text-primary-handoff:   #F4F5F7;
  --text-secondary-handoff: #C9CFD8;
  --text-muted-handoff:     #8A909B;
  --text-inverse:           #0B0C0F;

  --border-handoff:        rgba(255, 255, 255, 0.07);
  --border-strong-handoff: rgba(255, 255, 255, 0.16);
  --border-faint:          rgba(255, 255, 255, 0.04);

  --shadow-accent: 0 8px 24px -8px var(--accent);
}

/* =============================================================================
   2. RADIUS — handoff scale (--r-sm/md/lg/xl/pill)
   ============================================================================= */
:root {
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-pill: 9999px;
}

/* =============================================================================
   3. DENSITY — driven by [data-density="cozy|compact"]
   ============================================================================= */
:root {
  /* default cozy */
  --density-y: 12px;
  --density-x: 16px;
}
[data-density="cozy"]    { --density-y: 12px; --density-x: 16px; }
[data-density="compact"] { --density-y: 8px;  --density-x: 12px; }

/* =============================================================================
   4. MOTION — durations + easings + multiplier piloté par [data-anim]
   ============================================================================= */
:root {
  --ease-out:    cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --motion-mult: 1;
  --dur-fast:    calc(150ms * var(--motion-mult));
  --dur:         calc(250ms * var(--motion-mult));
  --dur-slow:    calc(400ms * var(--motion-mult));
}

/* L'attribut existant côté layout est `data-animations` (pas `data-anim`).
   On supporte les 2 pour compat avec localStorage existant + handoff naming. */
[data-anim="off"],       [data-animations="off"]    { --motion-mult: 0; }
[data-anim="subtle"],    [data-animations="subtle"] { --motion-mult: 0.6; }
[data-anim="ultra"],     [data-animations="ultra"]  { --motion-mult: 1; }

@media (prefers-reduced-motion: reduce) {
  :root { --motion-mult: 0; }
}

/* -----------------------------------------------------------------------------
   4 bis. VELOURS — loi du mouvement (2026-11-17). Source : docs/design/mouvement.md
   Trois catégories, trois plafonds :
     Geste      ≤ 150 ms  (appui, case, interrupteur)
     Transition ≤ 320 ms  (fenêtre, menu, page, liste) — ressort doux, dépassement ≤ 1,05
     Fête       ≤ 1,2 s   (liste fermée des moments forts, jamais bloquante)
   `--mouvement` vaut 1, ou 0 en Calme / mouvements réduits. Les niveaux Vivante et
   Festive ne changent PAS la vitesse : ils changent ce qui est joué (sons, particules).
   Les ressorts sont de vrais ressorts amortis échantillonnés en `linear()` (CSS pur,
   Chrome 113+, Safari 17.2+, Firefox 112+) ; repli `cubic-bezier` juste au-dessus.
   ----------------------------------------------------------------------------- */
:root {
  --mouvement: 1;
  --dur-geste:      calc(120ms * var(--mouvement));
  --dur-court:      calc(200ms * var(--mouvement));
  --dur-transition: calc(280ms * var(--mouvement));
  --dur-fete:       calc(1200ms * var(--mouvement));

  --ressort-doux: cubic-bezier(0.25, 1.05, 0.5, 1);   /* repli, dépassement ~3 % */
  --ressort-vif:  cubic-bezier(0.3, 1.25, 0.5, 1);    /* repli, dépassement ~5 % */
  --ressort-pop:  cubic-bezier(0.34, 1.56, 0.64, 1);  /* repli — FÊTE et éléments < 48 px seulement */
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --ressort-doux: linear(0, 0.0429, 0.1458, 0.2779, 0.4177, 0.5512, 0.6701, 0.7704, 0.8512, 0.9134, 0.9591, 0.9908, 1.0113, 1.0232, 1.0287, 1.0299, 1.0283, 1.025, 1.021, 1.0168, 1.0128, 1.0094, 1.0065, 1.0041, 1.0023, 1.001, 1.0002, 0.9996, 1);
    --ressort-vif:  linear(0, 0.0488, 0.1657, 0.3145, 0.4699, 0.6154, 0.7415, 0.8439, 0.9223, 0.9785, 1.0156, 1.0375, 1.0478, 1.05, 1.0468, 1.0405, 1.0329, 1.0252, 1.0181, 1.012, 1.007, 1.0033, 1.0007, 0.999, 0.998, 0.9976, 0.9975, 0.9977, 1);
    --ressort-pop:  linear(0, 0.0786, 0.2632, 0.4879, 0.7052, 0.886, 1.0174, 1.0981, 1.1349, 1.1386, 1.1206, 1.0916, 1.0598, 1.0309, 1.0081, 0.9924, 0.9836, 0.9804, 0.9812, 0.9845, 0.9888, 0.9932, 0.997, 0.9998, 1.0016, 1.0026, 1.0028, 1.0025, 1);
  }
}
[data-animations="off"] { --mouvement: 0; }
@media (prefers-reduced-motion: reduce) {
  :root { --mouvement: 0; }
}

/* =============================================================================
   5. ACCENT-SOFT — alias générique (existing accents.css définit --accent-10)
   ============================================================================= */
:root {
  --accent-soft: var(--accent-10, hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.10));
}

/* =============================================================================
   5b. STATUTS BENTO — littéraux partagés (identiques clair/sombre), refonte 2026-07-23
   =============================================================================
   Consommés par les pastilles .pill--{ok,wait,late,info,misc} (components/bento.css)
   et les composants finances/factures. --info reste piloté par --color-blue existant. */
:root {
  --ok:      #0F9D66;   --ok-dot:  #34D399;   --ok-bg:   rgba(52, 211, 153, .15);
  --wait:    #F59E0B;                          --wait-bg: rgba(245, 158, 11, .15);
  --late:    #F87171;                          --late-bg: rgba(248, 113, 113, .15);
  --misc:    #C084FC;                          --misc-bg: rgba(192, 132, 252, .15);
  /* --info / --info-bg : déjà définis dans design_tokens.css (var(--color-blue)). */
}

/* =============================================================================
   6. SCOPE OVERRIDES — empêcher --bg-primary legacy de polluer la landing v7
   =============================================================================
   Le legacy --bg-primary est défini dans tokens/design_tokens.css:219 comme
   hsl(var(--accent-h), 30%, 96%) — un pastel calculé depuis l'accent. Si une
   classe Tailwind ou utility utilise bg-primary sur la landing v7, on aurait
   un fond pastel-pinkish au lieu du cream pur. Cette règle scopée garantit
   que sous .lv7-page, --bg-primary = --bg-canvas exactement. */
.lv7-page {
  --bg-primary: var(--bg-canvas);
}

