/* iOS Performance Optimizations - Top-Tier App Quality */

/* Enable hardware acceleration for smooth animations */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Optimize scrolling performance */
body {
    -webkit-overflow-scrolling: touch;
}

/* Prevent bounce on scroll boundaries — app pages only.
   Landing/login/public pages use native viewport scroll and need
   default overscroll behavior. */
body[data-page] {
    overscroll-behavior-y: none;
}

/* Smooth momentum scrolling for all scrollable areas */
.scrollable, [data-scrollable] {
    -webkit-overflow-scrolling: touch;
    overflow-y: scroll;
}

/* Hardware-accelerated transforms for animations */
.animated, [data-animated] {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Optimize tap highlighting */
a, button, input, select, textarea {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
}

/* Remove iOS input shadows and borders */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="search"],
textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Optimize for notched devices (iPhone X+) */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    /* Safe area for fixed headers */
    header, .header, [data-header] {
        padding-top: max(20px, env(safe-area-inset-top));
    }

    /* Safe area for fixed footers */
    footer, .footer, [data-footer] {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* iOS Tab Bar Spacing - Pages with bottom navigation */
/* Apply to all pages with data-page attribute (regardless of value) */
body[data-page],
body.app-root:has(#unifiedTabBar) {
    /* Add bottom padding for fixed tab bar (65px) + spacing (20px) + safe area */
    padding-bottom: calc(85px + env(safe-area-inset-bottom, 20px));
    min-height: 100vh;
    box-sizing: border-box;
}

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Optimize rendering for iOS — scoped to app pages (data-page) to avoid
   breaking native body scroll on standalone pages like landing/login.
   Only applied to body, not html — html-level compositing can break scroll. */
body[data-page] {
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    -moz-perspective: 1000;
    perspective: 1000;
}

/* Prevent layout shift during font loading */
body {
    font-display: swap;
}

/* Optimize for dark mode */
@media (prefers-color-scheme: dark) {
    html {
        color-scheme: dark;
    }
}

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

/* Optimize images for performance */
img {
    image-rendering: -webkit-optimize-contrast;
}

/* Prevent flickering during animations */
.no-flicker {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}
