/* ================================================================
   BÉBÉ COMPAGNON — surcouche de bienvenue
   ================================================================
   Conteneur dédié, indépendant de #onb-modal.

   ── AUTONOMIE CSS ────────────────────────────────────────────────
   Le compagnon n'emprunte PLUS les classes .onb-* de styles.css. Il
   définit les siennes (.cpn-choice, .cpn-cta). Raison : le lot 2
   demande l'inverse de ce que font les classes de base (choix en blocs
   ombrés au lieu de champs à filet, sélection en CONTOUR jaune au lieu
   d'aplat plein, CTA en dégradé au lieu d'aplat bleu), et on ne peut
   pas les modifier — l'ancien onboarding les utilise encore (22 usages
   dans js/onboarding.js). Les surcharger pour les annuler serait de la
   dette à payer à chaque retouche. styles.css:2030-2210 part de toute
   façon à l'étape 6 avec C1/C2/C3.

   ── DEUX ÉTATS ───────────────────────────────────────────────────
   A — .cpn-mode-a : fond dégradé plein, texte blanc, blocs blancs
       flottants, jaune pour pastille / progression / bouton.
       Quand le compagnon PARLE sans rien attendre : accueil, clôture.
       Pas de contour distinct : l'objet entier EST la signature, un
       liseré ajouterait un second langage visuel. L'ombre portée
       suffit à détacher la carte.
   B — défaut : fond blanc, contour dégradé épais, titre en dégradé,
       pastille, progression, choix en blocs.
       Quand l'utilisateur doit AGIR. La carte guide y est aussi :
       elle explique, mais fait cinq lignes — c'est la longueur qui
       tranche, pas le rôle.

   GRAMMAIRE CHROMATIQUE — aucune teinte inventée :
     • émeraude #059669  → .pl2-cta--primary (Planning)
     • bleu     #144393  → .onb-cta-btn (auth/onboarding)
     • jaune    #F9BD09  → .onb-choice-btn.selected
   ================================================================ */

#companion-sheet {
  --cpn-emerald:     #059669;
  --cpn-blue:        #144393;
  --cpn-yellow:      #F9BD09;
  --cpn-bg:          #FFFFFF;
  --cpn-grad:        linear-gradient(135deg, #059669 0%, #144393 100%);

  --cpn-fs-title:    32px;
  --cpn-fs-subtitle: 16px;
  --cpn-fs-body:     18px;
  --cpn-fs-action:   18px;
  --cpn-lh:          1.55;

  --cpn-margin:      16px;
  --cpn-anim:        180ms;
}

/* ── Voile ─────────────────────────────────────────────────────── */
#companion-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .32s ease;
}
#companion-overlay.open { opacity: 1; pointer-events: auto; }

/* ── Cadre flottant ────────────────────────────────────────────────
   Marges sur les quatre côtés, contour fermé. Ce n'est pas une
   bottom-sheet : le vocabulaire « sheet » est celui du système, un
   cadre fermé se lit comme un objet distinct qui s'adresse à
   l'utilisateur.

   Technique double-background : `border-image` est incompatible avec
   border-radius, donc fond en padding-box + dégradé en border-box sur
   une bordure transparente. Supporté iOS Safari 15+.

   `top`, `height` et `max-height` sont posés en JS : ni vh ni dvh ne se
   réduisent à l'ouverture du clavier (cf. _cpnFitToViewport). `top` et
   `height` sont dans la transition pour que le cadre s'anime au lieu de
   sauter quand le contenu change de taille — ils sont écrits ENSEMBLE,
   avec la même durée, donc ils interpolent de concert. */
#companion-sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 201;
  width: calc(100% - (var(--cpn-margin) * 2));
  max-width: 460px;
  display: flex;
  flex-direction: column;
  border: 5px solid transparent;
  border-radius: 26px;
  background:
    linear-gradient(var(--cpn-bg), var(--cpn-bg)) padding-box,
    var(--cpn-grad) border-box;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .34), 0 4px 14px rgba(0, 0, 0, .18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) scale(.96);
  transition: opacity .26s ease,
              transform .3s cubic-bezier(.32, .72, 0, 1),
              top var(--cpn-anim) cubic-bezier(.4, 0, .2, 1),
              height var(--cpn-anim) cubic-bezier(.4, 0, .2, 1);
  font-family: Nunito, sans-serif;
  overflow: hidden;
}
#companion-sheet.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

