/* ============================================
   MOBILE OPTIMIZATIONS - All rules scoped to mobile
   Desktop view is unchanged; only @media (max-width: 940px) and below.
   ============================================ */

/* --- Safe areas (notch, home indicator) - mobile only --- */
@media (max-width: 940px) {
  header#site-header,
  #site-header {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-left: calc(clamp(24px, 4vw, 64px) + env(safe-area-inset-left, 0px));
    padding-right: calc(clamp(24px, 4vw, 64px) + env(safe-area-inset-right, 0px));
  }

  .footer-bottom {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  /* Cookie banner - safe area on notched devices */
  #cookie-banner {
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    right: calc(24px + env(safe-area-inset-right, 0px));
  }

  /* Full-screen mobile nav height - use dynamic viewport */
  header nav#primary-nav {
    max-height: calc(100dvh - 100px) !important;
  }

  @supports not (height: 100dvh) {
    header nav#primary-nav {
      max-height: calc(100vh - 100px) !important;
    }
  }

  /* Hero and full-screen panels - dynamic viewport */
  .hero-centered {
    min-height: 100dvh !important;
  }

  main .hero-centered:first-of-type {
    min-height: calc(100dvh - 60px - 1dvh) !important;
    height: calc(100dvh - 60px - 1dvh) !important;
  }

  @supports not (height: 100dvh) {
    .hero-centered {
      min-height: 100vh !important;
    }
    main .hero-centered:first-of-type {
      min-height: calc(100vh - 60px - 1vh) !important;
      height: calc(100vh - 60px - 1vh) !important;
    }
  }

  /* Vanta disabled on mobile: CSS-only hero background so LCP isn't blocked */
  body.vanta-disabled-mobile #vanta-bg {
    background: radial-gradient(ellipse 120% 70% at 50% 0%, rgba(123, 126, 242, 0.2) 0%, rgba(123, 126, 242, 0.08) 40%, transparent 70%),
                radial-gradient(ellipse 80% 50% at 50% 100%, rgba(123, 126, 242, 0.12) 0%, transparent 60%),
                var(--bg);
    opacity: 1;
  }

  /* --- Navigation / Header --- */
  header .brand-img {
    height: 56px;
    max-width: 120px;
    width: auto;
    object-fit: contain;
  }
  header {
    right: 0;
  }
  .nav-toggle {
    min-width: 44px;
    min-height: 44px;
  }
  header nav#primary-nav .nav-links li a,
  header nav#primary-nav .header-actions .btn-header {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 12px 20px;
  }

  /* --- Typography --- */
  .page-body,
  main p,
  .panel p {
    font-size: clamp(0.95rem, 2vw + 0.9rem, 1rem);
    line-height: 1.6;
  }
  .page-section-title,
  main h2,
  .section-title {
    font-size: clamp(1.4rem, 4vw, 1.6rem) !important;
  }

  /* --- Card grids: single column --- */
  .solutions-grid,
  .services-grid.solutions2-grid,
  #solutions-content .solutions2-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }
  .solutions-grid .card,
  .solutions-grid .service-card,
  .services-grid .service-card {
    margin-bottom: 1rem;
    padding: 1rem 1.25rem !important;
  }
  .solutions-grid .card-number,
  .card .card-number {
    font-size: 1.5rem !important;
  }
  .partners-grid,
  .page-our-partners .partners-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    gap: 1rem;
  }
  .partners-grid .gs-partner-card,
  .partners-grid .card {
    padding: 1rem 1.25rem !important;
  }

  /* --- Two-column layouts: stack --- */
  .two-col-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }
  .two-col-grid .key-benefits-box {
    min-height: auto;
  }

  /* --- Benefits / features box --- */
  .key-benefits-box {
    width: 100%;
    padding: 1.25rem 1rem !important;
  }
  .key-benefits-box ul {
    padding-left: 1.25rem;
  }
  .key-benefits-box li {
    margin-bottom: 0.5rem;
  }

  /* --- CTA sections --- */
  .page-cta .cta-buttons,
  main .panel.page-cta .cta-buttons {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-cta .cta-buttons .btn,
  main .panel.page-cta .cta-buttons .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
  .page-cta,
  main .panel.page-cta {
    padding: 1.5rem 1rem !important;
  }
  .cta-row {
    flex-direction: column;
    gap: 12px;
  }
  .cta-row .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  /* --- Footer --- */
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }
  .foot-col {
    margin-bottom: 0.5rem;
  }
  .footer-nav a,
  .foot-col a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .footer-bottom p {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* --- Panels --- */
  .panel {
    padding: 1rem 1.5rem !important;
  }

  /* --- Page navigation (back link, breadcrumbs) --- */
  .page-nav-row {
    gap: 12px;
    margin-bottom: 1rem;
  }
  .page-back {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 0;
  }

  /* --- Images --- */
  img {
    max-width: 100%;
    height: auto;
  }
  .partners-grid .gs-partner-card__logo-wrap img,
  .partners-grid .gs-partner-card__logo-wrap picture img,
  .page-our-partners .partners-grid img {
    max-width: 160px;
    width: auto;
    height: auto;
  }
  .partners-grid .gs-partner-card__logo-wrap,
  .page-our-partners .partners-grid .gs-partner-card__logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /* --- Solutions section (homepage): transparent background on mobile only --- */
  .solutions2-section {
    background: transparent !important;
  }
  .solutions2-bg-grid-wrap {
    opacity: 0.15;
  }

  /* --- Industries (homepage): stacked cards on mobile instead of slideshow --- */
  .industries-test-blades {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    flex-direction: column !important;
    gap: 0;
  }
  .industries-test-blade {
    flex: 0 0 auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    cursor: default;
    background: rgba(18, 18, 22, 0.85);
  }
  .industries-test-blade:last-of-type {
    border-bottom: none;
  }
  .industries-test-blade .industries-test-blade-v {
    display: none !important;
  }
  .industries-test-blade .industries-test-blade-h {
    display: block !important;
    opacity: 1 !important;
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    font-size: 1.35rem;
    padding: 1rem 1.25rem 0.5rem;
  }
  .industries-test-blade .industries-test-blade-content {
    display: flex !important;
    opacity: 1 !important;
    padding: 0 1.25rem 1.25rem;
    padding-top: 0.5rem;
  }
  .industries-test-blade .industries-test-blade-bg {
    opacity: 0;
  }
  .industries-test-blade .industries-test-blade-overlay {
    display: none;
  }
  .industries-test-blade-content p {
    font-size: 0.95rem;
  }
  .industries-test-blade-pills {
    margin-bottom: 12px;
  }
  .industries-test-blade-pill {
    font-size: 0.75rem;
    padding: 6px 12px;
  }
  .industries-test-dots {
    display: none !important;
  }

  /* --- Global Presence (homepage): stack map and legend --- */
  .global-presence {
    flex-direction: column !important;
    min-height: auto;
  }
  .global-presence-left,
  .global-presence-right {
    width: 100% !important;
  }
  .global-presence-map-wrap {
    width: 100%;
    min-height: 240px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .global-presence-map-wrap .global-presence-map {
    min-height: 240px;
    max-height: 320px;
  }
  .global-presence-right .locations-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .global-presence-left .locations-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .global-presence-right .locations-grid .dropdown-card-title,
  .global-presence-left .locations-grid .dropdown-card-title {
    white-space: normal;
    overflow: visible;
  }

  /* --- Newsroom: full width entries, content no overflow --- */
  .page-newsroom .newsroom-entry {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .page-newsroom .newsroom-entry-content {
    padding: 1rem !important;
    overflow-x: hidden;
  }
  .page-newsroom .newsroom-entry-content-inner {
    max-width: 100%;
  }
  .page-newsroom .newsroom-entry-text {
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
  .page-newsroom .newsroom-entry-partner-logo img,
  .page-newsroom .newsroom-entry-optronix-logo img {
    max-width: 120px;
    height: auto;
  }
  .page-newsroom .newsroom-entry-logos {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
}

/* --- Small phone fine-tuning (e.g. iPhone SE 375px) --- */
@media (max-width: 480px) {
  .solutions2-section {
    clip-path: none;
  }

  .solutions2-wrapper {
    clip-path: none;
  }

  .hero-title-blur-card h1,
  .hero-centered h1,
  .page-hero-title {
    font-size: 1.75rem !important;
  }
  .hero-title-blur-card .sub,
  .page-hero-tagline {
    font-size: 1rem !important;
  }

  .partners-grid .gs-partner-card__logo-wrap img,
  .partners-grid .gs-partner-card__logo-wrap picture img,
  .page-our-partners .partners-grid img {
    max-width: 140px;
  }

  .container {
    padding-inline: 1rem;
  }
}

/* --- Industries: readability and density tweaks on small mobile --- */
@media (max-width: 360px) {
  .industries-test-blade-content p {
    font-size: 0.95rem;
    line-height: 1.55;
  }

  .industries-test-blade-pill {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  .section-title {
    font-size: clamp(1rem, 5vw, 1.5rem) !important;
  }
}

