/* Mousse — la mascotte (une bouteille animée) et sa discussion.
   Ses couleurs suivent la bière choisie : --beer (liquide), --accent (étiquette), --deep / --paper (traits et halo).
   Toujours sous le chargement (100), la transition (96), la navigation (50) et le menu (45) : z-index 40. */

.mousse {
  --m-w: 76px; /* largeur du personnage ; hauteur = 1,52 × */
  position: fixed; right: 16px; bottom: 16px; z-index: 40;
  font: 400 15px/1.45 var(--f-text); color: var(--deep);
  transition: translate .6s var(--ease), opacity .4s var(--ease), visibility 0s;
}
.mousse[hidden], .mousse [hidden] { display: none !important; }
.mousse.is-away { translate: 0 130%; opacity: 0; visibility: hidden; pointer-events: none; transition: translate .5s var(--ease), opacity .3s, visibility 0s .5s; }
.mousse__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mousse :focus-visible { outline: 3px solid var(--deep); outline-offset: 2px; }

/* ---------- Le personnage ---------- */
.mousse__btn {
  display: block; width: var(--m-w); aspect-ratio: 100 / 152; padding: 0; border: 0; border-radius: 16px;
  background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.mousse__btn:focus-visible { outline-offset: 3px; box-shadow: 0 0 0 6px var(--paper); } /* double anneau : visible sur fond clair comme foncé */
.mousse__btn svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 6px 8px rgb(0 0 0 / .2)); }

