/* Mobile Overflow Fixes */
/* Fix for countdown sections that cause horizontal scrolling on mobile */

/* Countdown responsive fixes */
#countdown {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#countdown::-webkit-scrollbar {
    display: none;
}

/* Reduce countdown text size and gaps on very small screens */
@media (max-width: 480px) {
    #countdown {
        gap: 0.25rem !important;
        flex-wrap: nowrap;
        min-width: 0;
    }
    
    #countdown > div {
        min-width: 0;
        flex-shrink: 1;
    }
    
    #countdown span {
        font-size: 1.5rem !important;
        line-height: 1.2;
    }
    
    #countdown p {
        font-size: 0.625rem !important;
        white-space: nowrap;
    }
    
    #countdown .text-3xl {
        font-size: 1.5rem !important;
    }
    
    #countdown .sm\:text-5xl {
        font-size: 1.5rem !important;
    }
}

/* Fix for very small screens (320px and below) */
@media (max-width: 320px) {
    #countdown {
        gap: 0.125rem !important;
    }
    
    #countdown span {
        font-size: 1.25rem !important;
    }
    
    #countdown p {
        font-size: 0.5rem !important;
    }
}

/* Grid layout fixes for mobile */
@media (max-width: 640px) {
    /* Ensure grid containers don't overflow */
    .grid {
        overflow-x: hidden;
    }
    
    /* Reduce gaps on mobile for better fit */
    .gap-8 {
        gap: 1rem !important;
    }
    
    .gap-12 {
        gap: 1.5rem !important;
    }
    
    /* Fix for large gap values that might cause overflow */
    .md\:gap-8 {
        gap: 1rem !important;
    }
    
    .lg\:gap-12 {
        gap: 1.5rem !important;
    }
}

/* Flex container fixes */
@media (max-width: 640px) {
    .flex {
        flex-wrap: wrap;
    }
    
    /* Ensure flex items don't cause overflow */
    .flex > * {
        min-width: 0;
        flex-shrink: 1;
    }
}

/* Container and section fixes */
@media (max-width: 640px) {
    /* Ensure all containers have proper padding */
    .container,
    .max-w-4xl,
    .max-w-6xl,
    .max-w-7xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Fix for glass cards that might be too wide */
    .glass-card,
    .glass-card-strong {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
        max-width: calc(100vw - 1rem);
    }
}

/* Text size adjustments for mobile */
@media (max-width: 480px) {
    .text-oversized {
        font-size: 2rem !important;
        line-height: 1.2;
    }
    
    .text-3xl {
        font-size: 1.5rem !important;
    }
    
    .text-4xl {
        font-size: 1.75rem !important;
    }
    
    .text-5xl {
        font-size: 2rem !important;
    }
}

/* Specific fixes for problematic sections */
@media (max-width: 640px) {
    /* Hero sections */
    .hero-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Stats and feature grids */
    .grid.grid-cols-2.md\:grid-cols-3.lg\:grid-cols-5,
    .grid.grid-cols-2.md\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    /* Tools grid adjustments */
    .grid.md\:grid-cols-2.lg\:grid-cols-3 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Emergency overflow prevention */
* {
    max-width: 100%;
    box-sizing: border-box;
}

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

/* Prevent specific elements from causing overflow */
.w-full {
    width: 100% !important;
    max-width: 100% !important;
}

/* Fix for any remaining overflow issues */
@media (max-width: 640px) {
    .container,
    .max-w-sm,
    .max-w-md,
    .max-w-lg,
    .max-w-xl,
    .max-w-2xl,
    .max-w-3xl,
    .max-w-4xl,
    .max-w-5xl,
    .max-w-6xl,
    .max-w-7xl {
        max-width: calc(100vw - 2rem) !important;
        margin-left: auto;
        margin-right: auto;
    }
}