/* Mobile Layout Fixes for Android Firefox Compatibility */

/* CRITICAL: Mobile Performance - Prevent video loading on mobile devices */
@media (max-width: 768px) {
  /* Hide all videos on mobile to force static images */
  /* Keep !important: JS may set inline display/opacity on these */
  #hero-video,
  #hero-video-2,
  #hero-video-3,
  .background-video {
    display: none !important;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

  /* Show hero poster image instead */
  /* Keep !important on display/visibility: JS may toggle these */
  #hero-poster {
    display: block !important;
    visibility: visible;
    opacity: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  }

  /* Hide sound toggle on mobile */
  /* Keep !important on display: style.css has .hero-image:hover #sound-toggle with display */
  #sound-toggle {
    display: none !important;
    visibility: hidden;
    opacity: 0;
  }

  /* Force enterprise section static background */
  .enterprise-ai {
    background: linear-gradient(135deg, rgba(248, 244, 240, 0.85) 0%, rgba(232, 221, 212, 0.7) 100%);
    min-height: 600px;
    position: relative;
  }

  /* Center team member role subtitle on mobile */
  .team-member .role {
    text-align: center;
  }

  .enterprise-ai::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('https://pub-fb3e683317b24cf8b4260121edae02be.r2.dev/images/robot-group-mobile.webp');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    opacity: 0.15;
    z-index: -1;
  }
}

/* Prevent horizontal scrolling on mobile */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Ensure all containers respect viewport width */
* {
  max-width: 100%;
}

/* Fix for wide elements that cause horizontal scroll */
.container, .hero, .features-section, .journal-pages-container {
  max-width: 100vw;
  overflow-x: hidden;
}

/* Container mobile improvements */
@media (max-width: 768px) {
  .container {
    max-width: 100vw;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
  }
}

/* Footer text contrast fixes for Android Firefox */
@media (max-width: 768px) {
  /* Simplify footer text for better mobile compatibility */
  /* These need !important to override style.css body:not(.homepage) selectors which have higher specificity */
  body:not(.homepage) .footer-content .footer-section h3,
  body:not(.homepage) .footer-content .footer-section a {
    background: none !important;
    background-clip: initial !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: white !important;
    color: white !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9);
    opacity: 1;
    font-weight: 500;
  }

  body:not(.homepage) .footer-content .footer-section a:hover {
    background: none !important;
    background-clip: initial !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: #d4c4a0 !important;
    color: #d4c4a0 !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9);
  }

  /* Footer bottom links enhanced contrast */
  /* These need !important: style.css has body:not(.homepage) rules with !important */
  body:not(.homepage) .copyright,
  body:not(.homepage) .footer-bottom-links a,
  body:not(.homepage) .privacy-settings-link {
    color: white !important;
    background: none !important;
    -webkit-text-fill-color: white !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9);
    opacity: 1 !important;
    font-weight: 500;
  }
}

/* Hero section mobile improvements */
@media (max-width: 768px) {
  .hero-content {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .hero-text {
    max-width: 100%;
  }

  .hero-visual {
    margin: 0 auto;
    max-width: 300px;
  }

  .hero h1 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.2;
  }
}

/* Journal pages mobile fixes - ONLY apply on mobile screens */
@media (max-width: 768px) {
  .journal-pages-container {
    margin: 0 auto;
    overflow: visible;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    position: relative;
  }

  .journal-page {
    position: relative !important;
    width: 32px;
    max-width: 32px;
    min-width: 32px;
    height: 280px;
    margin: 0 1px;
    transform: none !important;
    border-radius: 0 3px 3px 0;
    display: inline-block;
    flex-shrink: 0;
  }

  /* Create bookshelf effect - show pages as book spines */
  .journal-page:first-child {
    border-radius: 3px 0 0 3px;
  }

  .journal-page:last-child {
    border-radius: 0 3px 3px 0;
  }

  /* Center the entire journal section */
  .davinci-journal-showcase {
    display: flex;
    flex-direction: column;
    text-align: center;
    gap: 0;
    flex: 0;
  }

  /* Better journal navigation layout on mobile */
  .journal-navigation {
    margin-bottom: 1.5rem;
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
  }

  .journal-nav-button {
    background: rgba(45, 60, 52, 0.1);
    border: 1px solid rgba(45, 60, 52, 0.2);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    color: #2d3c34;
    cursor: pointer;
    transition: all 0.3s ease;
  }

  .journal-nav-button:hover {
    background: rgba(45, 60, 52, 0.2);
    transform: translateY(-1px);
  }
}

