/* ===================================================
   SNAP GROWTH MARKETING — mobile.css
   Loaded AFTER style.css so these rules win without
   !important arms races. Mobile-first fixes:
   - Hamburger visibility & toggle
   - Fluid layout, no horizontal scroll
   - Typography & spacing
   - WhatsApp float safe positioning
   - CTA hierarchy
   =================================================== */

/* ---- 1. Global guards: no horizontal scroll, safe box sizing ---- */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}
*, *::before, *::after { box-sizing: border-box; }
img, video, svg, iframe { max-width: 100%; height: auto; }

/* Lock scroll when mobile menu is open (class set by components.js) */
body.menu-open { overflow: hidden; touch-action: none; }

/* ===================================================
   2. HEADER / HAMBURGER + SLIDE-IN DRAWER
   Root cause of the previous "click does nothing" bug:
   - .nav-container got position:relative + z-index:901 at mobile,
     creating a stacking context that trapped #nav-links inside it.
   - The toggle also fought display:none vs display:flex rules from
     the desktop baseline.
   Fix:
   - Backdrop + panel live OUTSIDE .nav-container (sibling elements),
     so no parent stacking context traps them.
   - Panel uses right: -100% → right: 0 transition (not display swap),
     so transitions are smooth and the element is always in the DOM.
   - z-index: 1200 for the panel, 1100 for the backdrop — above
     everything except modals (which are 1000 and hidden by default;
     bumped below via lead-popup override if ever needed).

   CSS custom properties let you tune without touching selectors.
   =================================================== */

:root {
  --drawer-width: min(86vw, 360px);
  --drawer-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --drawer-duration: 0.32s;
  --drawer-bg: rgba(5, 12, 24, 0.98);
  --nav-logo-height-desktop: 100px;
  --nav-logo-height-mobile: 78px;
}

/* ---- Logo: image-only, responsive height, aspect-ratio preserved ---- */
.nav-logo { display: inline-flex; align-items: center; min-width: 0; }
.nav-logo-img {
  height: var(--nav-logo-height-desktop);
  width: auto;          /* preserve aspect ratio */
  max-width: 100%;
  display: block;
  object-fit: contain;
}

/* ---- Desktop baseline: hamburger hidden, drawer + backdrop hidden ---- */
.hamburger { display: none; }
.nav-backdrop { display: none; }
.mobile-drawer { display: none; }

