/* ==========================================================================
   Tokens — seul fichier autorisé à contenir des couleurs en dur
   ========================================================================== */

/* Ordre des couches : les utilitaires Tailwind (tailwind.css) passent après les composants */
@layer theme, base, components, utilities;

:root {
  color-scheme: light;

  /* Couleurs — mode clair */
  --bg: #FCF8F1;            /* papier */
  --surface: #FFFCF7;       /* cartes */
  --text: #3A281F;          /* espresso */
  --text-2: rgba(58, 40, 31, .72);
  --text-3: rgba(58, 40, 31, .66);  /* .58 donnait 3,65:1 : relevé pour atteindre 4,5:1 (AA) sur les petits textes */
  --border: rgba(58, 40, 31, .12);
  --action: #9A5125;        /* terracotta = cliquable uniquement */
  --action-hover: #7E4019;
  --on-action: #FCF8F1;
  --focus: #3A281F;
  --accent: #C99A3A;        /* moutarde = badges */
  --on-accent: #3A281F;

  /* Typo */
  --font-title: "DM Serif Display", Georgia, serif;
  --font-text: "Manrope", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --fs-h1: clamp(2.6rem, 6vw, 4.5rem);
  --fs-h2: clamp(1.75rem, 3.5vw, 2.25rem);
  --fs-h3: 1.375rem;
  --fs-body: 1rem;
  --fs-small: .875rem;
  --fs-mono: .8125rem;
  --lh: 1.6;

  /* Espacements (base 4 px) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  /* Formes */
  --r-btn: 6px; --r-card: 10px; --r-pill: 999px;
  --maxw: 1100px; --readw: 68ch;

  /* Mouvement (transition de page) */
  --page-out: .15s;         /* sortie du contenu, pendant que le repère de navigation glisse */
  --page-in: .35s;          /* arrivée du contenu de la nouvelle page */
  --ease-out: cubic-bezier(.22, 1, .36, 1);

  /* Coloration syntaxique : blocs de code, toujours sur fond sombre (charte) */
  --code-bg: #2A1F19;
  --code-text: #FCF8F1;     /* aussi les fonctions */
  --code-keyword: #D9804F;
  --code-string: #E0B65C;
  --code-type: #E6C9A0;
  --code-number: #D69A86;
  --code-comment: #A08B7C;
}

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

  --bg: #1E1612;            /* nuit */
  --surface: #2A1F19;
  --text: #FCF8F1;
  --text-2: rgba(252, 248, 241, .75);
  --text-3: rgba(252, 248, 241, .55);
  --border: rgba(252, 248, 241, .12);
  --action: #D9804F;        /* terracotta claire */
  --action-hover: #EBA27A;   /* terracotta plus claire, pas la moutarde */
  --on-action: #1E1612;
  --focus: #C99A3A;
  --accent: #C99A3A;
  --on-accent: #1E1612;
}

/* ==========================================================================
   Base
   ========================================================================== */

@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
  }

  body {
    font-family: var(--font-text);
    font-size: var(--fs-body);
    line-height: var(--lh);
    margin: 0;
  }

  h1, h2, h3, h4 {
    font-family: var(--font-title);
    font-weight: 400;
    line-height: 1.1;
    color: var(--text);
    text-wrap: balance;
  }

  h1 { font-size: var(--fs-h1); }
  h2 { font-size: var(--fs-h2); }
  h3 { font-size: var(--fs-h3); }
  h4 { font-size: var(--fs-h3); }

  p {
    max-width: var(--readw);
    color: var(--text-2);
  }

  img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  .container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--s5);
  }

  :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  ::selection {
    background: var(--accent);
    color: var(--on-accent);
  }

  @media (prefers-reduced-motion: reduce) {
    * {
      animation: none !important;
      transition: none !important;
    }
  }
}
