/* Shared Styles - Mobile Optimizations and Performance */

/* Screen Reader Only - for SEO and Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* FontAwesome Fallbacks for Mobile Devices */
.mobile-device.no-fontawesome .fa-phone::before {
    content: "📞";
}

.mobile-device.no-fontawesome .fa-envelope::before {
    content: "✉️";
}

.mobile-device.no-fontawesome .fa-map-marker-alt::before {
    content: "📍";
}

.mobile-device.no-fontawesome .fa-facebook::before {
    content: "👥";
}

.mobile-device.no-fontawesome .fa-instagram::before {
    content: "📷";
}

.mobile-device.no-fontawesome .fa-star::before {
    content: "⭐";
}

.mobile-device.no-fontawesome .fa-heart::before {
    content: "❤️";
}

.mobile-device.no-fontawesome .fa-check::before {
    content: "✓";
}

.mobile-device.no-fontawesome .fa-arrow-right::before {
    content: "→";
}

.mobile-device.no-fontawesome .fa-arrow-left::before {
    content: "←";
}

.mobile-device.no-fontawesome .fa-times::before {
    content: "✕";
}

.mobile-device.no-fontawesome .fa-bars::before {
    content: "☰";
}

/* Mobile Device Optimizations */
.mobile-device * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.mobile-device body {
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
}

/* Font Loading Strategy */
@font-face {
    font-family: 'Poppins-Fallback';
    src: local('Arial'), local('Helvetica'), local('sans-serif');
    font-display: swap;
    font-weight: 300 700;
    font-style: normal;
}

