/*
  Hub candidat - binome flottant (tranche 4.3). Panneau chat Giancarlo AI (bord gauche)
  et capsule LinkedIn (bord droit). Charge APRES styles.css : reutilise ses tokens/vars
  (--hub-*, --space-*, --font-sans, --content-max...). Regles reprises de
  design/v2-mockups/assets/hub-float.css et hub-candidate.css, plus ajouts sobres pour
  le fil live (message utilisateur, message neutre, ligne de chargement, compteur,
  bouton reessayer). Aucun code visuel de type messagerie (ni pulse ni onde).
*/

/* ============================================================
   Nom Giancarlo AI dans l'en-tete du chat (miroir 11deg, fidelite maquette)
   ============================================================ */
.giancarlo-ai-name {
  margin: 0;
  color: var(--hub-ink);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}

/* E-274 C. SEULE RETOUCHE DE CETTE FEUILLE, ET ELLE EST DUE A UNE MESURE.
   Le nom fait 1.05rem, soit 16.8px : sous les 18.66px gras du seuil "grand
   texte", c est donc du texte courant au sens AA. Sur --hub-band (#f2f5f3
   depuis E-274 C), --hub-terracotta #c55c3d ne rend que 3.85:1. --accent-text
   y rend 4.81:1. Le reste de chat.css suit les jetons sans etre touche. */
.giancarlo-ai-name__inner,
.giancarlo-ai-name__final {
  display: inline-block;
  color: var(--accent-text);
  transform-origin: center;
}

.giancarlo-ai-name__inner {
  transform: skewX(11deg);
}

.giancarlo-ai-name__final {
  transform: skewX(-11deg);
}

.giancarlo-chat__status {
  margin: 0.2rem 0 0;
  color: var(--hub-muted);
  font-size: 0.76rem;
}

/* ============================================================
   Layout hub avec binome flottant
   ============================================================ */
.hub-float-page .hub-main > .shell {
  width: auto;
  max-width: var(--content-max);
  margin-left: 26rem;
  margin-right: 7rem;
}

/* ============================================================
   Panneau chat (portique miroir, bord gauche mi-hauteur, fixe)
   ============================================================ */
.float-chat-shell {
  position: fixed;
  top: 50%;
  left: 0;
  z-index: 30;
  width: 23.75rem;
  transform: translateY(-50%);
}

.float-chat {
  position: relative;
  overflow: hidden;
  padding: 1px 1px 1px 0;
  border: 0;
  background: var(--hub-petrol);
  box-shadow: 0 0.75rem 2rem rgb(16 47 53 / 8%);
  clip-path: polygon(0 0, calc(100% - 1.35rem) 0, 100% 1.35rem, 100% 100%, 1.35rem 100%, 0 calc(100% - 1.35rem));
}

.float-chat > summary {
  cursor: pointer;
  list-style: none;
}

.float-chat > summary::-webkit-details-marker {
  display: none;
}

.float-chat[open] > summary {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 2;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--hub-line);
  background: var(--hub-paper);
  color: var(--hub-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.float-chat[open] > summary img,
.float-chat[open] .float-chat__open {
  display: none;
}

.float-chat__reduce {
  display: inline;
}

.float-chat:not([open]) {
  width: 4.4rem;
  height: 4.4rem;
  padding: 1px 1px 1px 0;
  clip-path: polygon(0 0, calc(100% - 0.72rem) 0, 100% 0.72rem, 100% 100%, 0.72rem 100%, 0 calc(100% - 0.72rem));
}

.float-chat:not([open]) > summary {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  background: var(--hub-paper);
  clip-path: polygon(0 0, calc(100% - 0.68rem) 0, 100% 0.68rem, 100% 100%, 0.68rem 100%, 0 calc(100% - 0.68rem));
}

.float-chat:not([open]) > summary img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: polygon(0 0, calc(100% - 0.65rem) 0, 100% 0.65rem, 100% 100%, 0.65rem 100%, 0 calc(100% - 0.65rem));
}

.float-chat:not([open]) .float-chat__reduce,
.float-chat:not([open]) .float-chat__open {
  display: none;
}

