/* T-est — règles communes permanentes.
   Elles suivent les pages validées lors de leur promotion.
   Les comportements sont opt-in via data-stip-* pour éviter toute régression
   sur les formulaires qui n'ont pas encore été migrés. */

[data-stip-intent-target][hidden] {
  display: none !important;
}

body.stip-keyboard-focus-lock {
  overflow: hidden !important;
  overscroll-behavior: none;
}


/* Recherche mobile — la barre active devient un écran de recherche commun.
   Les résultats/suggestions déjà présents dans le bloc restent visibles. */
[data-stip-search-focus] .stip-keyboard-search-exit {
  display: none !important;
}
[data-stip-search-focus].stip-keyboard-focus-mode {
  position: fixed !important;
  z-index: 10020 !important;
  left: 0 !important;
  right: 0 !important;
  top: var(--stip-vv-top, 0px) !important;
  width: 100% !important;
  height: var(--stip-vv-height, 100dvh) !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 62px 16px max(16px, env(safe-area-inset-bottom)) !important;
  overflow: auto !important;
  overscroll-behavior: contain;
  box-sizing: border-box !important;
  background:
    radial-gradient(circle at 50% 18%, rgba(8,198,218,.13), transparent 36%),
    linear-gradient(180deg, #fff, #edf8fa) !important;
}
[data-stip-search-focus].stip-keyboard-focus-mode > *:not(.stip-keyboard-search-path):not(.stip-keyboard-search-exit):not([class*="result"]):not([id*="result"]):not([class*="suggest"]):not([id*="suggest"]):not([data-picker]):not([class*="list"]):not([id*="list"]):not([id*="List"]) {
  display: none !important;
}
[data-stip-search-focus].stip-keyboard-focus-mode .stip-keyboard-search-exit {
  position: absolute !important;
  z-index: 5 !important;
  top: 12px !important;
  right: 14px !important;
  width: 38px !important;
  height: 38px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  border: 1px solid rgba(4,82,104,.16) !important;
  border-radius: 13px !important;
  background: rgba(255,255,255,.9) !important;
  color: #55747c !important;
  font-size: 1.2rem !important;
  font-weight: 900 !important;
  box-shadow: 0 5px 14px rgba(4,82,104,.08) !important;
}
[data-stip-search-focus].stip-keyboard-focus-mode input[type="search"] {
  width: 100% !important;
  min-height: 58px !important;
  margin: 0 !important;
  padding: 13px 15px !important;
  border: 2px solid #08c6da !important;
  border-radius: 18px !important;
  outline: 0 !important;
  background: #fff !important;
  color: #063f4d !important;
  font-size: 1rem !important;
  box-shadow: 0 0 0 5px rgba(8,198,218,.15), 0 12px 28px rgba(4,82,104,.12) !important;
}

/* Porte d'entrée : mise en page fixe, mais geste natif de rafraîchissement conservé.
   Le contenu ne défile pas : seul le document racine reste disponible comme
   limite de défilement afin que Chrome/Android puisse déclencher pull-to-refresh. */
html:has(#loginView.t-entry-screen:not(.hidden)),
body:has(#loginView.t-entry-screen:not(.hidden)) {
  width: 100%;
  height: 100%;
  min-height: 100%;
  max-height: 100%;
  margin: 0;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior-x: none !important;
  overscroll-behavior-y: auto !important;
}

body:has(#loginView.t-entry-screen:not(.hidden)) > .app-shell {
  height: 100dvh;
  min-height: 0 !important;
  max-height: 100dvh;
  overflow: hidden !important;
}

#loginView.t-entry-screen:not(.hidden) {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100dvh !important;
  min-height: 0 !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
  overscroll-behavior-x: none !important;
  overscroll-behavior-y: auto !important;
  touch-action: pan-y pinch-zoom;
}

#loginView.t-entry-screen:not(.hidden) > .t-entry-shell {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow: hidden !important;
  overscroll-behavior-x: none !important;
  overscroll-behavior-y: auto !important;
  touch-action: pan-y pinch-zoom;
}

/* Quand le clavier mobile est ouvert, la porte d'entrée se cale sur la
   hauteur réellement visible. Cela évite de centrer les champs derrière
   le clavier lorsque le viewport de mise en page reste à 100dvh. */
#loginView.t-entry-screen:not(.hidden).stip-keyboard-focus-mode {
  inset: auto 0 auto 0 !important;
  top: var(--stip-vv-top, 0px) !important;
  height: var(--stip-vv-height, 100dvh) !important;
  min-height: 0 !important;
  max-height: var(--stip-vv-height, 100dvh) !important;
}

