/* =====================================================
   MOBILE ENHANCEMENTS - Clearview Screens & Liberty Awnings
   Style C: Card-Based Navigation with Product Images
   Updated: Image preloading & loading states
   ===================================================== */

/* =============================================
   DESKTOP STYLES - Company Name in Header
   ============================================= */
@media (min-width: 769px) {
    header {
        height: auto !important;
        min-height: 45px !important;
        padding: 10px 20px !important;
    }
    
    .header-content {
        gap: 15px !important;
    }
    
    .logo {
        display: flex !important;
        align-items: center !important;
        gap: 20px !important;
        text-decoration: none !important;
    }
    
    .logo-img {
        height: 65px !important;
        width: auto !important;
        margin-top: 0 !important;
    }
    
    .company-name-desktop {
        display: flex !important;
        align-items: center !important;
        flex: 1 !important;
        height: 80px !important;
        margin-left: 15px !important;
        margin-right: 20px !important;
    }
    
    .company-name-desktop img {
        height: 70px !important;
        width: auto !important;
        max-width: 100% !important;
        object-fit: contain !important;
    }
    
    .mobile-company-name {
        display: none !important;
    }
    
    .logo-text {
        display: none !important;
    }
    
    .mobile-sticky-cta {
        display: none !important;
    }
    
    .mobile-quote-btn {
        display: none !important;
    }
}

/* =============================================
   MOBILE STYLES
   ============================================= */
