/* Jarvis mobile. Un seul thème (sombre, identité de Jarvis), un seul accent (cyan désaturé),
   rayons : 14 px pour les surfaces, pilule pour les boutons ronds et la saisie. */

@font-face { font-family: "Geist"; src: url("polices/Geist-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Geist"; src: url("polices/Geist-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Geist"; src: url("polices/Geist-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("polices/GeistMono-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --fond: #080b0f;
  --surface: #10161c;
  --surface-2: #161e26;
  --ligne: rgb(214 232 244 / 0.08);
  --ligne-forte: rgb(214 232 244 / 0.14);
  --texte: #e6edf2;
  --texte-doux: #93a3b1;
  --texte-faible: #8191a0;
  --accent: #6fcce8;
  --accent-encre: #05202a;
  --accent-voile: rgb(111 204 232 / 0.12);
  --rayon: 14px;
  --sortie: cubic-bezier(0.16, 1, 0.3, 1);
  --marge: 20px;
  --haut-sur: env(safe-area-inset-top, 0px);
  --bas-sur: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--fond); }
body {
  margin: 0; min-height: 100dvh; background: var(--fond); color: var(--texte);
  font: 400 16px/1.5 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
.invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

/* ================================================================ structure */
.appli {
  display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr);
  height: 100dvh; padding-top: var(--haut-sur); position: relative;
}
.barre {
  display: flex; align-items: center; gap: 12px; height: 60px;
  padding: 0 calc(var(--marge) - 6px) 0 var(--marge); position: relative; z-index: 3;
}
.identite { display: flex; flex-direction: column; line-height: 1.15; transition: transform 0.55s var(--sortie); }
.nom { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.etat { font-size: 13px; color: var(--texte-doux); transition: color 0.3s; }
.barre-actions { margin-left: auto; display: flex; gap: 2px; }
.bouton-icone {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 999px; color: var(--texte-doux);
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.bouton-icone:active { transform: scale(0.94); background: var(--surface-2); }
.bouton-icone[aria-pressed="false"] { color: var(--texte-faible); }

/* Le visage : grand à l'accueil ; une fois la conversation lancée, il se range à gauche du nom. */
.scene {
  position: absolute; left: 50%; top: calc(var(--haut-sur) + 52px); width: 216px; height: 216px;
  translate: -50% 0; pointer-events: none; z-index: 2;
  transition: translate 0.6s var(--sortie), scale 0.6s var(--sortie), top 0.6s var(--sortie), left 0.6s var(--sortie);
}
.scene canvas { width: 100%; height: 100%; display: block; }
body.en-conversation .scene { left: 4px; top: calc(var(--haut-sur) - 4px); translate: 0 0; scale: 0.3; transform-origin: 0 0; }
body.en-conversation .identite { transform: translateX(54px); }

/* ================================================================ fil de la conversation */
.fil {
  overflow-y: auto; overflow-x: hidden; padding: 0 var(--marge) 16px;
  display: flex; flex-direction: column; gap: 22px; scroll-behavior: smooth;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-top: 14px;
  /* le texte qui défile s'estompe sous l'en-tête au lieu d'être coupé net */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 22px);
}
.accueil { padding-top: 224px; display: flex; flex-direction: column; }
.salut { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.025em; }
.sous-salut { margin: 6px 0 22px; color: var(--texte-doux); font-size: 16px; }
.raccourcis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.raccourci {
  display: flex; align-items: center; gap: 12px; text-align: left; min-height: 64px;
  padding: 12px 14px; border-radius: var(--rayon); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ligne); transition: background 0.2s, transform 0.15s var(--sortie);
}
.raccourci-large { grid-column: span 2; }
.raccourci svg { color: var(--accent); width: 24px; height: 24px; }
.raccourci span { display: flex; flex-direction: column; min-width: 0; }
.raccourci b { font-weight: 500; font-size: 15px; }
.raccourci small { color: var(--texte-doux); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.raccourci:active { transform: scale(0.98); background: var(--surface-2); }

/* messages */
.msg { max-width: 100%; animation: arrivee 0.42s var(--sortie) both; }
.msg-pierre {
  align-self: flex-end; max-width: 82%; padding: 10px 15px; border-radius: 20px 20px 6px 20px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--ligne); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-pierre p { margin: 0; }
/* bulle avec photos : les images occupent la bulle, le texte dessous */
.msg-pierre.avec-photos { padding: 4px; width: 280px; max-width: 82%; }
.msg-pierre.avec-photos p { padding: 6px 11px 6px; }
.msg-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 4px; }
.msg-photos img {
  display: block; width: 100%; aspect-ratio: 4 / 3; max-height: 240px; object-fit: cover; border-radius: 16px 16px 4px 16px;
  background: var(--surface);
}
.msg-photos img:only-child { aspect-ratio: auto; max-height: 300px; }
.msg-photo-repere { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--texte-doux); }
.msg-photo-repere svg { width: 16px; height: 16px; color: var(--accent); }
.msg-photo-repere + p { margin-top: 2px; }
/* conversation reprise à l'ouverture : elle est déjà là, elle n'arrive pas */
.msg.repris { animation: none; }
.msg-jarvis { align-self: stretch; font-size: 17px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-jarvis p { margin: 0; }
.activite {
  display: flex; width: fit-content; align-items: center; gap: 8px; margin-bottom: 8px;
  font-size: 13px; color: var(--texte-doux);
}
.activite svg { width: 16px; height: 16px; color: var(--accent); }
.activite.finie svg { color: var(--texte-faible); }
.attente { display: grid; gap: 9px; padding-top: 4px; }
.attente i {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 40%, var(--surface) 80%) 0 0 / 300% 100%;
  animation: reflet 1.4s linear infinite;
}
.attente i:nth-child(1) { width: 88%; }
.attente i:nth-child(2) { width: 62%; }
.erreur { display: flex; gap: 10px; align-items: flex-start; color: var(--texte); }
.erreur > svg { color: var(--accent); margin-top: 2px; }
.erreur button {
  margin-top: 8px; display: inline-flex; gap: 8px; align-items: center; min-height: 40px; padding: 0 14px;
  border-radius: 999px; box-shadow: inset 0 0 0 1px var(--ligne-forte); color: var(--texte); font-size: 14px;
}
.erreur button svg { width: 18px; height: 18px; }

/* demande d'accord */
.accord {
  align-self: stretch; padding: 16px; border-radius: var(--rayon); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ligne-forte), 0 12px 32px rgb(0 8 14 / 0.5);
  animation: arrivee 0.42s var(--sortie) both;
}
.accord h2 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.accord p { margin: 0 0 14px; color: var(--texte-doux); font-size: 15px; overflow-wrap: anywhere; }
.accord .boutons { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.accord button {
  min-height: 48px; border-radius: 999px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; transition: transform 0.15s var(--sortie), opacity 0.2s;
}
.accord button svg { width: 18px; height: 18px; }
.accord .non { box-shadow: inset 0 0 0 1px var(--ligne-forte); color: var(--texte); }
.accord .oui { background: var(--accent); color: var(--accent-encre); }
.accord button:active { transform: scale(0.97); }
.accord button:disabled { opacity: 0.45; }
.accord-decide {
  display: flex; width: fit-content; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; color: var(--texte-doux);
}
.accord-decide svg { width: 16px; height: 16px; color: var(--accent); }
.msg-jarvis .accord { margin: 2px 0 12px; }

/* ================================================================ saisie */
.dock {
  padding: 8px var(--marge) calc(10px + var(--bas-sur)); background: linear-gradient(to top, var(--fond) calc(100% - 10px), rgb(8 11 15 / 0));
  position: relative; z-index: 3;
}
/* pendant l'écoute, ce que Jarvis entend prend la place du champ de saisie */
.ecoute {
  flex: 1; margin: 0; min-height: 52px; max-height: 132px; overflow-y: auto; padding: 14px 18px; border-radius: 26px;
  font-size: 16px; line-height: 24px; color: var(--texte); background: var(--accent-voile);
  box-shadow: inset 0 0 0 1px rgb(111 204 232 / 0.35); animation: arrivee 0.3s var(--sortie) both;
}
.ecoute:empty::before { content: "Je vous écoute…"; color: var(--texte-doux); }
.ecoute:not([hidden]) + textarea { display: none; }
.saisie { display: flex; align-items: flex-end; gap: 10px; }
.saisie textarea {
  flex: 1; resize: none; min-height: 52px; max-height: 132px; padding: 14px 18px; border: 0; border-radius: 26px;
  font: inherit; font-size: 16px; line-height: 24px; color: var(--texte); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ligne); transition: box-shadow 0.2s;
}
.saisie textarea::placeholder { color: var(--texte-faible); }
.saisie textarea:focus { outline: none; box-shadow: inset 0 0 0 1px rgb(111 204 232 / 0.55); }
.bouton-action {
  position: relative; width: 52px; height: 52px; border-radius: 999px; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-encre); transition: transform 0.18s var(--sortie), background 0.2s;
}
.bouton-action svg { grid-area: 1 / 1; width: 24px; height: 24px; transition: opacity 0.18s, transform 0.25s var(--sortie); }
.bouton-action .ico-envoyer, .bouton-action .ico-stop { opacity: 0; transform: scale(0.6); }
.bouton-action.mode-envoyer .ico-micro, .bouton-action.mode-stop .ico-micro { opacity: 0; transform: scale(0.6); }
.bouton-action.mode-envoyer .ico-envoyer, .bouton-action.mode-stop .ico-stop { opacity: 1; transform: none; }
.bouton-action:active { transform: scale(0.93); }
.bouton-action.mode-stop { background: var(--texte); }
/* anneau d'écoute : montre que le micro est ouvert */
.bouton-action.mode-stop::after {
  content: ""; position: absolute; inset: -6px; border-radius: inherit; box-shadow: 0 0 0 2px rgb(230 237 242 / 0.35);
  animation: ecoute 1.6s var(--sortie) infinite;
}
.bouton-action:disabled { opacity: 0.5; }
/* appareil photo : discret à gauche de la saisie, le bouton principal reste l'accent */
.bouton-photo {
  width: 52px; height: 52px; border-radius: 999px; flex: none; display: grid; place-items: center;
  background: var(--surface); color: var(--texte-doux); box-shadow: inset 0 0 0 1px var(--ligne);
  transition: transform 0.18s var(--sortie), background 0.2s, color 0.2s, opacity 0.2s;
}
.bouton-photo svg { width: 24px; height: 24px; }
.bouton-photo:active { transform: scale(0.93); background: var(--surface-2); color: var(--texte); }
.bouton-photo:disabled { opacity: 0.4; }
/* photos jointes, au-dessus de la saisie */
.vignettes { display: flex; gap: 8px; margin: 0 0 10px; }
.vignette {
  position: relative; width: 68px; height: 68px; border-radius: 12px; overflow: visible;
  animation: arrivee 0.32s var(--sortie) both;
}
.vignette img {
  width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--ligne-forte); background: var(--surface);
}
.vignette-retirer {
  position: absolute; top: -7px; right: -7px; width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--texte); box-shadow: 0 0 0 2px var(--fond), inset 0 0 0 1px var(--ligne-forte);
}
.vignette-retirer::before { content: ""; position: absolute; inset: -9px; }   /* cible tactile de 44 px */
.vignette-retirer svg { width: 12px; height: 12px; }