/* ---- Mobile: ≤1023px ---- */
@media (max-width: 1023px) {
  /* Shrink logo for mobile header */
  .nav-logo-img { height: var(--nav-logo-height-mobile); }

  /* Hamburger button — always visible on mobile, visibility owned by CSS */
  .hamburger {
    display: inline-flex !important;
    position: relative;
    z-index: 905;
    width: 44px;
    height: 44px;
    padding: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .hamburger span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.3s var(--drawer-ease), opacity 0.2s ease;
  }
  .hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .hamburger.open span:nth-child(2) { opacity: 0; }
  .hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Hide desktop-only nav bits on mobile */
  .nav-phone,
  .btn-nav { display: none !important; }

  /* Hide the desktop horizontal nav-links list entirely on mobile —
     we render a dedicated body-level drawer instead (see below). */
  #nav-links.nav-links { display: none !important; }

  /* Keep nav-container normal flow; no new stacking context. */
  .nav-container {
    position: relative;
    z-index: auto;
  }

  /* ---- BACKDROP: click to dismiss ---- */
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    z-index: 1100;
    transition: opacity var(--drawer-duration) var(--drawer-ease),
                visibility 0s linear var(--drawer-duration);
  }
  .nav-backdrop.show {
    opacity: 1;
    visibility: visible;
    transition: opacity var(--drawer-duration) var(--drawer-ease),
                visibility 0s linear 0s;
  }

  /* ---- DRAWER PANEL (body-level) — slide in from right ----
     Injected at the END of <body> so NO ancestor can create a
     containing-block for this position:fixed element.
     That was the final bug: when #navbar.scrolled added
     backdrop-filter, a drawer nested inside the navbar was
     clipped to the navbar's 60px-ish strip. Body-level = immune. */
  .mobile-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: -100%;              /* HIDDEN STATE */
    bottom: 0;
    left: auto;
    width: var(--drawer-width);
    max-width: 100vw;
    background: var(--drawer-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
    z-index: 1200;
    overflow: hidden;          /* drawer itself does NOT scroll */
    overscroll-behavior: contain;
    transition: right var(--drawer-duration) var(--drawer-ease);
  }
  .mobile-drawer.open {
    right: 0;                  /* ACTIVE STATE */
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto;
  }

  /* Drawer header (logo + close button) */
  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    background: var(--drawer-bg);
    z-index: 2;
  }
  .mobile-drawer-logo { display: inline-flex; align-items: center; }
  .mobile-drawer-logo img {
    height: 36px;
    width: auto;
    object-fit: contain;
    display: block;
  }
  .mobile-drawer-close {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #fff;
    font-size: 1.05rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-drawer-close:hover { background: rgba(255, 255, 255, 0.14); }

  /* Drawer nav — grows to fill remaining height and scrolls independently */
  .mobile-drawer-nav {
    padding: 8px 14px 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .mobile-drawer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
  }
  .mobile-drawer-links > li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .mobile-drawer-links > li:last-child { border-bottom: none; }
  .mobile-drawer-links > li > a,
  .mobile-drawer-links .mobile-submenu-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 14px 12px;
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.4;
    color: #f8fafc;
    background: transparent;
    border: none;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, padding-left 0.2s ease;
    font-family: inherit;
  }
  .mobile-drawer-links > li > a:hover,
  .mobile-drawer-links > li > a:focus-visible,
  .mobile-drawer-links .mobile-submenu-toggle:hover,
  .mobile-drawer-links .mobile-submenu-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    padding-left: 16px;
    outline: none;
  }
  .mobile-drawer-links > li > a.nav-active {
    background: rgba(99, 179, 237, 0.12);
    color: #fff;
  }

  /* Submenu (Services) — accordion */
  .mobile-submenu-toggle {
    justify-content: space-between;
  }
  .mobile-submenu-toggle > span { flex: 1; }
  .mobile-submenu-toggle .fa-chevron-down {
    transition: transform 0.25s var(--drawer-ease);
    font-size: 0.85rem;
    opacity: 0.85;
  }
  .mobile-submenu.open .mobile-submenu-toggle .fa-chevron-down {
    transform: rotate(180deg);
  }
  .mobile-submenu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s var(--drawer-ease);
  }
  .mobile-submenu.open .mobile-submenu-list {
    max-height: 900px;  /* enough for all 13 service links */
  }
  .mobile-submenu-list li {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
  }
  .mobile-submenu-list a {
    display: block;
    padding: 11px 14px 11px 24px;
    font-size: 0.93rem;
    font-weight: 500;
    color: #cbd5e1;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
  }
  .mobile-submenu-list a:hover,
  .mobile-submenu-list a:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    padding-left: 28px;
    outline: none;
  }

  /* CTA inside drawer — sticky at bottom, never overlaps nav */
  .mobile-drawer-cta {
    display: flex;
    flex-shrink: 0;           /* never compress */
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px 18px 8px;
    padding: 14px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #0055cc 0%, #0077ee 100%);
    border-radius: 12px;
    box-shadow: 0 6px 22px rgba(0, 85, 204, 0.45);
    text-align: center;
  }
  .mobile-drawer-cta:hover { filter: brightness(1.08); }

  /* Contact shortcuts — flex-shrink 0 so they don't compress */
  .mobile-drawer-contact {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    gap: 4px;
    margin: 8px 14px 0;
    padding: 14px 4px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .mobile-drawer-contact a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    font-size: 0.92rem;
    font-weight: 500;
    color: #cbd5e1;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
  }
  .mobile-drawer-contact a:hover,
  .mobile-drawer-contact a:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    outline: none;
  }
  .mobile-drawer-contact .fa-phone { color: #63b3ed; }
  .mobile-drawer-contact .fa-whatsapp { color: #25D366; }
}

/* ===================================================
   3. LAYOUT & SPACING  (≤768px)
   Fluid container, consistent padding, grid → stack
   =================================================== */
@media (max-width: 768px) {
  .container {
    width: 100%;
    padding-left: 20px;
    padding-right: 20px;
  }

  /* Hero — readable on small screens */
  #hero {
    padding: 96px 20px 56px;
    gap: 28px;
    min-height: auto;
  }
  .hero-badge { font-size: 0.72rem; padding: 6px 12px; }
  .hero-headline {
    font-size: clamp(1.75rem, 7.5vw, 2rem); /* h1 28–32px band */
    line-height: 1.22;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
  }
  .hero-sub {
    font-size: 0.95rem;       /* body 14–16px */
    line-height: 1.65;
    max-width: 46ch;          /* reduce paragraph width for readability */
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 28px;
  }

  /* Hide decorative blobs/grid on mobile — cleaner + faster paint */
  .hero-blob { opacity: 0.15; }
  .hero-scroll-hint { display: none; }

  /* Sections — consistent rhythm */
  section { padding-left: 0; padding-right: 0; }
  .section-header { margin-bottom: 32px; padding: 0 4px; }
  .section-header h2 {
    font-size: clamp(1.5rem, 6vw, 1.85rem);
    line-height: 1.25;
  }
  .section-header p { font-size: 0.95rem; line-height: 1.6; }

  /* Trust / stats — single source of truth */
  .trust-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .trust-metric { padding: 20px 12px; }
  .metric-number { font-size: clamp(1.75rem, 7vw, 2.2rem); }
  .metric-label { font-size: 0.78rem; }
}

/* ===================================================
   4. CTA HIERARCHY  (≤768px)
   One clear primary, outline is clearly secondary
   =================================================== */
