/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE OVERRIDES — Quant AI
   ══════════════════════════════════════════════════════════
   This file is loaded LAST and contains ONLY @media rules.
   No bare selectors. Desktop view is never affected.
   ══════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────
   HAMBURGER NAV TOGGLE (hidden on desktop)
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Show hamburger button (!important overrides inline style="display:none;") */
    .nav-toggle {
        display: flex !important;
        order: 1;
        align-items: center;
        justify-content: center;
        background: none;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 8px;
        color: var(--cos-text, rgba(245, 248, 255, 0.92));
        width: 40px;
        height: 40px;
        cursor: pointer;
        padding: 0;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
        transition: border-color 0.2s ease;
    }

    .nav-toggle:hover {
        border-color: rgba(34, 211, 238, 0.4);
    }

    .nav-toggle svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
    }

    nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        flex-wrap: nowrap;
    }

    nav > .logo {
        order: 2;
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Wrapper div stays as a flex row in the header — never becomes the panel */
    nav > div {
        order: 3;
        display: flex !important;
        align-items: center !important;
        margin-left: auto;
        flex: 0 0 auto;
    }

    /* Keep Launch QAI visible in the mobile header row at all times */
    nav .launch-button {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        margin-left: 0;
        padding: 0.55rem 1rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Mobile nav panel — .nav-links itself becomes the dropdown panel
       (not the wrapper div, so .launch-button stays in the header row) */
    nav.nav-open .nav-links {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(5, 6, 17, 0.98);
        border-top: 1px solid rgba(34, 211, 238, 0.12);
        border-bottom: 1px solid rgba(34, 211, 238, 0.12);
        padding: 1rem 1.5rem;
        gap: 0;
        z-index: 1000;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    }

    /* Nav items in mobile panel */
    nav.nav-open .nav-links li {
        width: 100%;
    }

    nav.nav-open .nav-links li a {
        display: block;
        padding: 0.85rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        font-size: 0.95rem;
    }

    nav.nav-open .nav-links li:last-child a {
        border-bottom: none;
    }

    /* Home dropdown in mobile panel — static section, no dropdown behavior */
    nav.nav-open .home-dropdown > a {
        pointer-events: none;
        cursor: default;
        border-bottom: none;
        padding-bottom: 0.4rem;
    }

    nav.nav-open .home-dropdown > a .dropdown-arrow {
        display: none;
    }

    nav.nav-open .home-dropdown-menu {
        display: block !important;
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
        margin: 0;
        min-width: 0;
    }

    nav.nav-open .home-dropdown-menu::before {
        display: none;
    }

    nav.nav-open .home-dropdown-menu li {
        width: 100%;
    }

    nav.nav-open .home-dropdown-menu li a {
        display: block;
        padding-left: 1.2rem;
        font-size: 0.88rem;
        color: var(--cos-text-muted, rgba(245, 248, 255, 0.72));
    }

    /* Account dropdown in mobile panel */
    nav.nav-open .account-dropdown .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        margin-top: 0;
        background: rgba(10, 14, 26, 0.6);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 10px;
        min-width: 0;
        box-shadow: none;
    }

    nav.nav-open .account-dropdown .dropdown-menu::before {
        display: none;
    }

    /* Light theme mobile panel */
    [data-theme="light"] nav.nav-open .nav-links {
        background: rgba(248, 250, 252, 0.98);
        border-top-color: rgba(0, 0, 0, 0.08);
        border-bottom-color: rgba(0, 0, 0, 0.08);
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    }

    [data-theme="light"] nav.nav-open .nav-links li a {
        border-bottom-color: rgba(0, 0, 0, 0.06);
    }

    [data-theme="light"] nav.nav-open .home-dropdown-menu li a {
        color: rgba(15, 23, 42, 0.72);
    }

    [data-theme="light"] .nav-toggle {
        border-color: rgba(0, 0, 0, 0.15);
        color: rgba(15, 23, 42, 0.85);
    }

    [data-theme="light"] .nav-toggle:hover {
        border-color: rgba(0, 120, 180, 0.4);
    }
}

/* ───────────────────────────────────────────
   HEADER & NAV — TABLET
   ─────────────────────────────────────────── */
@media (max-width: 1024px) {
    /* Tighten nav gap on tablets */
    .nav-links {
        gap: 1.2rem;
    }
}

/* ───────────────────────────────────────────
   HERO SECTION — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Override cosmic-pro hero grid */
    body.cosmic-pro .hero-content {
        grid-template-columns: 1fr;
    }

    /* Allow hero heading to wrap */
    body.cosmic-pro .hero h1 {
        white-space: normal;
        font-size: clamp(1.8rem, 6vw, 2.5rem);
    }

    /* Remove inline margin-left on hero paragraphs */
    .hero-text p {
        margin-left: 0 !important;
    }

    /* Hero chat area */
    .hero-chat-form {
        max-width: 100%;
    }

    .hero-chat-suggestions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .hero-suggestion {
        font-size: 0.8rem;
        padding: 0.5rem 0.8rem;
    }

    /* Signup box */
    .signup-box {
        padding: 1.2rem;
    }

    .hero-products-nav {
        gap: 0.4rem;
    }

    .hero-product-item {
        font-size: 0.85rem;
        padding: 0.5rem 0.6rem;
    }
}