.m-h { fill: none; stroke: var(--paper); stroke-width: 8; stroke-linecap: round; } /* halo clair autour des membres */
.m-s { fill: none; stroke: var(--deep); stroke-width: 4.4; stroke-linecap: round; }
.m-end { fill: var(--deep); stroke: var(--paper); stroke-width: 2; paint-order: stroke; }
.m-halo { fill: none; stroke: var(--paper); stroke-width: 7; stroke-linejoin: round; }
.m-line { fill: none; stroke: var(--deep); stroke-width: 2.6; stroke-linejoin: round; }
.m-glass { fill: color-mix(in srgb, var(--paper) 72%, var(--beer)); }
.m-beer { fill: var(--beer); }
.m-foam { fill: #fbf2df; }
.m-label { fill: var(--accent); }
.m-shine { fill: #fff; opacity: .35; }
.m-cap { fill: var(--gold); stroke: var(--deep); stroke-width: 2; }
.m-eye { fill: #fff; }
.m-pupils { fill: var(--deep); translate: calc(var(--lx, 0) * 1px) calc(var(--ly, 0) * 1px); }
.m-smile { fill: none; stroke: var(--on-accent); stroke-width: 2.2; stroke-linecap: round; }
.m-o { fill: var(--on-accent); opacity: 0; }
.m-paddle { display: none; }
.m-wood { fill: none; stroke: #c99a62; stroke-width: 3.4; stroke-linecap: round; }
.m-blade { fill: #c99a62; stroke: var(--deep); stroke-width: 1.4; }
.m-z { display: none; font: 600 12px/1 var(--f-display); fill: var(--deep); stroke: var(--paper); stroke-width: 3px; paint-order: stroke; }

/* Pivots (unités du dessin) ; la marche est pilotée par --l1 --l2 --a1 --bob (requestAnimationFrame) */
.m-all { transform-origin: 50px 147px; translate: 0 calc(var(--bob, 0) * 1px); }
.m-body { transform-origin: 50px 128px; animation: m-breathe 3.6s ease-in-out infinite; }
.m-eyes { transform-origin: 50px 89px; animation: m-blink 5.4s infinite; }
.m-arm-l, .m-arm-r { rotate: calc(var(--a1, 0) * 1deg); transition: transform .5s var(--ease); }
.m-arm-l { transform-origin: 31px 72px; }
.m-arm-r { transform-origin: 69px 72px; }
.m-leg-l { translate: 0 calc(var(--l1, 0) * -1px); }
.m-leg-r { translate: 0 calc(var(--l2, 0) * -1px); }

.is-run .m-body { animation-duration: 1.1s; }
.is-point .m-arm-l { transform: rotate(62deg); } /* montre le contenu, à gauche */
.is-brew .m-paddle { display: inline; } /* le fourquet du brasseur, dans les sections de l'atelier */
.is-brew .m-arm-r { animation: m-stir 2.6s ease-in-out infinite; }
.is-calm .m-body, .is-calm .m-eyes, .is-calm .m-arm-r, .is-calm .m-z text { animation: none; } /* mode discret */
.is-wave .m-arm-r { animation: m-wave 1.8s var(--ease); }
.is-jump .m-all { animation: m-jump .7s var(--ease); }
.is-talk .m-smile { animation: m-talk .32s steps(1) infinite; }
.is-talk .m-o { animation: m-o .32s steps(1) infinite; }
.is-nap .m-eyes { animation: none; transform: scaleY(.12); }
.is-nap .m-pupils { translate: none; }
.is-nap .m-body { animation-duration: 6s; }
.is-nap .m-z { display: inline; }
.m-z text { animation: m-z 2.8s ease-out infinite; }
.m-z text + text { animation-delay: 1.4s; }

@keyframes m-breathe { 50% { transform: scale(1.015, 1.03); } }
@keyframes m-blink { 0%, 93%, 97%, 100% { transform: none; } 95% { transform: scaleY(.1); } }
@keyframes m-wave { 0%, 100% { transform: none; } 18%, 48%, 78% { transform: rotate(-150deg); } 33%, 63% { transform: rotate(-118deg); } }
@keyframes m-stir { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(12deg); } }
@keyframes m-jump { 0%, 100% { transform: none; } 20% { transform: scale(1.08, .9); } 48% { transform: translateY(-16px) scale(.96, 1.05); } 75% { transform: scale(1.04, .95); } }
@keyframes m-talk { 50% { opacity: 0; } }
@keyframes m-o { 50% { opacity: 1; } }
@keyframes m-z { from { opacity: 0; transform: none; } 30% { opacity: 1; } to { opacity: 0; transform: translate(6px, -12px); } }
@keyframes m-pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }

/* ---------- Astuce (bulle) ---------- */
.mousse__tip {
  position: absolute; right: calc(var(--m-w) * .62); bottom: calc(var(--m-w) * 1.32);
  width: max-content; max-width: min(250px, calc(100vw - 110px)); padding: 12px 14px 10px;
  border-radius: 16px 16px 4px 16px; background: var(--paper); color: var(--deep); cursor: pointer;
  box-shadow: 0 12px 32px rgb(0 0 0 / .2), 0 0 0 1px color-mix(in srgb, var(--deep) 10%, transparent);
  transform-origin: 100% 100%; animation: m-pop .45s var(--ease);
}
.mousse__tip-txt { margin: 0; font: 500 17px/1.25 var(--f-display); letter-spacing: -.01em; }
.mousse__tip-act { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.mousse__tip-act button {
  min-width: 32px; min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--deep) 9%, transparent); color: inherit; font: 600 13px/1 var(--f-text);
}
.mousse__tip-act button:hover { background: var(--deep); color: var(--paper); }
.mousse.is-open .mousse__tip { display: none; }

/* ---------- Discussion (fenêtre non modale, à côté de Mousse) ---------- */
.mousse__chat {
  position: absolute; right: calc(100% + 12px); bottom: 0;
  display: flex; flex-direction: column; width: min(380px, calc(100vw - var(--m-w) - 44px));
  max-height: min(640px, calc(100vh - 110px)); max-height: min(640px, calc(100svh - 110px));
  /* fenêtre basse (téléphone à l'horizontale) : le volet défile plutôt que de couper le champ de saisie */
  border-radius: 22px; overflow: hidden auto; overscroll-behavior: contain; background: var(--paper); color: var(--deep);
  box-shadow: 0 24px 60px rgb(0 0 0 / .25), 0 0 0 1px color-mix(in srgb, var(--deep) 10%, transparent);
  transform-origin: 100% 100%; animation: m-pop .4s var(--ease);
}
.mousse__head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 12px 18px; background: var(--bg); color: var(--on); }
.mousse__head :focus-visible { outline-color: var(--on); }
.mousse__name { margin: 0 auto 0 0; font: 600 21px/1 var(--f-display); letter-spacing: -.02em; }
.mousse__name span { display: block; margin-top: 4px; font: 400 13px/1.2 var(--f-text); letter-spacing: 0; opacity: .8; }
/* contour plutôt que fond teinté : le texte garde le contraste --on / --bg (4,9:1 au minimum selon la bière) */
.mousse__calm, .mousse__close { flex: none; border: 0; border-radius: 999px; background: none; color: inherit; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--on) 45%, transparent); }
.mousse__calm { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 12px 0 10px; font: 600 13px/1 var(--f-text); }
.mousse__calm::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .35; }
.mousse__calm[aria-pressed="true"]::before { opacity: 1; }
.mousse__close { width: 40px; height: 40px; font: 400 26px/1 var(--f-text); }
.mousse__calm:hover, .mousse__close:hover { background: var(--on); color: var(--bg); }

