/* ==========================================================================
   HADITECH — MOBILE TOUCH & VIEWPORT REFINEMENTS
   Loaded last. Mobile-only rules; approved desktop layout is unchanged.
   ========================================================================== */

@media (max-width: 860px) {
  /* Keep the page still while the mobile drawer is open. */
  body.menu-open {
    overflow: hidden !important;
  }

  /* JS toggles .dropdown-open; older CSS only reacted to .open. */
  .nav-item-dropdown.dropdown-open .nav-sub-menu,
  .nav-item-dropdown.open .nav-sub-menu {
    display: flex !important;
    flex-direction: column !important;
    position: static !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    box-shadow: none !important;
    border: none !important;
    background: #f0f4ff !important;
    border-radius: 10px !important;
    margin: 4px 0 8px 12px !important;
    padding: 8px !important;
    min-width: 0 !important;
  }

  .nav-sub-menu .sub-nav-link {
    white-space: normal !important;
    min-height: 44px !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    display: flex !important;
    align-items: center !important;
  }

  /* Inline and footer links still need a comfortable tap area. */
  .site-footer .footer-links-list a,
  .site-footer .footer-bottom a,
  .contact-info-card a,
  .tabular-nums a,
  a.tabular-nums {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }
}

@media (min-width: 861px) and (max-width: 900px) {
  /* Same click-toggle support in the narrow desktop/tablet transition band. */
  .nav-item-dropdown.dropdown-open .nav-sub-menu,
  .nav-item-dropdown.open .nav-sub-menu {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(-50%) translateY(0) !important;
  }

  .nav-sub-menu .sub-nav-link {
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
  }
}

@media (max-width: 768px) {
  /* 44px minimum hit area for the hamburger and dropdown controls. */
  .nav-mobile-toggle {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .nav-menu a,
  .nav-menu button,
  .nav-item-dropdown .dropdown-toggle-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .nav-menu a {
    display: flex;
    align-items: center;
  }

  /* Drawer links must be full-width so the 44px minimum applies in practice. */
  .nav-menu > a,
  .nav-menu > .nav-item-dropdown > .nav-link,
  .nav-menu > .nav-item-dropdown > .nav-sub-menu a {
    width: 100%;
  }

  /* Fit the hero to shorter phones while retaining the approved 540px mobile height. */
  .hero-carousel {
    height: min(540px, calc(100vh - 72px));
    min-height: 440px;
  }

  .hero-carousel-title {
    font-size: 1.75rem !important;
    line-height: 1.2 !important;
  }

  .hero-carousel-desc {
    font-size: 1rem !important;
    line-height: 1.55 !important;
  }

  /* Keep the hero buttons touch-friendly at every tested width. */
  .hero-carousel-actions .btn {
    min-height: 44px !important;
  }

  /* Keep the carousel controls visually compact but give fingers a 44px target. */
  .hero-carousel-arrow {
    width: 44px !important;
    height: 44px !important;
  }

  .hero-carousel-arrow.prev { left: 6px !important; }
  .hero-carousel-arrow.next { right: 6px !important; }

  .hero-carousel-dots {
    gap: 0 !important;
    bottom: 10px !important;
  }

  .hero-carousel-dot {
    position: relative;
    width: 44px !important;
    height: 44px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .hero-carousel-dot::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #FFFFFF;
    border: 1.5px solid var(--color-primary);
    box-shadow: 0 1px 4px rgba(11, 27, 69, 0.35);
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
  }

  .hero-carousel-dot.active::before,
  .hero-carousel-dot:hover::before {
    background: var(--color-primary);
    border-color: #FFFFFF;
    transform: scale(1.25);
  }

  /* Floating welcome/chat widget: stay bottom-right, clear of screen edges and notches. */
  .floating-whatsapp-btn {
    right: max(20px, env(safe-area-inset-right)) !important;
    bottom: max(20px, env(safe-area-inset-bottom)) !important;
    width: 56px !important;
    height: 56px !important;
  }
}

@supports (height: 100svh) {
  @media (max-width: 768px) {
    .hero-carousel {
      height: min(540px, calc(100svh - 72px));
    }
  }
}

@media (max-width: 430px) {
  /* Larger, still balanced hero copy for small phones. */
  .hero-carousel-title {
    font-size: 1.75rem !important;
  }

  .hero-carousel-desc {
    font-size: 1rem !important;
  }

  /* The legacy 375px override shrank button text too far. */
  .hero-carousel-actions .btn {
    font-size: 0.82rem !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-carousel-dot::before {
    transition: none;
  }
}
