/* =====================================================================
   ESS — Base: reset, typography, layout primitives, a11y
   ===================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--c-ink);
  background: var(--c-paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* Arabic / RTL — activé en phase bilingue */
[dir="rtl"] body,
html[lang="ar"] body { font-family: var(--font-arabic); }

img, picture, svg, video { display: block; max-width: 100%; height: auto; }

a { color: var(--c-blue); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--c-sky); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

ul, ol { list-style: none; padding: 0; }

/* ---- Headings ------------------------------------------------------ */
h1, h2, h3, h4, h5 {
  font-family: var(--font-head);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--c-ink);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); line-height: var(--lh-snug); }
h4 { font-size: var(--fs-h4); font-weight: var(--fw-semi); }

p { text-wrap: pretty; }

/* ---- Échelle typographique — classes utilitaires -------------------
   Référence unique du site (tokens dans tokens.css). Utiliser ces classes
   pour tout texte qui n'est pas un titre sémantique h1–h4. */
.text-hero    { font-size: var(--fs-display); }   /* Hero — 64px */
.text-h1      { font-size: var(--fs-h1); }         /* 48px */
.text-h2      { font-size: var(--fs-h2); }         /* 36px */
.text-h3      { font-size: var(--fs-h3); }         /* 28px */
.text-h4      { font-size: var(--fs-h4); }         /* 22px */
.text-body-lg { font-size: var(--fs-lead); }       /* Body large — 18px */
.text-body    { font-size: var(--fs-base); }       /* Body — 16px */
.text-sm      { font-size: var(--fs-sm); }         /* Small / metadata — 14px */
.text-caption { font-size: var(--fs-xs); }         /* Caption — 12px */

strong, b { font-weight: var(--fw-semi); }

/* SÉLECTION — vert de marque, texte noir. L'ancien couple (blanc sur bleu
   ciel) ne donnait que 2,99:1, sous le minimum AA de 4,5:1 : sélectionner
   un paragraphe le rendait MOINS lisible qu'avant de le sélectionner. Le
   couple de surlignage vaut 7,93:1. */
::selection { background: var(--c-highlight); color: var(--c-highlight-fg); }

/* ---- Focus (a11y) -------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--c-sky);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---- Skip link ----------------------------------------------------- */
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -60px;
  z-index: 200;
  background: var(--c-blue);
  color: #fff;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  font-weight: var(--fw-semi);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--sp-4); color: #fff; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* =====================================================================
   Layout primitives
   ===================================================================== */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--wide { max-width: var(--container-wide); }
.container--text { max-width: var(--container-text); }

.section { padding-block: var(--section-y); }
.section--mist { background: var(--c-mist); }
.section--blue { background: var(--c-blue); color: #fff; }
.section--tight { padding-block: calc(var(--section-y) * 0.6); }

/* Responsive auto-grid: desktop 3 / tablet 2 / mobile 1 */
.grid { display: grid; gap: var(--sp-5); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

@media (max-width: 900px) {
  .grid--3, .grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }

.flow > * + * { margin-top: 1em; }
.flow h2 { margin-top: 1.6em; }
.flow h3 { margin-top: 1.4em; }

.center { text-align: center; }
.measure { max-width: 60ch; }
.mx-auto { margin-inline: auto; }

/* Utility spacing */
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }
.hidden { display: none !important; }

/* ---- Reveal on scroll ---------------------------------------------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}
[data-reveal].is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* ---- Horizontal carousel ------------------------------------------- */
.carousel { position: relative; }
.carousel__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(300px, 1fr);
  gap: var(--sp-5);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--sp-3);
  scrollbar-width: thin;
}
.carousel__track > * { scroll-snap-align: start; }
.carousel__track::-webkit-scrollbar { height: 8px; }
.carousel__track::-webkit-scrollbar-thumb { background: var(--c-line-strong); border-radius: 99px; }
@media (min-width: 900px) { .carousel__track { grid-auto-columns: minmax(0, calc((100% - 2 * var(--sp-5)) / 3)); } }
.carousel__nav { display: flex; gap: var(--sp-2); }
.carousel__nav button {
  width: 44px; height: 44px; border-radius: var(--r-pill);
  border: 1px solid var(--c-line-strong); display: grid; place-items: center; color: var(--c-blue);
  transition: all var(--dur-fast) var(--ease);
}
.carousel__nav button:hover { background: var(--c-blue); color: #fff; border-color: var(--c-blue); }
.carousel__nav button:disabled { opacity: .35; cursor: default; }
.carousel__nav button:disabled:hover { background: none; color: var(--c-blue); border-color: var(--c-line-strong); }
