/* =========================================================
   VeloCrew App Shell Lock

   Final authority for mobile PWA geometry:
   - fixed app viewport
   - safe-area top and bottom clearance
   - floating bottom tab bar
   - stable auth focus layout
   ========================================================= */

:root {
  --vc-shell-topbar-h: 76px;
  --vc-tabbar-bottom: 14px;
  --vc-tabbar-h: 68px;
  --vc-tabbar-inset: 22px;
  --vc-tabbar-max: 680px;
  --vc-tabbar-clear: calc(var(--vc-tabbar-bottom) + var(--vc-tabbar-h) + var(--chrome-safe-bottom) + 28px);
}

html.pwa-standalone,
body.pwa-standalone {
  position: fixed !important;
  inset: 0 auto auto 0 !important;
  width: var(--app-width) !important;
  min-width: var(--app-width) !important;
  max-width: var(--app-width) !important;
  height: var(--app-height) !important;
  min-height: var(--app-height) !important;
  max-height: var(--app-height) !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: pan-y !important;
}

html.pwa-standalone .app-shell.standalone-shell {
  position: fixed !important;
  inset: 0 auto auto 0 !important;
  width: var(--app-width) !important;
  min-width: var(--app-width) !important;
  max-width: var(--app-width) !important;
  height: var(--app-height) !important;
  min-height: var(--app-height) !important;
  max-height: var(--app-height) !important;
  overflow: hidden !important;
  transform: translateX(0) !important;
  contain: layout paint;
}

html.pwa-standalone .app-shell.standalone-shell:not(.auth-shell) .topbar {
  left: 0 !important;
  right: auto !important;
  top: 0 !important;
  width: var(--app-width) !important;
  max-width: var(--app-width) !important;
}

html.pwa-standalone .app-shell.standalone-shell:not(.auth-shell) .topbar-inner {
  width: var(--app-width) !important;
  max-width: var(--app-width) !important;
  padding-top: calc(var(--chrome-safe-top) + 8px) !important;
  padding-right: max(14px, var(--chrome-safe-right)) !important;
  padding-bottom: 8px !important;
  padding-left: max(14px, var(--chrome-safe-left)) !important;
}

html.pwa-standalone .app-shell.standalone-shell:not(.auth-shell) .app-title {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: start !important;
  gap: 8px !important;
}

html.pwa-standalone .app-shell.standalone-shell:not(.auth-shell) .topbar-actions {
  max-width: min(86px, 32vw) !important;
  flex-wrap: nowrap !important;
}

html.pwa-standalone .app-shell.standalone-shell:not(.auth-shell) .main-flow {
  position: absolute !important;
  inset: 0 auto auto 0 !important;
  width: var(--app-width) !important;
  max-width: var(--app-width) !important;
  height: var(--app-height) !important;
  max-height: var(--app-height) !important;
  margin: 0 !important;
  padding-top: calc(var(--chrome-safe-top) + var(--vc-shell-topbar-h)) !important;
  padding-right: max(14px, var(--chrome-safe-right)) !important;
  padding-bottom: var(--vc-tabbar-clear) !important;
  padding-left: max(14px, var(--chrome-safe-left)) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
}

html.pwa-standalone .app-shell.standalone-shell:not(.auth-shell) .bottom-nav {
  left: var(--vc-tabbar-inset) !important;
  right: var(--vc-tabbar-inset) !important;
  bottom: var(--vc-tabbar-bottom) !important;
  width: auto !important;
  max-width: var(--vc-tabbar-max) !important;
  height: calc(var(--vc-tabbar-h) + var(--chrome-safe-bottom)) !important;
  margin: 0 auto !important;
  padding: 10px 10px calc(10px + var(--chrome-safe-bottom)) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  border-radius: 999px !important;
  background: rgba(10, 13, 20, 0.9) !important;
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
  overflow: hidden !important;
  z-index: 40 !important;
}

html.pwa-standalone .app-shell.standalone-shell:not(.auth-shell)::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--vc-tabbar-clear) + 22px);
  pointer-events: none;
  z-index: 30;
  background: linear-gradient(180deg, rgba(5, 7, 11, 0), rgba(5, 7, 11, 0.88));
}

@media (max-width: 360px) {
  html.pwa-standalone .app-shell.standalone-shell:not(.auth-shell) .bottom-nav {
    left: 14px !important;
    right: 14px !important;
  }
}

html.auth-standalone .app-shell.auth-shell.standalone-shell .auth-flow {
  width: var(--app-width) !important;
  max-width: min(430px, var(--app-width)) !important;
  height: var(--app-height) !important;
  max-height: var(--app-height) !important;
  margin: 0 auto !important;
  padding-top: calc(var(--chrome-safe-top) + 14px) !important;
  padding-right: max(22px, var(--chrome-safe-right)) !important;
  padding-bottom: calc(var(--chrome-safe-bottom) + 18px) !important;
  padding-left: max(22px, var(--chrome-safe-left)) !important;
  overflow: hidden !important;
}

html.auth-keyboard-focus .app-shell.auth-shell.standalone-shell .auth-flow,
html.auth-standalone:has([data-auth-field]:focus) .app-shell.auth-shell.standalone-shell .auth-flow {
  padding-top: calc(var(--chrome-safe-top) + 12px) !important;
  padding-bottom: calc(var(--chrome-safe-bottom) + 12px) !important;
}

html.auth-keyboard-focus .app-shell.auth-shell.standalone-shell .toolkit-landing,
html.auth-standalone:has([data-auth-field]:focus) .app-shell.auth-shell.standalone-shell .toolkit-landing {
  grid-template-rows: minmax(96px, 0.2fr) auto minmax(0, 1fr) !important;
  align-content: stretch !important;
  gap: 10px !important;
  overflow: hidden !important;
}

html.auth-keyboard-focus .app-shell.auth-shell.standalone-shell .landing-hero,
html.auth-standalone:has([data-auth-field]:focus) .app-shell.auth-shell.standalone-shell .landing-hero {
  display: block !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: 112px !important;
  padding: 0 !important;
  opacity: 0;
  pointer-events: none;
}

html.auth-keyboard-focus .app-shell.auth-shell.standalone-shell .password-card,
html.auth-standalone:has([data-auth-field]:focus) .app-shell.auth-shell.standalone-shell .password-card {
  align-self: start !important;
  max-height: min(360px, calc(var(--visible-height) - var(--chrome-safe-top) - var(--chrome-safe-bottom) - 132px)) !important;
  overflow: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

html.auth-keyboard-focus .app-shell.auth-shell.standalone-shell .auth-edit-field,
html.auth-standalone:has([data-auth-field]:focus) .app-shell.auth-shell.standalone-shell .auth-edit-field {
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
}
