/* ===== IDTrax — Composants du tunnel d'inscription =====
 *
 * Se charge APRÈS styles.css, uniquement sur /inscription.
 *
 * L'échelle typographique, les espacements et les couleurs de la refonte v2
 * vivent dans styles.css (jetons --t-*, --sp-*, --stroke) : source unique pour
 * tout le site. Ce fichier n'apporte plus que les composants propres au tunnel.
 */

/* Titres du tunnel, alignés sur l'échelle globale */
.v2 h1 { font-size: var(--t-h1); line-height: 1.03; letter-spacing: -.03em; }
.v2 h2 { font-size: var(--t-h2); line-height: 1.08; letter-spacing: -.025em; }
.v2 h3 { font-size: var(--t-h3); line-height: 1.2; letter-spacing: -.015em; }
.v2 .lead { font-size: var(--t-lead); color: var(--muted); line-height: 1.55; }

/* ===== Tunnel d'inscription =====
   Deux colonnes : le formulaire à gauche, le panneau de réassurance à droite.
   Sous 940px la colonne de droite passe au-dessus, réduite à l'essentiel. */

.tun-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Fond uni : le quadrillage est réservé à l'accueil, une page où l'on
     regarde. Ici on remplit un formulaire, rien ne doit distraire. */
  background: var(--bg);
}

.tun-head {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.tun-head__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 76px;
}
.tun-head__logo { display: flex; align-items: center; gap: 10px; }
.tun-head__logo img { width: 52px; height: 52px; object-fit: contain; }
.tun-head__right { display: flex; align-items: center; gap: 14px; font-size: 14.5px; color: var(--muted); }
.tun-head__right a { font-weight: 600; color: var(--text); border-bottom: 2px solid var(--yellow); }
.tun-head__right a:hover { color: var(--orange-d); }

.tun {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: clamp(32px, 5vw, 80px);
  align-items: start;
  padding: clamp(36px, 5vw, 72px) 0 var(--sp-block);
}

/* ----- Colonne formulaire ----- */
.tun__main { min-width: 0; max-width: 560px; }

/* Fil d'étapes : trois pastilles reliées par un trait qui se remplit en jaune */
/* display:flex l'emporterait sur l'attribut hidden posé par le script à l'écran final. */
.tun-steps[hidden] { display: none; }
.tun-steps {
  display: flex;
  align-items: flex-start;
  margin-bottom: var(--sp-block);
  counter-reset: step;
}
.tun-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  position: relative;
  text-align: center;
}
/* Le trait de liaison part du centre de la pastille vers celle de gauche */
.tun-step::before {
  content: '';
  position: absolute;
  top: 17px;
  right: 50%;
  left: -50%;
  height: var(--stroke);
  background: var(--border);
}
.tun-step:first-child::before { display: none; }
.tun-step__dot {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  background: var(--surface);
  color: var(--muted);
  border: var(--stroke) solid var(--border);
  transition: background .25s ease, color .25s ease, border-color .25s ease;
}
.tun-step__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .01em;
}
/* Étape courante */
.tun-step.is-current .tun-step__dot {
  background: var(--yellow);
  border-color: var(--ink);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--yellow-d);
}
.tun-step.is-current .tun-step__label { color: var(--text); }
/* Étapes déjà franchies : pastille noire, trait de liaison jaune */
.tun-step.is-done .tun-step__dot { background: var(--ink); border-color: var(--ink); color: var(--yellow); }
.tun-step.is-done .tun-step__label { color: var(--text); }
.tun-step.is-done::before,
.tun-step.is-current::before { background: var(--yellow); }

.tun-panel { display: none; }
.tun-panel.is-active { display: block; animation: tunIn .3s ease both; }
@keyframes tunIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.tun-panel__hat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--yellow-soft);
  border: 1px solid var(--yellow);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}
.tun-panel h1 { margin-bottom: 12px; }
.tun-panel .lead { margin-bottom: var(--sp-block); }

/* ----- Champs ----- */
.tun-field { margin-bottom: 18px; }
.tun-label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 7px;
  letter-spacing: .01em;
}
.tun-input {
  width: 100%;
  padding: 15px 16px;
  font: inherit;
  font-size: 16px; /* 16px minimum : en dessous, iOS zoome au focus */
  color: var(--text);
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.tun-input::placeholder { color: var(--muted); opacity: .7; }
.tun-input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(255, 204, 0, .35);
}
.tun-input.is-bad { border-color: var(--ko); }
.tun-hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* Œil « afficher le mot de passe » */
.tun-pass { position: relative; }
.tun-pass .tun-input { padding-right: 52px; }
.tun-pass__eye {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  cursor: pointer;
}
.tun-pass__eye:hover { background: var(--surface-2); color: var(--text); }