* {
    font-family: 'Poppins', 'Poppins-Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

.font-loading {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

.fonts-loaded * {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* Viewport Height Variables */
:root {
    --vh: 1vh;
    --mobile-vh: 100vh;
    --hero-header-offset: 80px;
}

/* iOS Safari Support and AOS Fix */
@supports(-webkit-touch-callout: none) {
    html {
        min-height: 100%; /* Changed from height to min-height */
        position: relative;
        overflow-x: hidden !important; /* Critical for AOS on iOS */
        overflow-y: visible !important; /* Allow vertical scrolling */
    }

    body {
        overscroll-behavior-y: none;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        position: relative;
        overflow-y: visible !important; /* Changed to visible */
        overflow-x: hidden !important; /* Critical for AOS on iOS */
        -webkit-overflow-scrolling: touch;
    }

    .hero-section {
        min-height: calc(var(--mobile-vh, 100vh) - env(safe-area-inset-top));
    }

    main {
        position: relative;
        z-index: 1;
        overflow-x: hidden !important; /* Prevent horizontal overflow from AOS */
        overflow-y: visible !important; /* Allow content to flow */
        min-height: auto !important; /* Remove height restrictions */
    }

    /* Ensure sections are not cut off */
    section {
        position: relative !important;
        overflow: visible !important;
    }
}

/* iOS-specific fixes - CRITICAL: Do NOT force opacity or transform */
.ios-device {
    overflow-x: clip !important; /* Modern approach that doesn't break scrolling */
    overflow-y: visible !important;
}

.ios-device body {
    overflow-x: clip !important; /* Prevents horizontal scroll */
    overflow-y: visible !important; /* Allows vertical scroll */
    min-height: 100vh !important;
}

/* CRITICAL: Let AOS handle animations - only ensure GPU acceleration */
.ios-device [data-aos] {
    -webkit-transform: translateZ(0); /* Force GPU acceleration */
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000px;
    perspective: 1000px;
}

/* Standard AOS fallback - DO NOT override on iOS */
[data-aos] {
    opacity: 0;
    transition-property: opacity, transform;
}

[data-aos].aos-animate {
    opacity: 1;
}

/* Base Touch Optimizations */
* {
    -webkit-tap-highlight-color: transparent;
}

html, body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Interactive Element Touch Actions */
button, a, .cursor-pointer, [role="button"], [onclick], .gallery-item, .modal-content {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.overflow-auto, .overflow-y-auto, .overflow-x-auto, .overflow-scroll {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.gm-style, .gm-style-iw, [id*="map"], [class*="map"] {
    touch-action: pan-x pan-y;
}

/* Box model handled by TailwindCSS base layer */

/* Parallax code removed - no longer used */

/* Hero Section Layout - Responsive Background Images */
.hero-section {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    min-height: var(--mobile-vh, 100vh);
    margin-top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-size: cover;
    background-position: center;
    background-color: transparent;
    background-repeat: no-repeat;
    /* Default fallback - smallest image */
    background-image: url('../assets/images/hero/c4s_hero_1366x768.webp');
}

/* Mobile Portrait (≤767px, portrait) - 414x816 */
@media (max-width: 767px) and (orientation: portrait) {
    .hero-section {
        background-image: url('../assets/images/hero/c4s_hero_414x816_portrait.webp');
    }
}

/* Mobile Landscape (≤767px, landscape) - 816x414 */
@media (max-width: 767px) and (orientation: landscape) {
    .hero-section {
        background-image: url('../assets/images/hero/c4s_hero_816x414.webp');
    }
}

/* Tablet (768px - 1279px) - 1366x768 */
@media (min-width: 768px) and (max-width: 1279px) {
    .hero-section {
        background-image: url('../assets/images/hero/c4s_hero_1366x768.webp');
    }
}

/* Desktop (1280px - 1919px) - 1366x768 */
@media (min-width: 1280px) and (max-width: 1919px) {
    .hero-section {
        background-image: url('../assets/images/hero/c4s_hero_1366x768.webp');
    }
}

/* Desktop Large (1920px - 2559px) - 1920x1080 */
@media (min-width: 1920px) and (max-width: 2559px) {
    .hero-section {
        background-image: url('../assets/images/hero/c4s_hero_1920x1080.webp');
    }
}

/* Desktop XL (≥2560px) - 2560x1440 */
@media (min-width: 2560px) {
    .hero-section {
        background-image: url('../assets/images/hero/c4s_hero_2560x1440.webp');
    }
}

/* Section backgrounds */
.section-bg-gray {
    background-color: #f9fafb;
}

/* Performance Optimization Classes */
.gpu-accelerated {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.gpu-accelerated-complex {
    transform: translateZ(0) translateX(0) translateY(0);
    -webkit-transform: translateZ(0) translateX(0) translateY(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Layout Utility Classes */
.overflow-hidden {
    overflow: hidden;
}

.overflow-x-hidden {
    overflow-x: hidden;
}

.overflow-y-hidden {
    overflow-y: hidden;
}

/* Global HTML/Body Optimizations */
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
    overscroll-behavior: none;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    position: relative;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Selectable Text Elements */
p, span, h1, h2, h3, h4, h5, h6, li, td, th, .selectable {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Performance Optimizations */
.gpu-accelerate {
    transform: translate3d(0, 0, 0);
    will-change: transform;
}

.hero-cta-button, .nav-link, button, a {
    will-change: transform, opacity;
}

.transition-transform, .transition-all {
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Button and Interactive Element Standards */
button, .nav-link, .hero-cta-button, a[role="button"], input[type="submit"], input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

button:active, .nav-link:active, a[role="button"]:active {
}

/* iOS Safari Specific Fixes - DISABLED TO FIX HEADER */
.ios-safari-disabled {
    position: fixed;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

.ios-safari-disabled body {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

/* Android Chrome Optimizations - use .gpu-accelerated class instead */
.android-chrome {
    will-change: scroll-position;
}

.android-chrome.keyboard-open {
    --vh: calc(var(--keyboard-height, 0px) * -1);
}

.android-chrome.keyboard-open .hero-section {
    height: 60vh;
    min-height: 60vh;
}

.android-chrome.low-memory * {
    animation-duration: 0.2s !important;
    transition-duration: 0.2s !important;
}

.android-chrome.low-memory .hero-cta-button {
    animation-duration: 0.3s !important;
    transition-duration: 0.3s !important;
}

.android-chrome.low-memory .timeline-item {
    animation: none !important;
}

.android-chrome .timeline-item,
.android-chrome .hero-cta-button,
.android-chrome .mobile-menu {
    -webkit-perspective: 1000px;
    perspective: 1000px;
}

.android-chrome body {
    scroll-behavior: auto;
    -webkit-overflow-scrolling: auto;
}

/* Animation Keyframes */
@keyframes fade-in {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse-gentle {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.animate-fade-in {
    animation: fade-in 0.8s ease-out forwards;
}

.animate-pulse-gentle {
    animation: pulse-gentle 2s ease-in-out infinite;
}

@keyframes scrollBackground {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.scrolling-background {
    background-size: 120% 120% !important;
    animation: scrollBackground 12s ease-in-out infinite;
}


/* Global Transition Defaults */
* {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}

a, button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

img {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease, box-shadow 0.4s ease;
}
