/* ============================================
   MOBILE RESPONSIVENESS FIXES - FINAL VERSION
   This file contains ALL mobile fixes
   Load AFTER styles.css
   ============================================ */

/* ===== PREVENT HORIZONTAL SCROLL ===== */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Prevent scroll anchoring issues */
* {
    overflow-anchor: none;
}

html {
    overflow-anchor: auto;
}

/* ===== RESPONSIVE IMAGES ===== */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== MODERN VIEWPORT UNITS FOR HERO ===== */
/* NOTE: These rules are scoped to mobile/tablet only to preserve desktop 70vh from styles.css */

/* Tablet and below (≤900px) - Apply viewport unit fixes */
@media (max-width: 900px) {
    /* Base hero - 100vh fallback for older browsers */
    .hero {
        height: 100vh;
        min-height: 500px;
    }

    /* Modern viewport units for iOS Safari - dvh accounts for dynamic toolbar */
    @supports (height: 100dvh) {
        .hero {
            height: 100dvh;
        }
    }

    /* Small viewport height for when keyboard is open or landscape */
    @supports (height: 100svh) {
        .hero {
            height: 100svh;
        }
    }

    /* iOS Safari specific fix for address bar */
    @supports (-webkit-touch-callout: none) {
        .hero {
            height: -webkit-fill-available;
        }
    }

    /* Contact page hero with plane */
    .hero-contact {
        min-height: 500px;
    }

    @supports (height: 100dvh) {
        .hero-contact {
            height: 65dvh;
        }
    }
}

/* ===== RESPONSIVE TYPOGRAPHY WITH CLAMP() ===== */

/* Hero heading - scales from 28px (mobile) to 80px (desktop) */
.hero h1 {
    font-size: clamp(1.75rem, 7vw, 5rem) !important;
    line-height: 1.1;
}

