/**
 * Tablet Responsiveness Fixes
 *
 * Optimizations for tablet devices (768px - 1366px)
 * Targets: iPad, iPad Pro, Android tablets (portrait and landscape)
 *
 * @package Light_Theme_Homepage
 * @version 1.1.1
 * @since 1.1.1
 */

/* ============================================
   TABLET BREAKPOINT REFERENCE
   ============================================

   iPad (9.7"): 768x1024px
   iPad Air/Pro 10.5": 834x1112px
   iPad Pro 11": 834x1194px
   iPad Pro 12.9": 1024x1366px
   Android tablets: 800-1280px typically

   Portrait: 768px - 1024px width
   Landscape: 1024px - 1366px width
   ============================================ */

/* ============================================
   FIX #1: Tablet Portrait Warning - Less Aggressive
   ============================================ */

/* Make portrait warning dismissible instead of blocking */
@media (max-width: 1366px) and (min-width: 768px) and (orientation: portrait) {
    .tablet-portrait-warning {
        /* Allow dismissing by making it less intrusive */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important; /* Only cover top, not full screen */
        height: auto !important;
        background: rgba(0, 0, 0, 0.85) !important;
        z-index: 999999 !important;
        padding: 20px !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }

    .tablet-portrait-warning-content {
        padding: 20px !important;
        max-width: 600px !important;
        margin: 0 auto !important;
    }

    .tablet-portrait-title {
        font-size: 1.4rem !important;
        margin-bottom: 10px !important;
    }

    .tablet-portrait-message {
        font-size: 0.95rem !important;
    }

    /* Allow content to be visible below warning */
    .light-theme-video-header > *:not(.tablet-portrait-warning) {
        display: block !important;
        margin-top: 140px !important; /* Push content below warning */
    }
}

/* ============================================
   FIX #2: Tablet Landscape Optimization (1024px - 1366px)
   ============================================ */

@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
    /* Optimize video overlay for better readability */
    .light-theme-video-header .video-overlay,
    .light-theme-video-header .about-overlay,
    .light-theme-video-header .tech-overlay,
    .projects-overlay,
    .products-overlay,
    .light-theme-video-header .contact-overlay {
        background: rgba(0, 0, 0, 0.5) !important;
    }

    /* Ensure sections use full viewport */
    .light-theme-video-header .main-content,
    .light-theme-video-header .about-section,
    .light-theme-video-header .tech-section,
    .light-theme-video-header .projects-section,
    .light-theme-video-header .products-section,
    .light-theme-video-header .contact-section {
        width: 100vw !important;
        max-width: 100vw !important;
    }

    /* Gallery optimization */
    .light-theme-video-header .company-gallery {
        bottom: 30px !important;
        height: 30vh !important;
        min-height: 200px !important;
    }

    .light-theme-video-header .gallery-title {
        font-size: 1.5rem !important;
        margin-bottom: 16px !important;
    }

    .light-theme-video-header .companies-slider {
        height: 90px !important;
        max-height: 90px !important;
    }

    .company-logo {
        height: 90px !important;
        max-width: 180px !important;
    }

    /* Tech section cards - optimal size for tablet landscape */
    .light-theme-video-header .tech-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
        gap: 24px !important;
        padding: 0 40px !important;
    }

    .light-theme-video-header .service-item {
        min-height: auto !important;
        padding: 24px 20px !important;
    }

    .light-theme-video-header .service-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.85rem !important;
    }

    /* Projects grid - 2 columns on tablet landscape */
    .projects-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 32px !important;
        padding: 0 40px !important;
    }

    /* Products grid - 2 columns on tablet landscape */
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 28px !important;
        padding: 0 40px !important;
    }

    /* Touch targets - ensure 44x44px minimum */
    .light-theme-video-header .video-header-button,
    .company-all-button,
    .products-all-button,
    .light-theme-video-header .social-icon {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 12px 24px !important;
    }

    /* Social media corner - better positioning */
    .light-theme-video-header .social-media-corner {
        bottom: 24px !important;
        right: 24px !important;
    }

    .light-theme-video-header .social-icon {
        width: 48px !important;
        height: 48px !important;
        font-size: 1.1rem !important;
    }
}