/*
  Le panneau est une colonne flex bornee en hauteur ; SEULE la zone conversation defile
  (min-height:0 + overflow-y:auto), de sorte que la derniere reponse reste toujours visible
  et que l'en-tete, les suggestions et le compositeur restent ancres.
*/
.float-chat__panel {
  display: flex;
  flex-direction: column;
  max-height: 82vh;
  min-height: 0;
  background: var(--hub-paper);
  clip-path: polygon(0 0, calc(100% - 1.3rem) 0, 100% 1.3rem, 100% 100%, 1.3rem 100%, 0 calc(100% - 1.3rem));
}

.float-chat__header,
.float-chat__suggestions,
.float-chat__composer,
.float-chat__counter {
  flex: 0 0 auto;
}

.float-chat__header {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 1rem 4.5rem 1rem 1rem;
  border-bottom: 1px solid var(--hub-line);
  background: var(--hub-band);
}

.float-chat__avatar {
  width: 3.5rem;
  height: 3.5rem;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--hub-terracotta);
  border-radius: 50%;
}

.float-chat__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.float-chat__conversation {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem;
  background: var(--hub-chip);
}

.float-chat__conversation > * + * {
  margin-top: 0.75rem;
}

.float-chat__message {
  padding: 1rem;
  border-left: 3px solid var(--hub-terracotta);
  background: var(--hub-paper);
  color: var(--hub-ink);
  font-size: 1.08rem;
  line-height: 1.58;
}

.float-chat__message p {
  margin: 0;
}

.float-chat__message p + p {
  margin-top: 0.75rem;
}

/* Ajouts sobres : message utilisateur (aligne a droite), message neutre, chargement */
.float-chat__message--user {
  max-width: 85%;
  margin-left: auto;
  border-left: 0;
  border-right: 3px solid var(--hub-petrol);
  background: var(--hub-chat-user);
  font-size: 1rem;
}

.float-chat__message--neutral {
  border-left-color: var(--hub-muted);
  color: var(--hub-muted);
  font-size: 1rem;
}

.float-chat__loading {
  margin: 0;
  color: var(--hub-muted);
  font-size: 0.86rem;
}

.float-chat__retry {
  margin-top: 0.6rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--hub-petrol);
  background: var(--hub-paper);
  color: var(--hub-petrol);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.float-chat__retry:hover {
  border-color: var(--hub-petrol-deep);
}

.float-chat__suggestions {
  display: grid;
  gap: 0.55rem;
  padding: 0 1.25rem 1.25rem;
  background: var(--hub-chip);
}

.float-chat__suggestions[hidden] {
  display: none;
}

.float-chat__suggestions button {
  padding: 0.78rem 0.85rem;
  border: 1px solid rgb(24 63 70 / 48%);
  background: var(--hub-paper);
  color: var(--hub-petrol);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.float-chat__suggestions button:hover {
  border-color: var(--hub-petrol);
}

.float-chat__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0;
  padding: 0.85rem;
  border-top: 1px solid var(--hub-line);
}

.float-chat__composer input {
  min-width: 0;
  padding: 0.5rem 0;
  border: 0;
  border-bottom: 1px solid var(--hub-line);
  background: transparent;
  color: var(--hub-ink);
  transition: padding 160ms ease, border-color 160ms ease;
}

.float-chat__composer input:disabled {
  opacity: 0.55;
}

.float-chat__composer .button {
  width: 0;
  min-width: 0;
  padding-inline: 0;
  overflow: hidden;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
  transition: width 160ms ease, padding 160ms ease, opacity 160ms ease;
}

.float-chat__composer:focus-within {
  gap: 0.55rem;
}

.float-chat__composer:focus-within input,
.float-chat__composer.is-active input {
  padding: 0.72rem 0.8rem;
  border: 1px solid var(--hub-petrol);
  background: white;
}

.float-chat__composer:focus-within .button,
.float-chat__composer.is-active .button {
  width: auto;
  padding-inline: 0.9rem;
  border-width: 1px;
  opacity: 1;
  pointer-events: auto;
}

