/*
 * Arboria Mundi — Chaque arbre, un monde.
 * Tokens de la charte opérationnelle 1.0 (3 novembre 2026), communs au site et à la console.
 * Les composants emploient les couleurs sémantiques, jamais directement la palette de marque.
 * Les noms de la DA V1 (--am-surface-alt, --am-control-border…) restent des alias.
 */

:root {
  color-scheme: light;

  /* Palette de marque (référence, pas pour les composants) */
  --am-brand-foret: #183A2E;
  --am-brand-feuillage: #3F6B50;
  --am-brand-lichen: #A7C49A;
  --am-brand-ivoire: #F6F3EB;
  --am-brand-sable: #E7DFD2;
  --am-brand-ocre: #B8863B;
  --am-brand-nuit: #0D1613;
  --am-brand-sous-bois: #1E2E27;
  --am-brand-mousse: #2F493C;
  --am-brand-lichen-clair: #D9E3D2;
  --am-brand-ivoire-sombre: #E8E2D5;
  --am-brand-lumiere: #C9A65A;

  /* Sémantique, thème clair */
  --am-bg: #F6F3EB;
  --am-surface: #FCFBF7;
  --am-surface-raised: #FFFFFF;
  --am-surface-soft: #E7DFD2;
  --am-text: #183A2E;
  --am-text-muted: #53665B;
  --am-action: #183A2E;
  --am-action-hover: #244F3C;
  --am-on-action: #F6F3EB;
  --am-link: #285A40;
  --am-border: #D2D6CD;
  --am-border-control: #748277;
  --am-focus: #76511E;
  --am-selected: #D9E3D2;
  --am-on-selected: #183A2E;
  --am-success: #24503A;
  --am-success-bg: #E5EDE1;
  --am-warning: #704B15;
  --am-warning-bg: #F2E8D4;
  --am-danger: #962F35;
  --am-danger-bg: #F8E7E4;
  --am-info: #28556C;
  --am-info-bg: #E7EFF2;
  --am-decoration: #B8863B;
  --am-overlay: rgb(13 22 19 / 56%);
  --am-shadow-card: 0 1px 2px rgb(24 58 46 / 6%), 0 8px 24px -12px rgb(24 58 46 / 18%);
  --am-shadow-popover: 0 12px 32px -8px rgb(13 22 19 / 22%);

  /* Alias DA V1 */
  --am-surface-alt: var(--am-surface-soft);
  --am-control-border: var(--am-border-control);
  --am-selected-text: var(--am-on-selected);
  --am-selected-control-border: var(--am-border-control);
  --am-accent: var(--am-focus);

  /* Typographie */
  --am-font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --am-font-editorial: var(--am-font-display);
  --am-font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --am-weight-regular: 400;
  --am-weight-medium: 500;
  --am-weight-semibold: 600;
  --am-type-display: clamp(2.5rem, 1.6rem + 4vw, 5.5rem);
  --am-type-h1: clamp(2.25rem, 1.7rem + 2.7vw, 4rem);
  --am-type-h2: clamp(1.75rem, 1.4rem + 1.6vw, 2.75rem);
  --am-type-h3: clamp(1.375rem, 1.2rem + .8vw, 1.875rem);
  --am-type-body: 1.125rem;   /* lecture : 18 px */
  --am-type-ui: 1rem;         /* interface : 16 px */
  --am-type-small: .875rem;   /* aide, légende : 14 px */
  --am-line-title: 1.08;
  --am-line-body: 1.65;
  --am-line-ui: 1.5;
  --am-reading-max: 68ch;
  --am-measure: var(--am-reading-max);

  /* Espacements 4 → 128 px */
  --am-space-0: 0;
  --am-space-1: .25rem;
  --am-space-2: .5rem;
  --am-space-3: .75rem;
  --am-space-4: 1rem;
  --am-space-6: 1.5rem;
  --am-space-8: 2rem;
  --am-space-12: 3rem;
  --am-space-16: 4rem;
  --am-space-24: 6rem;
  --am-space-32: 8rem;
  --am-gutter: clamp(1.25rem, 3.5vw, 4rem);
  --am-public-max: 90rem;
  --am-page-max: var(--am-public-max);
  --am-console-max: 105rem;
  --am-console-nav: 15rem;
  --am-control-min: 2.75rem;  /* cible 44 px */
  --am-button-min: 3rem;      /* bouton 48 px */
  --am-field-min: 3rem;

  /* Formes : 8 contrôles, 12 cartes, 16 dialogues */
  --am-radius-control: .5rem;
  --am-radius-card: .75rem;
  --am-radius-dialog: 1rem;
  --am-radius-image: var(--am-radius-card);
  --am-radius-pill: 999px;
  --am-rule: 1px;
  --am-focus-width: 3px;
  --am-focus-offset: 3px;

  /* Mouvement */
  --am-duration-fast: 140ms;
  --am-duration-normal: 220ms;
  --am-duration-panel: 320ms;
  --am-duration-image: var(--am-duration-panel);
  --am-ease: cubic-bezier(.2, .7, .2, 1);
}

