/* ============================================================
   XINFERENCE — SHARED MOBILE RESPONSIVENESS
   Linked by all pages. Overrides page-specific inline styles.
   ============================================================ */

/* ─── HAMBURGER MENU ─────────────────────────────────────── */

@media (max-width: 768px) {

    /* Collapse 3-col navbar to logo + hamburger */
    .navbar-inner {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.75rem 5% !important;
        overflow: visible !important;
        position: relative !important;
    }

    /* Hide desktop nav & CTA buttons */
    .nav-links {
        display: none !important;
        flex-direction: column;
        gap: 0 !important;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-secondary, #ffffff);
        border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.09));
        padding: 0.75rem 5% 1.25rem;
        z-index: 998;
        box-shadow: 0 8px 32px rgba(0,0,0,0.09);
    }

    .navbar {
        position: fixed !important;
        overflow: visible !important;  /* allow dropdown to escape, positioning context for hamburger */
    }

    /* Open state: show the nav */
    .navbar.nav-open .nav-links {
        display: flex !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
    }

    /* Mobile nav links styling */
    .nav-links li {
        border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.06));
    }

    .nav-links li:last-child {
        border-bottom: none;
    }

    .nav-links > li > a {
        display: block;
        padding: 0.8rem 0.25rem;
        font-size: 1rem;
        font-weight: 500;
    }

    /* Show dropdown sub-items expanded on mobile */
    .dropdown-menu {
        position: static !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        box-shadow: none !important;
        background: transparent !important;
        border: none !important;
        padding: 0 0 0.5rem 1rem !important;
        min-width: unset !important;
        backdrop-filter: none !important;
    }

    .dropdown-menu li a {
        padding: 0.45rem 0.5rem !important;
        font-size: 0.9rem !important;
        color: var(--text-secondary) !important;
    }

    .dropdown-arrow {
        display: none !important;
    }

    /* Hide desktop CTA */
    .nav-cta {
        display: none !important;
    }

    /* Hamburger button — absolutely positioned so it's always top-right
       regardless of the container's grid or flex layout */
    .mobile-menu-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 40px !important;
        height: 40px !important;
        border-radius: 8px !important;
        background: var(--glass-bg, rgba(255,255,255,0.85)) !important;
        border: 1px solid var(--glass-border, rgba(0,0,0,0.12)) !important;
        color: var(--text-primary, #1e293b) !important;
        font-size: 1.2rem !important;
        cursor: pointer !important;
        transition: background 0.2s ease;
        z-index: 1010 !important;
        flex-shrink: 0 !important;
        position: absolute !important;
        right: 5% !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        /* Ensure it's never invisible in dark mode */
        box-shadow: 0 1px 4px rgba(0,0,0,0.15) !important;
    }

    [data-theme="dark"] .mobile-menu-btn {
        background: rgba(255,255,255,0.1) !important;
        border-color: rgba(255,255,255,0.2) !important;
        color: #ffffff !important;
    }

    .mobile-menu-btn:hover {
        background: var(--bg-tertiary, #f1f5f9);
    }

    /* Logo size */
    .logo-icon {
        height: 36px !important;
    }

    /* ─── HERO SECTIONS ──────────────────────────────────── */

    .hero {
        padding-top: 5.5rem !important;
        padding-bottom: 3rem !important;
        min-height: auto !important;
        text-align: center !important;
    }

    .hero h1 {
        text-align: center !important;
    }

    .hero .cta-buttons {
        justify-content: center !important;
    }

    .product-hero,
    .pricing-hero,
    .about-hero,
    .partner-hero,
    .demo-hero,
    .use-cases-hero {
        padding-top: 6rem !important;
        padding-bottom: 3rem !important;
        min-height: auto !important;
    }

    /* ─── GRID LAYOUTS ───────────────────────────────────── */

    /* Force single column on all common grid patterns */
    .steps-container {
        grid-template-columns: 1fr !important;
    }

    .intro-section {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        padding: 3rem 5% !important;
    }

    .github-layout {
        grid-template-columns: 1fr !important;
        gap: 3rem !important;
    }

    /* ─── FONT SCALING ───────────────────────────────────── */

    .stat-number {
        font-size: clamp(2rem, 7vw, 3rem) !important;
    }

    .bento-metric {
        font-size: clamp(2rem, 7vw, 3.5rem) !important;
    }

    .plan-price {
        font-size: clamp(1.75rem, 6vw, 2.75rem) !important;
    }

    /* ─── HERO STATS ROW ─────────────────────────────────── */

    .hero-stats-inline {
        flex-wrap: wrap;
        gap: 0.75rem 0;
    }

    /* ─── ORB SIZE REDUCTION ─────────────────────────────── */

    .orb-1 {
        width: min(350px, 80vw) !important;
        height: min(350px, 80vw) !important;
    }

    .orb-2 {
        width: min(280px, 70vw) !important;
        height: min(280px, 70vw) !important;
    }

    .orb-3 {
        width: min(220px, 60vw) !important;
        height: min(220px, 60vw) !important;
    }

    /* ─── TOUCH TARGET MINIMUM SIZE ──────────────────────── */

    .btn {
        min-height: 44px;
    }

    /* ─── SECTION PADDING REDUCTION ─────────────────────── */

    .three-steps,
    .cost-savings,
    .features-section,
    .github-section,
    .comparison-section,
    .faq-section,
    .intro-section-wrapper {
        padding-top: 4rem !important;
        padding-bottom: 4rem !important;
    }

    /* ─── INDEX PAGE SECTION PADDING ─────────────────────── */

    .xagent-section,
    .features,
    .pricing,
    .cta-section {
        padding-top: 4rem !important;
        padding-bottom: 4rem !important;
    }

    .cost-savings {
        padding-top: 4rem !important;
        padding-bottom: 4rem !important;
    }

    .footer {
        padding-top: 3rem !important;
        padding-bottom: 2rem !important;
    }

    /* ─── HERO GRID SINGLE COLUMN ────────────────────────── */

    /* Force single column even if hero-right display:none
       doesn't collapse the second grid track */
    .hero-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        padding: 0 1.25rem !important;
    }

    /* ─── SOCIAL PROOF STATS ─────────────────────────────── */

    .social-proof-inner .hero-stat-item {
        padding: 0 1.25rem 0 0 !important;
    }

    .social-proof-inner .hero-stat-divider {
        margin-right: 1.25rem !important;
    }

    .social-proof-inner .hero-stat-number {
        font-size: 1.75rem !important;
    }

    /* ─── PREVENT NOWRAP OVERFLOW ────────────────────────── */

    .section-subtitle {
        white-space: normal !important;
    }

    /* ─── CTA BANNER BUTTONS STACK ───────────────────────── */

    .cta-banner .cta-banner-buttons {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
        padding: 0 1rem !important;
    }

    .cta-banner .cta-banner-buttons .btn {
        text-align: center !important;
        width: 100% !important;
    }

    /* ─── TEMPLATES GRID ─────────────────────────────────── */

    .templates-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ─── SMALL PHONES (480px) ───────────────────────────────── */

