/* PWA-specific fixes for mobile devices */

/* Prevent iOS bounce effect while allowing scrolling - exclude landing page */
html {
  width: 100%;
}

body:not(.landing-page) html {
  height: 100%;
}

body {
  width: 100%;
  margin: 0;
  -webkit-overflow-scrolling: touch;
  /* Allow normal page scroll by default; PWA override below will re-enable containment */
  overscroll-behavior-y: auto;
}

body:not(.landing-page) {
  height: 100%;
}

/* Ensure the app root takes full height - exclude landing page */
body:not(.landing-page) #__next {
  /* Use dynamic viewport height for mobile browser compatibility */
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  width: 100%;
}

body.landing-page #__next {
  width: 100%;
}

/* Prevent text selection on UI elements */
.prevent-select {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Ensure proper safe area handling */
.safe-area-top {
  padding-top: env(safe-area-inset-top, 0px);
}

.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.safe-area-left {
  padding-left: env(safe-area-inset-left, 0px);
}

.safe-area-right {
  padding-right: env(safe-area-inset-right, 0px);
}

/* Improve touch targets for mobile */
@media (pointer: coarse) {
  button, 
  a, 
  .MuiButtonBase-root {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Prevent pull-to-refresh only in PWA standalone mode to avoid trapping scroll in sections */
@media all and (display-mode: standalone) {
  body {
    overscroll-behavior-y: contain;
  }
}

/* Fix for iOS status bar in PWA mode */
@supports (padding: env(safe-area-inset-top)) {
  .ios-status-bar-fix {
    padding-top: constant(safe-area-inset-top);
    padding-top: env(safe-area-inset-top);
  }
}

/* Ensure FAB doesn't interfere with scrolling */
.MuiFab-root {
  touch-action: manipulation;
}

/* Optimize animations for mobile */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}