/*
  MyJob77 — Feuille de style accessible
  ──────────────────────────────────────
  Trois publics cibles :
  ① Asperger   → structure claire, aucune ambiguïté, calme visuel
  ② Daltoniens → palette bleu/orange (sûre pour protanopie, deutéranopie, tritanopie)
                  chaque état est codé couleur + forme + texte (triple codage)
  ③ Dyslexiques → police Lexend, taille 18 px, interligne 1.7, pas de justification,
                   lignes courtes (max 65 ch), espacement généreux
*/

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  /* Bleu principal (daltonien-safe) */
  --bleu:       #1A56DB;
  --bleu-sombre:#1239A6;
  --bleu-clair: #E1EFFE;

  /* Orange accent (contraste sûr sur bleu, visible daltoniens) */
  --orange:     #C2570A;
  --orange-clair:#FEF3C7;

  /* Niveaux de compatibilité — couleur + forme différentes */
  /* ③★★★ Très compatible  → bleu     + forme ■ */
  --c-haut-bg:  #E1EFFE;
  --c-haut-fg:  #1A3A8F;
  --c-haut-brd: #1A56DB;

  /* ②★★  Compatible       → teal     + forme ▲ */
  --c-mid-bg:   #D1FAE5;
  --c-mid-fg:   #065F46;
  --c-mid-brd:  #059669;

  /* ①★   Neutre           → ambre    + forme ● */
  --c-low-bg:   #FEF3C7;
  --c-low-fg:   #92400E;
  --c-low-brd:  #D97706;

  /* ✗    Peu compatible   → gris-brun + forme ✕ */
  --c-non-bg:   #F3F4F6;
  --c-non-fg:   #4B5563;
  --c-non-brd:  #9CA3AF;

  /* Typo / structure */
  --texte:      #111827;
  --texte-sec:  #4B5563;
  --fond:       #F9FAFB;
  --carte-fond: #FFFFFF;
  --bordure:    #E5E7EB;
  --radius:     10px;
  --ombre:      0 1px 4px rgba(0,0,0,.10), 0 2px 12px rgba(0,0,0,.06);
}

/* ── Reset minimal ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base — règles dyslexie ──────────────────────────────────────────────── */
html {
  font-size: 18px;          /* Grande taille de base */
  scroll-behavior: smooth;
}

body {
  font-family: 'Lexend', system-ui, sans-serif;  /* Lexend = police dyslexie */
  line-height: 1.7;          /* Interligne généreux */
  background: var(--fond);
  color: var(--texte);
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: 6rem;
  text-align: left;          /* Jamais justifié — aide la dyslexie */
  -webkit-font-smoothing: antialiased;
}

/* Largeur de ligne limitée pour la lisibilité */
p, li { max-width: 65ch; }