/* ───────────────────────────────────────────
   STATS SECTION — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .stat-number {
        font-size: 2rem;
    }

    .stat-item {
        padding: 1rem;
    }
}

/* ───────────────────────────────────────────
   ABOUT SECTION — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Override inline text-align on about card label */
    .about-card-label {
        text-align: left !important;
        padding-right: 0 !important;
    }
}

/* ───────────────────────────────────────────
   CONTACT SECTION — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .contact-form-container {
        padding: 1.5rem;
    }

    .contact-method {
        padding: 1rem;
        gap: 1rem;
    }
}

/* ───────────────────────────────────────────
   FOOTER — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 2rem;
    }

    .footer-company-reg {
        font-size: 0.8rem;
        line-height: 1.6;
    }
}

/* ───────────────────────────────────────────
   CONTAINER & SECTION SPACING — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    body.cosmic-pro .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    body.cosmic-pro section {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }

    body.cosmic-pro footer.section--solid {
        padding: 2rem 0;
    }
}

/* ───────────────────────────────────────────
   DOWNLOAD / LAUNCH PAGE — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .launch-buttons-container {
        flex-direction: column;
        gap: 1.5rem;
    }

    .launch-card {
        width: 100%;
        max-width: 100%;
    }

    .launch-help-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .download-buttons-row {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .download-btn {
        width: 100%;
        max-width: 280px;
    }

    .tier-info-section {
        padding: 0.75rem;
    }
}

/* ───────────────────────────────────────────
   ACCOUNT PAGES — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Subscription pricing cards */
    .pricing-row {
        flex-direction: column;
        gap: 1.5rem;
    }

    .pricing-card {
        width: 100%;
        max-width: 100%;
    }

    /* Usage metrics */
    .usage-metrics-grid {
        grid-template-columns: 1fr;
    }

    /* Settings page */
    .auth-container {
        padding: 0 0.5rem;
    }

    .settings-content {
        padding: 1rem;
    }

    /* General account section stacking */
    .auth-section .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

@media (max-width: 480px) {
    /* Credits grid */
    .credits-grid {
        grid-template-columns: 1fr;
    }

    /* Team table horizontal scroll */
    .team-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ───────────────────────────────────────────
   AUTH PAGES — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 480px) {
    .auth-box {
        padding: 1.5rem 1rem;
    }

    .auth-section {
        padding: 2rem 0;
    }

    .auth-header h1 {
        font-size: 1.6rem;
    }
}

/* ───────────────────────────────────────────
   LEGAL & CONTENT PAGES — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .legal-content {
        padding: 1.5rem;
    }

    .legal-header {
        margin-bottom: 2rem;
    }

    /* Help centre layout already handled by helpcentre.html inline styles */
}

@media (max-width: 480px) {
    .legal-header h1 {
        font-size: 1.6rem;
        letter-spacing: 0.10em;
    }
}

/* ───────────────────────────────────────────
   TOUCH TARGETS & USABILITY — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Ensure minimum tap target sizes */
    .cta-button,
    .auth-button,
    .contact-submit,
    .signup-button,
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-tertiary,
    .about-btn,
    .ide-button,
    .whitepaper-button,
    .launch-button {
        min-height: 44px;
    }

    /* Cookie banner mobile adjustments */
    .cookie-banner {
        left: 8px;
        right: 8px;
        bottom: 8px;
    }

    .banner-content {
        flex-direction: column;
        gap: 12px;
    }

    .banner-actions {
        width: 100%;
    }

    /* Cookie popup mobile */
    .cookie-popup {
        width: 95%;
        max-width: 95%;
    }

    .cookie-actions {
        flex-direction: column;
    }

    .cookie-actions .btn {
        width: 100%;
    }

    /* Dropdown on mobile: full width */
    .account-dropdown .dropdown-menu {
        left: auto;
        right: 0;
        transform: translateY(-10px);
        min-width: 220px;
    }

    .account-dropdown:hover .dropdown-menu {
        transform: translateY(0);
    }
}

/* ───────────────────────────────────────────
   ARTICLES GRID — ALREADY HANDLED
   articles-grid collapses at 768px in styles.css
   ─────────────────────────────────────────── */

/* ───────────────────────────────────────────
   VISUAL ELEMENTS — MOBILE
   ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Reduce decorative element sizes */
    .qai-soundwave-orb {
        transform: scale(0.8);
    }

    .agi-core {
        transform: scale(0.8);
    }

    /* IDE mockup */
    .ide-body {
        flex-direction: column;
        min-height: auto;
    }

    .ai-assistant {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--cos-border);
    }
}
