/* =========================================================
   vAvtobyse 2.9.19 — GLOBAL iPhone / iPad pass
   Loaded last. Scope is iOS/iPadOS only via html.vav-ios.
   Goals: stable Safari/PWA viewport, safe areas, keyboard-safe shell,
   native-feeling scrolling/taps, modal/call/voice sizing, landscape.
   ========================================================= */

html.vav-ios{
  -webkit-text-size-adjust:100%!important;
  text-size-adjust:100%!important;
  -webkit-tap-highlight-color:transparent;
  --vav-ios-shell-height:100dvh;
  --vav-ios-viewport-top:0px;
}
html.vav-ios,html.vav-ios body{max-width:100%;overflow-x:hidden}
html.vav-ios body{-webkit-font-smoothing:antialiased}

/* Make UI controls feel like app controls without disabling selection in inputs. */
html.vav-ios button,
html.vav-ios [role="button"],
html.vav-ios .conversation-item,
html.vav-ios .mobile-bottom-nav,
html.vav-ios .chat-header,
html.vav-ios .composer-toolbar,
html.vav-ios .mobile-composer-inline{
  touch-action:manipulation;
  -webkit-touch-callout:none;
}
html.vav-ios input,
html.vav-ios textarea,
html.vav-ios select{
  font-size:16px!important;
  -webkit-text-size-adjust:100%;
}

/* ---------- document/auth mode ----------
   Safari owns page panning while the keyboard is visible. Do not turn the
   document into a fixed app shell and do not animate scroll positions. */
html.vav-ios body.vav-document-mode{
  position:static!important;
  inset:auto!important;
  width:100%!important;
  height:auto!important;
  min-height:100svh!important;
  max-height:none!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  overscroll-behavior-y:auto!important;
  -webkit-overflow-scrolling:touch!important;
}
html.vav-ios.vav-mobile-layout body.vav-document-mode .auth-flow-screen{
  width:100%!important;
  min-height:100svh!important;
  height:auto!important;
  max-height:none!important;
  padding-top:max(8px,env(safe-area-inset-top))!important;
  padding-right:max(8px,env(safe-area-inset-right))!important;
  padding-bottom:max(24px,env(safe-area-inset-bottom))!important;
  padding-left:max(8px,env(safe-area-inset-left))!important;
  overflow:visible!important;
  scroll-behavior:auto!important;
  overflow-anchor:none!important;
}
html.vav-ios.vav-mobile-layout body.vav-document-mode .auth-flow-screen .titlebar{
  position:relative!important;
  top:auto!important;
}
html.vav-ios body.vav-document-mode input,
html.vav-ios body.vav-document-mode textarea,
html.vav-ios body.vav-document-mode select{
  scroll-margin-top:18px!important;
  scroll-margin-bottom:18px!important;
}

/* ---------- signed-in shell ----------
   Use the real visual viewport. The JS variable follows Safari/PWA and the
   software keyboard, while safe-area padding stays on the actual controls. */
html.vav-ios.vav-mobile-layout body.vav-shell-mode{
  position:fixed!important;
  left:0!important;
  right:0!important;
  bottom:auto!important;
  top:var(--vav-ios-viewport-top,0px)!important;
  width:100%!important;
  height:var(--vav-ios-shell-height,100dvh)!important;
  min-height:0!important;
  max-height:var(--vav-ios-shell-height,100dvh)!important;
  overflow:hidden!important;
  overscroll-behavior:none!important;
}
html.vav-ios.vav-mobile-layout body.vav-shell-mode #appScreen{
  width:100%!important;
  height:100%!important;
  min-height:0!important;
  max-height:100%!important;
  overflow:hidden!important;
}
html.vav-ios.vav-mobile-layout body.vav-shell-mode .contacts-window,
html.vav-ios.vav-mobile-layout body.vav-shell-mode .chat-window,
html.vav-ios.vav-mobile-layout body.vav-shell-mode .active-chat{
  height:100%!important;
  min-height:0!important;
  max-height:100%!important;
}

