/* --- MOBILE RESPONSIVE DESIGN --- */

/* Global overflow fix ONLY (safe for all screens) */
html {
    overflow-x: hidden;
}

/* Tablets and small laptops */
@media (max-width: 1024px) {
    .container {
        padding: 0 20px;
    }

    .hero h1 {
        font-size: 3rem !important;
    }

    .blog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* Mobile devices - ALL mobile-specific rules MUST be in this block */
@media (max-width: 768px) {

    /* Fix navbar to top and create space for content */
    .navbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 9997 !important;
        background: rgba(4, 5, 8, 0.98) !important;
        backdrop-filter: blur(10px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }

    /* Push body content down to account for fixed navbar */
    body {
        padding-top: 80px !important;
    }

    /* Additional spacing for main content sections */
    .hero {
        padding-top: 20px !important;
        padding-bottom: 40px !important;
    }

    main[style*="padding-top: 120px"] {
        padding-top: 20px !important;
        /* Override inline padding on Market Pulse */
    }

    /* Critical Grid Fixes - Forces stacking of columns ON MOBILE ONLY */
    .responsive-grid,
    .footer-grid,
    div[style*="grid-template-columns: repeat(3, 1fr)"],
    div[style*="grid-template-columns: 1.3fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
        width: 100% !important;
    }

    /* Market Pulse specific - target the crypto cards container */
    .dashboard-grid>div[style*="grid-template-columns: repeat(2, 1fr)"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Ensure all nested grids stack on mobile */
    div[style*="display: grid"][style*="repeat(2, 1fr)"] {
        grid-template-columns: 1fr !important;
    }

    /* Typography adjustments */
    h1 {
        font-size: 2rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    .hero h1 {
        font-size: 2.2rem !important;
        line-height: 1.2 !important;
    }

    .hero p {
        font-size: 1rem !important;
    }

    /* Container padding */
    .container {
        padding: 0 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Hide desktop navigation */
    .nav-links {
        display: none !important;
    }

    /* Mobile menu button - fixed position */
    .mobile-menu-btn {
        display: flex !important;
        position: fixed !important;
        top: 15px !important;
        right: 15px !important;
        z-index: 99999 !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: rgba(0, 217, 255, 0.15);
        border: 1px solid rgba(0, 217, 255, 0.4);
        border-radius: 8px;
        cursor: pointer;
        font-size: 1.5rem;
        color: #00D9FF;
        transition: all 0.3s;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }

    .mobile-menu-btn:hover {
        background: rgba(0, 217, 255, 0.25);
    }

    /* Mobile nav overlay */
    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100vh !important;
        background: rgba(0, 0, 0, 0.98);
        display: none;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        z-index: 99998;
        padding: 20px;
    }

    .mobile-nav-overlay.active {
        display: flex !important;
    }

    .mobile-nav-content a {
        color: #fff;
        font-size: 1.5rem;
        padding: 16px;
        margin: 8px 0;
        transition: color 0.3s;
        text-decoration: none;
        display: block;
    }

    .mobile-nav-content a:hover {
        color: #00D9FF;
    }

    .logo {
        font-size: 1.2rem !important;
    }

    /* About page image - keep reasonable size on mobile */
    .visionary-container img {
        width: 100% !important;
        height: auto !important;
    }

    /* Tech Visionary badge positioning on mobile */
    div[style*="position: absolute"][style*="top: -14px"] {
        position: static !important;
        display: inline-block;
        margin: 10px auto;
        font-size: 0.85rem !important;
        padding: 8px 16px !important;
    }

    /* Blog grid */
    .blog-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .blog-card {
        margin-bottom: 0;
        padding: 20px !important;
    }

    /* Images responsive */
    .article-image,
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Footer */
    footer {
        padding: 40px 0 20px !important;
        margin-top: 60px !important;
    }

    footer .container {
        padding: 0 20px !important;
    }

    footer form {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    footer input[type="email"] {
        max-width: 100% !important;
        width: 100% !important;
        padding: 12px !important;
        box-sizing: border-box !important;
    }

    footer button {
        width: 100% !important;
        padding: 12px !important;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.8rem !important;
    }

    .container {
        padding: 0 12px !important;
    }

    .blog-card {
        padding: 16px !important;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {

    a,
    button,
    .btn,
    .mobile-menu-btn {
        min-height: 44px;
    }
}