/* On The Map Caféhouse 6.0.208 — POS mobile layer repair
   The register's order drawer was parked below the viewport using translateY(),
   which still let it surface in full-page captures and could confuse scroll layers.
   Keep it genuinely hidden until summoned; prioritize the active drawer over all
   fixed POS controls. No payment API or transaction logic changes. */

@media (max-width: 640px) {
  /* A predictable navigation height and position, regardless of the theme. */
  body.otml-mode-staff > .otml-hub-tabs {
    position: fixed !important;
    top: auto !important;
    bottom: max(5px, env(safe-area-inset-bottom, 0px)) !important;
    z-index: 99990 !important;
    box-sizing: border-box !important;
    padding: 9px 8px !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  body.otml-mode-staff > .otml-hub-tabs button {
    box-sizing: border-box !important;
    min-height: 58px !important;
    height: 58px !important;
    max-height: 58px !important;
  }
  /* The cart shortcut belongs immediately above the nav, not in the menu grid. */
  body.otml-mode-staff #otmlMobileCartJump {
    position: fixed !important;
    top: auto !important;
    bottom: calc(94px + env(safe-area-inset-bottom, 0px)) !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    z-index: 99985 !important;
    min-height: 50px !important;
    padding: 9px 12px !important;
    box-sizing: border-box !important;
  }
  /* Long order/message/history pages can reach their last buttons. */
  body.otml-mode-staff {
    padding-bottom: calc(172px + env(safe-area-inset-bottom, 0px)) !important;
    scroll-padding-bottom: calc(158px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body.otml-mode-staff :is(#hubTabOrders, #hubTabPos, #hubTabMembers) {
    scroll-padding-bottom: calc(158px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* CLOSED: render no cart drawer in the document or full-page screenshot. */
  body.otml-mode-staff:not(.otml-mobile-cart-open) #posRegisterWorkspace .otml-pos-right {
    position: fixed !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    transform: translate3d(0, 108%, 0) !important;
  }

  /* OPEN: mobile checkout is its own independently scrolling viewport sheet. */
  body.otml-mode-staff.otml-mobile-cart-open #posRegisterWorkspace .otml-pos-right {
    position: fixed !important;
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    transform: translate3d(0, 0, 0) !important;
    top: max(10px, env(safe-area-inset-top, 0px)) !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: auto !important;
    max-height: calc(100dvh - max(10px, env(safe-area-inset-top, 0px))) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
    box-sizing: border-box !important;
    z-index: 2147482000 !important;
    padding: 14px 12px calc(28px + env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 22px 22px 0 0 !important;
    scroll-padding-bottom: calc(102px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body.otml-mode-staff.otml-mobile-cart-open #otmlMobileCartBackdrop {
    position: fixed !important;
    inset: 0 !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 2147481900 !important;
    background: rgba(16, 4, 10, .62) !important;
  }
  /* The navigation and quick cart button must NOT stay above an open sheet. */
  body.otml-mode-staff.otml-mobile-cart-open > .otml-hub-tabs,
  body.otml-mode-staff.otml-mobile-cart-open #otmlMobileCartJump,
  body.otml-mode-staff.otml-mobile-cart-open #otmlPosMoreOverlay {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  body.otml-mode-staff.otml-mobile-cart-open #posRegisterWorkspace .otml-mobile-cart-head {
    position: sticky !important;
    top: -14px !important;
    z-index: 26 !important;
    padding: 13px 12px !important;
  }
  body.otml-mode-staff.otml-mobile-cart-open #posRegisterWorkspace .otml-checkout-actions {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 25 !important;
    padding: 12px 8px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }
  /* Restore normal scroll ownership when the sheet is closed. */
  body.otml-mode-staff:not(.otml-mobile-cart-open) #otmlMobileCartBackdrop {
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.otml-mode-staff #posRegisterWorkspace .otml-pos-right,
  body.otml-mode-staff #otmlMobileCartBackdrop { transition-duration: 0.01ms !important; }
}
