/* Mobile-First Responsive Fixes */

/* Mobile Navigation */
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.mobile-nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100%;
    background: var(--surface-color);
    z-index: 1001;
    transition: right 0.3s ease;
    padding: 2rem;
    border-left: 1px solid var(--border-color);
}

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

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-nav-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-nav-links li {
    margin-bottom: 1rem;
}

.mobile-nav-links a {
    display: block;
    padding: 1rem 0;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem;
    transition: color 0.3s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-nav-links a:hover {
    color: var(--accent-color);
}

/* Mobile Breakpoints */
@media (max-width: 768px) {
    .mobile-nav-toggle {
        display: block;
    }
    
    .nav-links {
        display: none;
    }
    
    /* Mobile Hero Adjustments */
    .hero {
        padding: 4rem 1rem 2rem;
        min-height: 90vh;
        position: relative;
        /* Add fallback gradient background for mobile */
        background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 50%, #0f0f0f 100%);
        overflow: hidden;
    }
    
    /* Add subtle animated background pattern for mobile */
    .hero::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: 
            radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.05) 0%, transparent 50%);
        animation: subtleFloat 20s ease-in-out infinite;
        z-index: 1;
    }
    
    @keyframes subtleFloat {
        0%, 100% { transform: translateY(0px) rotate(0deg); }
        33% { transform: translateY(-10px) rotate(1deg); }
        66% { transform: translateY(5px) rotate(-0.5deg); }
    }
    
    /* Hide WebGL canvas on mobile - too heavy */
    .hero-visual {
        display: none !important;
    }
    
    /* Hide WebGL controls on mobile */
    .topology-controls {
        display: none !important;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
        padding: 0;
        min-height: auto;
        position: relative;
        z-index: 2;
    }
    
    .hero-visual-placeholder {
        order: 2;
        display: none; /* Hide on mobile to save space */
    }
    
    .hero-text {
        order: 1;
    }
    
    .hero-intro {
        max-width: none;
    }
    
    .hero-title {
        font-size: clamp(1.8rem, 8vw, 2.5rem);
        line-height: 1.1;
        margin-bottom: 1rem;
    }
    
    .hero-subtitle {
        font-size: clamp(1.8rem, 8vw, 2.5rem);
        margin-bottom: 1.5rem;
        line-height: 1.2;
        text-align: center;
        position: relative;
        min-height: clamp(1.8rem, 8vw, 2.5rem);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Fix language switcher alignment and size on mobile */
    .language-switcher {
        font-size: clamp(1.8rem, 8vw, 2.5rem) !important;
        line-height: 1.2 !important;
        text-align: center !important;
        display: block;
        margin: 0 auto;
        width: 100%;
        position: relative;
        min-height: 1.2em; /* Prevent layout shift */
    }
    
    /* Ensure morphing text effect works properly on mobile and stays centered */
    .morphing-text-effect {
        font-size: inherit;
        line-height: inherit;
        text-align: center !important;
        width: 100% !important;
        display: block !important;
        margin: 0 auto;
        position: relative !important;
        min-height: 1.2em; /* Reserve space to prevent layout shift */
        overflow: visible;
    }
    
    /* Force morphing text containers to stay centered and prevent layout shifts */
    .morphing-text {
        text-align: center !important;
        left: 0 !important;
        top: 0 !important;
        transform: none !important;
        width: 100% !important;
        white-space: nowrap !important;
        position: absolute !important;
        display: block !important;
    }
    
    /* Override any absolute positioning for mobile */
    .hero-subtitle .morphing-text-effect {
        position: relative !important;
        display: block !important;
        text-align: center !important;
        width: 100% !important;
        min-height: 1.2em !important;
        margin: 0 auto;
    }
    
    .hero-subtitle .morphing-text {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        right: 0 !important;
        transform: none !important;
        display: block !important;
        text-align: center !important;
        width: 100% !important;
        margin: 0;
    }
    
    /* Center hero features and bullets */
    .hero-features {
        margin: 2rem auto;
        text-align: center;
        max-width: 400px;
    }
    
    .feature-point {
        margin-bottom: 1rem;
        font-size: 0.9rem;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .feature-point .bullet {
        color: var(--accent-color);
        font-weight: bold;
        flex-shrink: 0;
    }
    
    .hero-buttons {
        margin-top: 2rem;
        text-align: center;
        display: flex;
        justify-content: center;
        width: 100%;
    }
    
    .hero-buttons .btn {
        margin: 0 auto;
    }
    
    .hero-description {
        font-size: 1rem;
        line-height: 1.5;
        margin-bottom: 2rem;
        padding: 0 1rem;
        text-align: center;
        margin-top: 0; /* Ensure consistent spacing */
    }
    
    /* Prevent layout shifts during animations */
    .hero-text {
        position: relative;
    }
    
    .hero-intro {
        max-width: none;
        position: relative;
    }
    
    .btn {
        padding: 1rem 2rem;
        font-size: 1rem;
        min-height: 48px; /* Touch-friendly */
    }
    
    /* Mobile WebGL Controls - Hidden since WebGL is disabled on mobile */
    .topology-controls {
        display: none !important;
    }
    
    #info-btn {
        display: none !important;
    }
    
    #panel-toggle {
        display: none !important;
    }
    
    #panel-content {
        display: none !important;
    }
    
    /* Mobile Agents Section */
    .agents-typography {
        gap: 2rem;
        margin-top: 2rem;
    }
    
    .agent-domain {
        padding: 1.5rem 0;
    }
    
    .domain-header {
        padding: 0;
    }
    
    .domain-title {
        font-size: 1.3rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }
    
    .domain-description {
        font-size: 0.95rem;
        line-height: 1.5;
        margin-bottom: 1rem;
    }
    
    .domain-capabilities.collapsed-view {
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .capability {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    /* Mobile Magazine Grid */
    .executive-magazine-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 1rem;
    }
    
    .magazine-card {
        padding: 1.5rem;
    }
    
    .magazine-title {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .magazine-text {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    .magazine-tags {
        gap: 0.4rem;
        margin-top: 1rem;
    }
    
    .magazine-tag {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }
    
    /* Mobile Screenshots Grid */
    .glowing-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 2rem;
    }
    
    .grid-item {
        min-height: 14rem;
    }
    
    .card-3d-body {
        padding: 1rem;
        gap: 0.8rem;
    }
    
    .card-item h3 {
        font-size: 1.1rem;
    }
    
    .card-item p {
        font-size: 0.8rem;
        height: auto;
    }
    
    .image-item {
        margin-top: 1rem;
    }
    
    /* Mobile Advantages */
    .advantages-typography {
        gap: 2rem;
        margin-top: 2rem;
    }
    
    .advantage-item {
        padding: 1.5rem 0;
    }
    
    .advantage-title {
        font-size: 1.3rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }
    
    .advantage-number {
        font-size: 1rem;
        margin-right: 1rem;
    }
    
    .advantage-description {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    /* Mobile Section Headers */
    .section-title {
        font-size: clamp(1.8rem, 6vw, 2.5rem);
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    .section-subtitle {
        font-size: 1rem;
        line-height: 1.5;
        padding: 0 1rem;
    }
    
    /* Mobile Container */
    .container {
        padding: 0 1rem;
    }
    
    /* Mobile Navigation Brand */
    .nav-brand {
        gap: 0.5rem;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .logo-icon {
        height: 1.8rem;
        width: 1.8rem;
    }
}

/* Tablet Breakpoint */
@media (max-width: 1024px) and (min-width: 769px) {
    .hero-content {
        gap: 3rem;
    }
    
    .topology-controls {
        top: 2rem;
        left: 2rem;
    }
    
    .glowing-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .executive-magazine-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* Small Mobile Breakpoint */
@media (max-width: 480px) {
    .hero {
        padding: 3rem 0.5rem 2rem;
    }
    
    .hero-title {
        font-size: clamp(1.5rem, 7vw, 2rem);
    }
    
    .hero-subtitle {
        font-size: clamp(1.5rem, 7vw, 2rem);
        position: relative;
        min-height: clamp(1.5rem, 7vw, 2rem);
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 1.5rem;
    }
    
    /* Ensure language switcher scales down properly on small screens */
    .language-switcher {
        font-size: clamp(1.5rem, 7vw, 2rem) !important;
    }
    
    .hero-description {
        font-size: 0.9rem;
        padding: 0 0.5rem;
        text-align: center;
    }
    
    /* Ensure morphing text stays centered on very small screens */
    .hero-subtitle .morphing-text {
        text-align: center !important;
    }
    
    .container {
        padding: 0 0.5rem;
    }
    
    .mobile-nav-menu {
        width: 100%;
        right: -100%;
    }
    
    .mobile-nav-menu.active {
        right: 0;
    }
}

/* High-DPI Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-icon,
    .btn-github-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape Mobile Orientation */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
        padding: 2rem 1rem;
    }
    
    .hero-content {
        min-height: auto;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
    
    .hero-text {
        order: 1;
    }
    
    .hero-visual-placeholder {
        order: 2;
        display: block;
    }
    
    /* Keep WebGL disabled even in landscape mobile mode */
    .hero-visual {
        display: none !important;
    }
    
    .topology-controls {
        display: none !important;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Support Enhancement */
@media (prefers-color-scheme: dark) {
    .mobile-nav-menu {
        background: var(--surface-color);
        border-left-color: var(--border-color);
    }
    
    #panel-content {
        background: rgba(10, 10, 10, 0.95);
    }
}
