/**
 * Model A PWA — html.IsPwaStandalone only. Spec: SharedDocuments/UI/Safe-Phones-Area.md §VI
 * Tab / desktop height stays in mobile-safe-area.css (100%). Capacitor is not this file.
 * PoC: 100dvh (fallback 100lvh, 100svh, 100vh). Do not re-declare in src CSS.
 * Load after mobile-safe-area.css, before app-specific CSS.
 * Requires: viewport-fit=cover; IsPwaStandalone set in index.html + MobileSafeAreaSetup.
 */

html.IsPwaStandalone {
  --AppViewportHeight: 100vh;
  --AppViewportHeight: 100svh;
  --AppViewportHeight: 100lvh;
  --AppViewportHeight: 100dvh;
  --AppViewportHeightStable: 100vh;
  --AppViewportHeightStable: 100svh;
  --AppViewportHeightStable: 100lvh;
  --AppViewportHeightStable: 100dvh;
  --SafeAreaInsetBottom: min(16px, env(safe-area-inset-bottom, 16px));
}

html.IsPwaStandalone,
html.IsPwaStandalone body,
html.IsPwaStandalone #root,
html.IsPwaStandalone .App,
html.IsPwaStandalone #App {
  height: 100vh;
  height: 100svh;
  height: 100lvh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100svh;
  max-height: 100lvh;
  max-height: 100dvh;
  overflow: hidden;
}

html.IsPwaStandalone #root {
  padding-bottom: 0;
}

/*
 * Nested GIS OS iframe (Docs / Portal): not IsPwaStandalone — keep tab 100%.
 * iOS still reports env(safe-area-inset-bottom) ~34px inside the iframe, so
 * AppFixedBottom sits above standalone PWA (D8 16px cap). Cap the token only.
 * Do not set 100dvh here (host already sized the iframe).
 * html.IsNestedFrame: index.html + MobileSafeAreaSetup (self !== top).
 * @media standalone: same cap before that class is copied. Do not key height
 * off display-mode (Android tablets) — Safe-Phones-Area.md §IV.
 */
html.IsNestedFrame {
  --SafeAreaInsetBottom: min(16px, env(safe-area-inset-bottom, 16px));
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  html:not(.IsPwaStandalone) {
    --SafeAreaInsetBottom: min(16px, env(safe-area-inset-bottom, 16px));
  }
}

/*
 * Overlay editors (#modal-dialogs). Spec: AllAppsBottomButtonsBar.md D10.
 * Tab overlay stays height:100% in mobile-safe-area.css (bottom is ignored when height is set).
 * PWA must match the shell so AppFixedBottom sits with in-flow bars.
 */
html.IsPwaStandalone .AppShellOverlay {
  height: 100vh;
  height: 100svh;
  height: 100lvh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100svh;
  max-height: 100lvh;
  max-height: 100dvh;
}
