/* IRLife Mobile Optimizations & PWA Native Feel */

/* iOS Safe Area Support */
:root {
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
}

/* Smooth Scrolling with Momentum (iOS rubber-band effect) */
html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prevent Zoom on Input Focus (iOS) */
input, select, textarea {
    font-size: 16px !important;
}

/* Touch-friendly Tap Targets (minimum 44x44px) */
button, a, input[type="submit"], input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* Disable Text Selection for UI Elements */
.logo, button, .cta-btn, .nav-cta, .step-number, .stat-number {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Smooth 60fps Animations */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* GPU-Accelerated Transitions — only on primary interactive elements to avoid 20+ composite layers */
.cta-btn, .nav-cta {
    transform: translateZ(0);
    backface-visibility: hidden;
    /* will-change applied on hover/focus to avoid permanent GPU layer overhead */
}
.cta-btn:hover, .nav-cta:hover {
    will-change: transform;
}
/* Disable will-change when user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    .cta-btn, .nav-cta {
        will-change: auto;
    }
}

/* Enhanced Button Press Feedback */
button:active, .cta-btn:active, .nav-cta:active {
    transform: scale(0.97) translateZ(0);
    transition: transform 0.1s ease;
}

/* PWA Install Banner Styles */
#pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, var(--bg-secondary), rgba(22, 32, 64, 0.98));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 20px;
    padding-bottom: calc(20px + var(--safe-area-inset-bottom));
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#pwa-install-banner.visible {
    transform: translateY(0);
}

.install-banner-content {
    max-width: 600px;
    margin: 0 auto;
}

.install-banner-text {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.install-banner-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.install-banner-title {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.install-banner-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.install-banner-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.install-btn-dismiss, .install-btn-install {
    padding: 10px 20px;
    border-radius: 8px;
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.install-btn-dismiss {
    background: rgba(245, 239, 230, 0.1);
    color: var(--text-muted);
}

.install-btn-dismiss:active {
    background: rgba(245, 239, 230, 0.15);
}

.install-btn-install {
    background: var(--accent);
    color: var(--warm-white);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3);
}

.install-btn-install:active {
    background: var(--accent-glow);
    transform: scale(0.97);
}

/* Bottom Navigation Bar (Native Feel) */
.bottom-nav {
    position: fixed;
    top: auto !important; /* CRITICAL: Override generic 'nav' selector's top:0 from page styles */
    bottom: 0;
    left: 0;
    right: 0;
    height: auto; /* Prevent full-viewport stretch from top:0 + bottom:0 conflict */
    background: var(--bg-secondary);
    border-top: 1px solid rgba(139, 92, 246, 0.15);
    padding: 8px 0;
    padding-bottom: calc(8px + var(--safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    border-radius: 12px;
    min-width: 70px;
}

.bottom-nav-item:active {
    background: rgba(139, 92, 246, 0.1);
    transform: scale(0.95);
}

.bottom-nav-item.active {
    color: var(--accent);
}

.bottom-nav-item .nav-icon {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
    transition: all 0.3s ease;
}

.bottom-nav-item.active .nav-icon {
    animation: bounce 0.4s ease;
    stroke: url(#nav-gradient);
}

/* SVG Gradient for Active Nav Icons */
.bottom-nav::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Inline SVG gradient definition */
@supports (background: paint(something)) {
    .bottom-nav {
        --nav-gradient-start: #8B5CF6;
        --nav-gradient-end: #A78BFA;
    }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Add padding to body when bottom nav is present */
.has-bottom-nav {
    padding-bottom: calc(70px + var(--safe-area-inset-bottom));
}

/* Pull-to-Refresh Visual Feedback */
body {
    transition: transform 0.2s ease-out;
}

/* Skeleton Loading States */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        rgba(139, 92, 246, 0.1) 50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loading Spinner (Minimal) */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Swipe Gesture Feedback */
.swipeable {
    touch-action: pan-x;
    cursor: grab;
}

.swipeable:active {
    cursor: grabbing;
}

/* iOS Status Bar Styling */
.pwa-mode {
    padding-top: var(--safe-area-inset-top);
}

.pwa-mode .top-nav {
    top: var(--safe-area-inset-top);
}

/* Improved Form Inputs for Mobile */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 12px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 14px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 16px;
    width: 100%;
    transition: all 0.2s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Optimized for Dark/Light Theme Toggle */
[data-theme="light"] .bottom-nav {
    background: var(--bg-secondary);
    border-top-color: rgba(139, 92, 246, 0.1);
}

[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
    background: var(--warm-white);
    border-color: rgba(139, 92, 246, 0.15);
}

/* Responsive Bottom Nav - Hide on Desktop */
@media (min-width: 769px) {
    .bottom-nav {
        display: none;
    }

    .has-bottom-nav {
        padding-bottom: 0;
    }
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    /* Larger touch targets */
    .cta-btn {
        padding: 20px 40px;
        font-size: 1rem;
    }

    /* Better spacing for mobile */
    .hero {
        min-height: calc(100vh - var(--safe-area-inset-top));
    }

    /* Optimize font sizes for mobile readability */
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Better card spacing on mobile */
    .format-card, .stat, .step {
        padding: 32px 24px;
    }
}

/* Performance: Reduce animations when battery is low */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    button, .cta-btn, .nav-cta {
        border: 2px solid currentColor;
    }
}