/* ── MODE A — dégradé plein ────────────────────────────────────────
   Une seule couche en border-box : le dégradé traverse la bordure ET
   le fond sans couture, donc plus aucun contour distinct, sans le
   moindre décalage de mise en page (la bordure reste 5px transparente). */
#companion-sheet.cpn-mode-a {
  background: var(--cpn-grad) border-box;
}
/* Entrée d'une carte de mode A : la carte monte en s'ouvrant. Latéral =
   on avance dans la série ; vertical + expansion = on change de
   registre. */
@keyframes cpn-rise {
  from { transform: translateX(-50%) translateY(14px) scale(.97); opacity: .4; }
  to   { transform: translateX(-50%) translateY(0)    scale(1);   opacity: 1; }
}
#companion-sheet.cpn-rising {
  animation: cpn-rise 280ms cubic-bezier(.32, .72, 0, 1) both;
}

/* ── Barre de progression en segments ──────────────────────────────
   Vue dérivée du registre, calculée au rendu. Rien n'est persisté :
   aucun compteur d'étape ne revient dans la logique. */
.cpn-progress {
  display: flex;
  gap: 5px;
  padding: 0 22px 2px;
  flex-shrink: 0;
}
.cpn-progress-seg {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(20, 67, 147, .12);
  overflow: hidden;
}
.cpn-progress-seg > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--cpn-emerald);
  transition: width var(--cpn-anim) cubic-bezier(.4, 0, .2, 1);
}
.cpn-mode-a .cpn-progress-seg { background: rgba(255, 255, 255, .26); }
.cpn-mode-a .cpn-progress-seg > i { background: var(--cpn-yellow); }

/* ── Header : retour à gauche, « Fermer » à droite ─────────────────
   Remontés hors de la zone du pouce. */