/* Hero paragraph - scales from 15px (mobile) to 23px (desktop) */
.hero p {
    font-size: clamp(0.9375rem, 3.5vw, 1.45rem) !important;
    line-height: 1.5;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

/* CTA heading - scales from 24px (mobile) to 38px (desktop) */
.cta-box h2,
.cta-section h2 {
    font-size: clamp(1.5rem, 5vw, 2.4rem) !important;
    line-height: 1.2;
}

/* CTA lead text - scales from 15px (mobile) to 18px (desktop) */
.lead-text,
.cta-box p {
    font-size: clamp(0.9375rem, 3vw, 1.15rem) !important;
    line-height: 1.65;
}

/* Headings */
h2 {
    font-size: clamp(1.75rem, 4.5vw, 2.5rem) !important;
    line-height: 1.2;
}

h3 {
    font-size: clamp(1.25rem, 3vw, 1.75rem) !important;
    line-height: 1.3;
}

/* Body text */
p, li {
    font-size: clamp(0.9375rem, 2vw, 1.05rem);
    line-height: 1.65;
}

/* ===== RESPONSIVE CONTAINERS ===== */
.cta-container,
.hero__content,
.container {
    width: 100%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    padding-left: clamp(1rem, 4vw, 3rem);
    padding-right: clamp(1rem, 4vw, 3rem);
}

/* ===== TAP-FRIENDLY BUTTONS (44px minimum) ===== */
.cta-button,
.btn-primary,
.whatsapp-cta,
.nav-cta,
.hero-cta-button,
.send-btn,
button[type="submit"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 24px;
    font-size: clamp(0.875rem, 2vw, 1.05rem);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}

/* ===== iOS SAFE AREA PADDING ===== */

/* Body safe area */
body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Hero content safe area */
.hero__content {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: env(safe-area-inset-bottom);
}

/* Navigation safe area */
.header-global {
    padding-left: max(30px, env(safe-area-inset-left));
    padding-right: max(30px, env(safe-area-inset-right));
}

/* Contact form safe area */
.contact-card,
.cta-box {
    padding-left: max(1.5rem, env(safe-area-inset-left));
    padding-right: max(1.5rem, env(safe-area-inset-right));
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

/* ===== PREVENT LAYOUT BREAKS ===== */

/* Long words shouldn't break layout */
.lead-text,
.cta-box p,
.testimonial-card blockquote,
p {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

/* Tables and code blocks */
table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

pre, code {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
}

/* ===== TABLET BREAKPOINT (≤900px) ===== */
@media (max-width: 900px) {
    
    /* Adjust hero height for tablets */
    .hero {
        height: auto;
        min-height: 60vh; /* Reduced from 65vh */
        max-height: 600px; /* Reduced from 700px */
    }
    
    /* Modern viewport units for tablets */
    @supports (height: 100dvh) {
        .hero {
            min-height: 60dvh;
        }
    }

    /* Contact hero */
    .hero-contact {
        min-height: 55vh;
    }

    /* Reduce section padding */
    section,
    .cta-section {
        padding: clamp(2.5rem, 8vw, 5rem) clamp(1rem, 4vw, 2rem) !important;
    }

    /* Stack grids on tablets */
    .testimonials-container,
    .trust-content,
    .differentiators-container,
    .categories-grid,
    .features-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Hide nav menu on tablets */
    .nav-menu {
        display: none;
    }
}

/* ===== MOBILE BREAKPOINT (≤600px) ===== */
@media (max-width: 600px) {

    /* ===== HERO SECTION ===== */
    .hero {
        height: auto !important;
        min-height: 70vh !important; /* Reduced from 85vh - much better on phones */
        max-height: none !important;
    }
    
    /* Modern viewport units for mobile - accounts for iOS Safari toolbar */
    @supports (height: 100dvh) {
        .hero {
            min-height: 70dvh !important;
        }
    }
    
    @supports (height: 100svh) {
        .hero {
            min-height: 70svh !important;
        }
    }

    /* Contact hero */
    .hero-contact {
        min-height: 60vh !important;
    }

    @supports (height: 100dvh) {
        .hero-contact {
            min-height: 60dvh !important;
        }
    }

    .hero__grid {
        grid-template-rows: 70% 30% !important;
    }

    .hero__content {
        padding: clamp(1rem, 3vw, 2rem) 1rem 0 !important;
        gap: 0.5rem;
    }

    /* Hide line breaks on mobile */
    .hero__content br {
        display: none;
    }

    /* Hero buttons */
    .hero .btn-primary,
    .hero-cta-button {
        width: min(280px, 90%) !important;
        padding: 14px 20px !important;
        font-size: 0.875rem !important;
        margin-top: 0.75rem;
    }

    /* ===== CTA SECTION ===== */
    .cta-section {
        padding: 3rem 1rem !important;
    }

    .cta-box {
        padding: 2.5rem 1.5rem !important;
        border-radius: 16px;
    }

    /* Fix text wrapping - prevent orphan words like "are." */
    .lead-text,
    .cta-box p {
        max-width: 500px !important;
        margin-left: auto;
        margin-right: auto;
        overflow-wrap: break-word;
        word-wrap: break-word;
        hyphens: auto;
    }

    /* CTA buttons */
    .cta-button,
    .whatsapp-cta {
        width: min(280px, 90%);
        padding: 14px 24px !important;
        font-size: 0.95rem !important;
    }

    /* ===== GENERAL MOBILE IMPROVEMENTS ===== */
    
    /* Section padding */
    section {
        padding: 2.5rem 1rem !important;
    }

    /* Card/Box padding */
    .testimonial-card,
    .differentiator-item,
    .feature-box,
    .category,
    .contact-card,
    .timeline-step {
        padding: 1.5rem !important;
    }

    /* Headings */
    h2 {
        font-size: clamp(1.5rem, 5vw, 2rem) !important;
        margin-bottom: 1rem;
    }

    h3 {
        font-size: clamp(1.1rem, 3.5vw, 1.3rem) !important;
        margin-bottom: 0.75rem;
    }

    /* Body text */
    p, li {
        font-size: clamp(0.875rem, 2.5vw, 1rem) !important;
        line-height: 1.6;
    }

    /* Images - ensure responsiveness */
    .hero__img,
    .logo-icon,
    img {
        max-width: 100%;
        height: auto;
    }

    /* Logo sizing */
    .logo-icon {
        height: 70px !important;
        margin-top: -10px;
        margin-bottom: -10px;
    }

    /* Navigation */
    .header-global {
        padding: 12px 16px !important;
    }

    .logo-text {
        font-size: 0.9rem !important;
        letter-spacing: 1px;
    }

    .nav-menu {
        display: none;
    }

    /* Form inputs - prevent iOS zoom */
    input,
    textarea,
    select {
        font-size: max(16px, 1rem) !important;
        padding: 12px !important;
    }
    
    /* iOS Safari specific input fix */
    @supports (-webkit-touch-callout: none) {
        input,
        textarea,
        select {
            font-size: max(16px, 1rem) !important;
        }
    }

    /* Form buttons */
    .send-btn,
    button[type="submit"] {
        width: 100%;
        padding: 14px !important;
        font-size: 1rem !important;
    }

    /* Contact page plane adjustment */
    .plane-container {
        bottom: -60px !important;
        max-width: 100% !important;
    }

    /* Footer adjustments */
    .footer-main {
        flex-direction: column;
        gap: 2rem;
        text-align: center;
    }

    .footer-left img {
        height: 80px !important;
        margin: 0 auto 0.75rem;
    }

    /* Testimonials */
    .testimonials-section {
        padding: 3rem 1rem !important;
    }

    .testimonials-intro,
    .testimonials-subtitle {
        font-size: clamp(0.875rem, 2.5vw, 1rem) !important;
    }

    .testimonial-card blockquote {
        font-size: clamp(0.9rem, 2.5vw, 1rem) !important;
    }

    .testimonial-author {
        font-size: 0.95rem !important;
    }

    .testimonial-company {
        font-size: 0.8rem !important;
    }

    /* Trust section */
    .trust-section {
        padding: 3rem 1rem !important;
    }

    .trust-item h3 {
        font-size: clamp(2rem, 8vw, 3rem) !important;
    }

    .trust-item p {
        font-size: clamp(0.9rem, 2.5vw, 1rem) !important;
    }

    /* Differentiators */
    .differentiators-section {
        padding: 3rem 1rem !important;
    }

    .differentiator-icon {
        width: 50px !important;
        height: 50px !important;
    }

    /* Product categories */
    .intro {
        padding: 2.5rem 1rem !important;
    }

    .category-icon {
        width: 40px !important;
        height: 40px !important;
    }

    .category ul li {
        font-size: clamp(0.875rem, 2.5vw, 0.95rem) !important;
    }

    /* About us / How we work */
    .welcome-section,
    .who-section,
    .why-section,
    .process-section {
        padding: 2.5rem 1rem !important;
    }

    .step-number {
        font-size: clamp(1.5rem, 6vw, 2rem) !important;
        width: 50px !important;
        height: 50px !important;
    }

    /* Contact form */
    .sand {
        padding: 3rem 1rem 4rem !important;
    }

    .contact-card {
        padding: 2rem 1.25rem !important;
    }

    .row {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    textarea {
        min-height: 120px !important;
    }

    /* Prefooter CTA */
    .prefooter-cta {
        padding: 3rem 1rem !important;
    }

    .prefooter-cta__box {
        padding: 2.5rem 1.5rem !important;
    }
}

/* ===== SMALL MOBILE (≤400px) ===== */
@media (max-width: 400px) {
    
    /* Extra small adjustments */
    .hero h1 {
        font-size: 1.65rem !important;
    }

    .hero p {
        font-size: 0.9rem !important;
    }

    .hero {
        min-height: 65vh !important;
    }

    @supports (height: 100dvh) {
        .hero {
            min-height: 65dvh !important;
        }
    }

    .cta-box,
    .contact-card {
        padding: 2rem 1rem !important;
    }

    .btn-primary,
    .cta-button {
        width: 95% !important;
        padding: 12px 16px !important;
        font-size: 0.8rem !important;
    }

    .testimonial-card,
    .differentiator-item,
    .feature-box,
    .category {
        padding: 1.25rem !important;
    }
}

/* ===== ACCESSIBILITY ===== */

/* Focus states for keyboard navigation */
a:focus,
button:focus,
input:focus,
textarea:focus {
    outline: 2px solid var(--orange, #d97634);
    outline-offset: 2px;
}

/* Better contrast on mobile */
@media (max-width: 600px) {
    .hero__content p,
    .hero p {
        text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .hero {
        height: auto;
        min-height: 500px;
    }
}

/* END MOBILE FIXES */
