/* Galium — la fleur du gaillet a 4 pétales : c'est notre croix de pharmacie, en plus doux.
   Mise en page : formulaire "Mon besoin" + liste à gauche, carte à droite ; sur téléphone, onglets Liste / Carte. */
:root {
  --paper: #f4f6f2;      /* fond, gris-vert très léger */
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --ink: #15231b;        /* texte, vert presque noir */
  --muted: #5d6a62;
  --line: #dbe1da;
  --leaf: #2d6a4b;       /* vert feuille : ce qui colle */
  --leaf-bg: #e2efe7;
  --galium: #efbd2b;     /* jaune gaillet : marque, à négocier */
  --galium-ink: #4a3900;
  --galium-bg: #fbf0cd;
  --bad: #a83a2c;
  --shadow: 0 1px 2px rgba(21, 35, 27, .06), 0 8px 24px rgba(21, 35, 27, .08);
  --f-titre: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --f-texte: "Instrument Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  --r: 14px;
  --ressort: cubic-bezier(.34, 1.56, .64, 1);   /* rebond */
  --doux: cubic-bezier(.22, 1, .36, 1);         /* sortie douce */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1512; --surface: #172019; --surface-2: #1e2922; --ink: #e6ede8; --muted: #9ba8a0; --line: #27332b;
    --leaf: #74c49b; --leaf-bg: #1b3326; --galium: #f3c843; --galium-ink: #f6dc8a; --galium-bg: #3a3014; --bad: #e8806f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.45 var(--f-texte); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- en-tête ---------- */
.tete { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line); background: var(--surface); }
.marque { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font: 800 24px/1 var(--f-titre); letter-spacing: -.02em; }
.fleur { width: 30px; height: 30px; }
.baseline { margin: 0; color: var(--muted); font-size: 14px; }
.baseline em { font-style: normal; color: var(--ink); font-weight: 600; }
.apropos { color: var(--muted); font-size: 12.5px; text-decoration: underline; }
.maj { margin: 0 0 0 auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---------- grille ---------- */
.app { display: grid; grid-template-columns: 400px 1fr; grid-template-rows: auto 1fr; height: calc(100% - 59px); min-height: 0; }
.besoin { grid-column: 1; grid-row: 1; border-right: 1px solid var(--line); background: var(--surface); min-width: 0; }
.resultats { grid-column: 1; grid-row: 2; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.carte-zone { grid-column: 2; grid-row: 1 / 3; position: relative; min-height: 0; }
#carte { position: absolute; inset: 0; }
.carte-vide { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--surface-2); }

/* ---------- formulaire ---------- */
.besoin-bouton { display: none; }
.besoin-corps { padding: 14px 16px 12px; display: grid; gap: 12px; max-height: 52vh; overflow-y: auto; border-bottom: 1px solid var(--line); }
.champ { border: 0; margin: 0; padding: 0; min-width: 0; position: relative; }
.champ > label:not(.bascule), .champ legend, .champ.deux label:not(.bascule) { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; padding: 0; }
.champ output { text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 600; font-size: 13px; }
.champ.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
input[type=text], input[type=date], select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); min-height: 42px; }
.adresse { display: flex; gap: 6px; }
.icone { flex: none; width: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; }
.icone svg { width: 20px; height: 20px; }
.suggestions { position: absolute; z-index: 20; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.suggestions li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--surface-2); }
.suggestions small { color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--leaf); }
.segments, .puces { display: flex; flex-wrap: wrap; gap: 6px; }
.segments button, .puces button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; min-height: 34px; }
.segments button.on, .puces button.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.sous-choix { margin-top: 8px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.sous-choix[hidden] { display: none; }
.sous-titre { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.salaire { display: grid; gap: 8px; }
.pas { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.pas button { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; font-weight: 700; line-height: 1; }
.pas output { text-align: center; font: 700 20px/1 var(--f-titre); font-variant-numeric: tabular-nums; }
#salPresets button { font-variant-numeric: tabular-nums; }
.bascule { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.bascule input { width: 18px; height: 18px; accent-color: var(--leaf); }
.strict { color: var(--muted); }
.reset { justify-self: start; border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 0; font-size: 13px; }

/* ---------- liste ---------- */
.onglets { display: none; }
.compte { padding: 10px 16px; font-weight: 600; border-bottom: 1px solid var(--line); background: var(--surface); }
.compte small { display: block; font-weight: 400; color: var(--muted); }
.tri { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
.tri span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 2px; }
.tri button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600;
  transition: transform .22s var(--ressort), background-color .2s, color .2s; }
.tri button.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.tri button:active { transform: scale(.92); }
.tri button:disabled { opacity: .45; cursor: not-allowed; }
.tag.neuf { background: var(--galium); color: #3a2e00; }
.age { color: var(--muted); font-size: 12px; font-weight: 500; }
.liste { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.groupe { padding: 10px 8px 2px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.offre-btn { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 11px 12px; display: grid; gap: 4px; }
.offre-btn:hover, .offre.actif .offre-btn { border-color: var(--leaf); }
.offre.actif .offre-btn { box-shadow: inset 3px 0 0 var(--leaf); }
.l1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ville { font: 700 16px/1.2 var(--f-titre); letter-spacing: -.01em; }
.trajet { flex: none; font-weight: 700; font-size: 13px; color: var(--leaf); font-variant-numeric: tabular-nums; }
.l2 { color: var(--muted); font-size: 13.5px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.tag.urg { background: var(--bad); color: var(--surface); }
.tag.poste { background: var(--ink); color: var(--surface); }
.tag.av { background: var(--leaf-bg); color: var(--leaf); }
.tag.fb { background: var(--galium-bg); color: var(--galium-ink); }
.nego { font-size: 12.5px; color: var(--galium-ink); }
.nego:empty { display: none; }
.vide { padding: 30px 16px; color: var(--muted); text-align: center; }

/* ---------- détail ---------- */
.detail { position: fixed; z-index: 30; top: 70px; right: 16px; width: min(420px, calc(100% - 32px)); max-height: calc(100% - 86px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 18px 18px 20px; }
.fermer { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--surface-2); }
.detail h2 { margin: 0 40px 2px 0; font: 800 22px/1.15 var(--f-titre); letter-spacing: -.02em; text-wrap: balance; }
.detail .sous { color: var(--muted); margin: 0 0 12px; }
.detail .ligne { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.detail .ligne span:first-child { color: var(--muted); }
.detail .ligne span:last-child { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.detail .desc { color: var(--muted); font-size: 13.5px; margin: 10px 0; white-space: pre-line; }
.detail .cta { display: block; text-align: center; margin-top: 12px; padding: 13px; border-radius: 12px; background: var(--ink); color: var(--surface); font-weight: 700; text-decoration: none; }
.detail .contact { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--galium-bg); color: var(--galium-ink); font-size: 14px; user-select: all; }
.voir-contact { width: 100%; border: 0; border-radius: 10px; padding: 10px; background: var(--galium); color: #3a2e00; font-weight: 700; }
.contact canvas { display: block; margin: 4px 0 8px; }
.contact-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.contact-actions a, .contact-actions button { cursor: pointer; border: 1px solid currentColor; border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 13px; background: transparent; color: inherit; text-decoration: none; }
.detail .avert { margin-top: 8px; font-size: 12px; color: var(--muted); }
.detail .verdict { padding: 10px 12px; border-radius: 12px; margin: 0 0 10px; font-size: 14px; }
.verdict.ok { background: var(--leaf-bg); color: var(--leaf); font-weight: 700; }
.verdict.nego { background: var(--galium-bg); color: var(--galium-ink); }

/* ---------- carte ---------- */
.maplibregl-popup-content { background: var(--surface); color: var(--ink); border-radius: 10px; font: 13px var(--f-texte); padding: 8px 10px; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* ---------- téléphone ---------- */
@media (max-width: 860px) {
  .tete { gap: 8px; } .baseline { display: none; }
  .app { display: flex; flex-direction: column; height: auto; min-height: calc(100% - 55px); }
  .besoin, .resultats { border-right: 0; }
  .besoin-bouton { display: flex; width: 100%; align-items: center; gap: 8px; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
    border: 0; border-bottom: 1px solid var(--line); background: var(--surface); font-weight: 700; text-align: left; }
  .besoin-bouton .resume { flex: 1; min-width: 0; color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .besoin-bouton[aria-expanded="true"] .chev { transform: rotate(180deg); }
  .besoin-corps { display: none; max-height: none; }
  .besoin.ouvert .besoin-corps { display: grid; }
  .onglets { display: flex; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); padding: 8px 16px; gap: 6px; }
  .onglets button { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px; font-weight: 700; }
  .onglets button[aria-selected="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
  .liste { overflow: visible; padding: 8px 16px 24px; }
  .carte-zone { height: calc(100vh - 160px); display: none; }
  .vue-carte .carte-zone { display: block; } .vue-carte .liste, .vue-carte .compte, .vue-carte .tri { display: none; }
  .detail { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-height: 80%; border-radius: 18px 18px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 860px) { .segments button, .puces button, .tri button { min-height: 40px; } .tri button { padding: 8px 13px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ================= mouvement : vivant, rebondissant, jamais lourd (transform + opacity seulement) ================= */
@media (prefers-reduced-motion: no-preference) {
  /* la fleur éclot à l'ouverture : 4 pétales l'un après l'autre */
  .fleur ellipse { transform-box: fill-box; transform-origin: center; animation: eclot .7s var(--ressort) both; }
  .fleur ellipse:nth-child(2) { animation-delay: .08s; } .fleur ellipse:nth-child(3) { animation-delay: .16s; } .fleur ellipse:nth-child(4) { animation-delay: .24s; }
  .fleur circle { transform-box: fill-box; transform-origin: center; animation: eclot .5s .3s var(--ressort) both; }
  .marque:hover .fleur { animation: tourne 1.2s var(--doux); }
  @keyframes eclot { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  @keyframes tourne { to { transform: rotate(90deg); } }

  /* pastilles et boutons : on les sent sous le doigt */
  .segments button, .puces button, .icone, .pas button, .onglets button, .reset, .offre-btn, .fermer, .detail .cta {
    transition: transform .22s var(--ressort), background-color .2s var(--doux), color .2s var(--doux), border-color .2s var(--doux), box-shadow .25s var(--doux); }
  .segments button:hover, .puces button:hover, .pas button:hover { transform: translateY(-1px); }
  .segments button:active, .puces button:active, .icone:active, .pas button:active, .onglets button:active, .fermer:active { transform: scale(.92); }
  .segments button.pop, .puces button.pop, .pas output.pop { animation: pop .38s var(--ressort); }
  @keyframes pop { 0% { transform: scale(.9); } 55% { transform: scale(1.08); } 100% { transform: scale(1); } }

  /* curseurs : la poignée grossit quand on la tient */
  input[type=range] { transition: filter .2s; }
  input[type=range]:active { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--leaf) 45%, transparent)); }

  /* les offres arrivent en cascade */
  .liste > li { animation: monte .42s var(--doux) both; animation-delay: calc(min(var(--i, 0), 14) * 22ms); }
  @keyframes monte { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
  .offre-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
  .offre-btn:active { transform: scale(.985); }
  .offre.actif .offre-btn { animation: pop .38s var(--ressort); }

  /* compteur */
  .compte b { display: inline-block; font-variant-numeric: tabular-nums; }
  .compte.change b { animation: pop .4s var(--ressort); }

  /* panneau de détail : glisse avec un ressort */
  .detail { transition: transform .45s var(--ressort), opacity .25s var(--doux); }
  .detail:not(.in) { transform: translateX(28px) scale(.97); opacity: 0; }
  .detail.in { transform: none; opacity: 1; }
  .detail .ligne, .detail .verdict, .detail .desc, .detail .cta, .detail .contact { animation: monte .4s var(--doux) both; }
  .detail .ligne:nth-of-type(2) { animation-delay: .03s; } .detail .ligne:nth-of-type(3) { animation-delay: .06s; } .detail .ligne:nth-of-type(4) { animation-delay: .09s; }
  .detail .ligne:nth-of-type(n+5) { animation-delay: .12s; } .detail .cta { animation-delay: .16s; }
  .detail .cta:hover { transform: translateY(-2px); } .detail .cta:active { transform: scale(.97); }

  /* « Mon besoin » qui s'ouvre (téléphone) et durée du CDD qui apparaît */
  .sous-choix { animation: deplie .35s var(--doux) both; transform-origin: top; }
  @keyframes deplie { from { opacity: 0; transform: translateY(-6px) scaleY(.96); } to { opacity: 1; transform: none; } }
  .suggestions { animation: deplie .22s var(--doux) both; }
  .besoin-bouton .chev { transition: transform .35s var(--ressort); }
}
@media (max-width: 860px) and (prefers-reduced-motion: no-preference) {
  .detail:not(.in) { transform: translateY(40px); opacity: 0; }
  .besoin.ouvert .besoin-corps { animation: deplie .35s var(--doux) both; }
  /* onglet actif : la pastille noire glisse de l'un à l'autre */
  .onglets { position: sticky; }
  .onglets::before { content: ""; position: absolute; top: 8px; bottom: 8px; left: 16px; width: calc(50% - 19px); border-radius: 999px; background: var(--ink);
    transition: transform .4s var(--ressort); z-index: 0; }
  .vue-carte .onglets::before { transform: translateX(calc(100% + 6px)); }
  .onglets button { position: relative; z-index: 1; background: transparent; transition: color .25s var(--doux); }
  .onglets button[aria-selected="true"] { background: transparent; border-color: transparent; color: var(--surface); }
}

/* ================= chargement : écran d'ouverture + carte ================= */
#ouverture { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--paper);
  transition: opacity .55s var(--doux), visibility 0s linear .55s; }
#ouverture.fini { opacity: 0; visibility: hidden; pointer-events: none; }
.ouv-coeur { display: grid; justify-items: center; gap: 10px; }
.ouv-nom { font: 800 34px/1 var(--f-titre); letter-spacing: -.02em; color: var(--ink); }
.ouv-texte { color: var(--muted); font-size: 14px; }
.fleur-anim { width: 56px; height: 56px; }
.fleur-anim.grande { width: 92px; height: 92px; }
.fleur-anim ellipse, .fleur-anim circle { transform-box: fill-box; transform-origin: center; }
.carte-vide { flex-direction: column; gap: 12px; display: flex; align-items: center; justify-content: center; transition: opacity .45s var(--doux); }
.carte-vide.fini { opacity: 0; pointer-events: none; }
.carte-vide span { font-weight: 600; }
/* la page arrive en douceur derrière l'écran d'ouverture */
body.prete .tete, body.prete .app { animation: arrive .6s var(--doux) both; }
body.prete .app { animation-delay: .06s; }
@keyframes arrive { from { opacity: 0; transform: translateY(10px) scale(.995); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  /* les 4 pétales éclosent une fois, puis la fleur tourne doucement, d'un seul bloc */
  .fleur-anim .petales { transform-box: fill-box; transform-origin: center; animation: tourne-lent 6s linear infinite; }
  .fleur-anim ellipse { animation: eclot .7s var(--ressort) both; }
  .fleur-anim ellipse:nth-child(2) { animation-delay: .08s; } .fleur-anim ellipse:nth-child(3) { animation-delay: .16s; } .fleur-anim ellipse:nth-child(4) { animation-delay: .24s; }
  .fleur-anim circle { animation: eclot .5s .3s var(--ressort) both; }
  @keyframes tourne-lent { to { transform: rotate(360deg); } }
  /* sortie : la fleur grandit et s'efface pendant que la page / la carte arrive */
  .fini .fleur-anim { transform: scale(1.6); opacity: 0; transition: transform .55s var(--doux), opacity .4s var(--doux); }
}