/* Safe areas on notched / Dynamic Island devices, including landscape. */
html.vav-ios.vav-mobile-layout body.vav-shell-mode .contacts-window>.titlebar{
  padding-top:env(safe-area-inset-top)!important;
  padding-right:max(10px,env(safe-area-inset-right))!important;
  padding-left:max(10px,env(safe-area-inset-left))!important;
}
html.vav-ios.vav-mobile-layout body.vav-shell-mode .chat-header{
  padding-top:calc(6px + env(safe-area-inset-top))!important;
  padding-right:max(8px,env(safe-area-inset-right))!important;
  padding-left:max(8px,env(safe-area-inset-left))!important;
}
html.vav-ios.vav-mobile-layout body.vav-shell-mode .conversation-list,
html.vav-ios.vav-mobile-layout body.vav-shell-mode .message-list,
html.vav-ios.vav-mobile-layout body.vav-shell-mode .modal-page,
html.vav-ios.vav-mobile-layout body.vav-shell-mode .modal>.padded,
html.vav-ios .voice-hub-body,
html.vav-ios .voice-channel-list,
html.vav-ios .voice-participant-list{
  -webkit-overflow-scrolling:touch!important;
  overscroll-behavior-y:contain!important;
}
html.vav-ios.vav-mobile-layout body.vav-shell-mode .conversation-list::-webkit-scrollbar,
html.vav-ios.vav-mobile-layout body.vav-shell-mode .message-list::-webkit-scrollbar,
html.vav-ios.vav-mobile-layout body.vav-shell-mode .modal-page::-webkit-scrollbar,
html.vav-ios .voice-hub-body::-webkit-scrollbar{width:0;height:0}

/* Keep the active theme instead of ever falling back to legacy white mobile CSS. */
html.vav-ios.vav-mobile-layout[data-theme="bus-past"] body.vav-shell-mode .conversation-list{
  background:#263136!important;
}
html.vav-ios.vav-mobile-layout[data-theme="bus-past"] body.vav-shell-mode .conversation-item{
  background:linear-gradient(180deg,#3a454b,#343e43)!important;
  color:#f0eadf!important;
}

/* Bottom navigation and composer are home-indicator safe. */
html.vav-ios.vav-mobile-layout body.vav-shell-mode .mobile-bottom-nav{
  left:0!important;
  right:0!important;
  bottom:0!important;
  padding-right:max(5px,env(safe-area-inset-right))!important;
  padding-left:max(5px,env(safe-area-inset-left))!important;
  padding-bottom:max(4px,env(safe-area-inset-bottom))!important;
  min-height:calc(61px + env(safe-area-inset-bottom))!important;
}
html.vav-ios.vav-mobile-layout body.vav-shell-mode .composer{
  padding-right:max(7px,env(safe-area-inset-right))!important;
  padding-left:max(7px,env(safe-area-inset-left))!important;
  padding-bottom:max(6px,env(safe-area-inset-bottom))!important;
}
html.vav-ios.vav-mobile-layout body.vav-shell-mode #messageInput{
  font-size:16px!important;
  line-height:21px!important;
}

/* iOS keeps safe-area-inset-bottom even while the keyboard occupies that area.
   Suppress the artificial gap while the keyboard is actually open. */
html.vav-ios.vav-ios-keyboard body.vav-shell-mode .mobile-bottom-nav{
  display:none!important;
  visibility:hidden!important;
  pointer-events:none!important;
}
html.vav-ios.vav-ios-keyboard body.vav-shell-mode .contacts-window{
  padding-bottom:0!important;
}
html.vav-ios.vav-ios-keyboard body.vav-shell-mode .composer{
  padding-bottom:5px!important;
}
html.vav-ios.vav-ios-keyboard body.vav-shell-mode .emoji-panel,
html.vav-ios.vav-ios-keyboard body.vav-shell-mode .voice-recording-bar{
  bottom:58px!important;
}
html.vav-ios.vav-ios-keyboard body.vav-shell-mode .modal-actions{
  padding-bottom:8px!important;
}
html.vav-ios.vav-ios-keyboard body.vav-shell-mode .modal-page,
html.vav-ios.vav-ios-keyboard body.vav-shell-mode .modal>.padded{
  padding-bottom:22px!important;
}