.float-chat__composer .button:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.float-chat__counter {
  margin: 0;
  padding: 0 0.85rem 0.6rem;
  color: var(--hub-muted);
  font-size: 0.7rem;
  text-align: right;
}

/* ============================================================
   Capsule LinkedIn (bord droit mi-hauteur, fixe)
   ============================================================ */
/* Accessibilite : focus clavier visible sur les elements interactifs du binome. */
.float-chat > summary:focus-visible,
.float-chat__suggestions button:focus-visible,
.float-chat__retry:focus-visible,
.float-human:focus-visible {
  outline: 2px solid var(--hub-petrol);
  outline-offset: 2px;
}

.founder-contact {
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 20;
  transform: translateY(-50%);
}

.float-human {
  display: block;
  padding: 1px 0 1px 1px;
  border: 0;
  border-radius: 0;
  background: var(--hub-petrol);
  text-decoration: none;
  clip-path: polygon(1rem 0, 100% 0, 100% 100%, 0 100%, 0 1rem);
}

.float-human > .float-human__inner {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  max-width: none;
  width: auto;
  height: auto;
  padding: 0.35rem 1rem 0.35rem 0.35rem;
  overflow: visible;
  background: var(--hub-paper);
  color: var(--hub-petrol-deep);
  opacity: 1;
  white-space: normal;
  clip: auto;
  clip-path: polygon(0.95rem 0, 100% 0, 100% 100%, 0 100%, 0 0.95rem);
}

.float-human__inner img {
  width: 4rem;
  height: 4rem;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.float-human .float-human__label {
  position: static;
  width: auto;
  height: auto;
  max-width: 8rem;
  overflow: visible;
  opacity: 1;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
  clip: auto;
}

/* ============================================================
   Responsive (repris de hub-float.css)
   ============================================================ */
@media (max-width: 1680px) and (min-width: 1361px) {
  .float-human > .float-human__inner {
    gap: 0;
    padding-right: 0.35rem;
  }

  .float-human .float-human__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .float-human:hover > .float-human__inner,
  .float-human:focus-visible > .float-human__inner {
    gap: 0.8rem;
    padding-right: 1rem;
  }

  .float-human:hover .float-human__label,
  .float-human:focus-visible .float-human__label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    opacity: 1;
    clip: auto;
    white-space: normal;
  }
}

@media (max-width: 1360px) {
  .hub-float-page .hub-main {
    padding-bottom: 18rem;
  }

  .hub-float-page .hub-main > .shell {
    width: calc(100% - 3rem);
    max-width: var(--content-max);
    margin-inline: auto;
  }

  .float-chat-shell {
    top: auto;
    right: 0;
    bottom: 0;
    width: 100%;
    transform: none;
  }

  /*
    Sous 1360px la page prime : le panneau ouvert est plafonne a ~45vh pour ne jamais
    masquer le contenu de facon irrecuperable (et il demarre replie par defaut, cf. app.js).
  */
  .float-chat[open] {
    width: 100%;
    max-height: 45vh;
  }

  .float-chat__panel {
    max-height: 45vh;
  }

  .float-chat:not([open]) {
    width: calc(100% - 2rem);
    height: 3.75rem;
    margin: 0 1rem 0.75rem;
    border: 0;
    border-radius: 0;
    clip-path: polygon(0 0, calc(100% - 0.8rem) 0, 100% 0.8rem, 100% 100%, 0.8rem 100%, 0 calc(100% - 0.8rem));
  }

  .float-chat:not([open]) > summary {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-start;
    align-items: center;
    padding: 0.35rem;
    background: var(--hub-paper);
    clip-path: polygon(0 0, calc(100% - 0.75rem) 0, 100% 0.75rem, 100% 100%, 0.75rem 100%, 0 calc(100% - 0.75rem));
  }

  .float-chat:not([open]) > summary img {
    width: 3rem;
    height: 3rem;
  }

  .float-chat:not([open]) .float-chat__open {
    display: inline;
    color: var(--hub-petrol-deep);
    font-size: 0.82rem;
    font-weight: 700;
  }

  .float-human {
    padding: 1px 0 1px 1px;
  }

  .float-human > .float-human__inner {
    gap: 0;
    padding: 0.3rem;
  }

  .float-human .float-human__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .hub-float-page .hub-main > .shell {
    width: calc(100% - 2rem);
  }

  .float-chat__header {
    padding-right: 4rem;
  }

  .float-chat__message {
    font-size: 1rem;
  }

  .float-chat__composer {
    grid-template-columns: 1fr;
  }

  .float-chat__composer:focus-within .button,
  .float-chat__composer.is-active .button {
    width: auto;
    justify-self: start;
  }
}

