/* Visite guidée (js/visite.js), reprise de Franchise OS : un cadre pulsé, une bulle d'une phrase, une barre de contrôle
   flottante en bas, puis une carte de fin. Téléphone : la barre de la visite prend la place du menu du bas. */

.visite {
  --vis-cadre: #283595;
  --vis-bulle: #1b2333;
  --vis-bulle-texte: #e4e7f2;
  --vis-trait: #d6dbea;
  --vis-bas: 20px;
  position: fixed; inset: 0; z-index: 80; pointer-events: none;
  color: #1b2333; font-size: 16px; line-height: 1.4; font-variant-numeric: tabular-nums;
}
.visite__bulle, .visite__barre { pointer-events: auto; }

/* Le cadre pulsé : bordure 3 px, coins 14 px, pastille numérotée de 28 px, halo qui pulse en 1,8 s. */
.visite__cadre { position: fixed; box-sizing: border-box; border: 3px solid var(--vis-cadre); border-radius: 14px; pointer-events: none;
  animation: visite-pulse 1.8s ease-out infinite; }
.visite__cadre[hidden] { display: none; }
.visite__num { position: absolute; left: -15px; top: -15px; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; background: var(--vis-cadre); color: #FFFFFF; font-size: 14px; font-weight: 800;
  box-shadow: 0 0 0 3px #FFFFFF; }

/* La bulle : 320 px, fond #1b2333, pastille jaune avec le numéro, titre du point, une phrase. */
.visite__bulle { position: fixed; left: 16px; top: 16px; box-sizing: border-box; width: min(320px, calc(100vw - 32px)); padding: 14px 16px;
  border-radius: 14px; background: var(--vis-bulle); color: #FFFFFF; box-shadow: 0 14px 32px rgb(0 0 0 / 0.26); opacity: 0; }
.visite__bulle.is-on { opacity: 1; }
.visite__bulle.is-pop-a { animation: visite-pop-a 0.4s ease-out both; }
.visite__bulle.is-pop-b { animation: visite-pop-b 0.4s ease-out both; }
.visite__bulle.is-sheet { width: calc(100vw - 32px); }
.visite__bulle:focus { outline: none; }
.visite__bulle:focus-visible { outline: 3px solid #f2c94c; outline-offset: 2px; }
.visite__fleche { position: absolute; left: var(--ax, 0); top: var(--ay, 0); width: 14px; height: 14px; background: var(--vis-bulle);
  transform: rotate(45deg); }
.visite__bulle:not([data-place="right"]):not([data-place="left"]):not([data-place="above"]):not([data-place="below"]) .visite__fleche { display: none; }
.visite__titre { position: relative; margin: 0; display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; line-height: 1.3; }
.visite__pastille { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  background: #f2c94c; color: #1b2333; font-size: 13px; font-weight: 800; }
.visite__phrase { position: relative; margin: 6px 0 0; font-size: 15px; line-height: 1.45; color: var(--vis-bulle-texte); }

/* La barre de contrôle : 20 px du bas, centrée, 760 px au plus, blanche, coins 16 px. */
.visite__barre { position: fixed; left: 50%; bottom: var(--vis-bas); transform: translateX(-50%); width: calc(100% - 32px); max-width: 760px;
  box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px solid var(--vis-trait);
  border-radius: 16px; background: #FFFFFF; box-shadow: 0 16px 40px rgb(0 0 0 / 0.22); animation: visite-barre 0.5s ease-out both; }
.visite--haut .visite__barre { top: 12px; bottom: auto; }
.visite__progres { display: grid; grid-template-columns: repeat(var(--n, 10), minmax(0, 1fr)); gap: 3px; }
.visite__seg { display: block; height: 4px; border-radius: 999px; background: var(--vis-trait); overflow: hidden; }
.visite__plein { display: block; height: 100%; background: #59c5c3; transform-origin: 0 50%; transform: scaleX(var(--a, 0)); }
.visite__plein.is-run-a { animation: visite-fill-a var(--dwell, 7s) linear both; }
.visite__plein.is-run-b { animation: visite-fill-b var(--dwell, 7s) linear both; }
.visite__ligne { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.visite__etat { margin: 0; min-width: 0; font-size: 14px; color: #5b6472; }
.visite__etat strong { font-weight: 700; color: #1b2333; }
.visite__boutons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* Boutons de la barre et des cartes (prototype : 36 px de haut, coins 10 px, 14 px 700). */
.visite__btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-sizing: border-box; min-height: 36px; margin: 0;
  padding: 0 12px; border: 1px solid #d6dbea; border-radius: 10px; background: #FFFFFF; color: #141a28; font: inherit; font-size: 14px;
  font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer; }
.visite__btn:hover { background: #f1f3fa; }
.visite__btn[hidden] { display: none; }
.visite__btn:focus-visible { outline: 3px solid #283595; outline-offset: 2px; }
.visite__btn--lien { padding: 0 10px; border-color: transparent; background: transparent; color: #283595; }
.visite__btn--lien:hover { background: #f1f3fa; color: #1f2a78; }
.visite__btn--vert { padding: 0 14px; border-color: transparent; background: #283595; color: #FFFFFF; }
.visite__btn--vert:hover { background: #1f2a78; color: #FFFFFF; }
.visite__icone { display: inline-flex; }

/* Cartes de fin (« Visite terminée… », « Revoir la visite », « Aller à l'accueil ») et de proposition. */
.visite-carte { position: fixed; z-index: 44; left: 50%; bottom: 20px; transform: translateX(-50%); width: calc(100% - 32px); max-width: 560px;
  box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px 16px;
  border: 1px solid #d6dbea; border-radius: 16px; background: #FFFFFF; color: #1b2333; box-shadow: 0 6px 20px rgb(20 24 45 / 0.08);
  font-size: 16px; line-height: 1.4; animation: visite-barre 0.5s ease-out both; }
.visite-carte__texte { flex: 1 1 220px; min-width: 0; }
.visite-carte__titre { margin: 0; font-size: 15px; font-weight: 700; }
.visite-carte__sous { margin: 2px 0 0; font-size: 14px; color: #5b6472; }
.visite-carte__boutons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.visite-carte__fermer { width: 36px; padding: 0; border-color: transparent; font-size: 20px; font-weight: 500; color: #5b6472; }

/* Une notification pendant qu'une carte attend : devant tout, comme dans le prototype, mais posée au-dessus de la
   carte, sans la cacher (hauteur de la carte publiée par visite.js). */
html:has(> body > .visite-carte) .toasts[popover] { bottom: calc(20px + var(--visite-carte-h, 0px) + 12px); }

@keyframes visite-pulse {
  0% { box-shadow: 0 0 0 0 rgb(40 53 149 / 0.5); }
  70% { box-shadow: 0 0 0 18px rgb(40 53 149 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(40 53 149 / 0); }
}
@keyframes visite-pop-a { from { opacity: 0; transform: translateY(10px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes visite-pop-b { from { opacity: 0; transform: translateY(10px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes visite-barre { from { opacity: 0; transform: translate(-50%, 24px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes visite-fill-a { from { transform: scaleX(var(--a)); } to { transform: scaleX(var(--b)); } }
@keyframes visite-fill-b { from { transform: scaleX(var(--a)); } to { transform: scaleX(var(--b)); } }

@media (max-width: 760px) {
  /* Pendant la visite, le menu du bas laisse sa place à la barre de la visite, collée en bas. */
  .visite-en-cours .sidebar { visibility: hidden; }
  /* La carte (proposition, fin) reste au-dessus du menu du bas (environ 60 px). */
  .visite-carte { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  html:has(> body > .visite-carte) .toasts[popover] { bottom: calc(72px + env(safe-area-inset-bottom, 0px) + var(--visite-carte-h, 0px) + 12px); }
  .visite { --vis-bas: 0px; }
  .visite__barre { left: 0; transform: none; width: 100%; max-width: none; gap: 6px; border-width: 1px 0 0;
    border-radius: 16px 16px 0 0; padding: 14px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 24px rgb(0 0 0 / 0.16); animation-name: visite-barre-tel; }
  .visite--haut .visite__barre { top: 0; bottom: auto; border-width: 0 0 1px; border-radius: 0 0 16px 16px;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 12px 8px; }
  .visite__progres { position: absolute; left: 12px; right: 12px; top: 6px; }
  .visite--haut .visite__progres { top: auto; bottom: 4px; }
  .visite__ligne { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 6px; }
  .visite__etat { font-size: 13px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .visite__boutons { flex-wrap: nowrap; justify-content: flex-end; gap: 4px; }
  .visite__btn--lien { margin-right: auto; padding: 0 8px; }
  .visite__btn { min-height: 40px; }
  .visite__btn--prev, .visite__btn--play { width: 40px; padding: 0; }
  .visite__mot { display: none; }
  .visite__bulle { padding: 12px 14px; }
  .visite__phrase { margin-top: 4px; font-size: 14px; }
}
@keyframes visite-barre-tel { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .visite__cadre, .visite__bulle, .visite__barre, .visite-carte, .visite__plein { animation: none !important; transition: none !important; }
  .visite__plein.is-run-a, .visite__plein.is-run-b { transform: scaleX(var(--b)); }
}
@media (forced-colors: active) {
  .visite__cadre { border-color: Highlight; }
  .visite__bulle, .visite__barre, .visite-carte { border: 1px solid CanvasText; }
}