/* Preserve desktop journal page positioning */
@media (min-width: 769px) {
  .journal-page {
    position: absolute;
    width: 250px;
    height: 350px;
    transform: initial;
  }

  .journal-pages-container {
    position: relative;
    width: 100%;
    max-width: 350px;
    height: 500px;
    perspective: 1000px;
    margin-top: 80px;
    overflow: visible;
  }
}

/* Prevent text overflow everywhere */
@media (max-width: 768px) {
  p, h1, h2, h3, h4, h5, h6, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  /* Force text wrapping in navigation */
  nav a, .nav-button {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}

/* Blog post mobile improvements */
@media screen and (max-width: 768px) {
  .blog-content {
    padding: 1.5rem;
    margin: 0 0.5rem;
    overflow-x: hidden;
  }

  .content-body {
    overflow-x: hidden;
  }

  .content-body pre {
    overflow-x: auto;
    max-width: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  .content-body img {
    max-width: 100% !important;
    height: auto;
  }

  .content-body table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Fix absolute positioned elements on mobile */
@media (max-width: 768px) {
  .hero-visual {
    position: relative;
  }

  /* Ensure no elements extend beyond viewport */
  .panel-art,
  .background-sketches,
  .sacred-geometry-bg {
    max-width: 100vw;
    overflow: hidden;
  }
}

/* Typography improvements for small screens */
@media (max-width: 480px) {
  .hero h1 {
    font-size: 2rem !important;
    line-height: 1.1;
  }

  .hero-description {
    font-size: 1rem;
    line-height: 1.5;
  }

  .post-title {
    font-size: 1.6rem !important;
    line-height: 1.2;
  }
}

/* Fix mobile section title and subtitle layout - Match hero sizing */
@media (max-width: 768px) {
  /* All section titles match hero h1 sizing and alignment */
  /* Keep !important: overriding style.css rules at various specificity levels */
  .features-section h2,
  .section-title,
  .enterprise-ai h2,
  .team-section h2,
  .signup-section h2,
  .ai-for-good-text h2,
  .contact-header h2,
  .expert-answers-content h2,
  h2 {
    font-size: 2.5rem !important;
    line-height: 1.2;
    margin-bottom: 1rem;
    margin-top: 2rem;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    padding: 0; /* Let parent section handle padding */
  }

  /* Ensure all section containers match hero margins */
  .features-section,
  .enterprise-ai,
  .team-section,
  .signup-section,
  .ai-for-good-text,
  .contact-header,
  .expert-answers-content,
  section {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Force line break for Enterprise AI title on mobile */
  .features-section h2 {
    white-space: normal;
  }

  /* Control desktop vs mobile title display */
  /* Keep !important: fighting style.css display rules */
  .enterprise-title .desktop-title {
    display: none !important;
  }

  .enterprise-title .mobile-title {
    display: block !important;
    font-size: 2.5rem;
    line-height: 1.2;
    text-align: left;
    margin: 2rem 0 1rem 0;
    padding: 0; /* Let parent section handle padding */
  }

  .enterprise-title .mobile-title br {
    display: block;
  }

  /* Features section title mobile control */
  .features-header h2 .desktop-title {
    display: none !important;
  }

  .features-header h2 .mobile-title {
    display: block !important;
    font-size: 2.5rem;
    line-height: 1.2;
    text-align: left;
    margin: 0;
    padding: 0;
  }

  .features-header h2 .mobile-title br {
    display: block;
  }

  /* All subtitle/description text match hero subtitle sizing and alignment */
  .features-section p,
  .section-description,
  .section-intro,
  .enterprise-ai p,
  .team-section p,
  .signup-section p,
  .signup-intro,
  .ai-for-good-text p,
  .contact-header p,
  .expert-answers-content p,
  .hero-section + section p:first-of-type,
  .features-section .section-description {
    font-size: 1.2rem;
    line-height: 1.5;
    margin-bottom: 2rem;
    margin-top: 0;
    text-align: left;
    padding: 0; /* Same as headers - no extra padding */
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  /* Ensure subtitles have no extra margin/padding differences from headers */
  .enterprise-ai .section-intro,
  .features-section .section-description {
    padding-left: 0;
    padding-right: 0;
    margin-left: 0;
    margin-right: 0;
  }

  /* Adjust spacing between sections on mobile */
  .enterprise-ai {
    margin-top: 1.5rem; /* Reduced space from hero */
  }

  /* Move enterprise header (title and subtitle) up to overlap video */
  .enterprise-header {
    position: relative;
    z-index: 10;
    margin-bottom: -100px; /* Pull panels up over video */
    margin: 0 2em;
  }

  /* Adjust panels container to overlap video background */
  .circular-panels-wrapper {
    position: relative;
    z-index: 10;
    margin-top: 150px; /* Position panels properly on mobile */
  }

  .features-section {
    /* padding-top: 0.5rem; */
    clear: both;
    position: relative;
    z-index: 2;
  }

  .hero + section {
    margin-top: 1.5rem; /* Reduced space from hero */
    padding-top: 0.5rem;
    clear: both;
    position: relative;
    z-index: 2;
  }

  /* Fix any overlapping with video strips */
  .video-strip,
  .background-videos {
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
  }

  /* Reduce section spacing */
  .section-spacing {
    padding-bottom: 1rem;
  }
}

/* Extra small screens match hero sizing (480px) */
@media (max-width: 480px) {
  /* All section titles match hero h1 on small screens */
  .features-section h2,
  .section-title,
  .enterprise-ai h2,
  .team-section h2,
  .signup-section h2,
  .ai-for-good-text h2,
  .contact-header h2,
  .expert-answers-content h2,
  .enterprise-title .mobile-title,
  h2 {
    font-size: 2rem !important;
    line-height: 1.1;
    margin-bottom: 1rem;
  }

  /* All subtitles match hero description on small screens */
  .features-section p,
  .section-description,
  .section-intro,
  .enterprise-ai p,
  .team-section p,
  .signup-section p,
  .signup-intro,
  .ai-for-good-text p,
  .contact-header p,
  .expert-answers-content p {
    font-size: 1rem;
    line-height: 1.5;
  }
}

/* Fix dropdown positioning on mobile */
@media (max-width: 768px) {
  .language-switcher-dropdown {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    max-width: 90vw;
  }

  .privacy-dropdown-content {
    left: 0;
    transform: none;
    min-width: 140px;
    max-width: 90vw;
  }
}

/* Transparency and backdrop filter fixes for Android Firefox */
@media (max-width: 768px) {
  /* Remove complex backdrop filters that may not work on Android Firefox */
  .glass-effect,
  .backdrop-blur {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Simplify transparency effects */
  .language-switcher-dropdown {
    background-color: rgba(248, 244, 240, 0.98);
    backdrop-filter: none;
  }

  /* Ensure proper contrast for transparent elements */
  .overlay-text {
    background-color: rgba(248, 244, 240, 0.9);
    padding: 0.5rem;
    border-radius: 4px;
  }
}

/* Safe area adjustments for mobile browsers */
@media (max-width: 768px) {
  .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  header {
    padding-left: max(2rem, env(safe-area-inset-left));
    padding-right: max(2rem, env(safe-area-inset-right));
  }
}

/* iOS-specific fixes for footer background and video controls */
@supports (-webkit-appearance: none) {
  /* iPhone/Safari specific fixes */
  @media (max-width: 768px) {
    /* Fix footer background stretching on iOS */
    body:not(.homepage) .site-footer {
      background-size: cover, cover, cover, 100% 100%;
      background-attachment: local, local, local, local;
      -webkit-background-size: cover, cover, cover, 100% 100%;
      will-change: auto;
      transform: translateZ(0);
    }

    /* Prevent background blur on iOS */
    body:not(.homepage) .site-footer::before {
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
      transform: translateZ(0);
    }

    /* Ensure video controls work properly on iOS */
    #hero-video {
      -webkit-playsinline: true;
      playsinline: true;
      -webkit-appearance: none;
    }

    /* Fix background videos on iOS */
    .background-video {
      -webkit-playsinline: true;
      playsinline: true;
      -webkit-appearance: none;
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
    }

    /* Ensure video container doesn't cause issues on iOS */
    .video-background-container {
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
    }

    /* iOS video control styling */
    #sound-toggle {
      -webkit-appearance: none;
      appearance: none;
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      touch-action: manipulation;
    }
  }
}

/* Force GPU acceleration for smoother animations on mobile */
@media (max-width: 768px) {
  .journal-page,
  .hero-visual,
  .cta-button {
    transform: translateZ(0);
    will-change: transform;
  }
}

/* Contact panels text color improvements */
@media (max-width: 768px) {
  /* Make contact panel text more readable with white color */
  /* Keep !important: overriding style.css .contact-method h3 color */
  .contact-method h3 {
    color: #f8f4f0 !important;
  }

  .contact-method p {
    color: #f8f4f0 !important;
    opacity: 0.9;
  }

  .contact-link {
    color: #f8f4f0 !important;
  }

  .contact-link:hover {
    color: #d4c4a0 !important;
    border-bottom-color: #d4c4a0;
  }
}

/* Apply contact text color improvements to all screen sizes */
/* Keep !important: overriding style.css .contact-method h3 { color: #1e3a2b } */
.contact-method h3 {
  color: #f8f4f0 !important;
}

.contact-method p {
  color: #f8f4f0 !important;
  opacity: 0.9;
}

.contact-link {
  color: #f8f4f0 !important;
}

.contact-link:hover {
  color: #d4c4a0 !important;
  border-bottom-color: #d4c4a0;
}

.features-section {
  margin-top: 1rem !important;
  padding-top: 1rem !important;
}

/* Desktop-specific spacing adjustments */
@media (min-width: 769px) {

  /* Add more space after hero and create proper section spacing */
  .enterprise-ai {
    margin-top: 4rem; /* Much more space from hero */
    padding-top: 2rem;
  }

  .enterprise-header {
    position: relative;
    z-index: 10;
    margin-bottom: -100px; /* Pull panels up over video on desktop */
  }

  .circular-panels-wrapper {
    margin: 150px auto 0 auto;
    position: relative;
    z-index: 10;
  }

  .video-background-container {
    top: calc(56% + 0px);
  }
}

/* Mobile video strip panels layout */
@media (max-width: 768px) {
  /* Remove horizontal padding from circular panels wrapper on mobile */
  .circular-panels-wrapper {
    padding-left: 0;
    padding-right: 0;
  }

  .enterprise-ai .video-background-container {
    top: calc(62% + 0px);
  }

  /* Show all 4 panels stacked vertically, full width matching section headers */
  .panels-container {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, auto);
    gap: 1rem;
    margin: 0;
    padding-left: 1rem; /* Match section container padding */
    padding-right: 1rem; /* Match section container padding */
    padding-top: 0;
    padding-bottom: 0;
    min-height: auto;
    width: 100%;
    box-sizing: border-box;
  }

  /* Show all 4 panels on mobile in single column */
  .panels-container .panel {
    display: block;
    margin-top: 0;
    position: static;
    z-index: auto;
    max-height: none;
  }

  /* Override nth-child desktop rule that pulls panels 3/4 up to overlap */
  .panels-container .panel:nth-child(3),
  .panels-container .panel:nth-child(4) {
    margin-top: 0;
    position: static;
    z-index: auto;
  }

  /* Adjust panel styling for mobile - full width matching headers exactly */
  .panels-container .panel {
    padding: 1.5rem; /* Consistent padding */
    min-height: fit-content; /* Fit to content */
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 1rem 0;
    display: block;
    overflow: visible;
  }

  /* Adjust panel text for mobile - larger and more readable */
  .panel h3 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    hyphens: none;
    word-break: normal;
    -webkit-hyphens: none;
    -moz-hyphens: none;
    -ms-hyphens: none;
  }

  .panel p {
    font-size: 1.1rem;
    line-height: 1.5;
    hyphens: none;
    word-break: normal;
    overflow-wrap: break-word;
    -webkit-hyphens: none;
    -moz-hyphens: none;
    -ms-hyphens: none;
  }

  /* Scale down panel art for mobile */
  .panel-art {
    width: 60px;
    height: 60px;
  }

  /* Consistent panel art positioning for all panels on mobile */
  .panels-container .panel .panel-art {
    top: -5px;
    left: -5px;
    width: 60px;
    height: 60px;
    bottom: auto;
    right: auto;
  }
}

/* Mobile Navigation and Header Improvements */
@media (max-width: 768px) {
  /* Clean mobile header layout */
  header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

@media (max-width: 768px) {

  /* Logo stays on left */
  .logo {
    flex: 0 0 auto;
  }

  /* Inline header actions so flexbox spaces logo / lang switcher / hamburger */
  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    z-index: 10002;
  }

  .language-switcher {
    position: relative;
  }

  /* Hide header demo button - use navigation one instead */
  /* Keep !important: style.css has .mobile-demo-button with !important */
  .mobile-demo-button {
    display: none !important;
  }

  /* Navigation takes full width below logo */
  nav {
    flex: 1 1 100%;
    order: 2;
    margin-top: 0.5rem;
  }

  nav ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    align-items: center;
    margin: 0;
    padding: 0;
  }

  nav ul li {
    margin: 0;
    list-style: none;
  }

  /* Hide specific items on mobile */
  /* Keep !important: style.css has these with !important */
  .mobile-hide {
    display: none !important;
  }

  /* Show mobile-only items */
  /* Keep !important: style.css has .mobile-only { display: none } */
  .mobile-only {
    display: inline-block !important;
  }

  /* Style mobile demo button as regular nav item */
  .mobile-only a {
    background: #d4c4a0;
    color: #2d3c34;
    border: 2px solid #d4c4a0;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
  }

  .mobile-only a:hover {
    background: #e8ddc7;
    border-color: #e8ddc7;
    transform: translateY(-1px);
  }
}

/* ===== Hamburger Menu ===== */

/* Hide hamburger on desktop */
.hamburger-menu {
  display: none;
}

@media (max-width: 768px) {
  /* Hamburger button */
  .hamburger-menu {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 10003;
    order: 1;
    flex-shrink: 0;
  }

  .hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background-color: #2d3c34;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }

  /* Animate to X when active */
  .hamburger-menu.is-active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .hamburger-menu.is-active .hamburger-line:nth-child(2) {
    opacity: 0;
  }

  .hamburger-menu.is-active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Hide nav links by default on mobile */
  /* Keep !important: JS toggles .nav-open class */
  nav ul#main-nav-links {
    display: none !important;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem 0;
  }

  /* Show nav when toggled open */
  nav ul#main-nav-links.nav-open {
    display: flex !important;
  }

  /* When hamburger menu is open, show all items including mobile-hide ones */
  nav ul#main-nav-links.nav-open li.mobile-hide {
    display: list-item !important;
  }

  /* Nav takes full width below header row */
  nav {
    flex: 1 1 100%;
    order: 3;
  }
}