/* ============================================
   FIX #3: Tablet Portrait Optimization (768px - 1024px)
   ============================================ */

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    /* Allow portrait mode - remove blocking behavior */
    .light-theme-video-header {
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    /* Video background - ensure proper coverage */
    .light-theme-video-header .video-background {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 0 !important;
    }

    /* Mobile portrait media for tablets */
    .mobile-portrait-media {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 1 !important;
    }

    /* Sections - scrollable content */
    .light-theme-video-header .main-content,
    .light-theme-video-header .about-section,
    .light-theme-video-header .tech-section,
    .light-theme-video-header .projects-section,
    .light-theme-video-header .products-section,
    .light-theme-video-header .contact-section {
        position: absolute !important;
        width: 100% !important;
        height: auto !important;
        min-height: 100vh !important;
        background-color: transparent !important;
    }

    /* Video content - center with adequate padding */
    .light-theme-video-header .video-content {
        padding: clamp(40px, 8vh, 80px) 40px !important;
    }

    /* Headings - readable size */
    .light-theme-video-header .video-header-title {
        font-size: clamp(2.2rem, 5vw, 3rem) !important;
    }

    .light-theme-video-header .video-header-subtitle {
        font-size: clamp(1rem, 2.5vw, 1.3rem) !important;
    }

    /* Gallery - single row horizontal scroll */
    .light-theme-video-header .company-gallery {
        position: absolute !important;
        bottom: 40px !important;
        height: auto !important;
        min-height: 180px !important;
    }

    .light-theme-video-header .gallery-container {
        padding: 20px 30px !important;
    }

    .light-theme-video-header .gallery-title {
        font-size: 1.4rem !important;
        margin-bottom: 20px !important;
    }

    .light-theme-video-header .companies-slider {
        height: 80px !important;
        display: flex !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        gap: 30px !important;
    }

    .company-logo {
        height: 80px !important;
        width: auto !important;
        flex-shrink: 0 !important;
    }

    /* Tech cards - grid layout for portrait tablets */
    .light-theme-video-header .tech-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 20px !important;
        padding: 0 30px !important;
    }

    .light-theme-video-header .service-item {
        min-height: auto !important;
        padding: 20px 16px !important;
    }

    .light-theme-video-header .service-icon {
        width: 56px !important;
        height: 56px !important;
    }

    /* About section - two column layout */
    .light-theme-video-header .about-content {
        padding: 40px 30px !important;
    }

    .light-theme-video-header .about-images {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }

    /* Projects - 2 columns */
    .projects-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 24px !important;
        padding: 0 30px !important;
    }

    /* Products - 2 columns */
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
        padding: 0 30px !important;
    }

    /* Contact form - comfortable width */
    .light-theme-video-header .contact-form {
        max-width: 600px !important;
        padding: 0 30px !important;
    }

    /* Touch targets */
    .light-theme-video-header .video-header-button,
    .company-all-button,
    .products-all-button {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 14px 28px !important;
        font-size: 0.85rem !important;
    }

    /* Social media - adequate size */
    .light-theme-video-header .social-icon {
        width: 52px !important;
        height: 52px !important;
        font-size: 1.2rem !important;
    }

    .light-theme-video-header .social-media-corner {
        bottom: 28px !important;
        right: 28px !important;
        gap: 16px !important;
    }
}

/* ============================================
   FIX #4: iPad Pro 12.9" Specific (1024px - 1366px portrait)
   ============================================ */

@media (min-width: 1024px) and (max-width: 1366px) and (orientation: portrait) {
    /* Larger tablet portrait - more columns */
    .light-theme-video-header .tech-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 24px !important;
    }

    .projects-grid,
    .products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 28px !important;
    }

    .light-theme-video-header .about-images {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 24px !important;
    }

    /* Larger text for bigger screen */
    .light-theme-video-header .video-header-title {
        font-size: clamp(2.5rem, 5vw, 3.5rem) !important;
    }

    .light-theme-video-header .video-content {
        padding: clamp(50px, 10vh, 100px) 60px !important;
    }
}

/* ============================================
   FIX #5: Orientation Change Handling
   ============================================ */

/* Smooth transition between orientations */
@media (min-width: 768px) and (max-width: 1366px) {
    .light-theme-video-header,
    .light-theme-video-header .main-content,
    .light-theme-video-header .about-section,
    .light-theme-video-header .tech-section,
    .light-theme-video-header .projects-section,
    .light-theme-video-header .products-section,
    .light-theme-video-header .contact-section {
        transition: all 0.3s ease-out !important;
    }

    /* Prevent flash of unstyled content during rotation */
    @media (orientation: portrait) {
        html {
            overflow-x: hidden !important;
        }
    }

    @media (orientation: landscape) {
        html {
            overflow-x: hidden !important;
        }
    }
}

/* ============================================
   FIX #6: Touch Interaction Improvements
   ============================================ */

