/* Mobile-First Optimization CSS for TeleHub */
/* Base styles are for mobile, then enhanced for larger screens */

/* ============================================
   BASE MOBILE STYLES (Default - Mobile First)
   ============================================ */

/* Reset and Base */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-size: 14px; /* Mobile base font size */
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Container and Layout - Mobile First */
#SITE_CONTAINER,
#site-root,
#masterPage {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* Wix-specific Mobile Optimizations - CRITICAL FIXES */
/* Force full width on ALL mobile devices - Maximum specificity */
html body.device-mobile-optimized #SITE_CONTAINER,
html body.device-mobile-optimized:not(.responsive) #SITE_CONTAINER,
html body #SITE_CONTAINER,
body.device-mobile-optimized #SITE_CONTAINER,
body.device-mobile-optimized:not(.responsive) #SITE_CONTAINER,
body:not(.responsive) #SITE_CONTAINER,
#SITE_CONTAINER {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
}

html body.device-mobile-optimized #site-root,
html body.device-mobile-optimized:not(.responsive) #site-root,
html body:not(.responsive) #site-root,
html body #site-root,
body.device-mobile-optimized #site-root,
body.device-mobile-optimized:not(.responsive) #site-root,
body:not(.responsive) #site-root,
body #site-root,
#site-root {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
}

body:not(.responsive) #site-root,
body #site-root {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Force responsive behavior */
body.device-mobile-optimized,
body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
}

body.device-mobile-optimized #SITE_CONTAINER,
body.device-mobile-optimized #site-root,
body.device-mobile-optimized #masterPage,
#SITE_CONTAINER,
#site-root,
#masterPage {
    overflow-x: hidden !important;
}

/* Override Wix's 320px fixed width */
@media screen and (max-width: 768px) {
    body.device-mobile-optimized:not(.responsive) #SITE_CONTAINER {
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
    }
    
    body:not(.responsive) #site-root {
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Force all containers to full width */
    #SITE_CONTAINER,
    #site-root,
    #masterPage {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
    
    /* Override any inline styles */
    [style*="width: 320px"],
    [style*="width:320px"],
    [style*="min-width: 320px"],
    [style*="min-width:320px"] {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

/* Images - Mobile First */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

img[width],
img[height] {
    max-width: 100% !important;
    height: auto !important;
}

/* Videos - Mobile First */
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* Tables - Mobile First */
table {
    width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Typography - Mobile First */
h1 {
    font-size: 1.5rem;
    line-height: 1.2;
    margin: 0.5em 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

h2 {
    font-size: 1.25rem;
    line-height: 1.3;
    margin: 0.5em 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

h3 {
    font-size: 1.125rem;
    line-height: 1.4;
    margin: 0.5em 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

h4, h5, h6 {
    font-size: 1rem;
    line-height: 1.4;
    margin: 0.5em 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

p, span, div, a {
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 0.95rem;
}

/* Buttons and Links - Mobile First */
button,
a,
input[type="button"],
input[type="submit"] {
    min-height: 44px; /* Minimum touch target size */
    min-width: 44px;
    touch-action: manipulation;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 20px;
    width: 100%;
    max-width: 100%;
    display: block;
    text-align: center;
}

a.button,
.cta-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    font-size: 1rem;
    width: 100%;
    max-width: 100%;
}

/* Forms - Mobile First */
input,
textarea,
select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Content Containers - Mobile First */
.content,
.container,
.wrapper {
    width: 100%;
    max-width: 100%;
    padding: 15px;
    box-sizing: border-box;
    margin: 0 auto;
}

section {
    padding: 20px 15px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Grid and Flex Containers - Mobile First */
[data-mesh-id$="-gridContainer"],
[data-mesh-id$="-gridWrapper"],
.grid-container,
.flex-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    display: block;
}

/* Navigation - Mobile First */
nav,
.menu,
.navigation {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Wix Components - Mobile First */
#comp-m43h0tvx,
#comp-m43h0tvy,
[id^="comp-"],
[data-mesh-id] {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Fix for fixed width elements */
[style*="width"],
[style*="min-width"] {
    max-width: 100% !important;
}

/* Fix for absolute positioned elements */
[style*="position: absolute"],
[style*="position:fixed"] {
    max-width: 100vw;
}

/* Prevent horizontal scroll */
html,
body {
    overflow-x: hidden !important;
    position: relative;
    width: 100%;
    max-width: 100vw;
}

/* ============================================
   PROGRESSIVE ENHANCEMENT FOR LARGER SCREENS
   ============================================ */

/* Small phones (320px+) - Already covered by base */
/* No changes needed - base styles are for mobile */

/* Large phones / Small tablets (481px and up) */
@media screen and (min-width: 481px) {
    html {
        font-size: 15px;
    }
    
    body {
        font-size: 15px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    .content,
    .container {
        padding: 20px;
    }
    
    button,
    a.button,
    .cta-button {
        padding: 14px 28px;
        font-size: 1.05rem;
        width: auto;
        max-width: none;
        display: inline-flex;
    }
}

/* Tablets (769px and up) */
@media screen and (min-width: 769px) {
    html {
        font-size: 16px;
    }
    
    body {
        font-size: 16px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
    
    p, span, div, a {
        font-size: 1rem;
    }
    
    .content,
    .container {
        max-width: 600px;
        padding: 30px;
    }
    
    button,
    a.button,
    .cta-button {
        padding: 16px 32px;
        font-size: 1.1rem;
    }
    
    /* Enable grid layouts on tablets */
    .grid-container,
    .flex-container {
        display: grid;
    }
}

/* Desktop (1024px and up) */
@media screen and (min-width: 1024px) {
    .content,
    .container {
        max-width: 800px;
        padding: 40px;
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    h2 {
        font-size: 2rem;
    }
    
    h3 {
        font-size: 1.75rem;
    }
    
    button,
    a.button,
    .cta-button {
        padding: 18px 40px;
        font-size: 1.2rem;
    }
}

/* Large Desktop (1440px and up) */
@media screen and (min-width: 1440px) {
    .content,
    .container {
        max-width: 1200px;
    }
}

/* ============================================
   SPECIAL CASES
   ============================================ */

/* Landscape orientation on mobile */
@media screen and (orientation: landscape) and (max-height: 500px) {
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 1.4rem;
    }
    
    .content {
        padding: 15px 20px;
    }
}

/* High DPI displays */
@media screen and (-webkit-min-device-pixel-ratio: 2),
       screen and (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    button:hover,
    a:hover {
        /* Remove hover effects on touch devices */
    }
    
    button:active,
    a:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* Print styles */
@media print {
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a,
    a:visited {
        text-decoration: underline;
    }
    
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}

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