/* Keeps the browser's OWN "scroll the focused element into view" clear of the app's fixed and
   sticky chrome, so tapping a field on a phone lands it in view instead of behind the app bar or
   under the SaveBar / dialog action bar. Global (unscoped) rules, so each host <link>s this file —
   an RCL cannot inject a <link> (the same reason maplibre-gl.css is linked in both host heads).

   scroll-padding shrinks a scrollport's snap area, which is what every scroll-into-view aligns
   against — so the browser lands the field correctly the FIRST time. That is strictly better than
   correcting the scroll afterwards, which is a visible hop; keyboard-focus.js only handles what CSS
   cannot know (where the on-screen keyboard is on browsers that ignore `interactive-widget`).

   Why the root element: scroll-padding on the root propagates to the viewport scrollport (like
   overflow does), and the document is what scrolls in both hosts — no page uses a full-height
   inner scroller. */
:root {
    /* The fixed app bar. ONE rule covers every scroll-into-view in the app, which is why elements
       that get scrolled to (e.g. the Activities day cells) carry no scroll-margin-top of their own:
       adding a per-element one back would double the offset. */
    scroll-padding-top: calc(var(--mud-appbar-height, 56px) + 8px);
    /* The sticky SaveBar on the explicit-save pages (Forms/SaveBar.razor.css), plus the safe-area
       inset it pads for. 72px clears the bar's measured 61px, which holds down to a 320px viewport
       (its message and button stay on one row). Reserved unconditionally: on a page without one (or
       while the form is clean, when SaveBar renders nothing) it only means a focused field lands
       slightly higher, and the browser clamps the scroll at the end of the content anyway. */
    scroll-padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* MudBlazor's dialog scrollport (a flex child with overflow:auto under the dialog's max-height),
   whose bottom edge the shared sticky action bar covers (Forms/DialogActionBar.razor.css).
   Deliberately much larger than the root's reservation: that bar WRAPS at phone widths, and the
   session dialog's worst case (delete + skip + add-manual-data + cancel + save, in Dutch) measures
   178px at 375px and 200px at 320px, against ~61px on a wide screen — sizing this for the
   unwrapped bar would leave a field far behind it and hand the fix to keyboard-focus.js, i.e. as a
   visible hop instead of a correctly-placed first scroll. Over-reserving is the safe direction:
   the food-log dialog's 51–92px bar only means a focused field lands a little higher, and the
   browser clamps the scroll at the end of the content anyway. Dialogs that keep their buttons in
   MudBlazor's own <DialogActions> render them OUTSIDE this scrollport, so for those the
   reservation is merely harmless — same trade-off as the root rule above. */
.mud-dialog-content {
    scroll-padding-bottom: 200px;
}
