/* ============================================================================
   Jetons de conception — Ma Cuisine
   ----------------------------------------------------------------------------
   Les jetons sont nommés par RÔLE, pas par apparence. L'ancien système
   (--cream, --ink, --rust…) décrivait des couleurs : rien n'empêchait
   d'utiliser le jeton de texte comme fond, ce que faisait #auth-screen, et le
   thème sombre s'inversait alors à l'envers. Le mode sombre redéfinit
   uniquement les jetons ci-dessous ; aucun composant ne devrait avoir besoin
   d'une règle [data-theme="dark"] dédiée.

   Les anciens noms restent définis en fin de fichier comme alias, le temps que
   les composants migrent.
   ========================================================================== */

:root {
  color-scheme: light;

  /* ── Surfaces ── */
  --surface-page:    #F7F6F1;
  --surface-card:    #FFFFFF;
  --surface-raised:  #FFFFFF;   /* modales, panneaux flottants */
  --surface-sunken:  #EDF1EA;   /* champs, pastilles, zones en creux */
  --surface-header:  rgba(247, 246, 241, 0.96);

  /* ── Texte ──
     --text-secondary est volontairement plus sombre que l'ancien --mid
     (#7A8A82), qui plafonnait à 3,0:1 sur blanc et échouait le seuil AA. */
  --text-primary:    #1F2A24;
  --text-secondary:  #566B60;
  --text-muted:      #7A8A82;   /* décoratif uniquement, jamais du texte courant */
  --text-on-accent:  #FFFFFF;

  /* ── Accent ── */
  --accent:          #2E7D57;
  --accent-hover:    #245E42;
  --accent-soft:     #3C6E55;
  --accent-weak:     #EDF1EA;

  /* ── Sémantique ──
     --rating est l'or décoratif de la marque (bordures, survols, fonds).
     Il tombe à 1,9:1 sur blanc, donc il ne doit jamais porter du texte :
     --gold-text est sa contrepartie lisible (5,4:1 sur blanc).
     --rating-graphic sert aux étoiles, qui sont un objet graphique et
     demandent 3:1. */
  --rating:          #E8A84C;
  --rating-graphic:  #B8791A;
  --gold-text:       #8A6410;
  --danger:          #9B2A3A;
  --success:         #2E7D57;
  --warning:         #B26A1B;

  /* ── Bordures ── */
  --border:          rgba(46, 125, 87, 0.15);
  --border-strong:   rgba(46, 125, 87, 0.28);

  /* ── Triplets RGB ──
     Remplacent les 37 rgba() écrits à la main à 14 opacités différentes. */
  --accent-rgb:      46, 125, 87;
  --ink-rgb:         31, 42, 36;
  --rating-rgb:      232, 168, 76;

  /* ── Élévation ── */
  --shadow-sm:       0 2px 12px rgba(31, 42, 36, 0.06);
  --shadow:          0 4px 24px rgba(31, 42, 36, 0.08);
  --shadow-lg:       0 12px 48px rgba(31, 42, 36, 0.14);
  --shadow-modal:    0 24px 80px rgba(31, 42, 36, 0.28);

  /* ── Rayons ── */
  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       16px;
  --radius-xl:       20px;
  --radius-pill:     999px;

  /* ── Espacement, grille de 4 px ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* ── Échelle typographique ──
     Six pas, contre 34 tailles distinctes auparavant. */
  --text-xs:   0.72rem;
  --text-sm:   0.82rem;
  --text-base: 0.95rem;
  --text-md:   1.1rem;
  --text-lg:   1.4rem;
  --text-xl:   2rem;

  --font-sans:  'DM Sans', system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;

  /* ── Icônes ── */
  --icon-sm: 16px;
  --icon-md: 18px;
  --icon-lg: 22px;

  /* ── Mouvement ── */
  --dur-fast: 0.15s;
  --dur-base: 0.2s;
  --dur-slow: 0.3s;
}

[data-theme="dark"] {
  color-scheme: dark;

  --surface-page:    #14181A;
  --surface-card:    #1B2220;
  --surface-raised:  #1B2220;
  --surface-sunken:  #1D2422;
  --surface-header:  #1A211E;

  --text-primary:    #EDEEE8;
  --text-secondary:  #A9BAB1;
  --text-muted:      #8A9C92;
  --text-on-accent:  #0E1412;

  --accent:          #4BAA7E;
  --accent-hover:    #5FC091;
  --accent-soft:     #5FA88A;
  --accent-weak:     #223029;

  --rating:          #F0B75A;
  --rating-graphic:  #F0B75A;
  --gold-text:       #F0B75A;
  --danger:          #C45E6B;
  --success:         #4BAA7E;
  --warning:         #D9944A;

  --border:          rgba(143, 168, 139, 0.16);
  --border-strong:   rgba(143, 168, 139, 0.30);

  --accent-rgb:      75, 170, 126;
  --ink-rgb:         0, 0, 0;
  --rating-rgb:      240, 183, 90;

  --shadow-sm:       0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow:          0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg:       0 12px 48px rgba(0, 0, 0, 0.6);
  --shadow-modal:    0 24px 80px rgba(0, 0, 0, 0.7);
}

/* ============================================================================
   Alias de compatibilité
   Les anciens noms pointent vers les jetons de rôle, pour que les composants
   pas encore migrés continuent de fonctionner dans les deux thèmes.
   ========================================================================== */
:root,
[data-theme="dark"] {
  --cream:   var(--surface-page);
  --ink:     var(--text-primary);
  --warm:    var(--accent-soft);
  --rust:    var(--accent);
  --gold:    var(--rating);
  --sage:    var(--text-muted);
  --wine:    var(--danger);
  --pale:    var(--surface-sunken);
  --mid:     var(--text-secondary);
  --card-bg: var(--surface-card);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