/* Full-screen app surfaces use the same stable iOS visual viewport. */
html.vav-ios .modal-backdrop,
html.vav-ios .voice-hub-overlay,
html.vav-ios .voice-call-overlay{
  height:var(--vav-ios-shell-height,100dvh)!important;
  max-height:var(--vav-ios-shell-height,100dvh)!important;
}
html.vav-ios .voice-call-card{
  height:100%!important;
  min-height:100%!important;
  max-height:100%!important;
  padding-top:max(18px,env(safe-area-inset-top))!important;
  padding-right:max(20px,env(safe-area-inset-right))!important;
  padding-bottom:max(18px,env(safe-area-inset-bottom))!important;
  padding-left:max(20px,env(safe-area-inset-left))!important;
}
html.vav-ios .voice-hub-shell{
  height:100%!important;
  max-height:100%!important;
}
html.vav-ios .voice-hub-titlebar{
  padding-top:max(10px,env(safe-area-inset-top))!important;
  padding-right:max(12px,env(safe-area-inset-right))!important;
  padding-left:max(12px,env(safe-area-inset-left))!important;
}
html.vav-ios .voice-hub-body{
  padding-right:max(8px,env(safe-area-inset-right))!important;
  padding-bottom:max(12px,env(safe-area-inset-bottom))!important;
  padding-left:max(8px,env(safe-area-inset-left))!important;
}
html.vav-ios.vav-ios-keyboard .voice-hub-body{padding-bottom:8px!important}

/* Modals: one scroll owner, keyboard-safe footer. */
html.vav-ios.vav-mobile-layout body.vav-shell-mode .modal-backdrop{
  top:0!important;
  bottom:auto!important;
}
html.vav-ios.vav-mobile-layout body.vav-shell-mode .modal-titlebar{
  padding-top:env(safe-area-inset-top)!important;
  padding-right:max(10px,env(safe-area-inset-right))!important;
  padding-left:max(10px,env(safe-area-inset-left))!important;
}
html.vav-ios.vav-mobile-layout body.vav-shell-mode .modal-actions{
  padding-right:max(10px,env(safe-area-inset-right))!important;
  padding-left:max(10px,env(safe-area-inset-left))!important;
}

/* Compact in-app heads-up: never cover half of the iPhone. */
html.vav-ios .modern-notification,
html.vav-ios .notification-heads-up,
html.vav-ios .vav-notification-card{
  max-width:min(430px,calc(100vw - 16px))!important;
  max-height:92px!important;
}
html.vav-ios .toast,
html.vav-ios .connection-banner{
  top:calc(8px + env(safe-area-inset-top))!important;
  right:max(8px,env(safe-area-inset-right))!important;
  left:max(8px,env(safe-area-inset-left))!important;
}

/* Landscape phones need notch-safe horizontal padding and a shorter call UI. */
@media (orientation:landscape) and (max-height:520px){
  html.vav-ios.vav-mobile-layout body.vav-shell-mode .contacts-window>.titlebar{
    min-height:calc(48px + env(safe-area-inset-top))!important;
    height:calc(48px + env(safe-area-inset-top))!important;
  }
  html.vav-ios.vav-mobile-layout body.vav-shell-mode .chat-header{
    min-height:calc(50px + env(safe-area-inset-top))!important;
    padding-top:calc(3px + env(safe-area-inset-top))!important;
    padding-bottom:3px!important;
  }
  html.vav-ios.vav-mobile-layout body.vav-shell-mode .mobile-bottom-nav{
    min-height:calc(54px + env(safe-area-inset-bottom))!important;
  }
  html.vav-ios .voice-call-card{padding-top:max(8px,env(safe-area-inset-top))!important;padding-bottom:max(8px,env(safe-area-inset-bottom))!important}
  html.vav-ios .voice-call-avatar{width:92px!important;height:92px!important;margin-top:6px!important;border-radius:26px!important}
  html.vav-ios .voice-call-name{font-size:24px!important;margin-top:10px!important}
  html.vav-ios .voice-call-status{font-size:14px!important;margin-top:4px!important}
  html.vav-ios .voice-call-eyebrow{margin-top:4px!important}
  html.vav-ios .voice-call-toggle,
  html.vav-ios .voice-call-hangup,
  html.vav-ios .voice-call-accept,
  html.vav-ios .voice-call-decline{min-height:66px!important}
  html.vav-ios .voice-call-controls,
  html.vav-ios .voice-call-incoming{padding-top:8px!important}
}
