/* Mobile Responsiveness Fixes */
/* Targeted fixes for navigation, hero section, and layout issues */

/* ============= BASE RESPONSIVE RESETS ============= */

/* Prevent horizontal overflow on all elements */
* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    width: 100%;
}

/* ============= NAVIGATION FIXES ============= */

/* Hide desktop navigation links on mobile and tablet */
@media (max-width: 1024px) {
    /* Hide the main navigation links */
    nav .nav-links,
    nav > div > div > div:first-child > div {
        display: none !important;
    }

    /* Hide desktop auth links on mobile */
    nav .dropdown-toggle,
    nav .dropdown-menu,
    nav a[href="/login"],
    nav a[href="/register"]:not(.mobile-hamburger) {
        display: none !important;
    }

    /* Ensure logo and hamburger are visible */
    nav > div > div {
        justify-content: space-between !important;
    }

    /* Make sure hamburger is visible */
    .mobile-hamburger {
        display: flex !important;
    }
}

/* Mobile hamburger menu implementation */
.mobile-hamburger {
    display: none;
    background: #1f2937;
    border: 1px solid #374151;
    color: var(--linear-text);
    font-size: 1rem;
    padding: 0.75rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 200ms ease;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
}

.mobile-hamburger:hover {
    background: #374151;
    border-color: #4b5563;
}