.cpn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 8px;
  flex-shrink: 0;
  min-height: 40px;
}
.cpn-back-btn,
.cpn-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: Nunito, sans-serif;
  color: var(--t2, #6B7280);
}
.cpn-back-btn { padding: 6px 4px; margin-left: -4px; display: flex; align-items: center; }
.cpn-close-btn { padding: 8px 6px; font-size: 15px; font-weight: 700; }
.cpn-back-btn[hidden] { display: none; }
.cpn-back-btn[hidden] + .cpn-close-btn { margin-left: auto; }
.cpn-back-btn:hover, .cpn-close-btn:hover { color: var(--text, #1A1A2E); }
.cpn-back-btn:focus-visible, .cpn-close-btn:focus-visible {
  outline: 3px solid var(--cpn-blue); outline-offset: 2px; border-radius: 6px;
}
.cpn-mode-a .cpn-back-btn,
.cpn-mode-a .cpn-close-btn { color: rgba(255, 255, 255, .82); }
.cpn-mode-a .cpn-back-btn:hover,
.cpn-mode-a .cpn-close-btn:hover { color: #FFF; }
.cpn-mode-a .cpn-back-btn:focus-visible,
.cpn-mode-a .cpn-close-btn:focus-visible { outline-color: #FFF; }

/* ── Corps ─────────────────────────────────────────────────────── */
.cpn-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
#companion-body { padding: 4px 22px 22px; }

.cpn-card { display: flex; flex-direction: column; gap: 14px; }
.cpn-sub  { display: flex; flex-direction: column; gap: 14px; }

/* Transition de contenu : c'est le CONTENU qui bouge, pas le cadre.
   Le cadre reste posé — c'est la présence du compagnon — pendant que
   ce qu'il dit change. */
.cpn-card, .cpn-sub {
  transition: opacity 90ms ease, transform 90ms ease;
}
.cpn-leaving-fwd  { opacity: 0; transform: translateX(-14px); }
.cpn-leaving-back { opacity: 0; transform: translateX(14px); }
.cpn-entering-fwd  { opacity: 0; transform: translateX(14px); }
.cpn-entering-back { opacity: 0; transform: translateX(-14px); }

/* ── Pastille + étiquette de section ───────────────────────────────
   Marque du compagnon, constante sur toutes les cartes. Pastille et
   étiquette sur une même ligne : ça lit comme un en-tête et ça
   économise de la hauteur — ce qui compte quand le clavier réduit la
   zone visible. */
.cpn-badge-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 2px;
}
.cpn-badge {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cpn-grad);
  color: #FFF;
  box-shadow: 0 4px 12px rgba(5, 150, 105, .3);
}
.cpn-mode-a .cpn-badge {
  background: var(--cpn-yellow);
  color: var(--cpn-blue);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.cpn-eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--t3, #9CA3AF);
}
.cpn-mode-a .cpn-eyebrow { color: rgba(255, 255, 255, .78); }

/* ── Titres et textes ──────────────────────────────────────────── */
.cpn-title {
  margin: 0;
  font-size: var(--cpn-fs-title);
  font-weight: 800;
  line-height: 1.2;
  color: var(--text, #1A1A2E);
  letter-spacing: -.6px;
}
/* Dégradé sur les TITRES uniquement ; le corps reste en couleur pleine.
   Sous @supports : sans ce garde-fou, un navigateur sans
   background-clip:text rendrait le titre transparent, donc invisible.
   Le padding compense le rognage des jambages (p, g, j). */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  #companion-sheet:not(.cpn-mode-a) .cpn-title {
    background-image: var(--cpn-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    padding-bottom: 2px;
    margin-bottom: -2px;
  }
}
.cpn-mode-a .cpn-title { color: #FFF; }

.cpn-subtitle {
  margin: 0;
  font-size: var(--cpn-fs-subtitle);
  font-weight: 500;
  line-height: var(--cpn-lh);
  color: var(--t2, #6B7280);
}
.cpn-mode-a .cpn-subtitle { color: rgba(255, 255, 255, .9); font-size: 18px; }

/* ── Blocs d'information ───────────────────────────────────────── */
.cpn-info {
  margin: 2px 0 0;
  padding: 16px 18px;
  border-left: 4px solid var(--cpn-blue);
  border-radius: 0 12px 12px 0;
  background: #F5F8FF;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text, #1A1A2E);
}
.cpn-inline-info {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--cpn-blue);
  border-radius: 0 10px 10px 0;
  background: #F5F8FF;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text, #1A1A2E);
}
/* Blocs blancs flottants sur le fond dégradé (mode A) */
.cpn-mode-a .cpn-info {
  background: rgba(255, 255, 255, .96);
  border-left-color: var(--cpn-yellow);
}

/* ── Choix — blocs posés, pas des champs à filet ──────────────────
   Sélection = contour jaune + coche + ombre colorée. Surtout PAS
   d'aplat jaune plein : le bloc reste blanc, l'accent le désigne. */
.cpn-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 2px; }
.cpn-choice {
  position: relative;
  width: 100%;
  min-height: 58px;
  padding: 16px 46px 16px 18px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: #FFF;
  box-shadow: 0 2px 8px rgba(20, 67, 147, .08), 0 0 0 1px rgba(20, 67, 147, .06);
  color: var(--text, #1A1A2E);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: box-shadow .16s ease, border-color .16s ease, transform .1s ease;
}
.cpn-choice:hover { box-shadow: 0 4px 14px rgba(20, 67, 147, .14); }
.cpn-choice:active { transform: scale(.985); }
.cpn-choice:focus-visible { outline: 3px solid var(--cpn-blue); outline-offset: 2px; }
.cpn-choice.selected {
  border-color: var(--cpn-yellow);
  box-shadow: 0 6px 18px rgba(249, 189, 9, .34), 0 0 0 1px rgba(249, 189, 9, .5);
}
/* Coche : révélée à la sélection */
.cpn-choice-check {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%) scale(.6);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--cpn-yellow);
  color: var(--cpn-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .16s ease, transform .16s cubic-bezier(.32, .72, 0, 1);
}
.cpn-choice.selected .cpn-choice-check { opacity: 1; transform: translateY(-50%) scale(1); }

/* ── Cases légales (guide) — rangée cliquable ──────────────────────
   Réutilise le vocabulaire des choix : bloc blanc ombré, coche jaune à
   l'état coché. La vraie <input> est masquée, la case dessinée suit. */
.cpn-check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: #FFF;
  box-shadow: 0 2px 8px rgba(20, 67, 147, .08), 0 0 0 1px rgba(20, 67, 147, .06);
  cursor: pointer;
  transition: box-shadow .16s ease, border-color .16s ease;
}
.cpn-check-row:has(.cpn-check:checked) {
  border-color: var(--cpn-yellow);
  box-shadow: 0 6px 18px rgba(249, 189, 9, .3), 0 0 0 1px rgba(249, 189, 9, .5);
}
.cpn-check { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cpn-check-box {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border-radius: 8px;
  border: 2px solid var(--border2, #D0D4E0);
  background: #FFF;
  color: var(--cpn-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.cpn-check-box > svg { opacity: 0; transform: scale(.6); transition: opacity .16s ease, transform .16s ease; }
.cpn-check:checked + .cpn-check-box {
  background: var(--cpn-yellow);
  border-color: var(--cpn-yellow);
}
.cpn-check:checked + .cpn-check-box > svg { opacity: 1; transform: scale(1); }
.cpn-check:focus-visible + .cpn-check-box { outline: 3px solid var(--cpn-blue); outline-offset: 2px; }
.cpn-check-label {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text, #1A1A2E);
}

/* Carte lien guide — saisie du code de l'apprenti (état non lié) */
.cpn-linkrow {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 2px;
}
/* Spécificité descendante (0,2,0) : bat .cpn-input / .cpn-cta (0,1,0)
   qui posent width:100%, quel que soit l'ordre des règles — sinon le
   bouton prend toute la largeur et écrase le champ. */
.cpn-linkrow .cpn-linkinput {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: 800;
  text-align: center;
}
.cpn-linkrow .cpn-linkbtn {
  flex: 0 0 auto;
  width: auto;
  min-height: 0;
  padding: 0 22px;
}
.cpn-linkrow .cpn-linkbtn[disabled] { opacity: .5; cursor: default; }
/* Repli discret : « tu ne l'as pas ? voici ton code » */
.cpn-linkfallback {
  margin: 14px 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--t2, #6B7280);
}
.cpn-code-inline {
  background: none;
  border: none;
  padding: 2px 4px;
  font-family: Nunito, sans-serif;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--cpn-blue);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Bloc « code à transmettre » (carte lien guide) */
.cpn-code {
  margin: 4px 0 0;
  padding: 20px;
  border-radius: 16px;
  background: #F5F8FF;
  text-align: center;
}
.cpn-code-value {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--cpn-blue);
  font-family: Nunito, sans-serif;
}
.cpn-code-copy {
  margin-top: 14px;
  padding: 12px 22px;
  border: 2px solid var(--cpn-blue);
  border-radius: 12px;
  background: #FFF;
  color: var(--cpn-blue);
  font-family: Nunito, sans-serif;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.cpn-code-copy:active { transform: scale(.97); }
.cpn-linked-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--cpn-emerald);
}

/* ── Champs texte ──────────────────────────────────────────────── */
.cpn-input {
  width: 100%;
  box-sizing: border-box;
  padding: 16px 18px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: #FFF;
  box-shadow: 0 2px 8px rgba(20, 67, 147, .08), 0 0 0 1px rgba(20, 67, 147, .08);
  font-family: Nunito, sans-serif;
  font-size: var(--cpn-fs-body);
  font-weight: 700;
  color: var(--text, #1A1A2E);
}
.cpn-input:focus {
  outline: none;
  border-color: var(--cpn-blue);
  box-shadow: 0 4px 14px rgba(20, 67, 147, .16);
}

/* ── Date en 3 champs JJ / MM / AAAA ───────────────────────────────
   Pas de <select> : saisie numérique, passage auto au champ suivant. */
.cpn-date-row { display: flex; align-items: center; gap: 10px; }
.cpn-date-field { display: flex; flex-direction: column; gap: 6px; }
.cpn-date-field--dd, .cpn-date-field--mm { width: 74px; }
.cpn-date-field--yyyy { width: 106px; }
.cpn-date-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .8px;
  color: var(--t3, #9CA3AF);
  text-transform: uppercase;
}
.cpn-date-input {
  width: 100%;
  box-sizing: border-box;
  padding: 15px 8px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: #FFF;
  box-shadow: 0 2px 8px rgba(20, 67, 147, .08), 0 0 0 1px rgba(20, 67, 147, .08);
  font-family: Nunito, sans-serif;
  font-size: 21px;
  font-weight: 800;
  text-align: center;
  color: var(--text, #1A1A2E);
  -moz-appearance: textfield;
}
.cpn-date-input::-webkit-outer-spin-button,
.cpn-date-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cpn-date-input:focus {
  outline: none;
  border-color: var(--cpn-blue);
  box-shadow: 0 4px 14px rgba(20, 67, 147, .16);
}

/* ── Erreur ────────────────────────────────────────────────────── */
.cpn-err {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--red, #DC2626);
}
.cpn-err:empty { display: none; }

/* ── Cartes de mode A : centrées, texte court ──────────────────── */
.cpn-speak {
  align-items: center;
  text-align: center;
  padding: 14px 0 6px;
  gap: 16px;
}
.cpn-speak .cpn-badge-row { flex-direction: column; gap: 14px; margin-bottom: 0; }
.cpn-speak .cpn-badge { width: 66px; height: 66px; }

/* ── Footer ────────────────────────────────────────────────────── */
.cpn-footer {
  flex-shrink: 0;
  padding: 14px 22px 18px;
  border-top: 1px solid rgba(0, 0, 0, .07);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cpn-mode-a .cpn-footer { border-top-color: rgba(255, 255, 255, .18); }

.cpn-cta {
  width: 100%;
  min-height: 56px;
  padding: 17px 18px;
  border: none;
  border-radius: 16px;
  background: var(--cpn-grad);
  color: #FFF;
  box-shadow: 0 8px 22px rgba(20, 67, 147, .32);
  font-family: inherit;
  font-size: var(--cpn-fs-action);
  font-weight: 800;
  cursor: pointer;
  transition: box-shadow .16s ease, transform .1s ease, opacity .16s ease;
}
.cpn-cta:active { transform: scale(.985); }
.cpn-cta:focus-visible { outline: 3px solid var(--cpn-blue); outline-offset: 3px; }
.cpn-cta[disabled] { opacity: .38; cursor: not-allowed; pointer-events: none; box-shadow: none; }
/* En mode A, le bouton passe au jaune : c'est l'accent du fond dégradé. */
.cpn-mode-a .cpn-cta {
  background: var(--cpn-yellow);
  color: var(--cpn-blue);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .22);
}
.cpn-mode-a .cpn-cta:focus-visible { outline-color: #FFF; }

.cpn-cta-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--t2, #6B7280);
}
.cpn-cta-hint[hidden] { display: none; }

.cpn-skip-btn {
  background: none;
  border: none;
  padding: 12px 2px 4px;
  font-family: Nunito, sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--t2, #6B7280);
  cursor: pointer;
}
.cpn-skip-btn:hover { color: var(--text, #1A1A2E); }
.cpn-skip-btn:focus-visible { outline: 3px solid var(--cpn-blue); outline-offset: 2px; border-radius: 6px; }
.cpn-skip-btn[hidden] { display: none; }
.cpn-mode-a .cpn-skip-btn { color: rgba(255, 255, 255, .8); }

/* ── Chrome de l'app pendant le compagnon ──────────────────────────
   Classe DÉDIÉE : surtout pas body.in-onboarding, pilotée par l'ancien
   flow et porteuse d'autres effets. */
body.in-companion #v2-bottom-nav { display: none !important; }

/* ── Mouvement réduit ──────────────────────────────────────────────
   Repli instantané : plus aucune transition ni animation, et le
   repositionnement clavier redevient synchrone. */
@media (prefers-reduced-motion: reduce) {
  #companion-sheet,
  #companion-overlay,
  .cpn-card, .cpn-sub,
  .cpn-progress-seg > i,
  .cpn-choice, .cpn-choice-check, .cpn-cta {
    transition: none !important;
    animation: none !important;
  }
}