/* ================================================================ appairage */
.appairage {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--haut-sur) + 24px) var(--marge) calc(var(--bas-sur) + 24px); max-width: 440px; margin: 0 auto;
}
.visage-appairage { width: 168px; height: 168px; margin: 0 0 8px -14px; }
.appairage h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.025em; }
.appairage-aide { margin: 10px 0 28px; color: var(--texte-doux); }
.appairage-form { display: grid; gap: 8px; }
.appairage-form label { font-size: 14px; color: var(--texte-doux); }
.appairage-form input {
  width: 100%; height: 60px; padding: 0 16px; border: 0; border-radius: var(--rayon); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ligne-forte); color: var(--texte);
  font: 500 24px/1 "Geist Mono", ui-monospace, monospace; letter-spacing: 0.32em; text-transform: uppercase;
}
.appairage-form input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent); }
.appairage-msg { min-height: 22px; margin: 0; font-size: 14px; color: var(--texte-doux); }
.appairage-msg.ko { color: #f0b4a8; }
.bouton-principal {
  height: 54px; border-radius: 999px; background: var(--accent); color: var(--accent-encre); font-weight: 600; font-size: 16px;
  transition: transform 0.15s var(--sortie), opacity 0.2s; margin-top: 6px;
}
.bouton-principal:active { transform: scale(0.98); }
.bouton-principal:disabled { opacity: 0.55; }

/* ================================================================ mouvement */
@keyframes arrivee { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes reflet { to { background-position: -150% 0; } }
@keyframes ecoute { 0% { transform: scale(0.92); opacity: 1; } 100% { transform: scale(1.22); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* écrans plus grands (tablette, PC) : la colonne reste à une largeur de lecture */
@media (min-width: 640px) {
  .appli { max-width: 560px; margin: 0 auto; }
  .scene { position: absolute; }
}

/* ------------------------------------------------------------------ verrou vocal (24/11/2026) */
.verrou {
  display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding: 10px 14px; border-radius: var(--rayon);
  font-size: 14px; line-height: 20px; color: var(--texte-doux); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ligne-forte); animation: arrivee 0.3s var(--sortie) both;
}
.verrou[hidden] { display: none; }
.verrou svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
