/* ============================================================
   TOUITIGROUP — base.css
   Reset · typographie selon la langue (:lang) · RTL · focus ·
   utilitaires. Dépend de tokens.css (à charger avant).
   Règle d'or : propriétés logiques (margin-inline, padding-inline,
   inset-inline) partout, pour que le RTL fonctionne sans surcharge.
   ============================================================ */

/* ===== 1. RESET ===== */
*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem; /* ancres sous la navbar fixe */
}

body {
  min-height: 100vh;
  background: var(--tg-color-black);
  color: var(--tg-color-text);
  font-family: var(--tg-font-body);
  font-size: var(--tg-text-base);
  font-weight: var(--tg-weight-regular);
  line-height: var(--tg-leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, picture, video, svg, canvas { display: block; max-width: 100%; }
img, video { height: auto; }

input, button, textarea, select { font: inherit; color: inherit; }

button {
  background: none;
  border: 0;
  cursor: pointer;
}
button:disabled { cursor: not-allowed; opacity: 0.6; }

a { color: inherit; text-decoration-skip-ink: auto; }

ul[role="list"], ol[role="list"] { list-style: none; }

p, h1, h2, h3, h4, h5, h6, li, dd, blockquote { overflow-wrap: break-word; }

::selection { background: var(--tg-color-selection); color: var(--tg-color-white); }

/* ===== 2. POLICES SELON LA LANGUE ===== */
/* Par défaut (et :lang(fr)) : Inter — arabe : Cairo */
:root,
:lang(fr) {
  --tg-font-heading: var(--tg-font-heading-fr);
  --tg-font-body:    var(--tg-font-body-fr);
  --tg-heading-leading: var(--tg-leading-tight);
}

/* Arabe : Cairo. S'applique aussi à un fragment lang="ar" dans une page FR. */
:lang(ar) {
  --tg-font-heading: var(--tg-font-heading-ar);
  --tg-font-body:    var(--tg-font-body-ar);
  --tg-heading-leading: 1.35;                     /* l'arabe a besoin de plus d'interligne */
}

/* Un fragment lang="xx" doit recalculer sa police : font-family est hérité déjà résolu.
   :where() = spécificité 0, pour que h1–h6 gardent leur police de titre. */
:where([lang]) { font-family: var(--tg-font-body); }

/* ===== 3. TYPOGRAPHIE ===== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--tg-font-heading);
  font-weight: var(--tg-weight-semibold);
  line-height: var(--tg-heading-leading);
  color: inherit;
  text-wrap: balance;
}
h1 { font-size: var(--tg-text-h1); font-weight: var(--tg-weight-extrabold); letter-spacing: -0.025em; }
h2 { font-size: var(--tg-text-h2); font-weight: var(--tg-weight-bold); letter-spacing: -0.02em; }
h3 { font-size: var(--tg-text-h3); font-weight: var(--tg-weight-semibold); letter-spacing: -0.01em; }
h4 { font-size: var(--tg-text-lg); }
h5, h6 { font-size: var(--tg-text-base); }

/* h3–h6 : interligne plus serré que les grands titres */
h3:lang(fr), h4:lang(fr), h5:lang(fr), h6:lang(fr) {
  font-family: var(--tg-font-body-fr);
  font-weight: var(--tg-weight-semibold);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

p { text-wrap: pretty; }

strong, b { font-weight: var(--tg-weight-semibold); }

small { font-size: var(--tg-text-sm); }

/* ===== 4. RTL ===== */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

/* L'espacement de lettres casse la liaison des lettres arabes */
:lang(ar), :lang(ar) * { letter-spacing: 0 !important; }

/* Icônes directionnelles (flèches, chevrons) : ajouter .tg-flip-rtl */
[dir="rtl"] .tg-flip-rtl { transform: scaleX(-1); }

/* Numéros de téléphone, emails, codes : toujours LTR, même en page AR */
.tg-ltr { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .tg-ltr { text-align: right; }

/* ===== 5. FOCUS (accessibilité) ===== */
:root { --tg-focus-color: var(--tg-color-gold); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--tg-focus-color);
  outline-offset: var(--tg-focus-offset);
  border-radius: 2px;
}

/* Sur fond clair, l'or #c9a84c n'atteint pas 3:1 → on passe sur gold-text */
.tg-surface-light { --tg-focus-color: var(--tg-color-gold-text); }

/* Lien d'évitement */
.tg-skip-link {
  position: absolute;
  inset-inline-start: var(--tg-space-md);
  top: -100px;
  z-index: 2000;
  padding: var(--tg-space-sm) var(--tg-space-md);
  background: var(--tg-color-gold);
  color: var(--tg-color-black);
  font-weight: var(--tg-weight-semibold);
  text-decoration: none;
  border-radius: var(--tg-radius-sm);
  transition: top 0.2s;
}
.tg-skip-link:focus { top: var(--tg-space-md); }

/* ===== 6. SURFACES ===== */
/* Section claire — ivoire uniquement (règle d'identité) */
.tg-surface-light {
  background: var(--tg-color-ivory);
  color: var(--tg-color-ink);
}

/* ===== 7. UTILITAIRES ===== */
.container {
  width: 100%;
  max-width: var(--tg-container-max);
  margin-inline: auto;
  padding-inline: var(--tg-container-pad);
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }

.mt-sm { margin-top: var(--tg-space-sm); }
.mt-md { margin-top: var(--tg-space-md); }
.mt-lg { margin-top: var(--tg-space-lg); }
.mt-xl { margin-top: var(--tg-space-xl); }

.mb-sm { margin-bottom: var(--tg-space-sm); }
.mb-md { margin-bottom: var(--tg-space-md); }
.mb-lg { margin-bottom: var(--tg-space-lg); }
.mb-xl { margin-bottom: var(--tg-space-xl); }

/* ===== 8. MOUVEMENT RÉDUIT ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
