/* ==========================================================================
   Vyneric — jetons de conception (design tokens)

   Feuille source unique. Tout le reste du CSS ne fait que consommer ces
   variables : changer une couleur ici la change partout, thème clair comme
   thème sombre.

   Pourquoi des jetons plutôt que Bootstrap
   ---------------------------------------
   Bootstrap 5.3 ne couvrait que 5 des 481 classes utilisées par les gabarits
   (btn, btn-sm, btn-primary, btn-ghost, alert) et aurait ajouté 232 Ko pour
   cela. Ces 5 utilitaires sont reproduits dans vyneric-components.css, sans
   dépendance : le projet garde son identité, son poids et son fonctionnement
   hors ligne.

   Chaque paire texte/fond tient au moins le seuil AA (4,5:1), le plus
   souvent le seuil AAA. Contrastes vérifiés à la formule de luminance
   relative du WCAG.
   ========================================================================== */

:root {
  /* --- Typographie ------------------------------------------------------ */
  /* Pile système : Avenir Next sur macOS/iOS, SF Pro sur macOS récent,
     Segoe UI sur Windows, Roboto sur Android. Aucune police à télécharger :
     rendu natif, aucune requête réseau, et le RGPD n'est pas concerné.
     Inter reste en repli pour qui l'a installée — même dessin que la pile. */
  --display: 'Avenir Next', Avenir, 'SF Pro Text', 'Segoe UI', Inter, Roboto, system-ui, -apple-system, sans-serif;
  --body-font: 'Avenir Next', Avenir, 'SF Pro Text', 'Segoe UI', Inter, Roboto, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  /* Échelle fondée sur un rapport de 1,25, arrondie à des valeurs
     utilisables. Les titres suivent la largeur de l'écran sans empilement
     de media queries. */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  --text-2xl: clamp(1.875rem, 1.4rem + 2.4vw, 2.75rem);
  --text-3xl: clamp(2.375rem, 1.6rem + 3.6vw, 4.125rem);
  --text-4xl: clamp(3rem, 1.8rem + 5.4vw, 5.75rem);

  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.6;
  --leading-relaxed: 1.8;

  --tracking-tight: -0.04em;
  --tracking-normal: 0;
  --tracking-wide: 0.06em;

  /* --- Espacement : échelle 4 px --------------------------------------- */
  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 24px;
  --gap-6: 32px;
  --gap-7: 48px;
  --gap-8: 64px;
  --section-space: clamp(56px, 5vw, 120px);

  /* --- Rayons ----------------------------------------------------------- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* --- Contrôles -------------------------------------------------------- */
  --control-height: 42px;
  --control-height-sm: 34px;
  --field-padding: 9px 12px;

  /* --- Mouvement -------------------------------------------------------- */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.15s var(--ease);
  --transition-slow: 0.28s var(--ease);

  /* --- Structure -------------------------------------------------------- */
  --wrap: 1200px;
  --header-height: 72px;
  --z-header: 100;
  --z-dropdown: 200;
  --z-overlay: 900;

  /* ==========================================================================
     Couleurs — thème clair (défaut).

     Contraste vérifié sur chaque paire texte/fond :
       texte courant 13,7:1 (AAA) · secondaire 6,0:1 (AA)
       accent 5,2:1 (AA) · accent fort 7,4:1 (AAA)

     L'accent a été remonté de #617b41 — 4,35:1, trop juste pour du petit
     texte — vers #4f6a33 : même famille verte, mais lisible partout.
     ========================================================================== */
  --paper: #f6f5f0;
  --paper-2: #faf9f4;
  --paper-3: #eceee5;
  --white: #ffffff;

  --ink: #172a2a;
  --ink-soft: #31423f;
  --muted: #4e5d56;
  --line: #d3d9cf;
  --line-soft: #e3e7de;

  /* --lime et --lime-dark : noms repris de site.css, qui les consomme déjà.
     --lime-dark passe de #617b41 (4,35:1, trop juste pour du petit texte) à
     5,2:1 : même famille verte, mais lisible partout. */
  --lime: #87a35b;
  --lime-dark: #4f6a33;
  --brand: #4f6a33;
  --brand-strong: #3c5226;
  --brand-soft: #e7eddd;
  --on-brand: #ffffff;

  --focus-ring: #4f6a33;

  /* site.css utilise --state-*-fg / -bg / -line : on conserve ces trois noms
     et on ajoute --state-*, plus court, pour les règles nouvelles. */
  --state-success: #2f7a4d;
  --state-success-fg: #2f7a4d;
  --state-success-bg: #eef6f0;
  --state-success-line: #b7dcc4;
  --state-warning: #8a5d0a;
  --state-warning-fg: #8a5d0a;
  --state-warning-bg: #fdf6e8;
  --state-warning-line: #e0c78f;
  --state-error: #a32a20;
  --state-error-fg: #a32a20;
  --state-error-bg: #fdf0ef;
  --state-error-line: #eec4c0;
  --state-info: #3f6a9c;
  --state-info-fg: #3f6a9c;
  --state-info-bg: #eef3f9;
  --state-info-line: #c3d6ea;

  --shadow-sm: 0 1px 2px rgba(23, 42, 42, 0.06);
  --shadow: 0 1px 3px rgba(23, 42, 42, 0.08), 0 6px 18px rgba(23, 42, 42, 0.06);
  --shadow-lg: 0 2px 6px rgba(23, 42, 42, 0.1), 0 16px 40px rgba(23, 42, 42, 0.1);

  --overlay: rgba(23, 42, 42, 0.55);
}