.mousse__log { flex: 1 1 auto; min-height: 140px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.mousse__msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.mousse__msg p { margin: 0; }
.mousse__msg p + p { margin-top: 6px; }
.mousse__msg--b { align-self: flex-start; border-bottom-left-radius: 6px; background: color-mix(in srgb, var(--deep) 8%, var(--paper)); }
.mousse__msg--u { align-self: flex-end; border-bottom-right-radius: 6px; background: var(--deep); color: var(--paper); }
.mousse__msg .mousse__links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mousse__link {
  display: inline-flex; align-items: center; min-height: 34px; padding: 4px 13px; border-radius: 999px;
  /* --accent / --on-accent tombe sous 4,5:1 pour La Cabane et La Tchanquée : fond teinté d'accent, texte --deep (6:1 au minimum) */
  background: color-mix(in srgb, var(--accent) 30%, var(--paper)); color: var(--deep); font: 600 13px/1.2 var(--f-text); text-decoration: none;
  transition: background-color .3s var(--ease), color .3s;
}
.mousse__link:hover { background: var(--deep); color: var(--paper); }

.mousse__typing { align-self: flex-start; display: flex; gap: 5px; padding: 13px 15px; border-radius: 18px 18px 18px 6px; background: color-mix(in srgb, var(--deep) 8%, var(--paper)); }
.mousse__typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--beer); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--deep) 35%, transparent); animation: m-bub 1s ease-in-out infinite; }
.mousse__typing i:nth-child(2) { animation-delay: .15s; }
.mousse__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes m-bub { 0%, 100% { transform: translateY(2px); opacity: .5; } 50% { transform: translateY(-4px); opacity: 1; } }

.mousse__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.mousse__chip {
  min-height: 34px; padding: 0 12px; border: 1.5px solid color-mix(in srgb, var(--deep) 24%, transparent); border-radius: 999px;
  background: none; color: inherit; font: 600 13px/1 var(--f-text); transition: background-color .3s var(--ease), color .3s, border-color .3s;
}
.mousse__chip:hover { background: var(--deep); border-color: var(--deep); color: var(--paper); }

.mousse__form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid color-mix(in srgb, var(--deep) 12%, transparent); }
.mousse__in {
  flex: 1; min-width: 0; min-height: 46px; padding: 0 16px; border: 1.5px solid color-mix(in srgb, var(--deep) 60%, var(--paper)); border-radius: 999px; /* bord à 3:1 au moins */
  background: color-mix(in srgb, #fff 75%, var(--paper)); color: var(--deep); font: 400 16px/1.2 var(--f-text); /* 16 px : pas de zoom sur iPhone */
}
.mousse__in::placeholder { color: color-mix(in srgb, var(--deep) 72%, var(--paper)); opacity: 1; } /* 4,7:1 au minimum */
.mousse__send { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 50%; background: var(--deep); color: var(--paper); }
.mousse__send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.mousse__note { margin: 0; padding: 0 16px 12px; font-size: 12px; line-height: 1.35; opacity: .78; }

/* ---------- Téléphone : petit personnage (≈ 64 px), discussion en volet pleine largeur ---------- */
@media (max-width: 760px) {
  .mousse { --m-w: 42px; right: 12px; bottom: 12px; }
  .mousse__tip-txt { font-size: 16px; }
}
@media (max-width: 560px) {
  .mousse__chat { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 86vh; max-height: 86svh; border-radius: 22px 22px 0 0; }
  .mousse.is-open .mousse__btn { visibility: hidden; }
  .mousse__msg { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .mousse, .mousse * { animation: none !important; transition: none !important; }
}
@media print { .mousse { display: none !important; } }