/* Desktop Header Layout - Fix positioning */
@media (min-width: 769px) {
  /* Keep !important: fighting mobile-first rules and style.css !important rules */
  .mobile-only {
    display: none !important;
  }

  .mobile-hide {
    display: revert !important;
  }

  nav ul li.mobile-hide {
    display: revert !important;
  }

  /* Ensure hamburger stays hidden on desktop */
  .hamburger-menu {
    display: none !important;
  }

  /* Restore proper desktop header layout */
  header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    padding: 2rem 4rem;
    gap: 0;
  }

  .logo {
    flex: 0 0 auto;
    order: 1;
  }

  nav {
    flex: 1 1 auto;
    order: 2;
    margin: 0;
    display: flex;
    justify-content: center;
  }

  .header-actions {
    flex: 0 0 auto;
    order: 3;
    position: static;
    display: flex;
    align-items: center;
    gap: 1rem;
    top: auto;
    right: auto;
  }

  .language-switcher {
    position: static;
  }

  /* Show desktop demo button, hide mobile one */
  /* Keep !important: fighting style.css .mobile-demo-button { display: none !important } */
  .mobile-demo-button {
    display: inline-block !important;
  }

  /* Desktop title display */
  /* Keep !important: fighting mobile rules */
  .enterprise-title .desktop-title {
    display: block !important;
  }

  .enterprise-title .mobile-title {
    display: none !important;
  }

  /* Features section desktop title display */
  .features-header h2 .desktop-title {
    display: block !important;
  }

  .features-header h2 .mobile-title {
    display: none !important;
  }
}