/* ── Lien d'évitement ────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--bleu);
  color: #fff;
  padding: .5rem 1rem;
  font-weight: 600;
  z-index: 100;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { top: 0; }

/* ── En-tête ─────────────────────────────────────────────────────────────── */
header {
  background: var(--bleu);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.header-title {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.logo {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  background: #FFB020;   /* orange sûr sur bleu */
  color: var(--bleu-sombre);
  font-size: 1.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

h1 {
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: .02em;
}

h1 strong {
  font-weight: 600;
  color: #FFB020;
}

.subtitle {
  font-size: .72rem;
  opacity: .85;
  letter-spacing: .03em;
}

/* ── Bouton installer ────────────────────────────────────────────────────── */
.btn-install {
  background: #FFB020;
  color: var(--bleu-sombre);
  border: none;
  border-radius: 8px;
  padding: .4rem .9rem;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-install:hover { background: #FFC64A; }

/* ── Filtres ─────────────────────────────────────────────────────────────── */
.filters {
  background: var(--carte-fond);
  border-bottom: 2px solid var(--bordure);
  padding: .9rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.filter-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--texte-sec);
  text-transform: uppercase;
  letter-spacing: .07em;
}

/* Groupes de pilules (score) */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.pill {
  background: var(--fond);
  border: 2px solid var(--bordure);
  border-radius: 20px;
  padding: .28rem .8rem;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 400;
  cursor: pointer;
  color: var(--texte);
  transition: background .12s, border-color .12s, color .12s;
}

.pill:hover {
  border-color: var(--bleu);
  color: var(--bleu);
}

.pill.active {
  background: var(--bleu);
  border-color: var(--bleu);
  color: #fff;
  font-weight: 600;
}

/* Sélect contrat */
select {
  font-family: inherit;
  font-size: .9rem;
  padding: .3rem .6rem;
  border: 2px solid var(--bordure);
  border-radius: 8px;
  background: #fff;
  color: var(--texte);
  cursor: pointer;
}
select:focus { outline: 3px solid var(--bleu); }

/* ── Barre d'info ────────────────────────────────────────────────────────── */
.info-bar {
  padding: .6rem 1.25rem;
  font-size: .8rem;
  color: var(--texte-sec);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .25rem;
}

/* ── Liste de cartes ─────────────────────────────────────────────────────── */
#liste-offres {
  list-style: none;
  padding: .25rem 1rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

/* ── Carte ───────────────────────────────────────────────────────────────── */
.carte {
  display: block;
  background: var(--carte-fond);
  border-radius: var(--radius);
  border-left: 5px solid var(--bleu);   /* remplacé par JS selon score */
  box-shadow: var(--ombre);
  padding: .9rem 1.1rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, transform .15s;
}

.carte:hover,
.carte:focus-visible {
  box-shadow: 0 4px 20px rgba(0,0,0,.14);
  transform: translateY(-2px);
}

/* Couleurs de bordure selon le niveau — aussi lisible sans couleur grâce aux badges */
.carte[data-niveau="haut"]  { border-left-color: var(--c-haut-brd); }
.carte[data-niveau="mid"]   { border-left-color: var(--c-mid-brd);  }
.carte[data-niveau="low"]   { border-left-color: var(--c-low-brd);  }
.carte[data-niveau="non"]   { border-left-color: var(--c-non-brd);  }

.carte-entete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}

.carte-titre {
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
  /* Pas de tout-en-majuscules : difficile pour dyslexiques */
}

/*
  Badge de compatibilité : triple codage
  → couleur de fond   (pour vision normale)
  → icône/forme       (pour daltoniens)
  → texte             (pour tout le monde)
*/
.badge {
  flex-shrink: 0;
  border-radius: 6px;
  padding: .18rem .55rem;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-haut { background: var(--c-haut-bg); color: var(--c-haut-fg); border-color: var(--c-haut-brd); }
.badge-mid  { background: var(--c-mid-bg);  color: var(--c-mid-fg);  border-color: var(--c-mid-brd);  }
.badge-low  { background: var(--c-low-bg);  color: var(--c-low-fg);  border-color: var(--c-low-brd);  }
.badge-non  { background: var(--c-non-bg);  color: var(--c-non-fg);  border-color: var(--c-non-brd);  }

.carte-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  font-size: .78rem;
  color: var(--texte-sec);
}

.meta-tag {
  background: var(--fond);
  border: 1px solid var(--bordure);
  border-radius: 4px;
  padding: .08rem .45rem;
}

.carte-source {
  font-size: .72rem;
  color: var(--texte-sec);
  margin-top: .35rem;
  opacity: .75;
}

/* ── États ───────────────────────────────────────────────────────────────── */
.etat-chargement,
.etat-vide {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .8rem;
  padding: 3rem 1rem;
  color: var(--texte-sec);
  font-size: .9rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bordure);
  border-top-color: var(--bleu);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.etat-erreur {
  margin: .5rem 1rem;
  padding: .7rem 1rem;
  background: var(--orange-clair);
  border: 1px solid var(--orange);
  border-radius: var(--radius);
  font-size: .82rem;
  color: var(--orange);
}

/* ── FAB (bouton actualiser) ─────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.25rem;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--bleu);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.30);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.fab:hover { background: var(--bleu-sombre); }

.fab svg { width: 22px; height: 22px; }

/* ── Focus visible global ────────────────────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--bleu);
  outline-offset: 3px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  html    { font-size: 16px; }
  header  { padding: .8rem 1rem; }
  .filters { padding: .7rem 1rem; }
  #liste-offres { padding: .25rem .5rem; }
}

/* ── Préférence "réduction de mouvement" ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .carte    { transition: none; }
  .fab      { transition: none; }
  .spinner  { animation-duration: 2s; }
}

/* ── Mode sombre (respecte les préférences système) ─────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --fond:       #111827;
    --carte-fond: #1F2937;
    --texte:      #F3F4F6;
    --texte-sec:  #9CA3AF;
    --bordure:    #374151;
    --c-haut-bg:  #1e3a5f;
    --c-mid-bg:   #064e3b;
    --c-low-bg:   #451a03;
    --c-non-bg:   #1F2937;
  }
}