/* ============================================================
   E-133. TELEPHONE : LE PANNEAU OUVERT PREND L ECRAN.
   ============================================================
   Sous 1360px le panneau ouvert etait plafonne a 45vh, c est-a-dire la moitie
   basse d un iPhone : l en-tete et les quatre suggestions empilees mangeaient
   cette moitie, le message d accueil n avait plus que deux lignes, et le champ
   de saisie tombait hors de l ecran. On ne pouvait plus ecrire librement.
   Ce bloc ne s applique QUE sous 640px et ne s appuie QUE sur l etat natif du
   <details> ([open]) : aucune classe d etat nouvelle sur le panneau, aucune
   regle hors de cette media query, donc AUCUN effet au-dessus de 640px.
   Les suggestions passent en CHIPS DEFILANTES HORIZONTALEMENT plutot que
   derriere un bouton "Suggestions" : une seule ligne au lieu de quatre (donc
   sous le plafond de deux lignes), les quatre restent atteignables d un
   glissement, et cela ne demande NI markup nouveau NI second etat a tenir.
   Aucune animation nouvelle, aucun jeton de couleur nouveau. */
@media (max-width: 640px) {
  /* a. Plein ecran, fond papier opaque, au-dessus du hub et de la capsule
        LinkedIn (z-index 20) et du shell (30). 100dvh avec repli 100vh. */
  .float-chat[open] {
    position: fixed;
    inset: 0;
    z-index: 60;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    padding: 0;
    background: var(--hub-paper);
    clip-path: none;
  }

  .float-chat[open] .float-chat__panel {
    height: 100%;
    max-height: none;
    clip-path: none;
  }

  /* Le hub derriere ne defile plus. La classe est posee sur <body> par app.js a
     chaque bascule du <details> ; elle n est ciblee QUE dans cette media query,
     donc elle est inerte sur bureau. */
  body.chat-fullscreen {
    overflow: hidden;
  }

  /* b. En-tete compact sur une ligne : avatar reduit, nom, bouton Reduire.
        Le sous-titre disparait, il ne porte aucune information d action. */
  .float-chat[open] .float-chat__header {
    gap: 0.6rem;
    padding: 0.6rem 4.5rem 0.6rem 0.9rem;
  }

  .float-chat[open] .float-chat__avatar {
    width: 2.25rem;
    height: 2.25rem;
  }

  .float-chat[open] .giancarlo-ai-name {
    font-size: 0.95rem;
  }

  .float-chat[open] .giancarlo-chat__status {
    display: none;
  }

  .float-chat[open] > summary {
    top: 0.6rem;
    right: 0.6rem;
  }

  /* c. La conversation prend tout l espace restant et defile seule. */
  .float-chat[open] .float-chat__conversation {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* d. Suggestions : une seule ligne de chips defilantes horizontalement. */
  .float-chat[open] .float-chat__suggestions {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .float-chat[open] .float-chat__suggestions::-webkit-scrollbar {
    display: none;
  }

  .float-chat[open] .float-chat__suggestions button {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* e. Champ et bouton d envoi ancres en bas, sur une seule ligne, au-dessus de
        la zone systeme (encoche / barre de geste). */
  .float-chat[open] .float-chat__composer {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0.7rem 1rem 0.5rem;
    background: var(--hub-paper);
  }

  .float-chat[open] .float-chat__counter {
    padding: 0 1rem calc(0.5rem + env(safe-area-inset-bottom));
    background: var(--hub-paper);
  }
}