/* Mobile Video Fixes - Allow all videos but control via JavaScript */
@media (max-width: 768px) {
  /* Let JavaScript handle video visibility on mobile */
  #hero-video-2,
  #hero-video-3 {
    opacity: 0;
    pointer-events: none;
  }

  #hero-video {
    opacity: 1;
  }

  /* Reduce space between header and hero section on mobile */
  .hero {
    padding-top: 1rem;
    margin-top: 0;
  }

  .hero-content {
    margin-top: 0;
    padding-top: 0;
    gap: 1rem;
  }

  /* Fix hero-image container sizing on mobile */
  .hero-image {
    flex: none;
    width: 100%;
    max-width: 400px;
    height: 300px;
    aspect-ratio: 4/3;
    margin: 1rem auto; /* Reduced from 2rem to 1rem */
    position: relative;
    overflow: hidden;
  }

  /* Ensure first video shows poster frame on mobile */
  #hero-video {
    poster: url('https://pub-fb3e683317b24cf8b4260121edae02be.r2.dev/images/Davinci_the_painter_painting_a_robot_in_a_line_art.webp');
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
  }

  /* Also fix the poster image */
  .davinci-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
  }

  .hero-video {
    max-width: 100%;
    height: auto;
  }

  /* Disable complex video cycling on mobile for better performance */
  .background-video {
    display: none;
  }

  /* Show only the default background video on mobile */
  #background-video-default {
    display: block;
  }

  /* Fix mobile features section layout */
  .features-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
    text-align: center;
    padding: 0 1rem;
  }

  .feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 280px;
  }

  .feature-item h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
    line-height: 1.2;
  }

  .feature-item p {
    margin-top: 0.5rem;
    line-height: 1.4;
    font-size: 0.95rem;
  }

  /* Center CTA buttons better on mobile - side by side */
  .cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    margin: 0.3rem auto 0 auto;
    padding: 0 1rem;
    width: 100%;
    box-sizing: border-box;
  }

  /* Only target CTA buttons in the hero section */
  .hero .cta-button,
  .hero .primary-button,
  .hero .secondary-button {
    width: 300px;
    max-width: 85%;
    text-align: center;
    justify-content: center;
    align-items: center;
    display: flex;
    white-space: nowrap;
    margin: 0 auto;
  }

  /* Extra specific override for Request demo button centering */
  .hero .cta-buttons .primary-button {
    text-align: center;
    justify-content: center;
    align-items: center;
    display: flex;
  }

  /* Keep header Request demo button normal size */
  .mobile-demo-button,
  header .cta-button {
    width: auto;
    max-width: none;
    margin: 0;
    min-width: 120px;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
  }

  /* Ensure sound toggle button is visible and functional on mobile */
  /* Keep !important on display: earlier rule in this file hides it */
  #sound-toggle {
    display: block !important;
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(45, 60, 52, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.9;
    transition: all 0.3s ease;
    pointer-events: auto;
    user-select: none;
  }

  #sound-toggle:hover,
  #sound-toggle:focus,
  #sound-toggle:active {
    opacity: 1;
    background: rgba(45, 60, 52, 0.95);
    transform: translateY(-1px);
  }
}

