/* Halloway keyboard-inset — reserve scroll room above the soft keyboard.
 *
 * Shell-only, Halloway-only. keyboard-inset.js publishes the keyboard height as
 * `--hw-kb-inset` and toggles `hw-kb-open` on <body> while the soft keyboard is
 * up. Loaded after the page's layout stylesheet (the canonical hunt/foyer CSS
 * on the hunts; shell.css on the account/console pages), so overriding only
 * `padding-bottom` here wins over those base body rules without editing them —
 * the base rules set the other three sides via the `padding` shorthand, which
 * we leave intact. (The few later <link>s a page may load — wordmark, ghost,
 * ambient — don't touch body padding, so this ordering holds.)
 */
:root {
  --hw-kb-inset: 0px;
  --hw-kb-offset-top: 0px;
  --hw-kb-runway: 24rem;
}

/* While the keyboard is open, give the document enough bottom room to scroll
 * the focused field (and, on the hunts, the key + feedback line) clear of the
 * keyboard. This generic rule covers every surface that loads the module —
 * the hunt/Foyer answer pages and the account/registration/settings/console
 * forms alike. */
body.hw-kb-open {
  padding-bottom: calc(var(--hw-kb-inset) + 3rem);
}

/* Viewport-resize environments can leave the measured inset at 0 even while the
 * focused field is below the shrunken viewport. While a text field is active,
 * keep a fixed scroll runway so constrained WebViews can still lift the field
 * above the keyboard edge. */
body.hw-kb-focus {
  padding-bottom: max(calc(var(--hw-kb-inset) + 3rem), var(--hw-kb-runway));
}

/* So any browser-native scroll-on-focus also lands clear of the keyboard. */
body {
  scroll-padding-bottom: calc(var(--hw-kb-inset) + 2.5rem);
}

body.hw-kb-focus {
  scroll-padding-bottom: max(calc(var(--hw-kb-inset) + 2.5rem), var(--hw-kb-runway));
}

/* Keep the answer surfaces named as a pinned contract, but do not let their
 * higher-specificity selectors overwrite the dynamic focus runway. Tall cards
 * such as Veil V need that runway to grow after the base inset reaches max
 * scroll. */
body.veil-body.hw-kb-open,
body.athanor-body.hw-kb-open,
body.threshold-body.hw-kb-open,
body.foyer-body.hw-kb-open,
body.cellar-body.hw-kb-open {
  padding-bottom: max(calc(var(--hw-kb-inset) + 3rem), var(--hw-kb-runway));
}
