|
32 | 32 | @apply bg-background text-foreground; |
33 | 33 | } |
34 | 34 |
|
| 35 | +/* |
| 36 | + Reserve space for system insets (status bar, gesture nav) when the WebView |
| 37 | + renders edge-to-edge - required since Android 15+ (SDK 35+) enforces this by |
| 38 | + default. Pairs with `viewport-fit=cover` in the MAUI BlazorWebView host page. |
| 39 | + Harmless on desktop where every term resolves to 0. |
| 40 | + |
| 41 | + The --android-safe-* / --android-wide-* / --android-ime-bottom custom properties |
| 42 | + are written by the MAUI Android host (see AndroidEdgeToEdgeInsets.cs) from real |
| 43 | + WindowInsetsCompat values -- we don't trust CSS env(safe-area-inset-*) inside the |
| 44 | + Android System WebView because it has been observed to report 0 even with |
| 45 | + viewport-fit=cover. iOS WKWebView populates env() reliably so we fall back to it |
| 46 | + there, and finally to 0 on desktop. |
| 47 | + |
| 48 | + --safe-area-inset-*: "chrome" inset (SystemBars + DisplayCutout only). For general |
| 49 | + page chrome -- status bar / nav bar / notch clearance. What `.app` pads with. |
| 50 | + --wide-area-inset-*: "wide" inset (chrome unioned with MandatorySystemGestures and |
| 51 | + TappableElement on Android). Use only for FLOATING elements (FABs, toasters) |
| 52 | + that need clearance from the gesture-nav tappable region, which can be wider |
| 53 | + than the visual handle in SystemBars. On iOS / desktop the env() fallback is |
| 54 | + the same as --safe-area-inset-* -- the distinction only matters on Android. |
| 55 | + |
| 56 | + --safe-viewport-height: system-bar-only safe height. Use for chrome surfaces |
| 57 | + (sidebars, drawers, dialogs) that should stay put when the keyboard opens. |
| 58 | + --content-viewport-height: safe height minus IME. Use for scrollable content |
| 59 | + areas that should shrink to remain visible above the soft keyboard. |
| 60 | +*/ |
| 61 | +:root { |
| 62 | + --safe-area-inset-top: var(--android-safe-top, env(safe-area-inset-top, 0px)); |
| 63 | + --safe-area-inset-right: var(--android-safe-right, env(safe-area-inset-right, 0px)); |
| 64 | + --safe-area-inset-bottom: var(--android-safe-bottom, env(safe-area-inset-bottom, 0px)); |
| 65 | + --safe-area-inset-left: var(--android-safe-left, env(safe-area-inset-left, 0px)); |
| 66 | + --wide-area-inset-top: var(--android-wide-top, env(safe-area-inset-top, 0px)); |
| 67 | + --wide-area-inset-right: var(--android-wide-right, env(safe-area-inset-right, 0px)); |
| 68 | + --wide-area-inset-bottom: var(--android-wide-bottom, env(safe-area-inset-bottom, 0px)); |
| 69 | + --wide-area-inset-left: var(--android-wide-left, env(safe-area-inset-left, 0px)); |
| 70 | + --ime-inset-bottom: var(--android-ime-bottom, 0px); |
| 71 | + --safe-viewport-height: calc(100dvh - var(--safe-area-inset-top) - var(--safe-area-inset-bottom)); |
| 72 | + --content-viewport-height: calc(100dvh - var(--safe-area-inset-top) - var(--ime-inset-bottom)); |
| 73 | +} |
| 74 | + |
| 75 | +/* |
| 76 | + Padding goes on `.app` (not `body`) because some descendants are sized to the |
| 77 | + visual viewport and would otherwise render under the status bar / gesture nav, |
| 78 | + ignoring any padding on `body`. The height clamp is applied via `min-h-dvh` on |
| 79 | + the `.app` element; padding stays here so it doesn't have to repeat on every |
| 80 | + direction-utility. |
| 81 | + |
| 82 | + Note: no padding-bottom. We deliberately let scroll content extend behind the |
| 83 | + gesture nav / FAB so the entries list visually continues into the floating |
| 84 | + chrome region. Floating elements (FAB, sonner) pay their own bottom inset. |
| 85 | +*/ |
| 86 | +.app { |
| 87 | + padding: var(--safe-area-inset-top) var(--safe-area-inset-right) 0 var(--safe-area-inset-left); |
| 88 | +} |
| 89 | + |
| 90 | +/* |
| 91 | + Status-bar band: a themed strip behind the OS status bar on Android edge-to-edge. |
| 92 | + Mirrors AppBar's background composite (primary @ 0.4 alpha over --background) so the |
| 93 | + band visually continues the AppBar through the status-bar region and re-themes |
| 94 | + automatically when the user toggles light/dark/accent in-app. Height collapses to 0 |
| 95 | + on iOS / desktop where --safe-area-inset-top resolves to 0. |
| 96 | + |
| 97 | + z-index 100 puts the band above everything in-app, including modal overlays |
| 98 | + (z-50). This is intentional: the band is OS-chrome-tier — its job is to keep |
| 99 | + the status bar icons legible regardless of what's open underneath. Modals |
| 100 | + darken in-app content; the status bar area stays bright. |
| 101 | + |
| 102 | + Hidden on project view (see the `:has([data-variant=inset])` rule below): |
| 103 | + there, `.app`'s bg-sidebar already covers the safe-top region in a single |
| 104 | + continuous color, so the band would just paint a different-shaded strip on |
| 105 | + top of it. |
| 106 | +*/ |
| 107 | +body::before { |
| 108 | + content: ''; |
| 109 | + position: fixed; |
| 110 | + inset: 0 0 auto 0; |
| 111 | + height: var(--safe-area-inset-top); |
| 112 | + background: |
| 113 | + linear-gradient(oklch(from var(--primary) l c h / 0.4)), |
| 114 | + var(--background); |
| 115 | + z-index: 100; |
| 116 | + pointer-events: none; |
| 117 | +} |
| 118 | + |
| 119 | +/* |
| 120 | + Project-view background: when the layout contains an inset-variant sidebar, |
| 121 | + paint `.app` AND `body` with bg-sidebar so the cutout / nav region and any |
| 122 | + area exposed when the IME shrinks `.app` (the strip alongside the keyboard |
| 123 | + in landscape, for instance) stay visually continuous with the sidebar |
| 124 | + instead of leaking through to bg-background. The themed status-bar band |
| 125 | + (body::before) still paints on top in the safe-top region. |
| 126 | +*/ |
| 127 | +.app:has([data-variant=inset]), |
| 128 | +body:has([data-variant=inset]) { |
| 129 | + background-color: var(--sidebar); |
| 130 | +} |
| 131 | + |
| 132 | +/* |
| 133 | + svelte-sonner offset / mobileOffset are configured as inline styles via the |
| 134 | + <Toaster> props (see lib/components/ui/sonner/sonner.svelte). External CSS-var |
| 135 | + overrides here would lose to the library's own inline `style:--offset-*=...` |
| 136 | + declarations on the <ol>, so we have to drive the values through the props. |
| 137 | +*/ |
| 138 | + |
| 139 | +/* Safe-area utilities. Apply at call sites instead of overriding slot selectors. */ |
| 140 | +@utility min-h-safe-screen { min-height: var(--safe-viewport-height); } |
| 141 | +@utility h-safe-screen { height: var(--safe-viewport-height); } |
| 142 | +@utility max-h-safe-screen { max-height: var(--safe-viewport-height); } |
| 143 | +@utility min-h-content-screen { min-height: var(--content-viewport-height); } |
| 144 | +@utility h-content-screen { height: var(--content-viewport-height); } |
| 145 | +/* Vaul drawer baseline is max-h-[90dvh]; this preserves the breathing room. */ |
| 146 | +@utility max-h-90-safe { max-height: calc(var(--safe-viewport-height) * 0.9); } |
| 147 | +@utility pt-safe { padding-top: var(--safe-area-inset-top); } |
| 148 | +@utility pr-safe { padding-right: var(--safe-area-inset-right); } |
| 149 | +@utility pb-safe { padding-bottom: var(--safe-area-inset-bottom); } |
| 150 | +@utility pl-safe { padding-left: var(--safe-area-inset-left); } |
| 151 | +@utility px-safe { |
| 152 | + padding-left: var(--safe-area-inset-left); |
| 153 | + padding-right: var(--safe-area-inset-right); |
| 154 | +} |
| 155 | +@utility py-safe { |
| 156 | + padding-top: var(--safe-area-inset-top); |
| 157 | + padding-bottom: var(--safe-area-inset-bottom); |
| 158 | +} |
| 159 | +@utility pb-ime { padding-bottom: var(--ime-inset-bottom); } |
| 160 | + |
| 161 | +/* |
| 162 | + Wide-inset utilities. Mirror pb-safe / pr-safe but pull from --wide-area-inset-* |
| 163 | + so floating elements (FAB, sonner offset calc) clear the gesture-nav tappable |
| 164 | + region on Android. Identical to safe variants on iOS / desktop. |
| 165 | +*/ |
| 166 | +@utility pb-wide { padding-bottom: var(--wide-area-inset-bottom); } |
| 167 | +@utility pr-wide { padding-right: var(--wide-area-inset-right); } |
| 168 | + |
| 169 | +/* |
| 170 | + "Extra" wide insets: the difference between wide and chrome. Use on floating |
| 171 | + elements that already sit inside `.app` (which adds chrome padding) but need to |
| 172 | + clear the full wide-inset region. `max(0px, ...)` because the wide vars fall |
| 173 | + back via env() on iOS where it can theoretically resolve unequal to safe. |
| 174 | +*/ |
| 175 | +@utility pb-wide-extra { padding-bottom: max(0px, calc(var(--wide-area-inset-bottom) - var(--safe-area-inset-bottom))); } |
| 176 | +@utility pr-wide-extra { padding-right: max(0px, calc(var(--wide-area-inset-right) - var(--safe-area-inset-right))); } |
| 177 | + |
| 178 | +/* |
| 179 | + Re-center a fixed element within the safe rect instead of the full viewport. |
| 180 | + Use with `translate-x-[-50%] translate-y-[-50%]` (which still mean "shift by |
| 181 | + half of self"); only the 50% anchor is biased by the inset asymmetry. When |
| 182 | + insets are symmetric or zero, this collapses to plain `top: 50%; left: 50%`. |
| 183 | +*/ |
| 184 | +@utility top-safe-center { top: calc(50% + (var(--safe-area-inset-top) - var(--safe-area-inset-bottom)) / 2); } |
| 185 | +@utility left-safe-center { left: calc(50% + (var(--safe-area-inset-left) - var(--safe-area-inset-right)) / 2); } |
| 186 | + |
35 | 187 | @layer base { |
36 | 188 | /* shadcn generated styles */ |
37 | 189 | * { |
|
0 commit comments