/* OnlyShows 0.11.19: stable wallpaper coordinates and keyboard-state add search. */

@media (max-width: 719px) {
  :root {
    --mobile-visual-top: 0px;
  }

  /*
   * At the home list's initial bottom position there is already enough room
   * for the fixed title. Do not mask another title-height from the cards:
   * that was the extra empty band introduced in v78.
   */
  html body:not(.mobile-database-tab):not(.mobile-profile-tab) #showGrid {
    -webkit-mask-image: linear-gradient(
      to bottom,
      #000 0,
      #000 calc(100% - 52px),
      rgb(0 0 0 / 76%) calc(100% - 40px),
      rgb(0 0 0 / 42%) calc(100% - 27px),
      rgb(0 0 0 / 12%) calc(100% - 14px),
      transparent calc(100% - 4px),
      transparent 100%
    ) !important;
    mask-image: linear-gradient(
      to bottom,
      #000 0,
      #000 calc(100% - 52px),
      rgb(0 0 0 / 76%) calc(100% - 40px),
      rgb(0 0 0 / 42%) calc(100% - 27px),
      rgb(0 0 0 / 12%) calc(100% - 14px),
      transparent calc(100% - 4px),
      transparent 100%
    ) !important;
  }

  /*
   * Lock the wallpaper to large-viewport geometry and compensate only for
   * VisualViewport panning. Opening an IME must not recrop or slide it.
   */
  html[data-background="prism-mono"] body > .theme-backdrop,
  html[data-background="prism-violet"] body > .theme-backdrop {
    top: 0 !important;
    right: auto !important;
    bottom: auto !important;
    left: 0 !important;
    width: 100lvw !important;
    height: 100lvh !important;
    min-height: 100lvh !important;
    transform: translate3d(0, var(--mobile-visual-top), 0) !important;
    transform-origin: top left !important;
  }

  /*
   * Focus and keyboard visibility are different states on Android. Keep the
   * search form in its normal top position until VisualViewport confirms an
   * IME, then pin it above the visible keyboard with a small breathing gap.
   */
  html body #searchDialog.search-dialog:not(.mobile-ime-visible) .remote-search,
  html body #searchDialog.search-dialog:has(#remoteSearchInput:focus):not(.mobile-ime-visible) .remote-search {
    position: relative !important;
    z-index: auto !important;
    inset: auto !important;
    width: auto !important;
    margin: 0 20px 18px !important;
    transform: none !important;
    will-change: auto;
  }

  html body #searchDialog.search-dialog.mobile-ime-visible .remote-search,
  html body #searchDialog.search-dialog.mobile-ime-visible:has(#remoteSearchInput:focus) .remote-search {
    position: fixed !important;
    z-index: 4;
    right: 18px !important;
    bottom: 8px !important;
    left: 18px !important;
    width: auto !important;
    margin: 0 !important;
    transform: translateY(calc(-1 * var(--remote-search-lift, 0px))) !important;
    will-change: transform;
  }
}
