/* Styles partagés du widget de recherche, utilisés par index.html et embed.html.
   Ce fichier porte la version neutre, celle du champ intégrable : il doit se fondre dans
   n'importe quel site, donc police du système, fond transparent, bordures grises et une
   seule couleur, l'accent du site hôte (paramètre ?accent= de l'iframe). Le portail
   (index.html) surcharge ces variables et ces formes avec sa propre identité. */

:root {
  --tl-texte: #1c2433;
  --tl-texte-doux: #5b6474;
  --tl-accent: #1d4ed8;
  --tl-sur-accent: #fff;          /* texte posé sur l'accent : calculé si ?accent= */
  --tl-bordure: rgba(0, 0, 0, 0.28);
  --tl-bordure-douce: rgba(0, 0, 0, 0.14);
  --tl-champ: rgba(255, 255, 255, 0.9);
  --tl-liste: #fff;
  --tl-carte: transparent;
  --tl-survol: rgba(0, 0, 0, 0.05);
  --tl-succes: #166534;
  --tl-erreur: #b91c1c;
}

/* Le widget est transparent pour se fondre dans la page hôte : son texte doit donc suivre
   le fond de celle-ci, qu'aucune CSS ne peut deviner depuis l'iframe (?theme=dark). */
:root[data-theme="dark"] {
  --tl-texte: #f1f5f9;
  --tl-texte-doux: #b6bcc5;
  --tl-accent: #93c5fd;
  --tl-sur-accent: #15171a;
  --tl-bordure: rgba(255, 255, 255, 0.3);
  --tl-bordure-douce: rgba(255, 255, 255, 0.16);
  --tl-champ: rgba(255, 255, 255, 0.06);
  --tl-liste: #1e2227;
  --tl-carte: rgba(255, 255, 255, 0.04);
  --tl-survol: rgba(255, 255, 255, 0.08);
  --tl-succes: #86efac;
  --tl-erreur: #fca5a5;
}

.autocomplete {
  position: relative;
  width: 100%;
}

.autocomplete input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;               /* 16 px : iOS ne zoome pas sur le champ */
  color: var(--tl-texte);
  border-radius: 8px;
  border: 1px solid var(--tl-bordure);
  background: var(--tl-champ);
}

.autocomplete input::placeholder {
  color: var(--tl-texte-doux);
  opacity: 1;
}

.autocomplete input:focus {
  outline: 2px solid var(--tl-accent);
  outline-offset: 1px;
}

/* Liste détachée du champ, opaque : elle passe par-dessus le contenu de la page. */
.suggestions {
  width: 100%;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  padding: 4px;
  color: var(--tl-texte);
  background: var(--tl-liste);
  border: 1px solid var(--tl-bordure-douce);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  z-index: 10;
}

/* Fermée, la liste est vidée mais reste dans le flux : sans ceci, ses bordures
   dessineraient un trait sous le champ. */
.suggestions:empty {
  display: none;
}

.suggestion {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 48px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.3;
  cursor: pointer;
}

.suggestion-nom {
  font-weight: 600;
}

.suggestion-lieu {
  font-size: 13px;
  color: var(--tl-texte-doux);
}

.suggestion:hover,
.suggestion-active {
  background: var(--tl-survol);
}

/* Repère visuel de la suggestion sélectionnée au clavier */
.suggestion-active {
  box-shadow: inset 3px 0 0 var(--tl-accent);
}

/* Dernière entrée de la liste : identifier un lieu absent, au moment du doute. */
.suggestion-ajouter {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-height: 44px;
  margin-top: 4px;
  border-top: 1px solid var(--tl-bordure-douce);
  border-radius: 0 0 6px 6px;
  color: var(--tl-accent);
}

.suggestion-ajouter .suggestion-nom::before {
  content: "+";
  display: inline-block;
  width: 18px;
  font-size: 18px;
  line-height: 1;
}

/* Fiche du lieu choisi */
.card {
  width: 100%;
  padding: 16px;
  color: var(--tl-texte);
  background: var(--tl-carte);
  border: 1px solid var(--tl-bordure-douce);
  border-radius: 10px;
}

.card h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.card p {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.45;
}

.card-adresse,
.card-note {
  color: var(--tl-texte-doux);
}

.card-note {
  font-size: 13px;
}

/* Action principale de la fiche, pleine et à l'accent du site hôte. */
.card button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 14px;
  padding: 8px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--tl-sur-accent);
  background: var(--tl-accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* Icône enveloppe en masque : elle prend la couleur du texte du bouton. */
.card button::before {
  content: "";
  flex: 0 0 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='M3 7l9 6 9-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='M3 7l9 6 9-6'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Assombrit l'accent quel qu'il soit ; ignoré par les navigateurs sans color-mix. */
.card button:hover {
  background: color-mix(in srgb, var(--tl-accent) 85%, #000);
}

.card button:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 2px;
}

.card button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.status {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.4;
}

.status:empty {
  display: none;
}

.status.success { color: var(--tl-succes); }
.status.error { color: var(--tl-erreur); }

.status.success::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  vertical-align: -4px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
}
