/* ═══════════════════════════════════════════════════════
   TMA.CSS — Telegram Mini App (TMA 7.0 / 8.0) Enhancements
   Telegram Theme Sync · Dynamic Viewports · Safe Areas
   ═══════════════════════════════════════════════════════ */

/* Telegram Environment Overrides — only apply default fallback colors if no custom theme is active */
:root:not([data-theme]) body.tg-env {
  --bg-primary: var(--tg-theme-bg-color, #1c1510);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #271e17);
  --text-primary: var(--tg-theme-text-color, #ffffff);
  --text-secondary: var(--tg-theme-hint-color, #d0c4b8);
  --accent: var(--tg-theme-button-color, #ff5500);
}

body.tg-env {
  /* Viewport Height from Telegram Mini App */
  min-height: var(--tg-viewport-height, 100dvh);
}

/* Safe area insets in TMA */
body.tg-env .app-header {
  padding-top: calc(10px + var(--tg-content-safe-area-inset-top, var(--safe-top)));
}

body.tg-env .bottom-cart-bar {
  bottom: calc(12px + var(--tg-content-safe-area-inset-bottom, var(--safe-bottom)));
}

body.tg-env .modal-sheet {
  padding-bottom: calc(24px + var(--tg-content-safe-area-inset-bottom, var(--safe-bottom)));
}

/* Hide desktop contact button inside Telegram client if profile is native */
body.tg-env .header-desktop-info {
  display: none;
}

/* Prevent accidental swipes closing the TMA when dragging sheets */
body.tg-env .modal-overlay.open {
  overscroll-behavior-y: none;
}

body.tg-env .modal-sheet {
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
