/* ============================================================
   MOBILE FIXES — myforgelabs.com
   Loaded LAST so it overrides earlier Tailwind / inline CSS.
   ============================================================ */

/* Global viewport hardening */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* Long word wrapping on all headings + paragraphs */
h1,
h2,
h3,
h4,
h5,
h6,
p,
li,
a,
span {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

h1,
h2,
h3 {
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* ============================================================
   Mobile menu: never let it inflate the document width.
   Original: right: -100% (can push layout offscreen right).
   Fix: keep right: 0 and use transform to hide.
   ============================================================ */
.mobile-menu {
  right: 0 !important;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out !important;
  will-change: transform;
}

.mobile-menu.open,
.mobile-menu[style*="right: 0"],
.mobile-menu[style*="right:0"],
.mobile-menu[style*="right: 0px"] {
  transform: translateX(0) !important;
}

/* ============================================================
   Decorative backgrounds: keep inside viewport.
   ============================================================ */
.psychedelic-bg {
  width: 100vw !important;
  max-width: 100%;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  max-width: 80vw;
  max-height: 80vw;
}

/* Particles canvas shouldn't push layout */
#particles-js {
  max-width: 100%;
  overflow: hidden;
}

/* ============================================================
   Mobile-only layout fixes (<= 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* Container padding sanity */
  .container,
  .container.mx-auto {
    max-width: 100% !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Hero: smaller headline, proper padding, full-width CTAs */
  #hero {
    min-height: auto;
  }

  #hero .container {
    padding-top: 6rem !important;
    padding-bottom: 3rem !important;
  }

  .hero-content h1 {
    font-size: clamp(1.6rem, 7vw, 2.4rem) !important;
    line-height: 1.15 !important;
    word-break: break-word;
  }

  .hero-content p,
  .hero-content li,
  .hero-content span {
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
  }

  /* Hide the IDE/typing code animation on mobile — it's decorative,
     renders poorly, and pushes the fold down dramatically. */
  .typing-effect-container,
  .floating .matrix-container {
    display: none !important;
  }

  /* Make sure hero CTAs are full-width and clearly tappable.
     Scope to anchor buttons only so we don't hit the typing-effect
     glassmorphism container. */
  #hero a.liquid-button,
  #hero a.glassmorphism {
    width: 100%;
    text-align: center;
    padding: 0.9rem 1rem !important;
    display: block !important;
    box-sizing: border-box;
  }

  /* Scroll indicator arrow positioning — keep it from
     overlapping the section below */
  .scroll-indicator {
    bottom: 10px !important;
  }

  /* ========================================================
     Section headings: no more cut-off words
     ======================================================== */
  section h2 {
    font-size: clamp(1.5rem, 6vw, 2.25rem) !important;
    line-height: 1.2 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  section h3 {
    font-size: clamp(1.15rem, 5vw, 1.5rem) !important;
    line-height: 1.25 !important;
  }

  section p {
    font-size: 0.95rem !important;
    line-height: 1.55 !important;
  }

  /* Service cards / glassmorphism tiles padding */
  .glassmorphism {
    padding: 1.25rem !important;
  }

  /* Grids collapse cleanly */
  .grid.grid-cols-2,
  .grid.md\:grid-cols-2,
  .grid.lg\:grid-cols-3,
  .grid.md\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* Section vertical rhythm */
  section.py-20 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
  }

  /* ========================================================
     Touch targets: min 44x44 for clickable items
     ======================================================== */
  .nav-link,
  .mobile-menu a,
  .mobile-menu-toggle,
  .mobile-submenu-item a,
  .cookie-link,
  footer a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .mobile-submenu-item {
    padding: 0.5rem 0 !important;
  }

  /* Make sure buttons are comfortably tall */
  .liquid-button,
  button,
  .cookie-button {
    min-height: 44px;
  }

  /* ========================================================
     Cookie banner: scrollable + smaller + under chat widget
     ======================================================== */
  .cookie-banner {
    padding: 14px !important;
    max-height: 80vh;
    overflow-y: auto;
    font-size: 0.9rem;
  }

  .cookie-content h3 {
    font-size: 1.1rem !important;
    margin-bottom: 8px !important;
  }

  .cookie-content p {
    font-size: 0.85rem !important;
    line-height: 1.4 !important;
    margin-bottom: 10px !important;
  }

  .cookie-categories {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    margin: 10px 0 !important;
  }

  .cookie-category {
    padding: 10px !important;
  }

  .category-description {
    font-size: 0.78rem !important;
  }

  .cookie-button {
    padding: 10px 14px !important;
    font-size: 0.9rem !important;
    width: 100%;
  }

  .cookie-buttons {
    gap: 8px !important;
  }

  .cookie-links {
    flex-wrap: wrap;
    gap: 10px 16px !important;
    margin-top: 10px !important;
  }

  .cookie-link {
    font-size: 0.8rem !important;
  }

  /* ========================================================
     Chatwoot floating bubble: keep smaller on mobile so
     it doesn't cover content.
     ======================================================== */
  .woot-widget-bubble,
  .woot--bubble-holder,
  .woot-widget-holder {
    transform: scale(0.8);
    transform-origin: bottom right;
  }

  /* ========================================================
     Navbar tightening
     ======================================================== */
  #navbar nav {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    gap: 0.5rem;
  }

  /* Shrink logo on mobile so it doesn't collide with hamburger */
  #navbar a.text-2xl {
    font-size: 1.1rem !important;
    min-width: 0;
    flex-shrink: 1;
  }

  #navbar a.text-2xl .text-gradient,
  #navbar a.text-2xl .text-white {
    font-size: 1.1rem !important;
  }

  #navbar img.h-10 {
    height: 2rem !important;
    width: auto !important;
    margin-right: 0.35rem !important;
  }

  .menu-toggle {
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  .menu-toggle i {
    font-size: 1.5rem !important;
  }

  /* ========================================================
     Forms
     ======================================================== */
  input,
  textarea,
  select {
    font-size: 16px !important; /* Prevents iOS auto-zoom on focus */
    max-width: 100%;
  }

  /* Prevent off-screen absolutely positioned pills */
  .service-card,
  .glassmorphism {
    max-width: 100%;
  }
}

/* ============================================================
   Extra-small devices (<= 360px): Galaxy S9, iPhone SE
   ============================================================ */
@media (max-width: 360px) {
  .hero-content h1 {
    font-size: clamp(1.4rem, 8vw, 2rem) !important;
  }

  section h2 {
    font-size: clamp(1.3rem, 7vw, 1.9rem) !important;
  }

  .container,
  .container.mx-auto {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .liquid-button {
    letter-spacing: 1px !important;
    padding: 0.8rem 1rem !important;
    font-size: 0.85rem !important;
  }
}

/* ============================================================
   Scroll offset so anchors land below the sticky header
   ============================================================ */
section[id] {
  scroll-margin-top: 80px;
}

/* ============================================================
   Respect reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .blob,
  .bg-gradient,
  .floating,
  .spinning-logo:hover {
    animation: none !important;
  }
}
