/* ==========================================================================
   css/keyboard-aware.css — companion to js/keyboard-aware.js     [KEYBOARD-1]
   Shared by storefront and admin pages (selectors for the other side are
   simply unused). --kb-h / html.kb-open come from the script; both are
   0 / absent when the keyboard is closed, so nothing changes then. In
   browsers that resize the page for the keyboard (Android Chrome with
   interactive-widget=resizes-content) --kb-h stays 0 and the dvh caps below
   do the work.
   ========================================================================== */
html { --kb-h: 0px; }

/* Leave room above the keyboard when the browser scrolls a field into view. */
input, textarea, select { scroll-margin-block: 80px; }

/* 1. Fixed bars pinned to the bottom would ride up on top of the keyboard and
      eat the visible area — hide them while a field is being typed in. */
html.kb-open .bottomnav,
html.kb-open .pd-mobile-purchase-bar,
html.kb-open .checkout-mini-total-bar,
html.kb-open .ls-bar,
html.kb-open .mobile-bottom-nav,
html.kb-open .wa-fab,
html.kb-open .pos-mobile-bar { display: none !important; }

/* 2. Storefront bottom sheets: lifted by the keyboard (overlay-mode browsers),
      height never taller than what is actually visible. */
.sheet-backdrop,
.ls-sheet-backdrop { padding-bottom: var(--kb-h, 0px); box-sizing: border-box; }
.sheet-panel { max-height: min(88vh, calc(100dvh - 16px - var(--kb-h, 0px))); }
html.kb-open .ls-sheet { max-height: min(96dvh, calc(100dvh - 8px - var(--kb-h, 0px))); }

/* 3. Admin modals (centered): same idea. */
.modal-overlay { padding-bottom: calc(20px + var(--kb-h, 0px)); box-sizing: border-box; }
.modal { max-height: min(90vh, calc(100dvh - 40px - var(--kb-h, 0px))); }
.toast-stack { bottom: calc(22px + var(--kb-h, 0px)); }

/* 4. POS mobile cart sheet (bottom-anchored, fixed). */
.pos-sheet {
  bottom: var(--kb-h, 0px);
  max-height: min(86vh, calc(100dvh - 8px - var(--kb-h, 0px)));
}