@media (max-width: 768px) {
  .hero-ctas {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 36px;
  }
  .hero-ctas .btn-primary,
  .hero-ctas .btn-outline {
    width: 100%;
    justify-content: center;
    padding: 14px 22px;
    font-size: 0.95rem;
  }
  /* Primary = solid gradient (already set), elevate it visually */
  .hero-ctas .btn-primary {
    box-shadow: 0 6px 22px rgba(0, 85, 204, 0.45);
  }
  /* Secondary = clear outline, subtle fill */
  .hero-ctas .btn-outline {
    background: transparent;
    border-width: 1.5px;
    box-shadow: none;
  }
}

/* ===================================================
   5. TYPOGRAPHY polish on mobile
   =================================================== */
@media (max-width: 768px) {
  body { font-size: 15px; line-height: 1.65; }
  p    { line-height: 1.65; max-width: 62ch; }
  h1   { line-height: 1.22; }
  h2   { line-height: 1.25; }
  h3   { line-height: 1.3; font-size: 1.1rem; }

  /* Prevent long strings (URLs, emails) forcing horizontal scroll */
  a, p, li { word-break: break-word; overflow-wrap: anywhere; }
}

/* ===================================================
   6. WHATSAPP FLOATING BUTTON — safe positioning
   Respect iOS safe-area, sit above footer, never cover CTAs
   =================================================== */
.whatsapp-float {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  z-index: 750;                       /* under modals (≥1000), above content */
}
.whatsapp-float .wa-tooltip { display: none; }  /* tooltip useless on touch */

@media (max-width: 768px) {
  .whatsapp-float {
    width: 52px;
    height: 52px;
    font-size: 1.4rem;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 16px;
  }
  /* Reserve space at bottom of the page so the floating button never
     overlaps the final section's CTA / footer links. */
  body { padding-bottom: 72px; }
  /* If the sticky CTA bar appears, push the WA button up so they don't stack */
  .sticky-cta:not(.hidden) ~ .whatsapp-float,
  body:has(.sticky-cta:not(.hidden)) .whatsapp-float {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}

/* ===================================================
   7. GRIDS → STACK on small screens
   =================================================== */
@media (max-width: 640px) {
  .services-grid,
  .portfolio-grid,
  .blog-grid,
  .why-grid,
  .contact-grid,
  .footer-grid,
  .team-grid,
  .mission-grid,
  .features-grid,
  .about-grid,
  .about-values,
  .results-grid,
  .process-timeline,
  .portfolio-page-grid {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }
  .trust-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* ===================================================
   8. NAV CONTAINER — prevent logo/hamburger collision
   =================================================== */
@media (max-width: 1023px) {
  .nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
  }
  .nav-logo { flex: 0 1 auto; min-width: 0; max-width: 62%; }
  .nav-logo-img { max-height: 82px; width: auto; }
  .nav-actions { margin-left: auto; gap: 8px; }
}

/* Very small phones */
@media (max-width: 380px) {
  .nav-container { padding: 8px 12px; }
  .hero-headline { font-size: 1.65rem; }
  .hero-sub { font-size: 0.9rem; }
  .whatsapp-float { width: 48px; height: 48px; font-size: 1.3rem; }
}

/* ===================================================
   9. REDUCED MOTION — respect user preferences
   =================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===================================================
   10. MOBILE DRAWER — HARD GUARANTEE list items render
   Defensive overrides so nothing global (e.g. a stray
   `ul { display:none }` in a future edit, or a style.css
   rule that targets `nav ul li`) can hide the drawer
   links. High-specificity + !important used sparingly.
   =================================================== */
@media (max-width: 1023px) {
  #mobile-drawer.mobile-drawer {
    display: flex !important;
    flex-direction: column !important;
    visibility: visible;
    opacity: 1;
  }
  #mobile-drawer .mobile-drawer-nav {
    display: block !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #mobile-drawer .mobile-drawer-links {
    display: flex !important;
    flex-direction: column !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
  }
  #mobile-drawer .mobile-drawer-links > li {
    display: list-item !important;
    width: 100%;
    visibility: visible !important;
    opacity: 1 !important;
  }
  #mobile-drawer .mobile-drawer-links > li > a,
  #mobile-drawer .mobile-drawer-links .mobile-submenu-toggle {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: #f8fafc !important;
    text-decoration: none;
  }
  #mobile-drawer .mobile-submenu-list li {
    display: list-item !important;
    visibility: visible !important;
  }
  #mobile-drawer .mobile-submenu-list a {
    display: block !important;
    color: #cbd5e1 !important;
    text-decoration: none;
  }
  /* Make sure the drawer header (logo + close) always renders */
  #mobile-drawer .mobile-drawer-header { display: flex !important; }
  /* And the CTA + contact block at the bottom */
  #mobile-drawer .mobile-drawer-cta     { display: flex !important; }
  #mobile-drawer .mobile-drawer-contact { display: flex !important; }
}