/* Jauge de robustesse du mot de passe (3 segments) */
.tun-meter { display: flex; gap: 5px; margin-top: 9px; }
.tun-meter i {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  transition: background .25s ease;
}
.tun-meter[data-score="1"] i:nth-child(1) { background: var(--ko); }
.tun-meter[data-score="2"] i:nth-child(-n+2) { background: var(--orange); }
.tun-meter[data-score="3"] i { background: var(--ok); }

/* ----- Messages ----- */
.tun-msg {
  display: none;
  border-radius: var(--radius);
  padding: 12px 15px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 18px;
  border: var(--stroke) solid transparent;
}
.tun-msg.is-on { display: block; }
.tun-msg--err { background: rgba(216, 58, 46, .1); border-color: var(--ko); color: var(--ko); }
.tun-msg--ok { background: rgba(31, 157, 77, .1); border-color: var(--ok); color: var(--ok); }
.tun-msg--info { background: var(--yellow-soft); border-color: var(--yellow); color: var(--text); }

/* ----- Séparateur « ou » ----- */
.tun-or {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.tun-or::before, .tun-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.tun-google { display: flex; justify-content: center; }

/* ----- Actions de bas de panneau ----- */
.tun-actions { display: flex; gap: 12px; align-items: center; margin-top: var(--sp-block); flex-wrap: wrap; }
.tun-actions .btn { flex: 1; min-width: 200px; justify-content: center; }
.tun-skip {
  background: none;
  border: 0;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 12px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tun-skip:hover { color: var(--text); }

.tun-legal { font-size: 12.5px; color: var(--muted); margin-top: 18px; line-height: 1.5; }
.tun-legal a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }

/* ----- Étape 3 : les employés ----- */
.tun-emp {
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  background: var(--surface);
}
.tun-emp__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.tun-emp__n { font-family: var(--font-head); font-weight: 700; font-size: 15px; }
.tun-emp__del {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tun-emp__del:hover { color: var(--ko); }
.tun-emp__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tun-emp__grid .tun-field { margin-bottom: 0; }
@media (max-width: 560px) { .tun-emp__grid { grid-template-columns: 1fr; } }

.tun-add {
  width: 100%;
  padding: 15px;
  border: var(--stroke) dashed var(--border);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.tun-add:hover { border-color: var(--yellow); background: var(--yellow-soft); }
.tun-add[disabled] { opacity: .45; cursor: not-allowed; }

/* ----- Écran final ----- */
.tun-done { text-align: center; padding: clamp(20px, 4vw, 40px) 0; }
.tun-done__mark {
  width: 84px;
  height: 84px;
  margin: 0 auto 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 8px 0 var(--yellow-d), 0 16px 34px rgba(255, 204, 0, .4);
}
.tun-creds {
  text-align: left;
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: var(--sp-block) 0;
  background: var(--surface);
}
.tun-creds__head {
  background: var(--ink);
  color: var(--yellow);
  padding: 13px 18px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14.5px;
}
.tun-creds__row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
  flex-wrap: wrap;
}
.tun-creds__row:first-of-type { border-top: 0; }
.tun-creds__row b { font-weight: 700; }
.tun-creds__row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  border-radius: 7px;
  padding: 2px 8px;
}
.tun-creds__note { padding: 13px 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

/* ----- Colonne de réassurance ----- */
/* L'aside n'est plus une carte : c'est une COLONNE qui empile le fil d'étapes
   et la carte de réassurance. Le cadre est descendu sur .tun__side-card, sinon
   il enfermerait aussi les étapes. */
.tun__side {
  position: sticky;
  top: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 0;
}
.tun__side-card {
  border: var(--stroke) solid var(--ink);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.tun__side-hat { height: 10px; }
.tun__side-body { padding: 26px; }
.tun__side h3 { margin-bottom: 18px; }
.tun-checks { list-style: none; display: grid; gap: 14px; margin-bottom: 26px; }
.tun-checks li { display: flex; gap: 11px; align-items: flex-start; font-size: 14.5px; line-height: 1.45; }
.tun-checks svg { flex-shrink: 0; margin-top: 2px; color: var(--ok); }
.tun-quote {
  border-top: 1px solid var(--border);
  padding-top: 22px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--muted);
}
.tun-quote b { color: var(--text); display: block; margin-top: 9px; font-size: 13.5px; }

/* ===== Grand écran : le tunnel tient dans la fenêtre, sans défilement =====
   Trois pièces solidaires, aucune ne suffit seule :
   1. La page est bornée à la hauteur de la fenêtre (100dvh, pas 100vh : sur
      mobile 100vh compte la barre d'adresse et dépasse toujours).
   2. min-height: 0 sur la grille ET sur la colonne. Sans lui, un élément de
      grille refuse de devenir plus petit que son contenu et déborde quand
      même : c'est la cause classique d'un overflow:hidden qui « ne marche
      pas ».
   3. Le débordement est rendu à la COLONNE du formulaire, pas à la page.
      Étapes 1 et 2 tiennent largement ; l'étape 3 grandit avec chaque employé
      ajouté et l'écran final avec chaque identifiant à recopier. Plutôt que
      d'interdire ces cas, c'est cette colonne-là qui défile, le cadre de la
      page ne bougeant jamais. */
@media (min-width: 941px) {
  .tun-page { height: 100dvh; overflow: hidden; }
  .tun { min-height: 0; padding-top: clamp(18px, 2.2vw, 32px); padding-bottom: clamp(18px, 2.2vw, 32px); }
  .tun__main { min-height: 0; max-height: 100%; overflow-y: auto; padding-right: 14px; }

  /* Fil d'étapes vertical : une pastille par ligne, reliées par un segment
     qui monte vers la précédente. Toutes les positions de la version
     horizontale doivent être remises à auto, sinon left:-50% subsiste et le
     trait part en travers. */
  .tun-steps { flex-direction: column; align-items: stretch; margin-bottom: 4px; }
  .tun-step { flex: none; flex-direction: row; align-items: center; gap: 14px;
    text-align: left; padding: 7px 0; }
  .tun-step::before {
    top: auto; right: auto; bottom: 100%;
    left: calc(18px - var(--stroke) / 2);
    width: var(--stroke); height: 14px;
  }
  .tun-step__label { font-size: 14.5px; }

  /* Le rythme des pages vitrines (--sp-block, 56px) est taillé pour séparer des
     sections, pas les lignes d'un formulaire : ces deux marges à elles seules
     coûtaient 112px de vide, soit plus que ce qui manquait pour tenir dans la
     fenêtre. C'est le premier endroit où reprendre de la hauteur si l'étape 1
     venait à gagner un champ. */
  .tun-panel .lead { margin-bottom: 22px; }
  .tun-actions { margin-top: 16px; }
  .tun-panel__hat { margin-bottom: 10px; }
  .tun-field { margin-bottom: 13px; }
  /* Marge de sécurité volontaire : la HAUTEUR DU BLOC GOOGLE N'EST PAS FIXE.
     Un visiteur déjà connecté à Google reçoit la carte personnalisée
     (« Se connecter en tant que … »), plus haute que le bouton générique de
     quelques pixels. Sans ces quelques pixels d'avance, le tunnel tient pour
     les uns et défile pour les autres. */
  .tun-legal { margin-top: 12px; }
  /* --t-h1 est calibré pour une accroche de page d'accueil (jusqu'à 58px) ;
     au-dessus d'un formulaire de trois champs c'est hors d'échelle. */
  .tun-panel h1 { font-size: clamp(28px, 2.6vw, 40px); }
}

/* Écrans PLATS (1366×768 et compagnie, très répandus dans les bureaux de PME,
   c'est-à-dire pile la clientèle visée). Le palier se déclenche sur la HAUTEUR
   de la fenêtre, pas sa largeur : c'est la hauteur qui manque. Sans lui il
   restait une quinzaine de pixels de trop à 768px et la colonne se mettait à
   défiler pour si peu. */
@media (min-width: 941px) and (max-height: 820px) {
  .tun { padding-top: 16px; padding-bottom: 16px; }
  .tun-panel h1 { font-size: clamp(24px, 2.1vw, 32px); }
  .tun-panel .lead { margin-bottom: 16px; font-size: 15px; }
  .tun-panel__hat { margin-bottom: 8px; }
  .tun-field { margin-bottom: 10px; }
  .tun-actions { margin-top: 16px; }
  .tun__side { gap: 14px; }
  .tun__side-body { padding: 18px; }
  .tun-checks { gap: 10px; margin-bottom: 16px; }
  .tun-quote { padding-top: 14px; }
}

@media (max-width: 940px) {
  .tun { grid-template-columns: 1fr; }
  .tun__main { max-width: none; }
  /* display: contents dissout l'aside : ses deux enfants deviennent des
     éléments de la grille et s'ordonnent séparément. Sans ça, les étapes et la
     réassurance restent soudées et passent en bloc devant le formulaire — le
     premier champ n'était alors pas visible sans faire défiler. */
  .tun__side { display: contents; }
  .tun-steps { order: -1; }
  .tun__main { order: 0; }
  .tun__side-card { order: 1; }
  .tun-quote { display: none; }
}
@media (max-width: 560px) {
  .tun-step__label { font-size: 11.5px; }
  .tun-actions .btn { min-width: 100%; }
}