/* Thème sombre : suit le système sans choix explicite… */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --am-bg: #0D1613;
    --am-surface: #1E2E27;
    --am-surface-raised: #2F493C;
    --am-surface-soft: #17251F;
    --am-text: #F6F3EB;
    --am-text-muted: #BAC8B7;
    --am-action: #D9E3D2;
    --am-action-hover: #EDF1E8;
    --am-on-action: #183A2E;
    --am-link: #D9E3D2;
    --am-border: #40594A;
    --am-border-control: #95A88F;
    --am-focus: #C9A65A;
    --am-selected: #334C3D;
    --am-on-selected: #F6F3EB;
    --am-success: #D9E3D2;
    --am-success-bg: #223D2B;
    --am-warning: #E7CA8E;
    --am-warning-bg: #3A301D;
    --am-danger: #F3B0A8;
    --am-danger-bg: #432829;
    --am-info: #AACFDF;
    --am-info-bg: #1D3440;
    --am-decoration: #C9A65A;
    --am-overlay: rgb(0 0 0 / 64%);
    --am-shadow-card: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 28px -14px rgb(0 0 0 / 60%);
    --am-shadow-popover: 0 14px 36px -8px rgb(0 0 0 / 55%);
  }
}

/* …ou sur choix explicite. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --am-bg: #0D1613;
  --am-surface: #1E2E27;
  --am-surface-raised: #2F493C;
  --am-surface-soft: #17251F;
  --am-text: #F6F3EB;
  --am-text-muted: #BAC8B7;
  --am-action: #D9E3D2;
  --am-action-hover: #EDF1E8;
  --am-on-action: #183A2E;
  --am-link: #D9E3D2;
  --am-border: #40594A;
  --am-border-control: #95A88F;
  --am-focus: #C9A65A;
  --am-selected: #334C3D;
  --am-on-selected: #F6F3EB;
  --am-success: #D9E3D2;
  --am-success-bg: #223D2B;
  --am-warning: #E7CA8E;
  --am-warning-bg: #3A301D;
  --am-danger: #F3B0A8;
  --am-danger-bg: #432829;
  --am-info: #AACFDF;
  --am-info-bg: #1D3440;
  --am-decoration: #C9A65A;
  --am-overlay: rgb(0 0 0 / 64%);
  --am-shadow-card: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 28px -14px rgb(0 0 0 / 60%);
  --am-shadow-popover: 0 14px 36px -8px rgb(0 0 0 / 55%);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --am-duration-fast: 0ms;
    --am-duration-normal: 0ms;
    --am-duration-panel: 0ms;
  }
}

/*
 * --am-border ne sert qu'aux séparations décoratives ; un champ s'identifie avec --am-border-control.
 * --am-decoration (ocre) est décoratif : jamais pour du texte courant sur ivoire.
 * Les statuts associent toujours texte et repère, jamais la couleur seule.
 */
