/* ==========================================================================
   MOBILE OPTIMIZATIONS — Signverse Infra
   Overrides desktop styles for viewports below 992px and 768px
   ========================================================================== */

/* --- Base & Reset for Mobile --- */
html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Hide mobile-specific elements on desktop */
.mobile-menu-toggle {
  display: none;
}
.mobile-cta {
  display: none;
}

@media (max-width: 992px) {
  /* --- Navigation & Header --- */
  .site-header {
    transition:
      transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
      background 0.3s ease;
  }

  .site-header.is-hidden {
    transform: translateY(-100%);
  }

  .site-header__inner {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .header-cta {
    display: none; /* Hide desktop CTA */
  }

  /* Hamburger Menu Button */
  .mobile-menu-toggle {
    display: block;
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    z-index: 1000;
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .hamburger-box {
    width: 24px;
    height: 16px;
    display: inline-block;
    position: relative;
  }

  .hamburger-inner {
    display: block;
    top: 50%;
    margin-top: -1px;
  }

  .hamburger-inner,
  .hamburger-inner::before,
  .hamburger-inner::after {
    width: 24px;
    height: 2px;
    background-color: var(--text);
    position: absolute;
    transition-property: transform, opacity;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    border-radius: 2px;
  }

  .hamburger-inner::before,
  .hamburger-inner::after {
    content: "";
    display: block;
  }

  .hamburger-inner::before {
    top: -7px;
  }

  .hamburger-inner::after {
    bottom: -7px;
  }

  /* Hamburger Open State */
  .mobile-menu-toggle[aria-expanded="true"] .hamburger-inner {
    transform: rotate(45deg);
  }
  .mobile-menu-toggle[aria-expanded="true"] .hamburger-inner::before {
    top: 0;
    opacity: 0;
  }
  .mobile-menu-toggle[aria-expanded="true"] .hamburger-inner::after {
    bottom: 0;
    transform: rotate(-90deg);
  }

  /* Fullscreen Nav Overlay */
  .nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(11, 13, 16, 0.95); /* Darker for better contrast */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px; /* Perfect vertical spacing */
    transform: translateY(-100%);
    opacity: 0;
    transition:
      transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.5s ease;
    z-index: 999; /* Below toggle but above content */
    pointer-events: none;
    padding: 40px 20px; /* Increased padding */
    box-sizing: border-box; /* Fix viewport overflow */
  }

  .nav.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav__link {
    font-size: 18px; /* Improved readability */
    font-weight: 600; /* Slightly bolder */
    color: var(--text);
    text-decoration: none;
    padding: 16px 24px;
    opacity: 0;
    transform: translateY(20px);
    transition:
      opacity 0.3s ease,
      transform 0.3s ease,
      background 0.2s ease,
      color 0.2s ease;

    /* Pill button styles */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 280px;
    text-align: center;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.03);
    -webkit-font-smoothing: antialiased;
    letter-spacing: 0.5px;
  }

  .nav__link:hover,
  .nav__link:active,
  .nav__link.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--brand); /* Gold highlight */
  }

  .nav.is-open .nav__link {
    opacity: 1;
    transform: translateY(0);
  }

  /* Staggered animation for links */
  .nav.is-open .nav__link:nth-child(1) {
    transition-delay: 0.1s;
  }
  .nav.is-open .nav__link:nth-child(2) {
    transition-delay: 0.15s;
  }
  .nav.is-open .nav__link:nth-child(3) {
    transition-delay: 0.2s;
  }
  .nav.is-open .nav__link:nth-child(4) {
    transition-delay: 0.25s;
  }
  .nav.is-open .nav__link:nth-child(5) {
    transition-delay: 0.3s;
  }
  .nav.is-open .nav__link:nth-child(6) {
    transition-delay: 0.35s;
  }

  .mobile-cta {
    display: flex; /* match other pills */
    justify-content: center;
    align-items: center;
    margin-top: 24px; /* Space for divider */
    font-size: 18px;
    padding: 16px 24px;
    background: var(--brand);
    color: var(--brand-fg);
    border-radius: 99px;
    font-weight: 600;
    position: relative;
    width: 100%;
    max-width: 280px;
  }

  /* Divider above Request Quote */
  .mobile-cta::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
  }

  .mobile-cta:hover,
  .mobile-cta:active {
    background: var(--brand-deep);
    color: var(--brand-fg); /* override the gold text color */
  }

  /* Prevent scrolling when menu is open */
  body.menu-open {
    overflow: hidden;
  }
}

@media (max-width: 768px) {
  /* --- Typography Adjustments --- */
  h1,
  .hero__title {
    font-size: clamp(32px, 8vw, 48px) !important;
    line-height: 1.1;
  }
  h2,
  .section-title {
    font-size: clamp(28px, 6vw, 36px) !important;
  }
  h3 {
    font-size: 24px !important;
  }
  p {
    font-size: 16px !important;
    line-height: 1.6;
  }

  /* --- Layout & Spacing --- */
  .container {
    padding-left: 20px !important;
    padding-right: 20px !important;
    width: 100% !important;
  }

  section {
    padding-top: 60px !important;
    padding-bottom: 60px !important;
  }

  /* --- Hero Section --- */
  .hero {
    min-height: 100vh;
    padding-top: 100px;
    text-align: center;
  }

  .hero__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .hero__cta {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }

  .hero__cta .button {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 16px 24px; /* Larger touch targets */
  }

  /* --- Grid to Stack --- */
  .grid,
  .segments-grid,
  .products-grid,
  .projects-grid,
  .features-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 24px !important;
  }

  /* --- Cards --- */
  .card,
  .segment-card,
  .product-card,
  .project-card,
  .feature-card {
    width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box;
  }

  /* Fix Mobile Image Rendering for Project Cards */
  .project-card__media {
    display: block;
    width: 100%;
    min-height: 250px; /* Fallback for browsers lacking aspect-ratio */
    flex-shrink: 0; /* Prevent flex squishing */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0); /* iOS Safari rendering fix */
  }

  /* --- Buttons & Touch Targets --- */
  button,
  .button,
  a,
  input,
  select,
  textarea {
    min-height: 44px; /* Apple/WCAG touch target minimum */
  }

  .button {
    padding: 12px 24px;
    font-size: 16px;
    width: 100%;
    justify-content: center;
  }

  /* --- Forms --- */
  .form-group,
  .form-row {
    flex-direction: column;
    gap: 16px;
  }

  input,
  textarea {
    width: 100%;
    padding: 16px; /* Larger touch area for inputs */
    font-size: 16px; /* Prevent iOS zoom */
  }

  /* --- Footer --- */
  .site-footer {
    padding: 40px 20px;
  }

  .footer-inner {
    display: flex;
    flex-direction: column;
    gap: 32px;
  }

  .footer-col {
    width: 100%;
    text-align: left;
  }

  .footer-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 430px) {
  /* Ultra-small devices (iPhone Mini, etc) */
  .hero__title {
    font-size: clamp(28px, 10vw, 36px) !important;
  }

  .site-header__inner {
    padding: 12px 16px;
  }
}