/* Un dialogue ouvert garde son propre comportement tactile/formulaire. */
#accessRequestDialog[open],
#accessRequestDialog[open] * {
  touch-action: auto;
}


/* Règle formulaire globale — clavier ouvert.
   Un formulaire séquentiel affiche la question active, son champ et l'action
   suivante. Les recherches et compositeurs natifs ne sont pas isolés. */
dialog.stip-keyboard-dialog-mode {
  width: 100vw !important;
  max-width: none !important;
  height: 100dvh !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  overflow: visible !important;
  background: transparent !important;
  box-shadow: none !important;
}
dialog.stip-keyboard-dialog-mode::backdrop {
  background: #edf8fa !important;
  backdrop-filter: none !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode {
  position: fixed !important;
  z-index: 10020 !important;
  left: 0 !important;
  right: 0 !important;
  top: var(--stip-vv-top, 0px) !important;
  width: 100% !important;
  height: var(--stip-vv-height, 100dvh) !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom)) !important;
  display: grid !important;
  grid-template-columns: minmax(0, 620px) !important;
  justify-content: center !important;
  align-content: center !important;
  gap: 10px !important;
  overflow: hidden !important;
  background:
    radial-gradient(circle at 50% 40%, rgba(8,198,218,.14), transparent 46%),
    linear-gradient(180deg, #fff, #edf8fa) !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode
  > *:not(.stip-keyboard-path):not(.stip-keyboard-question):not(.stip-keyboard-next-action):not(.stip-keyboard-prev-action):not(.stip-keyboard-overview-action):not(.stip-keyboard-nav-actions):not(.stip-autofill-context):not([data-stip-keyboard-accessory]) {
  display: none !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode
  .stip-keyboard-path > *:not(.stip-keyboard-path):not(.stip-autofill-context):not([data-stip-keyboard-accessory]) {
  display: none !important;
}

/* Les autres champs de profil restent rendus pour que le navigateur puisse
   préremplir le formulaire entier, sans réapparaître dans le mode question. */
[data-stip-form-focus].stip-keyboard-focus-mode
  > .stip-autofill-context:not(.stip-keyboard-path):not(.stip-keyboard-question),
[data-stip-form-focus].stip-keyboard-focus-mode
  .stip-keyboard-path > .stip-autofill-context:not(.stip-keyboard-path):not(.stip-keyboard-question) {
  position: fixed !important;
  left: -120vw !important;
  top: 0 !important;
  width: min(620px, 100vw) !important;
  max-width: 620px !important;
  opacity: .01 !important;
  pointer-events: none !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode .stip-keyboard-path,
[data-stip-form-focus].stip-keyboard-focus-mode .stip-keyboard-question,
[data-stip-form-focus].stip-keyboard-focus-mode .stip-keyboard-next-action {
  width: 100% !important;
  max-width: 620px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Les accessoires directs (ex. « Demander un accès ») suivent la largeur du
   formulaire. Les accessoires inline (ex. bouton « Voir » dans un champ)
   gardent leur propre largeur et ne peuvent plus écraser l'input. */
[data-stip-form-focus].stip-keyboard-focus-mode > [data-stip-keyboard-accessory] {
  width: 100% !important;
  max-width: 620px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode .stip-keyboard-question {
  display: block !important;
  margin-bottom: 1px !important;
  color: #164f5d !important;
  font-size: .78rem !important;
  line-height: 1.3 !important;
  font-weight: 900 !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode label.stip-keyboard-question {
  display: grid !important;
  gap: 9px !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode
  :is(input[data-stip-keyboard-focus], textarea[data-stip-keyboard-focus]) {
  width: 100% !important;
  min-height: 62px !important;
  margin: 0 !important;
  padding: 14px 16px !important;
  border: 2px solid #08c6da !important;
  border-radius: 18px !important;
  outline: 0 !important;
  background: #fff !important;
  color: #063f4d !important;
  font-size: 1rem !important;
  box-shadow:
    0 0 0 5px rgba(8,198,218,.16),
    0 14px 34px rgba(4,82,104,.14) !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode textarea[data-stip-keyboard-focus] {
  min-height: 76px !important;
  max-height: 104px !important;
  resize: none !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode .stip-keyboard-next-action {
  min-height: 58px !important;
  margin-top: 2px !important;
  padding: 0 18px !important;
  border: 0 !important;
  border-radius: 19px !important;
  background: linear-gradient(118deg, #006d89, #00a8c2 50%, #18d0df) !important;
  color: #fff !important;
  font-weight: 950 !important;
  font-size: .96rem !important;
  box-shadow: 0 14px 32px rgba(0,143,170,.32) !important;
  touch-action: manipulation !important;
}

[data-stip-step-nav].stip-keyboard-focus-mode .stip-keyboard-nav-actions {
  width: 100% !important;
  max-width: 620px !important;
  margin: 2px auto 0 !important;
  display: grid !important;
  grid-template-columns: minmax(0, .78fr) minmax(168px, 1.22fr) !important;
  align-items: center !important;
  gap: 10px !important;
}

[data-stip-step-nav].stip-keyboard-focus-mode .stip-keyboard-nav-actions[hidden] {
  display: none !important;
}

[data-stip-step-nav].stip-keyboard-focus-mode
  .stip-keyboard-nav-actions .stip-keyboard-prev-action {
  grid-column: 1 !important;
  justify-self: start !important;
  margin: 0 !important;
}

[data-stip-step-nav].stip-keyboard-focus-mode
  .stip-keyboard-nav-actions .stip-keyboard-next-action {
  grid-column: 2 !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  justify-self: stretch !important;
}

@media (max-width: 390px) {
  [data-stip-step-nav].stip-keyboard-focus-mode .stip-keyboard-nav-actions {
    grid-template-columns: minmax(0, .7fr) minmax(154px, 1.3fr) !important;
    gap: 8px !important;
  }

  [data-stip-step-nav].stip-keyboard-focus-mode
    .stip-keyboard-nav-actions .stip-keyboard-next-action {
    padding-inline: 12px !important;
    font-size: .88rem !important;
  }
}

[data-stip-form-focus] .stip-keyboard-next-action[hidden] {
  display: none !important;
}


/* Navigation pilote des formulaires à étapes.
   Active uniquement sur un formulaire portant data-stip-step-nav. */
[data-stip-step-nav].stip-keyboard-focus-mode .stip-keyboard-prev-action {
  width: max-content !important;
  min-height: 44px !important;
  margin: 0 !important;
  padding: 0 8px !important;
  justify-self: start !important;
  border: 0 !important;
  background: transparent !important;
  color: #58747c !important;
  font-size: .76rem !important;
  line-height: 1 !important;
  font-weight: 850 !important;
  box-shadow: none !important;
  touch-action: manipulation !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode .stip-keyboard-overview-action {
  position: absolute !important;
  z-index: 3 !important;
  top: 12px !important;
  right: 14px !important;
  width: auto !important;
  min-width: 38px !important;
  height: 38px !important;
  padding: 0 11px !important;
  display: grid !important;
  place-items: center !important;
  border: 1px solid rgba(4,82,104,.15) !important;
  border-radius: 13px !important;
  background: rgba(255,255,255,.72) !important;
  color: #55747c !important;
  font-size: .86rem !important;
  font-weight: 900 !important;
  opacity: .74 !important;
  box-shadow: 0 5px 14px rgba(4,82,104,.06) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

[data-stip-form-focus].stip-keyboard-focus-mode .stip-keyboard-overview-action:active {
  opacity: 1 !important;
  transform: scale(.96);
}

[data-stip-step-nav] .stip-keyboard-prev-action[hidden],
[data-stip-form-focus] .stip-keyboard-overview-action[hidden] {
  display: none !important;
}


/* STIP PIN contract — a six-digit numeric access code is not a browser
   password. Keep it masked visually without exposing password semantics to
   Chrome/Google Password Manager. */
input[data-stip-pin-field="1"] {
  -webkit-text-security: disc;
  text-security: disc;
}

input[data-stip-pin-field="1"][data-stip-pin-revealed="1"] {
  -webkit-text-security: none;
  text-security: none;
}

/* Contextual exit rule:
   - step form: Précédent / Suivant
   - revealed subview: Retour
   - modal/dialog keeps its own Annuler/Fermer action. */
.stip-intent-back-action {
  width: max-content !important;
  min-height: 44px !important;
  margin: 8px 0 0 !important;
  padding: 0 10px !important;
  border: 0 !important;
  border-radius: 12px !important;
  background: transparent !important;
  color: #58747c !important;
  font: inherit !important;
  font-size: .78rem !important;
  font-weight: 850 !important;
  line-height: 1 !important;
  box-shadow: none !important;
  touch-action: manipulation !important;
}

.stip-intent-back-action:active {
  transform: translateY(1px);
}

[data-stip-form-focus].stip-keyboard-focus-mode .stip-intent-back-action {
  justify-self: start !important;
  margin-top: 0 !important;
}
