/* ===================================================================
   MOBILE RESPONSIVE STYLES
   Optimizations for mobile UI/UX
   =================================================================== */

/* ===================================================================
   LAYOUT FIXES
   =================================================================== */

/* Fix hero section spacing from navigation header */
@media (max-width: 768px) {
    /* Add top padding to hero section to account for header */
    section.min-h-screen {
        padding-top: 5rem; /* Space for navigation header */
        min-height: calc(100vh - 4rem); /* Adjust min-height accordingly */
    }
    
    /* Reduce container padding on very small screens */
    .container.mx-auto.px-4 {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 480px) {
    /* More spacing for very small screens */
    section.min-h-screen {
        padding-top: 6rem;
        min-height: calc(100vh - 5rem);
    }
    
    /* Tighter padding for small screens */
    .container.mx-auto.px-4 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Optimize navigation for small screens */
    nav .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    nav .flex.justify-between {
        gap: 0.5rem; /* Add some gap between logo and hamburger */
    }
    
    /* Make logo smaller on tiny screens */
    nav .text-xl {
        font-size: 1.125rem; /* 18px instead of 20px */
    }
    
    nav .h-10 {
        height: 2rem; /* Smaller logo height */
    }
}

/* ===================================================================
   RESPONSIVE TYPOGRAPHY
   =================================================================== */

/* Hero Title - Fluid Typography */
h1.text-6xl {
    /* Mobile-first approach with fluid scaling */
    font-size: clamp(2rem, 6vw + 0.5rem, 4.5rem); /* 32px min, scales with viewport, 72px max */
    line-height: 1.1;
}

/* Specific breakpoint adjustments */
@media (max-width: 640px) {
    /* Small mobile devices */
    h1.text-6xl {
        font-size: 2rem; /* 32px */
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    /* Hero subtitle */
    p.text-xl {
        font-size: 1rem; /* 16px */
        line-height: 1.5;
    }
}

/* Extra small screens (iPhone SE, etc.) */
@media (max-width: 380px) {
    h1.text-6xl {
        font-size: 1.75rem; /* 28px */
        line-height: 1.1;
        margin-bottom: 0.75rem;
    }
    
    p.text-xl {
        font-size: 0.9rem; /* 14.4px */
        line-height: 1.4;
        margin-bottom: 1.5rem;
    }
    
    /* Adjust CTA buttons for small screens */
    .cta-button {
        font-size: 0.9rem;
        padding: 0.75rem 1.25rem;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    /* Large mobile / small tablet */
    h1.text-6xl {
        font-size: 2.5rem; /* 40px */
    }
    
    p.text-xl {
        font-size: 1.125rem; /* 18px */
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    /* Tablet / small laptop */
    h1.text-6xl {
        font-size: 3rem; /* 48px */
    }
}

@media (min-width: 1025px) {
    /* Desktop */
    h1.text-6xl {
        font-size: 4rem; /* 64px */
    }
}

/* ===================================================================
   MOBILE NAVIGATION
   =================================================================== */

/* Desktop auth section - show only on large screens */
.desktop-auth-only {
    display: none !important;
}

@media (min-width: 769px) {
    .desktop-auth-only {
        display: block !important;
    }
}

/* Force hide auth section on ALL mobile screens with maximum specificity */
@media (max-width: 768px) {
    div#authSection.desktop-auth-only,
    div#authSection,
    #authSection,
    .desktop-auth-only {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        left: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }
}

/* CRITICAL: Hide auth-header-container on mobile - EXCEPT for generator pages */
@media (max-width: 768px) {
    /* Hide auth header on non-generator pages */
    body:not(.generator-layout) .auth-header-container {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        left: -9999px !important;
        top: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        z-index: -999 !important;
        pointer-events: none !important;
    }
    
    /* Allow auth header on generator pages for hamburger menu */
    body.generator-layout .auth-header-container {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        left: auto !important;
        top: auto !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
        z-index: var(--z-auth-header, 100) !important;
        pointer-events: auto !important;
    }
    
    /* Remove body margin added by auth-header.js */
    body {
        margin-top: 0 !important;
    }
}

/* Extra protection for very small screens */
@media (max-width: 480px) {
    /* Nuclear option - hide everything auth related EXCEPT on generator pages */
    body:not(.generator-layout) .auth-header-container,
    body:not(.generator-layout) div#authSection.desktop-auth-only,
    body:not(.generator-layout) div#authSection,
    body:not(.generator-layout) #authSection,
    body:not(.generator-layout) .desktop-auth-only,
    body:not(.generator-layout) #guestNav,
    body:not(.generator-layout) #userNav,
    body:not(.generator-layout) nav div#authSection,
    body:not(.generator-layout) nav #guestNav,
    body:not(.generator-layout) nav #userNav,
    body:not(.generator-layout) #auth-header {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        left: -9999px !important;
        top: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        z-index: -999 !important;
        pointer-events: none !important;
    }
    
    /* Ensure generator pages show auth header with proper hamburger menu positioning */
    body.generator-layout .auth-header-container {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        left: auto !important;
        top: auto !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
        z-index: var(--z-auth-header, 100) !important;
        pointer-events: auto !important;
    }
    
    /* Ensure hamburger menu is properly positioned */
    #mobileMenuBtn {
        position: relative;
        z-index: 30;
        margin-left: auto;
    }
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block;
}

/* Enhanced Mobile Menu */
#mobileMenu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 320px;
    height: 100%;
    background-color: #1f2937;
    z-index: 50;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
}

#mobileMenu.active {
    right: 0;
}

