/* Devis express – SOS Micro 87 */
:root {
  --orange: #ff7a1a;
  --orange-fonce: #e35f00;
  --violet: #6c4cff;
  --menthe: #19d3a2;
  --texte: #1d1b3a;
  --texte-doux: #5b5878;
  --carte: #ffffff;
  --fond-1: #fff4ea;
  --fond-2: #f1ecff;
  --bordure: #e7e3f3;
  --ombre: 0 10px 30px rgba(45, 30, 110, .12);
  --rayon: 22px;
  --duree: .45s;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color: var(--texte);
  background: linear-gradient(160deg, var(--fond-1), var(--fond-2));
  overflow-x: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "haut" "mascotte" "app" "direct";
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }

/* Fond animé */
.fond { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.fond span {
  position: absolute; width: 55vmax; height: 55vmax; border-radius: 50%;
  filter: blur(60px); opacity: .35; animation: flotte 18s ease-in-out infinite alternate;
}
.fond span:nth-child(1) { background: var(--orange); top: -25vmax; left: -15vmax; }
.fond span:nth-child(2) { background: var(--violet); bottom: -30vmax; right: -20vmax; animation-delay: -6s; }
.fond span:nth-child(3) { background: var(--menthe); top: 40%; left: 50%; width: 30vmax; height: 30vmax; opacity: .22; animation-delay: -12s; }
@keyframes flotte { to { transform: translate(8vmax, 6vmax) scale(1.15); } }

/* Haut : retour + progression */
.haut {
  grid-area: haut; display: flex; align-items: center; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 6px;
}
.retour {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  background: var(--carte); box-shadow: var(--ombre); cursor: pointer; display: grid; place-items: center;
}
.retour[hidden] { visibility: hidden; display: grid; }
.retour svg { width: 22px; height: 22px; fill: none; stroke: var(--texte); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.progres { position: relative; flex: 1; height: 44px; display: flex; align-items: center; }
.piste { width: 100%; height: 10px; border-radius: 99px; background: rgba(255,255,255,.75); overflow: hidden; }
.trainee {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--menthe), var(--violet), var(--orange));
  transition: width .7s cubic-bezier(.3,1.4,.5,1);
}
.fusee {
  position: absolute; left: 0; top: 50%; width: 40px; height: 24px;
  transform: translate(0, -50%);
  transition: left .7s cubic-bezier(.3,1.4,.5,1), transform .7s cubic-bezier(.3,1.4,.5,1);
}
.fusee svg { width: 100%; height: 100%; overflow: visible; animation: vole 1.2s ease-in-out infinite; }
.coque-f { fill: var(--violet); }
.ailette { fill: var(--orange-fonce); }
.hublot { fill: #fff; stroke: var(--texte); stroke-width: 1.5; }
.flamme { fill: #ffb703; transform-origin: 8px 12px; animation: flamme .25s ease-in-out infinite alternate; }
@keyframes vole { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes flamme { from { transform: scaleX(.6); } to { transform: scaleX(1.3); } }
body[data-etape="0"] .fusee, body[data-etape="5"] .fusee { opacity: .9; }
.logo { font-weight: 800; font-size: 14px; letter-spacing: .02em; color: var(--orange-fonce); white-space: nowrap; }

/* Mascotte */
.mascotte { grid-area: mascotte; justify-self: center; width: 64px; margin-top: 2px; transition: width .4s cubic-bezier(.3,1.4,.5,1); }
body[data-etape="0"] .mascotte, body[data-etape="5"] .mascotte { width: 130px; margin-top: 16px; }
.mascotte svg { width: 100%; height: auto; overflow: visible; display: block; }
.coque { fill: var(--texte); }
.ecran { fill: #ffffff; }
.hp { fill: #44406a; }
.yeux ellipse { fill: var(--texte); transform-box: fill-box; transform-origin: center; animation: cligne 4.5s infinite; }
.joue { fill: #ffb3a1; opacity: .8; }
.bouche { fill: none; stroke: var(--texte); stroke-width: 4; stroke-linecap: round; transition: d .3s; }
.sourcils path { stroke: var(--texte); stroke-width: 3.5; stroke-linecap: round; opacity: 0; transition: opacity .3s; }
.fissure path { fill: none; stroke: #9aa0b8; stroke-width: 2; stroke-linejoin: round; opacity: 0; transition: opacity .3s; }
.bras-g, .bras-d { fill: none; stroke: var(--texte); stroke-width: 6; stroke-linecap: round; }
.bras-g circle, .bras-d circle { fill: var(--orange); stroke: none; }
.bras-g { transform-origin: 22px 80px; }
.bras-d { transform-origin: 98px 80px; }
.corps { transform-origin: 60px 138px; }
@keyframes cligne { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes coucou { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-28deg); } }
@keyframes sautille { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes danse { 0%, 100% { transform: rotate(-8deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-10px); } }
@keyframes tremble { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes bras-haut { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(-40deg); } }
@keyframes bras-haut-d { 0%, 100% { transform: rotate(10deg); } 50% { transform: rotate(40deg); } }

.mascotte[data-humeur="coucou"] .bras-d { animation: coucou .9s ease-in-out infinite; }
.mascotte[data-humeur="coucou"] .corps { animation: sautille 2.4s ease-in-out infinite; }
.mascotte[data-humeur="curieux"] .corps { animation: sautille 3s ease-in-out infinite; }
.mascotte[data-humeur="inquiet"] .bouche { d: path("M48 92 Q60 82 72 92"); }
.mascotte[data-humeur="inquiet"] .sourcils path { opacity: 1; }
.mascotte[data-humeur="inquiet"] .corps { animation: tremble .35s linear 3; }
.mascotte[data-humeur="casse"] .bouche { d: path("M48 92 Q60 82 72 92"); }
.mascotte[data-humeur="casse"] .sourcils path { opacity: 1; }
.mascotte[data-humeur="casse"] .fissure path { opacity: 1; }
.mascotte[data-humeur="casse"] .corps { animation: tremble .35s linear 3; }
.mascotte[data-humeur="content"] .bouche { d: path("M44 84 Q60 104 76 84"); }
.mascotte[data-humeur="content"] .corps { animation: sautille 1s ease-in-out 2; }
.mascotte[data-humeur="fete"] .bouche { d: path("M44 84 Q60 106 76 84"); }
.mascotte[data-humeur="fete"] .corps { animation: danse .6s ease-in-out infinite; }
.mascotte[data-humeur="fete"] .bras-g { animation: bras-haut-d .6s ease-in-out infinite; }
.mascotte[data-humeur="fete"] .bras-d { animation: bras-haut .6s ease-in-out infinite; }
.mascotte.pop .corps { animation: sautille .4s ease-out 1 !important; }

/* Zone principale */
main {
  grid-area: app; position: relative; width: 100%; max-width: 640px; justify-self: center;
  padding: 8px 16px 16px; display: flex; flex-direction: column; justify-content: center;
}
.etape { display: flex; flex-direction: column; gap: 14px; }
.etape[hidden] { display: none; }
.etape.entree { animation: entree var(--duree) cubic-bezier(.2,.9,.3,1.2) both; }
.etape.entree.inverse { animation-name: entree-inverse; }
@keyframes entree { from { opacity: 0; transform: translateX(60px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes entree-inverse { from { opacity: 0; transform: translateX(-60px) scale(.97); } to { opacity: 1; transform: none; } }
.etape > * { animation: monte .5s cubic-bezier(.2,.9,.3,1.2) both; }
.etape > *:nth-child(2) { animation-delay: .05s; }
.etape > *:nth-child(3) { animation-delay: .1s; }
.etape > *:nth-child(4) { animation-delay: .15s; }
.etape > *:nth-child(5) { animation-delay: .2s; }
.etape > *:nth-child(n+6) { animation-delay: .25s; }
@keyframes monte { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.sur-titre {
  margin: 0; align-self: flex-start; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--violet); background: rgba(108,76,255,.1); padding: 6px 12px; border-radius: 99px;
}
h1, h2 { margin: 0; line-height: 1.15; letter-spacing: -.02em; }
h1 { font-size: clamp(30px, 7.5vw, 52px); }
h2 { font-size: clamp(26px, 6.5vw, 40px); }
.surligne { background: linear-gradient(transparent 60%, rgba(255,122,26,.35) 60%); }
.aide { margin: 0; font-size: 17px; color: var(--texte-doux); }
.aide.grand { font-size: 20px; }

/* Boutons */
.bouton {
  margin-top: 6px; min-height: 58px; padding: 0 28px; border: 0; border-radius: 99px; cursor: pointer;
  font-size: 19px; font-weight: 800; color: #fff; text-decoration: none;
  background: linear-gradient(135deg, var(--orange), var(--orange-fonce));
  box-shadow: 0 8px 0 #b84c00, 0 14px 24px rgba(227,95,0,.35);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .12s, box-shadow .12s, opacity .25s, filter .25s;
}
.bouton:active:not(:disabled) { transform: translateY(6px); box-shadow: 0 2px 0 #b84c00, 0 6px 12px rgba(227,95,0,.3); }
.bouton:disabled { filter: grayscale(1); opacity: .35; cursor: not-allowed; box-shadow: 0 6px 0 #9b9b9b; }
.bouton:not(:disabled) { animation: monte .5s both, appel 2.4s 1s ease-in-out infinite; }
@keyframes appel { 0%, 85%, 100% { transform: none; } 90% { transform: scale(1.04); } }
.bouton.gros { min-height: 68px; font-size: 22px; }
.bouton.secondaire { background: var(--carte); color: var(--texte); box-shadow: 0 6px 0 var(--bordure), var(--ombre); }
.bouton:focus-visible, .carte:focus-visible, .pastille:focus-visible, .ligne:focus-visible, .retour:focus-visible {
  outline: 3px solid var(--violet); outline-offset: 3px;
}

/* Cartes appareils */
.cartes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.carte {
  position: relative; border: 2px solid transparent; border-radius: 18px; background: var(--carte);
  box-shadow: var(--ombre); cursor: pointer; padding: 12px 6px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 14px;
  transition: transform .2s cubic-bezier(.3,1.6,.5,1), border-color .2s, background .2s;
  animation: monte .45s cubic-bezier(.2,.9,.3,1.2) both;
}
.carte svg { width: 40px; height: 40px; fill: none; stroke: var(--texte); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: stroke .2s; }
.carte:hover { transform: translateY(-3px); }
.carte[aria-checked="true"] {
  border-color: var(--orange); background: #fff3e8; transform: scale(1.05);
  animation: rebond .45s cubic-bezier(.3,1.8,.5,1);
}
.carte[aria-checked="true"] svg { stroke: var(--orange-fonce); }
.carte[aria-checked="true"]::after {
  content: "✓"; position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--orange); color: #fff; font-size: 15px; display: grid; place-items: center;
  animation: rebond .4s cubic-bezier(.3,1.8,.5,1);
}
@keyframes rebond { 0% { transform: scale(.85); } 60% { transform: scale(1.12); } 100% { transform: scale(1.05); } }

label span { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
label em { font-weight: 400; color: var(--texte-doux); font-style: normal; }
input[type="text"], textarea {
  width: 100%; border: 2px solid var(--bordure); border-radius: 16px; background: var(--carte);
  padding: 14px 16px; font-size: 17px; outline: none; transition: border-color .2s, box-shadow .2s; resize: none;
}
input:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(108,76,255,.15); }

/* Pastilles pannes */
.pastilles { display: flex; flex-wrap: wrap; gap: 10px; }
.pastille {
  border: 2px solid var(--bordure); background: var(--carte); border-radius: 99px; cursor: pointer;
  padding: 11px 16px; font-size: 16px; font-weight: 700; display: inline-flex; gap: 8px; align-items: center;
  transition: transform .2s cubic-bezier(.3,1.6,.5,1), background .2s, border-color .2s, color .2s;
  animation: monte .4s cubic-bezier(.2,.9,.3,1.2) both;
}
.pastille[aria-pressed="true"] { background: var(--violet); border-color: var(--violet); color: #fff; animation: rebond .4s cubic-bezier(.3,1.8,.5,1) forwards; }

/* Téléphone */
.champ-tel { position: relative; }
.champ-tel input {
  width: 100%; border: 3px solid var(--bordure); border-radius: 20px; background: var(--carte);
  padding: 18px 64px 18px 20px; font-size: clamp(26px, 7vw, 34px); font-weight: 800; letter-spacing: .06em;
  outline: none; transition: border-color .25s, box-shadow .25s;
}
.champ-tel input:focus { border-color: var(--violet); box-shadow: 0 0 0 5px rgba(108,76,255,.15); }
.champ-tel.ok input { border-color: var(--menthe); box-shadow: 0 0 0 5px rgba(25,211,162,.18); }
.coche {
  position: absolute; right: 16px; top: 50%; width: 38px; height: 38px; margin-top: -19px; border-radius: 50%;
  background: var(--menthe); display: grid; place-items: center; transform: scale(0); transition: transform .35s cubic-bezier(.3,1.8,.5,1);
}
.coche svg { width: 24px; fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .4s .15s; }
.champ-tel.ok .coche { transform: scale(1); }
.champ-tel.ok .coche svg { stroke-dashoffset: 0; }
.mention { margin: 0; font-size: 14px; color: var(--texte-doux); }
.piege { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Récap */
.recap { display: flex; flex-direction: column; gap: 10px; }
.ligne {
  border: 0; background: var(--carte); border-radius: 18px; box-shadow: var(--ombre); padding: 14px 16px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left; cursor: pointer;
  transition: transform .2s;
}
.ligne:hover { transform: translateX(4px); }
.etiquette { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--violet); }
.valeur { grid-column: 1; font-size: 18px; font-weight: 700; }
.crayon { grid-column: 2; grid-row: 1 / 3; align-self: center; font-size: 20px; }
.erreur { margin: 0; padding: 12px 14px; border-radius: 14px; background: #ffe6e6; color: #a31515; font-weight: 600; }
.envoyer { white-space: nowrap; }
.envoyer.charge { pointer-events: none; }
.envoyer.charge span { display: none; }
.envoyer.charge::after {
  content: ""; width: 20px; height: 20px; border: 3px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%;
  animation: tourne .7s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }

/* Bravo */
.bravo { font-size: clamp(36px, 9vw, 60px); }
.horaires { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 6px 18px; }
.horaires p { margin: 12px 0; }
.horaires .petit { font-size: 14px; color: var(--texte-doux); }

.direct {
  grid-area: direct; text-align: center; margin: 0; font-size: 14px; color: var(--texte-doux);
  padding: 6px 16px max(12px, env(safe-area-inset-bottom));
}
.direct a { color: var(--orange-fonce); font-weight: 800; text-decoration: none; }

/* Bulle au-dessus du clavier */
.bulle {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20;
  background: var(--texte); color: #fff; border-radius: 18px; padding: 10px 14px 12px;
  box-shadow: 0 12px 30px rgba(29,27,58,.35);
  display: flex; flex-direction: column; gap: 2px;
  transform-origin: 50% 100%; animation: bulle-pop .3s cubic-bezier(.3,1.6,.5,1);
}
.bulle[hidden] { display: none; }
.bulle::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; width: 14px; height: 14px; margin-left: -7px;
  background: var(--texte); transform: rotate(45deg); border-radius: 3px;
}
.bulle-titre { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--menthe); }
.bulle-texte { display: block; font-size: 18px; font-weight: 600; line-height: 1.3; max-height: 3.9em; overflow: hidden; word-break: break-word; }
.bulle-texte > span { white-space: pre-wrap; }
.bulle-texte.vide > span { color: rgba(255,255,255,.45); font-weight: 400; }
.curseur { display: inline-block; width: 2px; height: 1.1em; background: var(--orange); vertical-align: -3px; margin-left: 1px; animation: clignote 1s steps(1) infinite; }
@keyframes clignote { 50% { opacity: 0; } }
@keyframes bulle-pop { from { opacity: 0; transform: translateY(10px) scale(.9); } to { opacity: 1; transform: none; } }

#confettis { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }

/* Petits écrans en hauteur */
@media (max-height: 700px) and (max-width: 899px) {
  .mascotte { width: 48px; }
  body[data-etape="0"] .mascotte, body[data-etape="5"] .mascotte { width: 96px; margin-top: 4px; }
  .carte { padding: 8px 4px; font-size: 13px; }
  .carte svg { width: 32px; height: 32px; }
  .etape { gap: 10px; }
}
@media (max-width: 360px) {
  .cartes { gap: 8px; }
  .carte { font-size: 12px; }
}

/* Grands écrans : mascotte à gauche, question à droite */
@media (min-width: 900px) {
  body {
    grid-template-columns: 1fr minmax(0, 1.25fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "haut haut" "mascotte app" "direct direct";
  }
  .haut { padding: 22px 32px 6px; max-width: 1200px; width: 100%; justify-self: center; }
  .mascotte, body[data-etape] .mascotte { width: min(260px, 22vw); align-self: center; justify-self: end; margin: 0 6vw 0 0; }
  main { justify-self: start; padding: 16px 32px 32px; }
  .cartes { gap: 14px; }
  .carte { padding: 18px 8px 14px; font-size: 16px; }
  .carte svg { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