/* Static Images Mode - Show static backgrounds when videos are disabled */
.enterprise-ai.static-images-mode {
  background: linear-gradient(135deg, #f8f4f0 0%, #e8ddd4 100%);
  background-size: cover;
  background-position: center;
  position: relative;
  min-height: 600px;
}

.enterprise-ai.static-images-mode::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* Modern browsers with WebP support */
  background-image: url('https://pub-fb3e683317b24cf8b4260121edae02be.r2.dev/images/robot-group-mobile.webp');
  background-image: image-set(
    url('https://pub-fb3e683317b24cf8b4260121edae02be.r2.dev/images/robot-group-mobile.webp') type('image/webp'),
    url('https://pub-fb3e683317b24cf8b4260121edae02be.r2.dev/images/robot-group-mobile.png') type('image/png')
  );
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.2;
  z-index: -1;
}

/* Optimize static image for mobile */
@media (max-width: 768px) {
  .enterprise-ai.static-images-mode::before {
    background-size: contain;
    background-position: center center;
    opacity: 0.1;
    background-repeat: no-repeat;
  }

  .enterprise-ai.static-images-mode {
    min-height: 400px;
    background: linear-gradient(135deg, rgba(248, 244, 240, 0.95) 0%, rgba(232, 221, 212, 0.95) 100%);
  }
}

