/* ============================================
   APPLE-GRADE MOBILE OPTIMIZATIONS
   TBM Commercial Cleaning Website

   Targets: 375px - 768px viewports
   iOS minimum touch target: 44x44pt (48x48px for safety)
   Android minimum: 48x48dp

   Focus: Smooth 60fps animations, proper touch targets,
   stable layouts, accessible typography
   ============================================ */

/* ============================================
   LICENSE VISIBILITY FIX
   ============================================ */
@media (max-width: 768px) {
    /* Make license highly visible on mobile */
    .footer-bottom p {
        font-size: 0.9rem !important;
        line-height: 1.6 !important;
        color: rgba(255, 255, 255, 0.9) !important;
        font-weight: 500 !important;
        padding: 0.75rem 1rem;
        text-align: center;
    }

    /* Improve footer readability */
    .footer-section p,
    .footer-section li {
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
    }

    /* Footer links - ensure touch targets */
    .footer-section a {
        display: inline-block;
        padding: 10px 6px;
        margin: -10px -6px;
        min-height: 48px;
        display: flex;
        align-items: center;
    }
}

/* ============================================
   TOUCH TARGETS - iOS/Android Compliance
   Minimum: 48x48px for all interactive elements
   ============================================ */
@media (max-width: 768px) {
    /* All buttons */
    .btn,
    button,
    input[type="submit"],
    input[type="button"],
    a[class*="btn"],
    .btn-primary,
    .btn-secondary,
    .btn-large {
        min-height: 48px;
        min-width: 48px;
        padding: 14px 24px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Large action buttons */
    .btn-large,
    .btn-large-primary,
    .btn-large-secondary {
        min-height: 52px;
        padding: 16px 32px;
        font-size: 1.05rem;
    }

    /* Phone numbers - extra emphasis */
    a[href^="tel:"] {
        min-height: 52px;
        padding: 14px 16px;
        margin: -14px -16px;
        font-size: 1.1rem;
        font-weight: 700;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: rgba(0, 166, 81, 0.15);
    }

    /* Navigation menu items */
    .navbar-menu a,
    .navbar-menu li a {
        min-height: 48px;
        padding: 14px 16px;
        display: flex;
        align-items: center;
    }

    /* Form inputs */
    input,
    textarea,
    select,
    .form-input,
    .form-textarea,
    .form-select {
        min-height: 48px;
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 14px 16px;
    }

    /* Preset cards and interactive cards */
    .preset-card,
    .response-option {
        min-height: 80px;
        padding: 16px 12px;
    }
}

/* ============================================
   60FPS ANIMATIONS - Hardware Acceleration
   ============================================ */

/* Force GPU acceleration */
.btn,
.card,
.feature-card-modern,
.pricing-card,
.floating-quote-btn,
.preset-card,
.response-option,
video {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
}

/* Optimized easing curves - Apple's standard */
.btn,
button,
a,
.preset-card,
.response-option {
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card,
.feature-card-modern,
.step-card {
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Active states - instant feedback */
.btn:active,
button:active,
.preset-card:active,
.response-option:active {
    transform: scale(0.97);
    transition: all 100ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Floating button active state */
.floating-quote-btn:active {
    transform: translateY(0) scale(0.95);
    transition: all 100ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   SMOOTH VIDEO PLAYBACK
   ============================================ */
video {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    max-width: 100%;
    height: auto;
    display: block;
}

/* Video containers - stable aspect ratio */
[style*="padding-bottom: 56.25%"] {
    will-change: transform;
    transform: translateZ(0);
}

/* ============================================
   TYPOGRAPHY - Legible & Scalable
   ============================================ */
@media (max-width: 768px) {
    /* Base font size */
    html {
        font-size: 16px;
    }

    /* Headings - readable hierarchy */
    h1 {
        font-size: 2rem;
        line-height: 1.2;
        margin-bottom: 1rem;
    }

    h2 {
        font-size: 1.75rem;
        line-height: 1.25;
        margin-bottom: 0.875rem;
    }

    h3 {
        font-size: 1.4rem;
        line-height: 1.3;
    }

    h4 {
        font-size: 1.2rem;
    }

    /* Body text - comfortable reading */
    p {
        font-size: 1rem;
        line-height: 1.65;
        margin-bottom: 1rem;
    }

    /* Section titles */
    .section-title {
        font-size: 1.875rem;
        line-height: 1.25;
    }

    .section-subtitle {
        font-size: 1.05rem;
        line-height: 1.6;
    }

    /* Hero titles */
    .hero h1,
    .hero-title {
        font-size: 2.25rem;
        line-height: 1.2;
    }

    .hero p,
    .hero-subtitle {
        font-size: 1.1rem;
        line-height: 1.6;
    }
}

/* ============================================
   LAYOUT STABILITY - Prevent Wobbling
   ============================================ */

/* Prevent horizontal overflow */
html,
body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

@media (max-width: 768px) {
    /* Container stability */
    .container,
    .container-narrow,
    .container-wide {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
        max-width: 100%;
        width: 100%;
    }

    /* Grid stability */
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        width: 100%;
        max-width: 100%;
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    /* Prevent text overflow */
    h1, h2, h3, h4, h5, h6, p, li, a {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        max-width: 100%;
    }

    /* Section padding optimization */
    section,
    .section {
        padding: 2.5rem 0;
    }

    /* Hero section */
    .hero,
    .hero-modern,
    .modern-hero {
        padding: 3rem 0 2.5rem;
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    /* Disable expensive hover effects */
    .card:hover,
    .feature-card-modern:hover,
    .pricing-card:hover,
    .testimonial-modern:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Simplify shadows */
    .card,
    .feature-card-modern,
    .pricing-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Optimize images */
    img {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        transform: translateZ(0);
        max-width: 100%;
        height: auto;
    }

    /* Remove complex animations */
    .fade-in,
    [class*="animate"] {
        animation: none !important;
    }
}

/* ============================================
   TRUST STATS - Mobile Stack
   ============================================ */
@media (max-width: 768px) {
    .trust-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
        padding: 1.25rem 1rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.85rem;
        line-height: 1.4;
    }
}

@media (max-width: 480px) {
    .trust-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* ============================================
   FORMS - Mobile Optimized
   ============================================ */
@media (max-width: 768px) {
    /* Form groups */
    .form-group {
        margin-bottom: 1.25rem;
    }

    /* Labels */
    .form-label {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: #1f2937;
    }

    /* Input fields */
    input,
    textarea,
    select {
        font-size: 16px !important;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 8px;
    }

    /* Textarea */
    textarea {
        min-height: 120px;
    }

    /* Form buttons full width */
    .form-group .btn,
    form .btn {
        width: 100%;
    }
}

/* ============================================
   ACCESSIBILITY - Motion & Contrast
   ============================================ */

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Smooth scrolling for those who prefer it */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Focus states - keyboard navigation */
:focus-visible {
    outline: 2px solid #00a651;
    outline-offset: 3px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary {
        border: 2px solid #000;
    }

    a {
        text-decoration: underline;
    }
}

/* ============================================
   TAP HIGHLIGHT - Platform Feel
   ============================================ */
button,
a,
input[type="submit"],
input[type="button"],
.btn,
.card,
.preset-card,
.response-option {
    -webkit-tap-highlight-color: rgba(0, 166, 81, 0.15);
    -webkit-touch-callout: none;
}

/* ============================================
   FLOATING ACTION BUTTON - Enhanced
   ============================================ */
@media (max-width: 768px) {
    .floating-quote-btn {
        bottom: 24px;
        right: 20px;
        padding: 16px 24px;
        min-height: 52px;
        min-width: 52px;
        font-size: 1rem;
        font-weight: 700;
        box-shadow: 0 4px 20px rgba(0, 166, 81, 0.4);
        z-index: 9999;
    }

    .floating-quote-btn:active {
        transform: translateY(0) scale(0.95);
    }
}

/* ============================================
   CTA SECTIONS - Mobile Optimized
   ============================================ */
@media (max-width: 768px) {
    /* CTA buttons stack on mobile */
    .hero-cta,
    .hero-cta-group,
    .cta-buttons {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    .hero-cta .btn,
    .hero-cta-group .btn,
    .cta-buttons .btn {
        width: 100%;
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Phone number displays */
    a[href^="tel:"][style*="font-size: 2.5rem"],
    [style*="font-size: 2.5rem"] a[href^="tel:"] {
        font-size: 2rem !important;
    }
}

/* ============================================
   PRICING CARDS - Mobile Stack
   ============================================ */
@media (max-width: 768px) {
    .pricing-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .pricing-card {
        padding: 2rem 1.5rem;
    }
}

/* ============================================
   TESTIMONIALS - Mobile Friendly
   ============================================ */
@media (max-width: 768px) {
    .testimonial-card,
    .testimonial-modern {
        padding: 1.5rem;
        margin-bottom: 1.25rem;
    }

    .testimonial-text,
    .testimonial-text-modern {
        font-size: 1rem;
        line-height: 1.65;
    }
}

/* ============================================
   SAFE AREA INSETS - iPhone X+ Support
   ============================================ */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .floating-quote-btn {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: max(20px, env(safe-area-inset-right));
    }

    .navbar {
        padding-top: max(0px, env(safe-area-inset-top));
    }
}

/* ============================================
   PREVENT LAYOUT SHIFT
   ============================================ */
img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* Reserve space for images to prevent shift */
img[width][height] {
    height: auto;
}

/* ============================================
   DARK MODE SUPPORT (Optional Enhancement)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Respect user's dark mode preference if desired */
    /* Currently disabled - can be enabled per client request */
}

/* ============================================
   CONTACT PAGE MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    /* Fleet photo - better visibility on mobile */
    img[src*="tbm-van-headquarters"],
    img[alt*="TBM Commercial Cleaning service van"] {
        max-width: 100% !important;
        min-height: 250px;
        object-fit: cover;
        filter: brightness(1.1) contrast(1.15) saturate(1.1) !important;
        box-shadow: 0 6px 20px rgba(0,0,0,0.2) !important;
    }

    /* Button container spacing - always use flexbox with gap */
    div[style*="margin-top: 3rem"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        align-items: stretch !important;
    }

    /* Ensure buttons are full width on mobile */
    div[style*="margin-top: 3rem"] .btn,
    div[style*="margin-top: 3rem"] a[class*="btn"] {
        width: 100% !important;
        margin: 0 !important;
        text-align: center;
    }
}