@media (max-width: 480px) {

    /* Tighter section padding */
    .three-steps,
    .cost-savings,
    .features-section,
    .github-section,
    .comparison-section,
    .faq-section {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }

    /* Hero heading */
    .hero h1 {
        font-size: clamp(1.75rem, 7.5vw, 2.5rem) !important;
    }

    /* Section titles */
    .section-title {
        font-size: clamp(1.4rem, 6.5vw, 2rem) !important;
    }

    /* Hero stat dividers hidden on tiny screens */
    .hero-stat-divider {
        display: none !important;
    }

    .hero-stat-item {
        padding: 0 0.75rem !important;
    }

    /* CTA buttons stack full-width */
    .cta-buttons {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .cta-buttons .btn {
        text-align: center;
        width: 100% !important;
        max-width: none !important;
    }

    /* Pricing grid 1 column */
    .pricing-grid {
        grid-template-columns: 1fr !important;
    }

    /* Bento grid 1 column */
    .bento-grid {
        grid-template-columns: 1fr !important;
    }

    .bento-card.col-2 {
        grid-column: span 1 !important;
    }

    /* Comparison table scroll on very narrow screens */
    .comparison-wrap {
        overflow-x: auto;
    }

    /* Partner / about hero subheadings */
    .product-hero-title,
    .pricing-hero-title {
        font-size: clamp(1.75rem, 7vw, 2.5rem) !important;
    }

    /* Savings bar label width */
    .savings-bar-label {
        width: 80px !important;
        font-size: 0.78rem !important;
    }

    /* Feature cards - less padding */
    .feature-card {
        padding: 1.25rem !important;
    }

    /* Step cards */
    .step-card {
        padding: 1.25rem !important;
    }

    /* Hero grid tighter on very small phones */
    .hero-grid {
        padding: 0 1rem !important;
    }

    /* Social proof stats wrap on tiny screens */
    .social-proof-inner .hero-stats-inline {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.5rem 0 !important;
    }

    .social-proof-inner .hero-stat-item {
        padding: 0.25rem 0.75rem !important;
    }

    .social-proof-inner .hero-stat-divider {
        display: none !important;
    }

    .social-proof-inner .hero-stat-number {
        font-size: 1.5rem !important;
    }

    /* CTA banner heading */
    .cta-banner h2 {
        font-size: clamp(1.5rem, 6vw, 2rem) !important;
    }

    .cta-banner-subtext {
        font-size: 0.9rem !important;
    }

    /* Footer brand max-width */
    .footer-brand {
        max-width: 100% !important;
    }

    /* Intro section buttons stack */
    .intro-section [style*="display: flex"] {
        flex-direction: column;
    }
}