@media (min-width: 768px) and (max-width: 1366px) {
    /* Ensure all interactive elements are touch-friendly */
    a,
    button,
    .light-theme-video-header .service-item,
    .light-theme-video-header .project-item,
    .light-theme-video-header .product-item,
    .company-logo,
    .light-theme-video-header .social-icon {
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1) !important;
        cursor: pointer !important;
    }

    /* Remove hover states that don't work well on tablets */
    @media (hover: none) and (pointer: coarse) {
        .light-theme-video-header .service-item:hover,
        .light-theme-video-header .project-item:hover,
        .light-theme-video-header .product-item:hover {
            transform: none !important;
        }

        /* Replace hover with active state */
        .light-theme-video-header .service-item:active,
        .light-theme-video-header .project-item:active,
        .light-theme-video-header .product-item:active {
            transform: scale(0.98) !important;
            transition: transform 0.1s ease-out !important;
        }
    }

    /* Prevent pull-to-refresh on tablets */
    body {
        overscroll-behavior-y: none !important;
        -webkit-overscroll-behavior-y: none !important;
    }

    /* Improve scrolling performance */
    .light-theme-video-header {
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ============================================
   FIX #7: Gallery Horizontal Scroll Optimization
   ============================================ */

@media (min-width: 768px) and (max-width: 1366px) {
    .light-theme-video-header .companies-slider {
        /* Enable smooth horizontal scrolling */
        scroll-behavior: smooth !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: thin !important;
        scrollbar-color: rgba(255, 255, 255, 0.3) transparent !important;
    }

    /* Hide scrollbar on tablets for cleaner look */
    .light-theme-video-header .companies-slider::-webkit-scrollbar {
        height: 4px !important;
    }

    .light-theme-video-header .companies-slider::-webkit-scrollbar-track {
        background: transparent !important;
    }

    .light-theme-video-header .companies-slider::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3) !important;
        border-radius: 2px !important;
    }

    .light-theme-video-header .companies-slider::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.5) !important;
    }
}

/* ============================================
   FIX #8: Modal/Popup Optimization for Tablets
   ============================================ */

@media (min-width: 768px) and (max-width: 1366px) {
    /* Service modals - better size for tablets */
    .light-theme-video-header .service-modal {
        padding: 40px 30px !important;
    }

    .light-theme-video-header .service-modal-content {
        max-width: 700px !important;
        width: 90% !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
    }

    .modal-close {
        width: 44px !important;
        height: 44px !important;
        font-size: 1.5rem !important;
        top: 20px !important;
        right: 20px !important;
    }

    /* Modal scrolling */
    .light-theme-video-header .service-modal-content {
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ============================================
   FIX #9: Safe Area Support for Tablets with Notches
   ============================================ */

@media (min-width: 768px) and (max-width: 1366px) {
    @supports (padding: env(safe-area-inset-top)) {
        /* Account for notches/camera cutouts on modern tablets */
        .light-theme-video-header {
            padding-top: env(safe-area-inset-top) !important;
            padding-bottom: env(safe-area-inset-bottom) !important;
            padding-left: env(safe-area-inset-left) !important;
            padding-right: env(safe-area-inset-right) !important;
        }

        .light-theme-video-header .social-media-corner {
            bottom: calc(24px + env(safe-area-inset-bottom)) !important;
            right: calc(24px + env(safe-area-inset-right)) !important;
        }

        .light-theme-video-header .company-gallery {
            bottom: calc(40px + env(safe-area-inset-bottom)) !important;
        }
    }
}

/* ============================================
   FIX #10: Performance Optimizations for Tablets
   ============================================ */

@media (min-width: 768px) and (max-width: 1366px) {
    /* Use transform for animations (GPU accelerated) */
    .light-theme-video-header .main-content,
    .light-theme-video-header .about-section,
    .light-theme-video-header .tech-section,
    .light-theme-video-header .projects-section,
    .light-theme-video-header .products-section,
    .light-theme-video-header .contact-section {
        will-change: transform, opacity !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
        transform: translate3d(0, 0, 0) !important;
    }

    /* Reduce particle effects on tablets for better performance */
    .floating-particles {
        opacity: 0.4 !important;
    }

    .particle {
        width: 1.5px !important;
        height: 1.5px !important;
    }

    /* Optimize video rendering */
    .light-theme-video-header .video-background iframe,
    .light-theme-video-header .video-background video {
        will-change: transform !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
    }
}

/* ============================================
   FIX #11: Typography Optimization for Tablets
   ============================================ */

@media (min-width: 768px) and (max-width: 1366px) {
    /* Ensure readable text on all tablet sizes */
    body {
        -webkit-text-size-adjust: 100% !important;
        -moz-text-size-adjust: 100% !important;
        text-size-adjust: 100% !important;
    }

    /* Optimal line length for tablets */
    .light-theme-video-header .about-text,
    .light-theme-video-header .tech-description,
    .projects-description,
    .products-description,
    .light-theme-video-header .contact-description {
        max-width: 700px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        line-height: 1.7 !important;
    }

    /* Comfortable reading size */
    p {
        font-size: clamp(0.95rem, 2vw, 1.1rem) !important;
    }

    h2 {
        font-size: clamp(1.8rem, 4vw, 2.5rem) !important;
    }

    h3 {
        font-size: clamp(1.4rem, 3vw, 1.8rem) !important;
    }
}

/* ============================================
   END OF TABLET FIXES
   ============================================ */
