/* =====================================================================
   RoboLab — base.css
   Variables de couleurs, typographie, mise en page générale, en-tête,
   menu (haut sur PC / bas sur téléphone), pied de page.
   On utilise les propriétés CSS « logiques » (margin-inline-start,
   inset-inline-end...) : la mise en page s'inverse toute seule en arabe.
   ===================================================================== */

:root {
  --bleu: #2563eb;
  --bleu-fonce: #1d4ed8;
  --bleu-nuit: #1e3a8a;
  --bleu-clair: #eff6ff;
  --bleu-pale: #dbeafe;
  --orange: #f97316;
  --orange-fonce: #ea580c;
  --orange-clair: #fff7ed;
  --vert: #16a34a;
  --rouge: #dc2626;
  --texte: #0f172a;
  --texte-doux: #475569;
  --bord: #e2e8f0;
  --fond: #f5f8ff;
  --carte: #ffffff;
  --rayon: 18px;
  --rayon-petit: 12px;
  --ombre: 0 4px 18px rgba(30, 58, 138, 0.08);
  --ombre-forte: 0 10px 30px rgba(30, 58, 138, 0.16);
  --police-fr: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --police-ar: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --police-code: "Consolas", "Fira Code", "Courier New", monospace;
  --hauteur-menu-bas: 64px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--police-fr);
  font-size: 16px;
  line-height: 1.6;
  color: var(--texte);
  background: var(--fond);
  /* place pour la barre de menu en bas sur téléphone */
  padding-bottom: calc(var(--hauteur-menu-bas) + env(safe-area-inset-bottom));
}

/* Arabe : police Cairo et interligne un peu plus grand */
html[lang="ar"] body { font-family: var(--police-ar); line-height: 1.8; }

img { max-width: 100%; display: block; }
a { color: var(--bleu); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; color: var(--bleu-nuit); }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); font-weight: 800; }
h2 { font-size: clamp(1.25rem, 3.2vw, 1.6rem); font-weight: 800; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; }

/* Le code et les éléments techniques restent toujours de gauche à droite */
code, pre, kbd, .ltr { direction: ltr; unicode-bidi: isolate; }

:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 6px; }

/* ---------- En-tête ---------- */
.entete {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(90deg, var(--bleu-fonce), var(--bleu));
  color: #fff;
  box-shadow: 0 2px 12px rgba(29, 78, 216, .25);
}
.entete-interieur {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.logo { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; }
.logo img { border-radius: 10px; background: #fff; }
.logo-texte { font-family: var(--police-fr); font-size: 1.35rem; font-weight: 800; letter-spacing: .3px; }
.logo-texte b { color: #fed7aa; }

.entete-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.puce-points {
  background: rgba(255, 255, 255, .16); color: #fff; text-decoration: none;
  padding: 5px 12px; border-radius: 999px; font-weight: 800; font-size: .9rem; white-space: nowrap;
}
.puce-points::before { content: "⭐ "; }
.btn-langue {
  font: inherit; font-weight: 700; cursor: pointer;
  background: var(--orange); color: #fff; border: 0;
  padding: 6px 14px; border-radius: 999px; min-height: 36px;
  transition: transform .15s, background .15s;
}
.btn-langue[lang="ar"] { font-family: var(--police-ar); }
.btn-langue[lang="fr"] { font-family: var(--police-fr); }
.btn-langue:hover { background: var(--orange-fonce); transform: translateY(-1px); }

/* ---------- Menu : barre fixe en bas (téléphone) ---------- */
.menu {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 60;
  display: flex; justify-content: space-around;
  background: #fff; border-top: 1px solid var(--bord);
  padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
}
.menu a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  color: var(--texte-doux); text-decoration: none; font-size: .68rem; font-weight: 700;
  padding: 4px 2px; border-radius: 12px; min-height: 52px; justify-content: center;
}
.menu svg { width: 24px; height: 24px; fill: currentColor; }
.menu a.actif { color: var(--bleu); background: var(--bleu-clair); }
.menu a.actif svg { fill: var(--orange); }
.nav-long { display: none; }

/* ---------- Menu : en haut (tablette / ordinateur) ---------- */
@media (min-width: 1100px) {
  body { padding-bottom: 0; }
  .menu {
    position: static; background: none; border: 0; box-shadow: none; padding: 0;
    justify-content: flex-start; gap: 2px; margin-inline-start: 18px;
  }
  .menu a {
    flex: 0 0 auto; flex-direction: row; gap: 6px; color: #dbeafe;
    font-size: .95rem; padding: 8px 12px; min-height: 40px;
  }
  .menu svg { width: 18px; height: 18px; }
  .menu a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
  .menu a.actif { background: rgba(255, 255, 255, .2); color: #fff; }
  .menu a.actif svg { fill: #fed7aa; }
  .nav-long { display: inline; }
  .nav-court { display: none; }
}
@media (max-width: 380px) {
  .logo-texte { display: none; }
  .menu a { font-size: .62rem; }
}

/* ---------- Contenu et pied de page ---------- */
.contenu { max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; outline: none; min-height: 60vh; }
.contenu.apparition { animation: apparition .35s ease both; }
@keyframes apparition { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.pied {
  text-align: center; color: var(--texte-doux); font-size: .9rem;
  padding: 24px 16px; border-top: 1px solid var(--bord); background: #fff;
}
.pied p { margin: 4px 0; }
.pied a { font-weight: 700; }

.alerte-stockage {
  background: #fef3c7; color: #92400e; text-align: center; padding: 8px 16px; font-size: .9rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Bouton « Installer l'application » (PWA) ---------- */
.btn-installer {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer;
  background: #fff; color: var(--bleu-fonce); border: 0;
  padding: 6px 12px; border-radius: 999px; min-height: 36px;
  white-space: nowrap; flex-shrink: 0;
  animation: invite-install 1.2s ease 2;
  transition: transform .15s;
}
.btn-installer[hidden] { display: none; }
.btn-installer:hover { transform: translateY(-1px); }
.btn-installer svg { width: 18px; height: 18px; fill: var(--orange); }
@keyframes invite-install { 50% { transform: scale(1.08); } }
/* Quand la place manque : icône seule (le texte reste lu par les lecteurs d'écran) */
@media (max-width: 560px), (min-width: 1100px) {
  .btn-installer span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .btn-installer { padding: 6px 9px; }
  .puce-points { padding: 5px 9px; }
}

/* ---------- Bandeau « nouvelle version disponible » ---------- */
.bandeau-maj {
  position: fixed; z-index: 95; inset-inline: 12px; bottom: calc(var(--hauteur-menu-bas) + 12px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bleu-nuit); color: #fff; font-weight: 700;
  padding: 10px 14px; border-radius: 16px; box-shadow: var(--ombre-forte);
  max-width: 560px; margin: 0 auto;
}
.bandeau-maj[hidden] { display: none; }
@media (min-width: 1100px) { .bandeau-maj { bottom: 20px; } }
/* Petit écran : quand le bouton Installer est visible, on garde seulement l'icône du logo */
@media (max-width: 480px) {
  .entete:has(.btn-installer:not([hidden])) .logo-texte { display: none; }
}