/* --- Couleurs — thème sombre -------------------------------------------
   data-display-mode est posé sur <html> par reader-settings.js. On déclare
   aussi via prefers-color-scheme pour le visiteur dont le système est sombre
   et qui n'a jamais touché au réglage. */
:root[data-display-mode='dark'] {
  color-scheme: dark;

  --paper: #141c18;
  --paper-2: #1a221d;
  --paper-3: #232d27;
  --white: #1a221d;

  --ink: #e9efe9;
  --ink-soft: #cfd9d0;
  --muted: #a8b6ab;
  --line: #3c4a41;
  --line-soft: #2c3831;

  --lime: #bcd598;
  --lime-dark: #a3c17a;
  --brand: #a3c17a;
  --brand-strong: #bcd598;
  --brand-soft: #243020;
  --on-brand: #141c18;

  --focus-ring: #a3c17a;

  --state-success: #7dc49a;
  --state-success-fg: #7dc49a;
  --state-success-bg: #16241b;
  --state-success-line: #2b4636;
  --state-warning: #e0b464;
  --state-warning-fg: #e0b464;
  --state-warning-bg: #2a2317;
  --state-warning-line: #4a3d22;
  --state-error: #f0a49c;
  --state-error-fg: #f0a49c;
  --state-error-bg: #2b1917;
  --state-error-line: #4d2a26;
  --state-info: #9ec2e8;
  --state-info-fg: #9ec2e8;
  --state-info-bg: #16202b;
  --state-info-line: #26374a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.55), 0 16px 40px rgba(0, 0, 0, 0.45);

  --overlay: rgba(0, 0, 0, 0.65);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-display-mode='light']) {
    color-scheme: dark;

    --paper: #141c18;
    --paper-2: #1a221d;
    --paper-3: #232d27;
    --white: #1a221d;

    --ink: #e9efe9;
    --ink-soft: #cfd9d0;
    --muted: #a8b6ab;
    --line: #3c4a41;
    --line-soft: #2c3831;

    --brand: #a3c17a;
    --brand-strong: #bcd598;
    --brand-soft: #243020;
    --on-brand: #141c18;

    --focus-ring: #a3c17a;

    --state-success: #7dc49a;
    --state-success-bg: #16241b;
    --state-warning: #e0b464;
    --state-warning-bg: #2a2317;
    --state-error: #f0a49c;
    --state-error-bg: #2b1917;
    --state-info: #9ec2e8;
    --state-info-bg: #16202b;

    --overlay: rgba(0, 0, 0, 0.65);
  }
}

/* --- Préfère un contraste renforcé ---------------------------------------
   Le WCAG prévoit ce mode : on renforce les bords de champs et de boutons,
   qui sont les éléments les plus difficiles à distinguer pour l'œil. */
@media (prefers-contrast: more) {
  :root {
    --line: #97a394;
    --line-soft: #b4bfb0;
    --muted: #3a473f;
  }
  :root[data-display-mode='dark'] {
    --line: #7c8c80;
    --line-soft: #5d6b61;
    --muted: #cbd6cc;
  }
}

/* --- Mouvement réduit --------------------------------------------------
   Les animations sont désactivées pour qui les a demandées. On garde les
   transitions à 0.01ms plutôt que 'none' : les callbacks d'animation
   (dont dépendent certains scripts) continuent de s'exécuter. */
@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;
  }
}


