/* [95-mobile] Téléphones et tablettes : plein écran, paysage, gestes du navigateur bloqués */

/* Pas de zoom de page au double appui ni de rafraîchissement en tirant vers le bas */
html, body {
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

#game-container {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Le quartier et la carte gèrent eux-mêmes le glisser et le pincement */
#neighborhood-pan-viewport,
#city-map-canvas {
  touch-action: none;
}

/* Message « Tournez votre téléphone » : masqué par défaut */
#rotate-overlay {
  display: none;
}

/* Écran tactile en portrait (téléphone) : le cadre 980 x 640 se joue en paysage */
@media (orientation: portrait) and (pointer: coarse) and (max-width: 900px) {
  #rotate-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    background: radial-gradient(circle at 50% 40%, #162f27, #0b0d0f 70%);
    color: #e2d9ce;
    font-family: 'Limelight', serif;
    text-align: center;
  }
  #rotate-overlay .rotate-phone {
    font-size: 64px;
    animation: rotate-hint 1.8s ease-in-out infinite;
  }
  #rotate-overlay p { margin: 0; font-size: 22px; font-weight: 700; color: #e3bb86; }
  #rotate-overlay span { font-family: 'Josefin Sans', sans-serif; font-size: 15px; opacity: 0.85; }
}

@keyframes rotate-hint {
  0%, 20% { transform: rotate(0deg); }
  50%, 70% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

/* Téléphone en paysage (peu de hauteur) : le portail web est masqué, le cadre prend tout l'écran */
@media (max-height: 520px) and (pointer: coarse) {
  #portal-header-bar,
  #upper-bar { display: none; }
}

/* Hauteur réelle visible (sans la barre d'adresse du navigateur mobile) : sinon le bas du cadre est coupé */
@supports (height: 100dvh) {
  body { height: 100dvh; }
}

/* ==========================================================================
   DISPOSITION TÉLÉPHONE (html.mobile-layout, posée par app.js) : cadre 980 x 470
   Rien ici ne s'applique au PC ni aux tablettes.
   ========================================================================== */
/* Vue Domaine : l'illustration garde ses 640 px de haut et glisse verticalement (zones cliquables intactes) */
html.mobile-layout #scene-estate-layer {
  bottom: auto;
  height: 640px;
  transform: translateY(var(--estate-shift, -85px));
}

/* Fenêtres : plus hautes que le cadre, elles défilent au doigt au lieu d'être coupées */
html.mobile-layout .game-modal-curtain,
html.mobile-layout .custom-modal-overlay {
  align-items: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 6px 0;
}
html.mobile-layout .game-modal-curtain > *,
html.mobile-layout .custom-modal-overlay > * {
  margin: auto;
  flex-shrink: 0;
}

/* Le portail web et le ruban restent masqués, même si le navigateur ne se déclare pas tactile */
html.mobile-layout #portal-header-bar,
html.mobile-layout #upper-bar { display: none; }

/* Colonne des conseillers (4 disques) : resserrée pour tenir au-dessus du chat replié */
html.mobile-layout #left-quest-badges-strip { top: 126px; gap: 8px; }

/* Glisser fluide : calques déjà rendus, déplacés par le GPU ; le doigt est géré par le jeu (pas de défilement du navigateur) */
html.mobile-layout #scene-estate-layer { will-change: transform; touch-action: none; }
html.mobile-layout #neighborhood-canvas { will-change: transform; }
/* Ombres portées des bâtiments : très coûteuses à redessiner sur téléphone pendant un déplacement */
html.mobile-layout .slot-building-sprite,
html.mobile-layout .slot-diamond-svg { filter: none; }

/* Aide verrouillage de rotation et bouton pour passer outre */
#rotate-overlay .rotate-lock-hint { max-width: 300px; font-size: 13px; opacity: 0.7; margin-top: 8px; }
#rotate-overlay #rotate-dismiss {
  margin-top: 14px; padding: 9px 18px; border: 1px solid var(--gold-bronze); border-radius: 4px;
  background: linear-gradient(180deg, #245645, #112e24); color: #e3bb86;
  font-family: 'Limelight', serif; font-size: 15px; font-weight: 700;
}
html.rotate-dismissed #rotate-overlay { display: none !important; }

/* Navigateur intégré (Messenger, Facebook) : il ne pivote pas ; on l'explique à la place de l'aide sur le verrouillage */
#rotate-overlay .rotate-inapp-hint { display: none; max-width: 300px; font-size: 14px; color: #e3bb86; margin-top: 8px; }
html.in-app-browser #rotate-overlay .rotate-inapp-hint { display: block; }
html.in-app-browser #rotate-overlay .rotate-lock-hint { display: none; }

/* Application posée sur l'écran d'accueil (barre d'état translucide) : l'heure et la batterie ne recouvrent plus le jeu */
body { padding-top: env(safe-area-inset-top, 0px); }
