/* ===========================================================================
   telegram.css — Harizma inside the Telegram Mini App.

   Applies only under <html class="hz-tg">, which public/js/telegram/tg-boot.js
   sets for a Telegram launch (docs/telegram-mini-app.md §6). Outside Telegram
   every rule here is inert.
   ======================================================================== */

/* Surfaces that only make sense in a browser — web push, installing the PWA,
   the Google pop-up sign-in, signing out (Telegram signs the person in again
   on the next open). Marked in their markup with data-hz-web-only. */
html.hz-tg [data-hz-web-only] { display: none !important; }

/* …and the other way round: surfaces that exist only inside Telegram (the
   Settings row for cookie choices — no banner is raised there). Marked with
   data-hz-tg-only; this file is loaded everywhere, so it hides them for the
   web too. */
html:not(.hz-tg) [data-hz-tg-only] { display: none !important; }

/* Safe areas: Telegram reports the device insets itself (Bot API 8.0
   --tg-safe-area-inset-*), and some Telegram webviews report env() as 0.
   The top stays env(): in Telegram's standard (non-fullscreen) mode its own
   header sits above the app. */
html.hz-tg {
  --hz-safe-right:  max(env(safe-area-inset-right, 0px),  var(--tg-safe-area-inset-right, 0px));
  --hz-safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --hz-safe-left:   max(env(safe-area-inset-left, 0px),   var(--tg-safe-area-inset-left, 0px));
  /* Telegram owns pull-to-close; the app must not rubber-band under it. */
  overscroll-behavior: none;
}

/* Bottom sheets and modals live in the area Telegram actually SHOWS.
   Telegram may show only the top part of a Mini App (not yet expanded, or
   while it animates), with the rest of the web view below the screen; the
   SDK publishes the visible height as --tg-viewport-stable-height (and sets
   it to 100vh when unknown). A sheet anchored to the bottom of the web view
   would put its primary button off screen there — so the overlays end at the
   visible bottom, and the sheets are capped by the visible height, not by
   100dvh of the whole web view. */
html.hz-tg .hz-sheet-overlay,
html.hz-tg .lm-overlay {
  bottom: auto;
  height: var(--tg-viewport-stable-height, 100%);
}
html.hz-tg .hz-sheet { max-height: calc(var(--tg-viewport-stable-height, 100dvh) * 0.9); }
/* A full page (HzSheet { fullscreen } — the Plans page) fills the visible area. */
html.hz-tg .hz-sheet-overlay--full .hz-sheet { height: var(--tg-viewport-stable-height, 100dvh); max-height: none; }
/* The sign-in family's card needs no cap of its own: it is never taller than its
   overlay's box (login-addon.js .lm-card max-height: 100%), and the overlay ends
   at the visible bottom above — or, with the keyboard up, at the keyboard. */
