/* Comprehensive Responsive Design System */
/* Mobile-first approach with all device optimizations */

/* Base Mobile Styles (320px - 767px) */
@media screen and (max-width: 767px) {
  /* Typography adjustments for mobile */
  :root {
    --text-display-large: 48px;
    --text-display: 40px;
    --text-heading-01: 32px;
    --text-heading-02: 28px;
    --text-heading-03: 24px;
    --text-heading-04: 20px;
    --text-body-large: 18px;
    --text-body: 16px;
    
    /* Spacing adjustments */
    --spacing-09: 48px;
    --spacing-10: 56px;
    --spacing-11: 64px;
    --spacing-12: 80px;
  }
  
  /* Hide entire animation sections on mobile for non-home pages */
  /* About page */
  .about-hero .hero-graphic,
  body[data-page="about"] .hero-graphic,
  
  /* Products page */
  .products-hero .hero-graphic,
  body[data-page="products"] .hero-graphic,
  .live-demo-section,
  
  /* Research page */
  .research-hero .hero-graphic,
  body[data-page="research"] .hero-graphic,
  
  /* Solutions page */
  .solutions-hero .hero-graphic,
  body[data-page="solutions"] .hero-graphic,
  .solutions-animation-container,
  
  /* All canvases except home */
  canvas#aboutAnimation,
  canvas#productsAnimation,
  canvas#researchAnimation,
  canvas#solutionsAnimation,
  canvas#solutions-animation,
  canvas#cognioAnimation,
  canvas#agent-flow-canvas {
    display: none !important;
  }
  
  /* Show home page animation but resized */
  canvas#cognio-animation-canvas {
    display: block !important;
  }
  
  /* Completely hide hero-graphic on non-home pages */
  section:not(.hero) .hero-graphic,
  .hero-graphic:has(#aboutAnimation),
  .hero-graphic:has(#researchAnimation),
  .hero-graphic:has(#solutionsAnimation),
  .hero-graphic:has(#productsAnimation),
  .hero-graphic:has(#cognioAnimation) {
    display: none !important;
  }
  
  /* Home page graphic should show the actual animation */
  .hero .hero-graphic {
    background: transparent !important;
  }
  
  .hero .hero-graphic::after {
    display: none !important;
  }
  
  @keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.05); opacity: 0.8; }
  }
  
  /* Navigation mobile menu */
  .nav-container {
    padding: 0 var(--spacing-03);
  }
  
  .nav-menu {
    position: fixed !important;
    top: 64px !important;
    left: -100%;
    width: 100%;
    height: calc(100vh - 64px);
    background: var(--color-background);
    flex-direction: column;
    padding: var(--spacing-04);
    gap: var(--spacing-03);
    transition: left 0.3s ease-in-out;
    z-index: 9999 !important;
    border-top: 1px solid var(--color-border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex !important;
    overflow-y: auto;
  }
  
  .nav-menu .nav-link {
    padding: var(--spacing-03) var(--spacing-02);
    font-size: var(--text-body-large);
    border-bottom: 1px solid var(--color-border);
    width: 100%;
    text-align: left;
  }
  
  .nav-menu .btn {
    width: 100%;
    margin-top: var(--spacing-03);
  }
  
  .nav-menu.active {
    left: 0 !important;
    display: flex !important;
  }
  
  .mobile-menu-toggle {
    display: flex !important;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
  }
  
  .mobile-menu-toggle span {
    display: block !important;
    width: 24px;
    height: 2px;
    background: var(--color-text-primary);
    transition: all var(--transition-base);
  }
  
  /* Hero section mobile */
  .hero {
    padding: var(--spacing-08) 0;
    min-height: auto;
  }
  
  /* Special mobile reordering for hero section */
  .hero-container {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-areas: 
      "title"
      "subtitle"
      "graphic"
      "actions" !important;
    gap: var(--spacing-04) !important;
  }
  
  .hero-content {
    display: contents !important; /* Allow children to participate in parent grid */
  }
  
  .hero-title {
    font-size: var(--text-display) !important;
    line-height: 1.2 !important;
    grid-area: title !important;
    text-align: center !important;
  }
  
  .hero-title span {
    font-size: inherit !important;
  }
  
  .hero-subtitle {
    font-size: var(--text-body-large);
    line-height: 1.5;
    grid-area: subtitle !important;
    text-align: center !important;
    padding: 0 var(--spacing-03) !important;
  }
  
  .hero-graphic {
    height: 200px !important;
    width: 200px !important;
    max-width: 200px !important;
    margin: 0 auto !important;
    grid-area: graphic !important;
    position: relative !important;
  }
  
  .hero-actions {
    flex-direction: column;
    width: 100%;
    grid-area: actions !important;
    display: flex !important;
    gap: var(--spacing-02) !important;
  }
  
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Grid adjustments */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
    gap: var(--spacing-03);
  }
  
  /* Cards and sections */
  .section {
    padding: var(--spacing-08) 0;
  }
  
  .card {
    padding: var(--spacing-03);
  }
  
  .metric-card {
    padding: var(--spacing-03);
  }
  
  /* Footer mobile */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-04);
  }
  
  /* Hide elements on mobile */
  .desktop-only {
    display: none;
  }
  
  /* Full width buttons on mobile */
  .btn {
    min-height: 44px; /* Touch-friendly size */
  }
  
  /* Inline metrics mobile */
  .inline-metrics {
    flex-direction: column;
    gap: var(--spacing-02);
  }
  
  .inline-metric {
    justify-content: space-between;
    width: 100%;
    padding: var(--spacing-02);
    background: var(--color-background-subtle);
    border-radius: var(--radius-medium);
  }
  
  /* When animation is hidden, content should take full width */
  .hero-container:has(.hero-graphic:empty),
  .hero-container:has(.hero-graphic[style*="display: none"]) {
    justify-content: center !important;
  }
  
  .hero-container .hero-content {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    text-align: center !important;
  }
  
  /* About page mobile optimizations */
  /* Reduce spacing above Our Mission on mobile */
  .about-page .hero + .section:first-of-type,
  body[data-page="about"] .hero + .section,
  .hero + .section:has(.mission-container) {
    padding-top: var(--spacing-05) !important;
  }
  
  .value-props {
    grid-template-columns: 1fr !important;
    gap: var(--spacing-03) !important;
  }
  
  .capabilities-grid {
    grid-template-columns: 1fr !important;
    gap: var(--spacing-03) !important;
  }
  
  .team-categories {
    grid-template-columns: 1fr !important;
    gap: var(--spacing-03) !important;
  }
  
  .team-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-02) !important;
  }
  
  .approach-grid {
    grid-template-columns: 1fr !important;
    gap: var(--spacing-03) !important;
  }
  
  .differentiators {
    grid-template-columns: 1fr !important;
    gap: var(--spacing-03) !important;
  }
  
  /* Products page mobile */
  .product-cards {
    grid-template-columns: 1fr !important;
  }
  
  .feature-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Solutions page mobile */
  .industry-grid {
    grid-template-columns: 1fr !important;
  }
  
  .solution-cards {
    grid-template-columns: 1fr !important;
  }
  
  .solutions-hero .hero-container,
  .solutions-page .hero-container {
    display: flex !important;
    flex-direction: column !important;
  }
  
  .solutions-hero .hero-content,
  .solutions-page .hero-content {
    width: 100% !important;
    flex: 1 1 100% !important;
    max-width: 100% !important;
    text-align: center !important;
  }
  
  .solutions-hero .hero-title,
  .solutions-page .hero-title {
    text-align: center !important;
    font-size: var(--text-display) !important;
  }
  
  .solutions-hero .hero-subtitle,
  .solutions-page .hero-subtitle {
    text-align: center !important;
    padding: 0 var(--spacing-03) !important;
  }
  
  /* Hide the entire graphic container on solutions page */
  .solutions-page .hero-graphic,
  body[data-page="solutions"] .hero-graphic {
    display: none !important;
  }
  
  /* Research page mobile */
  .research-areas {
    grid-template-columns: 1fr !important;
  }
  
  .paper-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Modal optimizations for mobile */
  .modal-content {
    width: 95% !important;
    max-width: none !important;
    margin: var(--spacing-02) !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
  
  .modal-body {
    padding: var(--spacing-03) !important;
  }
  
  /* Form optimizations for mobile */
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  
  input, select, textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
  
  /* Touch-friendly tap targets */
  a, button, .btn, .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* Tablet Styles (768px - 1023px) */
@media screen and (min-width: 768px) and (max-width: 1023px) {
  :root {
    --text-display-large: 64px;
    --text-display: 56px;
    --text-heading-01: 40px;
    --text-heading-02: 32px;
  }
  
  .container {
    padding: 0 var(--spacing-05);
  }
  
  .hero-container {
    grid-template-columns: 1fr;
    gap: var(--spacing-06);
  }
  
  .hero-title {
    font-size: var(--text-display) !important;
  }
  
  .hero-graphic {
    height: 350px;
  }
  
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-3, .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .nav-menu {
    gap: var(--spacing-03);
    position: static;
    flex-direction: row;
    height: auto;
    padding: 0;
    border: none;
    background: transparent;
  }
  
  .mobile-menu-toggle {
    display: none !important;
  }
}

/* Desktop Styles (1024px - 1439px) */
@media screen and (min-width: 1024px) and (max-width: 1439px) {
  .container {
    padding: 0 var(--spacing-06);
  }
  
  .hero-title {
    font-size: calc(var(--text-display-large) * 0.9) !important;
  }
}

/* Large Desktop (1440px+) */
@media screen and (min-width: 1440px) {
  .container {
    max-width: 1440px;
  }
}

/* Ultra-wide screens (1920px+) */
@media screen and (min-width: 1920px) {
  .container {
    max-width: 1600px;
  }
  
  :root {
    --text-display-large: 84px;
    --text-display: 72px;
  }
}

/* Landscape mobile adjustments */
@media screen and (max-width: 767px) and (orientation: landscape) {
  .hero {
    min-height: auto;
    padding: var(--spacing-06) 0;
  }
  
  .hero-graphic {
    height: 200px;
  }
}

/* Print styles */
@media print {
  .nav, .hero-graphic, .btn, .footer {
    display: none;
  }
  
  .hero-title {
    font-size: 32px !important;
    line-height: 1.3 !important;
  }
  
  .section {
    page-break-inside: avoid;
  }
}

/* Accessibility - High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --color-primary: #0040d0;
    --color-text-primary: #000000;
    --color-text-secondary: #333333;
    --color-background: #ffffff;
    --color-border: #000000;
  }
  
  .btn-primary {
    border: 2px solid var(--color-primary);
  }
}

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

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 48px;
    min-width: 48px;
  }
  
  .nav-link {
    padding: var(--spacing-02) var(--spacing-01);
  }
  
  .card:hover {
    transform: none;
  }
}

/* Specific device breakpoints */
/* iPhone SE */
@media screen and (width: 375px) {
  .hero-title {
    font-size: 36px !important;
  }
}

/* iPhone 12/13/14 Pro */
@media screen and (width: 390px) {
  .hero-title {
    font-size: 38px !important;
  }
}

/* iPhone 12/13/14 Pro Max */
@media screen and (width: 428px) {
  .hero-title {
    font-size: 42px !important;
  }
}

/* iPad */
@media screen and (width: 768px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* iPad Pro 11" */
@media screen and (width: 834px) {
  .hero-title {
    font-size: 60px !important;
  }
}

/* iPad Pro 12.9" */
@media screen and (width: 1024px) {
  .hero-title {
    font-size: 68px !important;
  }
}

/* Utility classes for responsive design */
.mobile-only {
  display: block;
}

.tablet-only {
  display: none;
}

.desktop-only {
  display: none;
}

@media (min-width: 768px) {
  .mobile-only {
    display: none;
  }
  
  .tablet-only {
    display: block;
  }
}

@media (min-width: 1024px) {
  .tablet-only {
    display: none;
  }
  
  .desktop-only {
    display: block;
  }
  
  .mobile-menu-toggle {
    display: none !important;
  }
}

/* Flexbox utilities */
.flex-mobile-column {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .flex-mobile-column {
    flex-direction: row;
  }
}

/* Text alignment utilities */
.text-mobile-center {
  text-align: center;
}

@media (min-width: 768px) {
  .text-mobile-center {
    text-align: left;
  }
}