@media (max-width: 1024px) {
    .mobile-hamburger {
        display: flex !important;
    }
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 300ms ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile slide-in menu */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: #0d1117;
    padding: 2rem 1.5rem;
    z-index: 999;
    transition: right 300ms ease;
    overflow-y: auto;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.mobile-menu-close {
    background: #1f2937;
    border: 1px solid #374151;
    color: var(--linear-text);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 200ms ease;
}

.mobile-menu-close:hover {
    background: #374151;
    border-color: #4b5563;
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 0;
    color: #9ca3af;
    text-decoration: none;
    font-size: 1.125rem;
    font-weight: 400;
    transition: all 200ms ease;
    min-height: 44px;
    border-bottom: 1px solid #1f2937;
    position: relative;
}

.mobile-nav-item:hover {
    color: var(--linear-text);
}

.mobile-nav-item:after {
    content: '→';
    position: absolute;
    right: 0;
    font-size: 1.25rem;
    color: #4b5563;
    transition: all 200ms ease;
}

.mobile-nav-item:hover:after {
    color: #9ca3af;
    transform: translateX(4px);
}

/* Remove icons from mobile nav to match Resend style */
.mobile-nav-item i {
    display: none;
}

/* Special styling for CTA buttons in mobile menu */
.mobile-nav-cta {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #1f2937;
}

.mobile-nav-cta .mobile-nav-item {
    border-bottom: none;
    margin-bottom: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    justify-content: center;
}

.mobile-nav-cta .mobile-nav-item:after {
    display: none;
}

.mobile-nav-login {
    background: transparent;
    border: 1px solid #374151;
    color: var(--linear-text);
}

.mobile-nav-login:hover {
    background: #1f2937;
}

.mobile-nav-signup {
    background: var(--linear-accent);
    color: #000000;
    font-weight: 500;
}

.mobile-nav-signup:hover {
    background: var(--linear-accent-hover);
    color: #000000;
}

/* ============= HERO SECTION FIXES ============= */

/* Base hero section responsiveness - reduced top padding */
.hero-section,
section[style*="padding: var(--linear-space-16)"] {
    padding: 2rem 1rem !important;
    overflow-x: hidden;
}

/* Aggressively reduce top padding for hero sections */
section[style*="padding: var(--linear-space-16)"][style*="background: linear-gradient"],
section[style*="background: linear-gradient"][style*="padding: var(--linear-space-16)"] {
    padding-top: 0 !important;
    padding-bottom: 2rem !important;
    margin-top: 0 !important;
}

/* Also target any potential margin on the container */
section[style*="background: linear-gradient"] > div {
    margin-top: 0 !important;
    padding-top: 1rem !important;
}

@media (min-width: 768px) {
    section[style*="padding: var(--linear-space-16)"][style*="background: linear-gradient"],
    section[style*="background: linear-gradient"][style*="padding: var(--linear-space-16)"] {
        padding-top: 0 !important;
        padding-bottom: 3rem !important;
    }

    section[style*="background: linear-gradient"] > div {
        padding-top: 1.5rem !important;
    }
}

@media (min-width: 1024px) {
    section[style*="padding: var(--linear-space-16)"][style*="background: linear-gradient"],
    section[style*="background: linear-gradient"][style*="padding: var(--linear-space-16)"] {
        padding-top: 0 !important;
        padding-bottom: 4rem !important;
    }

    section[style*="background: linear-gradient"] > div {
        padding-top: 2rem !important;
    }
}

/* Hero container fixes */
.hero-section > div,
section > div[style*="max-width: 1200px"] {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 auto;
}

/* Hero title responsiveness */
.hero-section h1,
h1[style*="font-size: 64px"] {
    font-size: clamp(2rem, 8vw, 3.5rem) !important;
    line-height: 1.1 !important;
    text-align: center !important;
    margin-bottom: 1.5rem !important;
}

/* Hero subtitle responsiveness */
.hero-section p,
p[style*="font-size: 24px"] {
    font-size: clamp(1rem, 4vw, 1.25rem) !important;
    text-align: center !important;
    margin: 0 0 2rem 0 !important;
    max-width: 100% !important;
    padding: 0 1rem;
}

/* Hero stats grid - mobile stacking */
div[style*="grid-template-columns: repeat(auto-fit, minmax(180px, 1fr))"] {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
    margin: 2rem 0 !important;
}

@media (max-width: 480px) {
    div[style*="grid-template-columns: repeat(auto-fit, minmax(180px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }
}

/* ============= BUTTON FIXES ============= */

/* CTA button container - stack on mobile */
div[style*="display: flex"][style*="gap: var(--linear-space-4)"][style*="justify-content: center"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    align-items: center !important;
    width: 100% !important;
    padding: 0 1rem !important;
}

@media (min-width: 768px) {
    div[style*="display: flex"][style*="gap: var(--linear-space-4)"][style*="justify-content: center"] {
        flex-direction: row !important;
        justify-content: center !important;
    }
}

/* Make buttons tap-friendly and full-width on mobile */
.linear-button,
a[class*="linear-button"],
button[class*="linear-button"] {
    min-height: 44px !important;
    padding: 1rem 1.5rem !important;
    font-size: 1rem !important;
    width: 100% !important;
    max-width: 280px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    text-align: center !important;
}

@media (min-width: 768px) {
    .linear-button,
    a[class*="linear-button"],
    button[class*="linear-button"] {
        width: auto !important;
        min-width: 120px !important;
    }
}

/* ============= SECTION LAYOUT FIXES ============= */

/* Force single-column layout on mobile */
div[style*="display: grid"][style*="grid-template-columns: repeat(auto-fit, minmax(350px, 1fr))"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    padding: 0 1rem !important;
}

@media (min-width: 768px) {
    div[style*="display: grid"][style*="grid-template-columns: repeat(auto-fit, minmax(350px, 1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    div[style*="display: grid"][style*="grid-template-columns: repeat(auto-fit, minmax(350px, 1fr))"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* How it works section - single column on mobile */
div[style*="grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    padding: 0 1rem !important;
}

@media (min-width: 768px) {
    div[style*="grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    div[style*="grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))"] {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ============= TYPOGRAPHY SCALING ============= */

/* Section titles */
h2[style*="font-size: 48px"] {
    font-size: clamp(1.75rem, 6vw, 3rem) !important;
    text-align: center !important;
    margin-bottom: 1rem !important;
    padding: 0 1rem !important;
}

/* Section subtitles */
p[style*="font-size: 20px"] {
    font-size: clamp(1rem, 3vw, 1.25rem) !important;
    text-align: center !important;
    padding: 0 1rem !important;
}

/* ============= SPACING AND PADDING FIXES ============= */

/* Ensure all sections have proper mobile padding */
section {
    padding: 3rem 1rem !important;
    overflow-x: hidden;
}

@media (min-width: 768px) {
    section {
        padding: 4rem 2rem !important;
    }
}

@media (min-width: 1024px) {
    section {
        padding: 6rem 2rem !important;
    }
}

/* Container max-width and centering */
div[style*="max-width: 1200px"] {
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 1rem !important;
}

@media (min-width: 768px) {
    div[style*="max-width: 1200px"] {
        max-width: 1200px !important;
        padding: 0 2rem !important;
    }
}

/* ============= MOBILE-SPECIFIC ADJUSTMENTS ============= */

@media (max-width: 480px) {
    /* Extra small mobile adjustments */
    .hero-section {
        padding: 2rem 0.75rem !important;
    }

    /* Trust indicators section */
    div[style*="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
}

/* ============= PREVENT HORIZONTAL SCROLLING ============= */

/* Force all potentially overflowing elements to stay within viewport */
.linear-app,
.linear-app * {
    max-width: 100vw;
}

/* Specific overflow fixes */
div[style*="display: flex"] {
    flex-wrap: wrap !important;
}

/* Navigation specific overflow prevention */
nav {
    width: 100% !important;
    overflow: hidden !important;
}

nav > div {
    width: 100% !important;
    max-width: 100% !important;
}

/* ============= ACCESSIBILITY IMPROVEMENTS ============= */

/* Focus states for mobile */
.mobile-nav-item:focus,
.mobile-hamburger:focus,
.mobile-menu-close:focus {
    outline: 2px solid var(--linear-accent);
    outline-offset: 2px;
}

/* Ensure tap targets are large enough */
button, a, .mobile-nav-item {
    min-height: 44px;
    min-width: 44px;
}