/* On-screen keyboard. keyboard.js puts "keyboard-open" on <body> while a text field has focus and the keyboard covers
   the screen, and "keyboard-short" as well when less than 520 px stay visible. --visual-viewport-height is the visible
   height in both worlds: in the app the whole WebView shrinks (100dvh shrinks with it), on the website only the visual
   viewport shrinks (100dvh stays) - so every height below is taken from it. --cdx-kb-inset is the part of the layout
   viewport under the keyboard: 0 in the app, the keyboard height on the website. */
body.cdx-shell-ready.keyboard-open {
  --cdx-tab-space: 0px;
  --cdx-content-height: calc(var(--visual-viewport-height, 100dvh) - var(--cdx-header-space) - var(--cdx-subheader-space) - var(--cdx-connection-space));
  --cdx-kb-inset: max(0px, calc(100dvh - var(--visual-viewport-height, 100dvh) - var(--visual-viewport-offset-top, 0px)));
}
html:has(body.keyboard-open) { scroll-padding-bottom: 104px; }
/* The sign-in form is centred in the page; with the keyboard it starts at the top of what is left. */
body.cdx-shell-ready.keyboard-open.logged-out main { min-height: calc(var(--visual-viewport-height, 100dvh) - 56px - env(safe-area-inset-top)); align-items: flex-start; }

/* Sheets and dialogs sit on the keyboard, not under it, and scroll inside when they are taller than what is left. */
body.keyboard-open :is(.exact-mileage__layer, .exact-vehicle-photo-layer, .exact-plan-sheet, .exact-history-sheet, .exact-vehicle-year-picker) { bottom: var(--cdx-kb-inset); }
body.keyboard-open :is(.add-sheet, #cityPickerDialog, .cd-flow-sheet, .picker-dialog) { bottom: var(--cdx-kb-inset); }
body.cdx-shell-ready.keyboard-open :is(.add-sheet, #cityPickerDialog, .cd-flow-sheet, .picker-dialog, .exact-mileage__sheet, .exact-vehicle-photo-sheet, .exact-plan-sheet > section, .exact-history-sheet > section) {
  max-height: calc(var(--visual-viewport-height, 100dvh) - 12px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Sticky bars sit on the keyboard too. */
body.keyboard-open :is(.exact-history-form__footer, .exact-doc-review__save, .exact-plan-editor footer, .exact-vehicle-manual form > footer, .exact-vehicle-edit form > footer, .exact-sts-review form > footer) { bottom: var(--cdx-kb-inset, 0px); }

/* A short screen: what is not needed for typing goes away, the sticky bars get thinner. */
body.keyboard-short :is(.exact-history-form__footer, .exact-doc-review__save, .exact-plan-editor footer, .exact-vehicle-manual form > footer, .exact-vehicle-edit form > footer, .exact-sts-review form > footer) { padding-block: 8px; gap: 6px; }
body.keyboard-short .exact-assist__identity { display: none; }
body.keyboard-short :is(.exact-auth__lead, .exact-auth__intro p) { display: none; }
body.keyboard-short .exact-auth { padding-block: 12px; }
body.keyboard-short .exact-auth--account > form { gap: 12px; }
body.keyboard-short .exact-auth__actions { padding-top: 0; }
body.keyboard-short #app { width: 100%; box-sizing: border-box; }
