/* ============================================================================
   VTEX WALLET PERSONNEL — CHÂSSIS UNIQUE
   ----------------------------------------------------------------------------
   Source de vérité du cadrage. Cette feuille est chargée EN DERNIER : elle
   tranche, seule, tout ce qui touche au châssis.

   Pourquoi elle existe : le cadrage était éclaté entre wallet-base.css (63
   règles `.phone`, 53 `.view`, 68 `#loader-screen`) et wallet-final.css. Les
   symptômes observés venaient de quatre causes précises, toutes traitées ici :

     1. des `min-height` héritées (720 px, 680 px, 760 px) plus hautes que la
        fenêtre réelle d'un téléphone — le châssis débordait sous la barre
        basse, d'où l'impression d'écran « zoomé » et de header encastré ;
     2. un en-tête élargi à `calc(100% + 8px)` avec `margin:-4px`, qui créait
        un débordement horizontal de 8 px ;
     3. une mise en page dépendante de `:has()` (supporté tardivement sur
        mobile) : sans lui, le cadrage de l'accueil ne s'appliquait pas ;
     4. une vidéo d'introduction en `min-width:100vw / min-height:100vh`, qui
        forçait le document à la largeur de l'écran.

   Règle tenue ici : un seul propriétaire du défilement (la vue active), une
   seule hauteur (celle du viewport), et les marges de sécurité du système
   (encoche et barre gestuelle) appliquées là où elles servent.
   ========================================================================== */

:root{
  --frame-header-h:64px;                 /* hauteur utile de l'en-tête collant */
  --frame-tabbar-h:72px;                 /* hauteur utile de la barre basse */
  --frame-safe-top:env(safe-area-inset-top,0px);
  --frame-safe-bottom:env(safe-area-inset-bottom,0px);
}

/* ---------------------------------------------------------------- 0. Base -- */

*,*::before,*::after{ box-sizing:border-box; }

html,body{
  width:100% !important; max-width:100% !important;
  height:100% !important; min-height:0 !important;
  margin:0 !important; padding:0 !important;
  overflow:hidden !important;                 /* le défilement appartient à la vue active */
  overscroll-behavior:none !important;
  /* iOS gonfle le texte des blocs larges sans cette règle : c'est l'une des
     sources du rendu « zoomé » signalé sur mobile. */
  -webkit-text-size-adjust:100% !important;
  text-size-adjust:100% !important;
}