@media (max-width: 768px) {
    
    /* Touch optimization - remove 300ms tap delay */
    a, button, .nav-card, .menu-toggle {
        touch-action: manipulation !important;
    }
    
    /* Header */
    header {
        padding: 8px 12px !important;
        height: auto !important;
        min-height: 45px !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        background: #ffffff !important;
    }
    
    /* Tagline Banner - Mobile */
    .tagline-banner {
        position: fixed !important;
        top: 55px !important;
        left: 0 !important;
        right: 0 !important;
        background: linear-gradient(135deg, #0f2840 0%, #1a3a5c 100%) !important;
        color: #ffffff !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 8px 10px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        z-index: 999 !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.15) !important;
    }
    
    .tagline-banner span {
        white-space: nowrap !important;
    }
    
    .tagline-banner .divider {
        color: #c9a227 !important;
        font-size: 8px !important;
    }
    
    .header-content {
        flex-wrap: nowrap !important;
        gap: 0 !important;
        justify-content: space-between !important;
        align-items: center !important;
        display: flex !important;
        position: relative !important;
    }
    
    .logo {
        display: flex !important;
        align-items: center !important;
        gap: 0 !important;
        flex: 0 0 auto !important;
        min-width: 0 !important;
        text-decoration: none !important;
        z-index: 2 !important;
    }
    
    .logo-img {
        height: 45px !important;
        width: auto !important;
        margin-top: 0 !important;
        flex-shrink: 0 !important;
    }
    
    /* Mobile company name - centered between logo and Free Quote button */
    .mobile-company-name {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: absolute !important;
        left: 55px !important; /* After logo */
        right: 58px !important; /* Before Free Quote button (45px + 8px right + 5px gap) */
        top: 50% !important;
        transform: translateY(-50%) !important;
        height: 60px !important;
        z-index: 1 !important;
        padding: 0 5px !important;
    }
    
    .mobile-company-name img {
        height: auto !important;
        width: 100% !important;
        max-height: 60px !important;
        object-fit: contain !important;
    }
    
    .company-name-desktop {
        display: none !important;
    }
    
    .logo-text {
        display: none !important;
    }
    
    /* =============================================
       MOBILE FREE QUOTE BUTTON (Top Right)
       Square, light grey, glow animation
       ============================================= */
    
    .mobile-quote-btn {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        position: absolute !important;
        right: 8px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 48px !important;
        height: 48px !important;
        background: #e5e5e5 !important;
        border-radius: 0 !important;
        text-decoration: none !important;
        z-index: 1003 !important;
        box-shadow: 
            4px 4px 0px #1a3a5c,
            0 4px 10px rgba(0, 0, 0, 0.4) !important;
        border: 2px solid #1a3a5c !important;
        animation: quoteButtonGlow 1.5s ease-in-out infinite !important;
    }
    
    .mobile-quote-btn:active {
        transform: translateY(-50%) scale(0.95) !important;
        animation: none !important;
    }
    
    .mobile-quote-btn .quote-text-free {
        font-size: 11px !important;
        font-weight: 900 !important;
        color: #dc2626 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        line-height: 1.2 !important;
    }
    
    .mobile-quote-btn .quote-text-quote {
        font-size: 10px !important;
        font-weight: 800 !important;
        color: #1a3a5c !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        line-height: 1.2 !important;
    }
    
    @keyframes quoteButtonGlow {
        0%, 100% {
            box-shadow: 
                4px 4px 0px #1a3a5c,
                0 4px 10px rgba(0, 0, 0, 0.4),
                0 0 0px rgba(220, 38, 38, 0);
        }
        50% {
            box-shadow: 
                4px 4px 0px #1a3a5c,
                0 4px 10px rgba(0, 0, 0, 0.4),
                0 0 20px rgba(220, 38, 38, 0.8),
                0 0 40px rgba(220, 38, 38, 0.4);
        }
    }
    
    /* =============================================
       HAMBURGER MENU - HIDDEN (using bottom CTA menu)
       ============================================= */
    
    .menu-toggle {
        display: none !important;
    }
    
    /* Original hamburger styles kept for reference
    .menu-toggle {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 5px !important;
        padding: 12px !important;
        cursor: pointer !important;
        z-index: 1002 !important;
        background: transparent !important;
        border: none !important;
        margin-left: auto !important;
        flex-shrink: 0 !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    */
    
    .menu-toggle span {
        display: none !important;
    }
    
    .menu-toggle.active span:nth-child(1),
    .menu-toggle.active span:nth-child(2),
    .menu-toggle.active span:nth-child(3) {
        display: none !important;
    }
    
    /* =============================================
       STYLE C: CARD-BASED NAVIGATION WITH IMAGES
       ============================================= */
    
    nav {
        display: none !important;
        position: fixed !important;
        top: 90px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 70px !important;
        background: #faf8f3 !important;
        background-color: #faf8f3 !important;
        flex-direction: column !important;
        padding: 15px !important;
        overflow-y: auto !important;
        z-index: 998 !important;
        -webkit-overflow-scrolling: touch !important;
        /* Ensure fully opaque */
        opacity: 1 !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }
    
    nav.active {
        display: block !important;
    }
    
    /* Solid backdrop behind nav when menu is open */
    nav.active::before {
        content: '' !important;
        position: fixed !important;
        top: 90px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 70px !important;
        background: #faf8f3 !important;
        z-index: -1 !important;
    }
    
    /* Grid Layout for Cards - 8 cards filling the space */
    .nav-card-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: repeat(4, 1fr) !important;
        gap: 12px !important;
        padding: 10px 0 !important;
        height: calc(100vh - 180px) !important;
        min-height: 400px !important;
        background: #faf8f3 !important;
        position: relative !important;
        z-index: 10 !important;
    }
    
    /* Individual Navigation Cards with Background Images */
    .nav-card {
        background: #1a3a5c !important;
        border-radius: 12px !important;
        overflow: hidden !important;
        text-decoration: none !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
        transition: transform 0.2s ease, border-color 0.2s ease !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        border: 2px solid transparent !important;
        padding: 0 !important;
        position: relative !important;
        min-height: 45px !important;
        /* GPU acceleration for smooth animations */
        transform: translateZ(0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        will-change: transform !important;
    }
    
    /* Background image layer */
    .nav-card-bg {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background-size: cover !important;
        background-position: center !important;
        z-index: 1 !important;
    }
    
    /* Dark overlay for text readability */
    .nav-card-overlay {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: linear-gradient(135deg, rgba(15, 40, 64, 0.7) 0%, rgba(26, 58, 92, 0.6) 100%) !important;
        z-index: 2 !important;
        transition: all 0.2s ease !important;
    }
    
    /* Hover & Active States */
    .nav-card:hover {
        border-color: #c9a227 !important;
        box-shadow: 0 4px 15px rgba(26, 58, 92, 0.25) !important;
    }
    
    .nav-card:hover .nav-card-overlay {
        background: linear-gradient(135deg, rgba(15, 40, 64, 0.5) 0%, rgba(26, 58, 92, 0.4) 100%) !important;
    }
    
    /* Enhanced tap/active state for mobile */
    .nav-card:active {
        transform: scale(0.97) !important;
        border-color: #c9a227 !important;
    }
    
    .nav-card:active .nav-card-overlay {
        background: linear-gradient(135deg, rgba(201, 162, 39, 0.8) 0%, rgba(184, 148, 31, 0.7) 100%) !important;
    }
    
    .nav-card:active .nav-card-title {
        color: #0f2840 !important;
    }
    
    /* Card Content */
    .nav-card-content {
        padding: 15px 10px !important;
        text-align: center !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: 100% !important;
        position: relative !important;
        z-index: 3 !important;
    }
    
    /* Card Title - White text on dark background, LARGE for older users */
    .nav-card-title {
        font-size: 20px !important;
        font-weight: 700 !important;
        color: #ffffff !important;
        line-height: 1.3 !important;
        text-transform: none !important;
        letter-spacing: 0 !important;
        margin: 0 !important;
        text-shadow: 1px 1px 3px rgba(0,0,0,0.5) !important;
    }
    
    .nav-card:hover .nav-card-title {
        color: #ffffff !important;
    }
    
    /* Hide default nav links - we're replacing with cards */
    nav > a {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        pointer-events: none !important;
    }
    
    /* Also hide any stray text nodes */
    nav {
        font-size: 0 !important;
    }
    
    .nav-card-grid {
        font-size: 16px !important;
    }
    
    /* =============================================
       STICKY CTA BUTTONS (3 buttons: Call, Text, Quote)
       American Colors: Red, White, Blue
       ============================================= */
    
    .floating-call {
        display: none !important;
    }
    
    .mobile-sticky-cta {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        display: flex !important;
        z-index: 1001 !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15) !important;
        background: #ffffff !important;
        border-top: 1px solid #e5e5e5 !important;
        /* GPU acceleration for smoother animations */
        transform: translateZ(0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
    }
    
    .mobile-sticky-cta a,
    .mobile-sticky-cta button {
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        padding: 16px 8px !important;
        font-size: 14px !important;
        font-weight: 700 !important;
        text-decoration: none !important;
        text-align: center !important;
        transition: none !important; /* Remove transitions for instant feedback */
        font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif !important;
        border: none !important;
        cursor: pointer !important;
        /* CRITICAL: Prevent tap delay on mobile */
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
        /* GPU acceleration for instant response */
        will-change: transform, background-color !important;
        transform: translateZ(0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        /* Larger touch target */
        min-height: 56px !important;
        /* Ensure nothing blocks the button */
        position: relative !important;
        z-index: 1 !important;
        /* iOS fix for button styling */
        -webkit-appearance: none !important;
        appearance: none !important;
        outline: none !important;
    }
    
    /* Tapped state - instant visual feedback */
    .mobile-sticky-cta .cta-call.tapped {
        background: linear-gradient(135deg, #8a0722 0%, #6d051a 100%) !important;
        transform: scale(0.95) translateZ(0) !important;
    }
    
    .mobile-sticky-cta .cta-text.tapped {
        background: linear-gradient(135deg, #e0e0e0 0%, #d0d0d0 100%) !important;
        transform: scale(0.95) translateZ(0) !important;
    }
    
    .mobile-sticky-cta .cta-quote.tapped {
        background: linear-gradient(135deg, #001838 0%, #000f28 100%) !important;
        transform: scale(0.95) translateZ(0) !important;
    }
    
    /* Call Button - American Red */
    .mobile-sticky-cta .cta-call {
        background: linear-gradient(135deg, #bf0a30 0%, #a00928 100%) !important;
        color: #ffffff !important;
    }
    
    .mobile-sticky-cta .cta-call:active {
        background: linear-gradient(135deg, #a00928 0%, #8a0722 100%) !important;
        transform: scale(0.97) !important;
    }
    
    .mobile-sticky-cta .cta-call svg {
        width: 18px !important;
        height: 18px !important;
        fill: none !important;
        stroke: currentColor !important;
        stroke-width: 2 !important;
        animation: phonePulse 2s infinite !important;
    }
    
    /* Text Button - White with Navy text */
    .mobile-sticky-cta .cta-text {
        background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%) !important;
        color: #002868 !important;
        border-left: 1px solid #e0e0e0 !important;
        border-right: 1px solid #e0e0e0 !important;
    }
    
    .mobile-sticky-cta .cta-text:active {
        background: linear-gradient(135deg, #f0f0f0 0%, #e5e5e5 100%) !important;
        transform: scale(0.97) !important;
    }
    
    .mobile-sticky-cta .cta-text svg {
        width: 18px !important;
        height: 18px !important;
        fill: none !important;
        stroke: currentColor !important;
        stroke-width: 2 !important;
    }
    
    /* Quote Button - American Blue */
    .mobile-sticky-cta .cta-quote {
        background: linear-gradient(135deg, #002868 0%, #001f4f 100%) !important;
        color: #ffffff !important;
    }
    
    .mobile-sticky-cta .cta-quote:active {
        background: linear-gradient(135deg, #001f4f 0%, #001838 100%) !important;
        transform: scale(0.97) !important;
    }
    
    .mobile-sticky-cta .cta-quote svg {
        width: 16px !important;
        height: 16px !important;
        fill: none !important;
        stroke: currentColor !important;
        stroke-width: 2 !important;
    }
    
    /* Menu Button - Navy Blue with hamburger lines */
    .mobile-sticky-cta .cta-menu {
        background: #1a3a5c !important;
        color: #ffffff !important;
        flex-direction: row !important;
        gap: 8px !important;
    }
    
    .mobile-sticky-cta .cta-menu:active {
        background: #0f2840 !important;
        transform: scale(0.97) !important;
    }
    
    .mobile-sticky-cta .cta-menu .menu-lines {
        display: flex !important;
        flex-direction: column !important;
        gap: 3px !important;
    }
    
    .mobile-sticky-cta .cta-menu .menu-lines span {
        display: block !important;
        width: 18px !important;
        height: 2px !important;
        background: #ffffff !important;
        border-radius: 1px !important;
    }
    
    @keyframes phonePulse {
        0%, 100% { transform: scale(1); }
        50% { transform: scale(1.1); }
    }
    
    /* =============================================
       BODY ADJUSTMENTS - CRITICAL FOR SCROLLING
       ============================================= */
    
    html, body {
        overflow-x: clip !important;
        height: auto !important;
        min-height: 100% !important;
    }
    
    html {
        overflow-y: scroll !important;
    }
    
    body {
        padding-top: 95px !important;
        padding-bottom: 70px !important;
        overflow-y: visible !important;
        position: static !important;
    }
    
    body.menu-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        left: 0 !important;
    }
    
    /* Hide all page content when menu is open */
    body.menu-open main,
    body.menu-open section,
    body.menu-open .hero,
    body.menu-open .page-hero,
    body.menu-open .product-content,
    body.menu-open .services,
    body.menu-open .about-us,
    body.menu-open .testimonials,
    body.menu-open .service-areas,
    body.menu-open footer,
    body.menu-open .top-bar {
        visibility: hidden !important;
        opacity: 0 !important;
    }
    
    /* Fix hero heights that block scrolling */
    .hero {
        margin-top: 0 !important;
        height: auto !important;
        min-height: 400px !important;
        max-height: none !important;
    }
    
    /* Hide hero buttons on mobile - redundant with sticky CTA */
    .hero-buttons {
        display: none !important;
    }
    
    .page-hero {
        margin-top: 0 !important;
        height: auto !important;
        min-height: 300px !important;
    }
    
    /* Ensure all content sections are visible and scrollable */
    .product-content,
    .services,
    .about-us,
    .testimonials,
    .service-areas,
    main,
    section {
        overflow: visible !important;
        position: relative !important;
        height: auto !important;
    }
    
    footer {
        margin-bottom: 0 !important;
        padding-bottom: 90px !important;
        position: relative !important;
        overflow: visible !important;
    }
    
    /* =============================================
       HERO TAGLINE BANNER - Mobile Layout
       Product name left, tagline right, shrunk height
       ============================================= */
    .hero-tagline-banner {
        padding: 6px 10px !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 10px !important;
    }
    
    /* Product name container (for landing page rotating names) */
    .product-name-container {
        position: static !important;
        transform: none !important;
        flex-shrink: 0 !important;
    }
    
    /* Product name label */
    .product-name-label {
        position: static !important;
        transform: none !important;
        font-size: 14px !important;
        padding: 4px 10px !important;
        flex-shrink: 0 !important;
        display: block !important;
    }
    
    /* For landing page only - hide inactive rotating names, show active */
    .product-name-container .product-name-label {
        display: none !important;
    }
    
    .product-name-container .product-name-label.active {
        display: block !important;
    }
    
    /* Tagline container */
    .tagline-container {
        height: auto !important;
        min-height: auto !important;
        text-align: right !important;
        flex-grow: 1 !important;
        position: static !important;
        width: auto !important;
    }
    
    /* Tagline slides */
    .tagline-slide {
        font-size: 12px !important;
        white-space: nowrap !important;
        display: none !important;
        position: static !important;
        transform: none !important;
        left: auto !important;
        top: auto !important;
        width: auto !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .tagline-slide.active {
        display: inline-block !important;
    }
    
    /* Highlighted word - bigger and bolder */
    .tagline-slide .highlight {
        font-size: 16px !important;
        font-weight: 700 !important;
    }
}

/* =============================================
   ENHANCEMENT STYLES (All Screen Sizes)
   ============================================= */

/* Page Loader */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.page-loader.loaded {
    opacity: 0;
    pointer-events: none;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e5e5;
    border-top-color: #1a3a5c;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #1a3a5c 0%, #0f2840 100%);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(26, 58, 92, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 998;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: linear-gradient(135deg, #c9a227 0%, #b8941f 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(201, 162, 39, 0.4);
}

.back-to-top:active {
    transform: translateY(0);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
}

/* Form Validation Feedback */
.form-group {
    position: relative;
}

.validation-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.form-group.valid .validation-icon {
    opacity: 1;
    color: #22c55e;
}

.form-group.invalid .validation-icon {
    opacity: 1;
    color: #ef4444;
}

.form-group.invalid .validation-icon::after {
    content: '✗';
}

.form-group.valid .validation-icon::after {
    content: '✓';
}

.form-group.valid input,
.form-group.valid select,
.form-group.valid textarea {
    border-color: #22c55e !important;
    background-color: rgba(34, 197, 94, 0.05) !important;
}

.form-group.invalid input,
.form-group.invalid select,
.form-group.invalid textarea {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.05) !important;
}

/* Adjust validation icon position for different field types */
.form-group:has(select) .validation-icon {
    right: 40px;
}

.form-group:has(textarea) .validation-icon {
    top: 35px;
    transform: none;
}

/* Mobile adjustments for back to top */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 80px;
        right: 15px;
        width: 45px;
        height: 45px;
    }
    
    .back-to-top svg {
        width: 20px;
        height: 20px;
    }
    
    /* Adjust validation icon for mobile */
    .validation-icon {
        right: 10px;
        font-size: 14px;
    }
}

/* =============================================
   DESKTOP HERO ADJUSTMENTS
   ============================================= */
@media (min-width: 769px) {
    .hero,
    .page-hero {
        max-width: 1200px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        border-radius: 12px !important;
        overflow: hidden !important;
    }
    
    .hero-slide {
        background-position: center 30% !important;
    }
}

/* ============================================
   DESKTOP HERO - CLEAN PICTURE FRAME (NO ROUNDED CORNERS)
   ============================================ */
@media (min-width: 769px) {
    .page-hero {
        border-radius: 0 !important;
    }
    .page-hero,
    .hero-slideshow,
    .hero-slide {
        border-radius: 0 !important;
    }
}