/* iPhone 12 Pro specific fixes (390px width) */
@media (max-width: 400px) {
  /* Header positioning fixes */
  .header-actions {
    right: 0.5rem;
    top: 0.8rem;
    z-index: 1000;
  }

  .language-switcher-current {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
  }

  /* Logo positioning on very small screens */
  .logo {
    margin-left: 0.5rem;
  }

  .logo img {
    max-height: 35px;
    width: auto;
  }

  .logo span {
    font-size: 1.1rem;
  }

  /* Navigation fixes for iPhone 12 Pro */
  nav ul {
    padding-right: 0.5rem;
    margin: 0;
  }

  nav ul li {
    margin: 0 0.3rem;
  }

  nav ul li a {
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
  }

  /* Hero section adjustments */
  .hero-content {
    padding: 0.5rem;
    gap: 0.8rem;
  }

  .hero-text h1 {
    font-size: 1.6rem;
    line-height: 1.1;
    margin-bottom: 0.8rem;
  }

  .hero-text p {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 1rem;
  }

  /* Feature list in hero - better spacing */
  .hero .features {
    gap: 0.5rem;
    margin: 1rem 0;
  }

  .hero .feature {
    font-size: 0.8rem;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    display: flex;
    flex-direction: row;
    gap: 0.3rem;
  }

  .hero .feature-icon {
    font-size: 1.5rem;
    min-width: 1.5rem;
    max-width: 1.5rem;
    height: 1.5rem;
    margin-right: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  /* Make heart icon specifically smaller */
  .hero .feature-icon-heart {
    font-size: 0.75rem !important;
  }

  /* Disable hyphenation for hero feature text - better mobile readability */
  .hero .feature-text {
    hyphens: none;
    word-break: keep-all;
    overflow-wrap: break-word;
    line-height: 1.3;
  }

  /* Ensure feature containers can wrap naturally */
  .hero .feature {
    flex-wrap: wrap;
    max-width: 100%;
    margin-bottom: 0.2rem;
    padding: 0.1rem 0;
  }

  /* Mobile layout for hero features - allow third item to wrap */
  .hero .features {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.1rem;
    margin: 0.3rem auto 0.4rem auto;
    max-width: 300px;
  }

  /* First two features on same row, third on new line */
  .hero .feature:nth-child(1),
  .hero .feature:nth-child(2) {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
  }

  .hero .feature:nth-child(3) {
    flex: 1 1 100%;
    justify-self: flex-start;
  }
}

/* Force mobile hero layout on all mobile devices */
@media (max-width: 480px) {
  .hero .features {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.1rem;
    margin: 0.3rem auto 0.4rem auto;
    max-width: 300px;
  }

  .hero .feature:nth-child(1),
  .hero .feature:nth-child(2) {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
    margin-bottom: 0.2rem;
    padding: 0.1rem 0;
  }

  .hero .feature:nth-child(3) {
    flex: 1 1 100%;
    justify-self: flex-start;
    margin-bottom: 0.2rem;
    padding: 0.1rem 0;
  }

  /* CTA buttons - more touch-friendly */
  .cta-buttons {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .primary-button,
  .secondary-button {
    min-height: 44px;
    font-size: 0.9rem;
    padding: 0.7rem 1.2rem;
    border-radius: 8px;
  }

  /* Enterprise section title */
  .enterprise-title .mobile-title {
    font-size: 1.6rem;
    line-height: 1.1;
  }

  /* Panel text in enterprise section - improved mobile readability */
  .panel h3 {
    font-size: 1.3rem;
    line-height: 1.3;
    margin-bottom: 0.75rem;
    font-weight: 600;
    hyphens: none;
    word-break: normal;
    -webkit-hyphens: none;
    -moz-hyphens: none;
    -ms-hyphens: none;
  }

  .panel p {
    font-size: 1.1rem;
    line-height: 1.5;
    hyphens: none;
    word-break: normal;
    overflow-wrap: break-word;
    -webkit-hyphens: none;
    -moz-hyphens: none;
    -ms-hyphens: none;
  }

  /* Features section title */
  .features-header h2 .mobile-title {
    font-size: 1.6rem;
    line-height: 1.1;
  }

  /* Journal pages - ensure they fit */
  .journal-pages-container {
    padding: 0 0.5rem;
    overflow-x: visible;
  }

  .journal-page {
    min-width: 28px;
    width: 28px;
    margin: 0 0.5px;
  }

  /* Prevent text overflow on small screens */
  * {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Improve touch targets */
  /* Keep !important: style.css has same rule with !important */
  button, a, [role="button"] {
    min-height: 32px !important;
  }

  /* Footer adjustments */
  .footer-content {
    padding: 1rem 0.5rem;
  }

  .footer-section {
    margin-bottom: 1rem;
  }

  .footer-section h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }

  .footer-section a {
    font-size: 0.85rem;
    line-height: 1.4;
  }
}

/* Ensure static mode content is visible */
.enterprise-ai.static-images-mode .enterprise-header,
.enterprise-ai.static-images-mode .circular-panels-wrapper {
  position: relative;
  z-index: 2;
}

/* Hero poster image styling when videos are disabled */
#hero-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* Alternative approach: Create a mobile-specific navigation layout */
@media (max-width: 768px) {
  .mobile-nav-container {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .mobile-nav-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .mobile-nav-items {
    display: flex;
    gap: 1rem;
    align-items: center;
  }
}

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

  html {
    scroll-behavior: auto !important;
  }
}

/* Additional iPhone 12 Pro fixes for specific viewport issues */
@media (max-width: 390px) {
  /* Ensure no horizontal scrolling on exact iPhone 12 Pro width */
  html {
    overflow-x: hidden;
    max-width: 100vw;
  }

  body {
    overflow-x: hidden;
    max-width: 100vw;
    position: relative;
  }

  /* Fix hero image container that might overflow */
  .hero-image {
    max-width: 350px;
    margin: 0.5rem auto;
  }

  /* Constrain wide SVG elements */
  .background-sketches,
  .feature-bg-sketch {
    max-width: 100vw;
    overflow: hidden;
  }

  /* Fix enterprise panels container */
  .circular-panels-wrapper {
    max-width: 100%;
    overflow: hidden;
    padding: 0 0.5rem;
  }

  .panels-container {
    max-width: 100%;
    gap: 0.5rem;
  }

  /* Journal showcase container */
  .davinci-journal-showcase {
    max-width: 100%;
    overflow: hidden;
    padding: 0 0.25rem;
  }

  /* Language switcher dropdown positioning */
  .language-switcher-dropdown {
    right: 0;
    left: auto;
    min-width: 200px;
    max-width: 280px;
  }

  /* Fix any potentially wide flex containers */
  .features-container,
  .enterprise-content,
  .hero-content {
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* Fix potential horizontal scroll from sections */
  section {
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  /* Improve team section on iPhone 12 Pro */
  .team-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 0.5rem;
  }

  /* Fix footer width issues */
  .site-footer {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .footer-content {
    max-width: 100%;
    padding: 1rem 0.5rem;
  }
}

/* Extra fixes for very narrow screens (iPhone SE and smaller) */
@media (max-width: 375px) {
  .hero-text h1 {
    font-size: 1.4rem;
  }

  .enterprise-title .mobile-title,
  .features-header h2 .mobile-title {
    font-size: 1.4rem;
  }

  .journal-page {
    min-width: 24px;
    width: 24px;
  }

  .logo span {
    font-size: 1rem;
  }

  nav ul li a {
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
  }
}

/* FINAL: Fix overflow and ensure proper padding on mobile panels */
@media (max-width: 768px) {
  .enterprise-ai .panels-container .panel {
    padding: 1.5rem; /* Slightly smaller but equal padding */
    margin-bottom: 1rem;
    min-height: fit-content; /* Fit to content */
    height: auto; /* Natural height based on content */
    display: block; /* Use block instead of flex */
    overflow: visible; /* Allow content to show */
  }

  .enterprise-ai .panels-container .panel h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1.2rem; /* Slightly smaller for better fit */
  }

  .enterprise-ai .panels-container .panel p {
    margin-bottom: 0;
    font-size: 1rem; /* Slightly smaller for better fit */
    line-height: 1.4;
  }
}