body{ background:var(--c-bg,#0b0a09); }

img,video,canvas,svg{ max-width:100%; }
img,video{ height:auto; }

/* --------------------------------------------------------------- 1. Châssis -- */

.phone{
  position:relative !important;
  width:100% !important; max-width:100% !important;
  height:100dvh !important;
  /* Aucune hauteur minimale : un châssis plus haut que la fenêtre est
     exactement ce qui poussait la barre basse hors de l'écran. */
  min-height:0 !important; max-height:100dvh !important;
  margin:0 auto !important;
  border:0 !important; border-radius:0 !important; box-shadow:none !important;
  overflow:hidden !important;
  isolation:isolate !important;
}
/* Navigateurs sans unité dynamique : la fenêtre visible reste la référence. */
@supports not (height:100dvh){
  .phone{ height:100vh !important; max-height:100vh !important; }
}

/* ------------------------------------------------------------ 2. Défilement -- */
/* La vue active est le SEUL conteneur qui défile. */
.view{
  position:absolute !important; inset:0 !important;
  width:100% !important; height:100% !important; max-height:100% !important;
  overflow-x:hidden !important; overflow-y:auto !important;
  -webkit-overflow-scrolling:touch !important;
  overscroll-behavior-y:contain !important;
  touch-action:pan-y !important;
  scroll-padding-top:calc(var(--frame-header-h) + var(--frame-safe-top)) !important;
  scroll-padding-bottom:calc(var(--frame-tabbar-h) + var(--frame-safe-bottom) + 20px) !important;
}
.view.active{ z-index:2 !important; }
.view:not(.active){ visibility:hidden !important; pointer-events:none !important; }

/* L'accueil gère ses propres marges latérales ; les autres vues gardent la
   gouttière de 16 px et dégagent la barre basse. */
.view:not(#view-accueil){
  padding:0 16px calc(var(--frame-tabbar-h) + var(--frame-safe-bottom) + 24px) !important;
}
#view-login,#view-otp{ padding:0 0 24px !important; }

/* ------------------------------------------------------------- 3. En-tête -- */
/* L'en-tête ne s'encastre plus dans l'encoche : il ajoute la marge du système
   à son propre rembourrage, et ne dépasse jamais la largeur de sa vue. */
#view-accueil .topbar,
.view > .vx-header,
.view > .hd,
.view > .top-row,
.view > .sr-top{
  width:100% !important; max-width:100% !important;
  margin-left:0 !important; margin-right:0 !important;
  padding-top:calc(14px + var(--frame-safe-top)) !important;
}
#view-accueil .topbar{
  position:sticky !important; top:0 !important; z-index:20 !important;
  margin-bottom:18px !important;
}

/* ----------------------------------------------------------- 4. Barre basse -- */
.tabbar{
  position:fixed !important; left:0 !important; right:0 !important; bottom:0 !important;
  width:100% !important;
  min-height:calc(var(--frame-tabbar-h) + var(--frame-safe-bottom)) !important;
  padding:8px 4px calc(10px + var(--frame-safe-bottom)) !important;
  z-index:100 !important;
  transform:translateZ(0) !important;
}
.tabbar.hidden{ transform:translate3d(0,115%,0) !important; }
.tab{ min-height:52px !important; padding:4px 2px !important; touch-action:manipulation !important; }
.tab .tab-ic{ width:34px !important; height:34px !important; }

/* --------------------------------------------------- 5. Anti-zoom des champs -- */
/* iOS agrandit toute la page dès qu'un champ de moins de 16 px reçoit le focus.
   C'est la cause la plus fréquente du « zoom abusif » sur mobile : on fixe la
   taille de saisie à 16 px et on garde la densité visuelle par le rembourrage. */
@media (max-width:1023px){
  input,textarea,select{ font-size:16px !important; }
}

/* --------------------------------------------------------- 6. Introduction -- */
/* Le film d'ouverture est ancré au viewport : il ne participe plus au flux et
   ne peut donc plus élargir le document. */
#loader-screen{
  position:fixed !important; inset:0 !important;
  width:100% !important; height:100dvh !important; max-height:100dvh !important;
  overflow:hidden !important;
  z-index:9000 !important;
}
@supports not (height:100dvh){
  #loader-screen{ height:100vh !important; max-height:100vh !important; }
}
#loader-screen .entry-video-bg,
#loader-screen .entry-video{
  position:absolute !important; inset:0 !important;
  width:100% !important; height:100% !important;
  min-width:0 !important; min-height:0 !important;
  max-width:100% !important; max-height:100% !important;
  object-fit:cover !important; object-position:center center !important;
  transform:translateZ(0) !important;
  backface-visibility:hidden !important;
  contain:paint !important;
}
#loader-screen .entry-video-bg{ will-change:opacity; }
#loader-screen .entry-video{ will-change:transform; }

/* ------------------------------------------------------- 7. Palier desktop -- */
/* Les vues secondaires gardent le châssis encadré ; l'accueil, qui porte le
   rail latéral, occupe la fenêtre. La classe `app-home` est posée par le
   routeur d'écrans (voir showView) : plus aucune dépendance à `:has()`. */
@media (min-width:1024px){
  .phone{
    width:min(1440px,calc(100vw - 56px)) !important; max-width:1440px !important;
    height:min(980px,calc(100dvh - 48px)) !important;
    min-height:0 !important; max-height:calc(100dvh - 48px) !important;
    border-radius:28px !important;
  }
  body.aurora-home-active .vtx-sidebar,
  .phone.app-home .vtx-sidebar{ display:flex !important; visibility:visible !important; transform:none !important; }
}

/* --------------------------------------------------- 8. Application installée -- */
/* En mode application, la fenêtre n'a plus de barre d'outils : la hauteur
   dynamique et les marges de sécurité suffisent. On ne laisse rien d'autre
   s'ajouter par-dessus. */
@media (display-mode:standalone){
  html,body{ height:100% !important; }
  .phone{ height:100dvh !important; max-height:100dvh !important; min-height:0 !important; }
  .tabbar{ padding-bottom:calc(10px + var(--frame-safe-bottom)) !important; }
}