/* Mobile Menu Header */
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #374151;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.mobile-menu-close:hover {
    color: #d1d5db;
}

/* Mobile Menu Content */
.mobile-menu-content {
    padding: 1rem;
}

.mobile-menu-content a,
.mobile-menu-content button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.mobile-menu-content a:hover,
.mobile-menu-content button:hover {
    background-color: #374151;
}

/* Mobile Auth Section Styling */
#mobileAuthSection {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #374151;
}

#mobileUserEmail {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
}

/* ===================================================================
   TOUCH-FRIENDLY ENHANCEMENTS
   =================================================================== */

/* Minimum touch target size (44x44px) */
@media (max-width: 768px) {
    /* All interactive elements */
    button, a, .cta-button {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* CTA Buttons on mobile */
    .cta-button {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Navigation links */
    nav a {
        padding: 0.75rem 1rem;
    }
}

/* ===================================================================
   AUTH RIBBON MOBILE OPTIMIZATION
   =================================================================== */

@media (max-width: 768px) {
    /* Stack auth buttons vertically on small screens */
    #guestNav,
    #userNav {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    #guestNav a,
    #userNav a,
    #userNav button {
        width: 100%;
        text-align: center;
        padding: 0.625rem 1rem;
        border-radius: 0.375rem;
        background-color: rgba(99, 102, 241, 0.1);
        transition: background-color 0.2s ease;
    }
    
    #guestNav a:hover,
    #userNav a:hover,
    #userNav button:hover {
        background-color: rgba(99, 102, 241, 0.2);
    }
}

/* ===================================================================
   HAMBURGER MENU ANIMATION
   =================================================================== */

/* Hamburger Icon Animation */
.hamburger-icon {
    width: 24px;
    height: 24px;
    position: relative;
    transition: transform 0.3s ease;
}

.hamburger-icon span {
    display: block;
    position: absolute;
    height: 3px;
    width: 100%;
    background: currentColor;
    border-radius: 3px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: 0.25s ease-in-out;
}

.hamburger-icon span:nth-child(1) {
    top: 0px;
}

.hamburger-icon span:nth-child(2) {
    top: 8px;
}

.hamburger-icon span:nth-child(3) {
    top: 16px;
}

/* When menu is open */
.hamburger-icon.active span:nth-child(1) {
    top: 8px;
    transform: rotate(135deg);
}

.hamburger-icon.active span:nth-child(2) {
    opacity: 0;
    left: -60px;
}

.hamburger-icon.active span:nth-child(3) {
    top: 8px;
    transform: rotate(-135deg);
}

/* ===================================================================
   PERFORMANCE OPTIMIZATIONS
   =================================================================== */

/* Reduce animations on low-end devices */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Hardware acceleration for smooth animations */
#mobileMenu,
.mobile-menu-overlay {
    will-change: transform, opacity;
}

/* ===================================================================
   LANDSCAPE MODE ADJUSTMENTS
   =================================================================== */

@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce hero text size in landscape */
    h1.text-6xl {
        font-size: 1.75rem;
    }
    
    /* Adjust hero section height */
    section.min-h-screen {
        min-height: auto;
        padding: 3rem 0;
    }
    
    /* Make mobile menu full width in landscape */
    #mobileMenu {
        max-width: 100%;
        width: 50%;
    }
}

/* ===================================================================
   UTILITY CLASSES
   =================================================================== */

/* Hide on mobile */
@media (max-width: 768px) {
    .mobile-hide {
        display: none !important;
    }
}

/* Show only on mobile */
.mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }
}