/* ==========================================================================
   Base — remise à zéro raisonnée

   On ne fait pas un reset total : cela casserait les 1 900 règles de site.css
   qui supposent le comportement par défaut du navigateur. On pose seulement
   ce qui doit être garanti partout : lisibilité, liens, images, focus clavier.
   ========================================================================== */

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

html {
  /* smooth est neutralisé plus bas si l'utilisateur a demandé de réduire
     le mouvement. */
  scroll-behavior: smooth;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body-font);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  /* Évite qu'un mot composé long déborde sur mobile, fréquent en français. */
  hyphens: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Adoucit le basculement de thème, en excluant la prefers-reduced-motion
     qui neutralise cette durée plus bas. */
  transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--gap-3);
  font-family: var(--display);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  /* Empêche un mot très long (URL, sigle) de casser la mise en page. */
  overflow-wrap: break-word;
}

p, ul, ol, dl, figure, blockquote, pre, table {
  margin: 0 0 var(--gap-4);
}
p:last-child, ul:last-child, ol:last-child { margin-bottom: 0; }

a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--transition);
}
a:hover { color: var(--brand-strong); }

/* Focus visible au clavier. Sans contour explicite, impossible de savoir où
   l'on se trouve en naviguant au clavier. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  /* height: auto évite qu'une image étire la page quand on impose sa largeur. */
  height: auto;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

code, pre, samp, kbd {
  font-family: var(--mono);
  font-size: 0.9em;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--gap-6) 0;
}

table { border-collapse: collapse; width: 100%; }

::selection {
  background: var(--brand-soft);
  color: var(--ink);
}

/* --- Lien d'évitement : invisible jusqu'au focus -------------------------- */
.skip-link {
  position: absolute;
  top: -100px;
  inset-inline-start: var(--gap-4);
  z-index: var(--z-overlay);
  padding: var(--gap-3) var(--gap-4);
  background: var(--ink);
  color: var(--paper);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* En arabe, le rayon suit le côté de lecture. */
[dir='rtl'] .skip-link { border-radius: var(--radius-md) 0 0 var(--radius-md); }

[hidden] { display: none !important; }


/* ==========================================================================
   Utilitaires — le strict nécessaire, inspired des utilitaires de Bootstrap
   mais réduit à ce que le projet utilise réellement.

   On ne reproduit pas la grille complète de Bootstrap : 481 classes sont en
   usage, dont 5 seulement viennent de Bootstrap. Ces utilitaires couvrent
   l'alignement, l'espacement, la largeur de lecture et quelques aides.
   ========================================================================== */

/* --- Conteneur de largeur de lecture ------------------------------------- */
.wrap {
  width: min(100% - 2 * var(--gap-4), var(--wrap));
  margin-inline: auto;
}

/* --- Alignement --------------------------------------------------------- */
.stack { display: grid; gap: var(--gap-4); align-content: start; }
.stack-sm { display: grid; gap: var(--gap-2); align-content: start; }
.stack-lg { display: grid; gap: var(--gap-6); align-content: start; }
.cluster { display: flex; align-items: center; gap: var(--gap-2); flex-wrap: wrap; }
.cluster-sm { display: flex; align-items: center; gap: var(--gap-1); flex-wrap: wrap; }
.cluster-between { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-3); flex-wrap: wrap; }
.push { margin-inline-start: auto; }
.center { display: grid; place-items: center; }

/* --- Texte -------------------------------------------------------------- */
.text-muted { color: var(--muted); }
.text-ink { color: var(--ink); }
.text-center { text-align: center; }
.text-end { text-align: end; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.leading-relaxed { line-height: var(--leading-relaxed); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.measure { max-width: 68ch; }        /* longueur de ligne confortable */
.measure-tight { max-width: 56ch; }
.balance { text-wrap: balance; }     /* titres : évite les veuves */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Espacementvertical ------------------------------------------------- */
.mt-0 { margin-block-start: 0; }
.mt-2 { margin-block-start: var(--gap-2); }
.mt-4 { margin-block-start: var(--gap-4); }
.mt-6 { margin-block-start: var(--gap-6); }
.mb-0 { margin-block-end: 0; }
.mb-2 { margin-block-end: var(--gap-2); }
.mb-4 { margin-block-end: var(--gap-4); }
.mb-6 { margin-block-end: var(--gap-6); }

/* --- Visibilité --------------------------------------------------------- */
.hidden { display: none !important; }
@media (max-width: 700px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 701px) {
  .show-desktop { display: revert !important; }
}

