/* Al-Haseen public-site mobile and tablet header repair — 2026-10-23 */

@keyframes alhaseen-preloader-timeout {
  to {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

/* Independent no-JS safety net; the early JS path hides sooner when available. */
#preloader:not(.hidden) {
  animation: alhaseen-preloader-timeout 0.3s ease 2.4s forwards !important;
}

#preloader.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 0.25s ease, visibility 0.25s ease !important;
}

html.nav-open,
body.nav-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

body.nav-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(12, 25, 47, 0.48);
}

@media (max-width: 1240px) {
  .header,
  #header.is-redesigned {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background-color: rgba(255, 255, 255, 0.98) !important;
  }

  /* Non-redesigned page headers switch to a drawer before tablet navigation crowds. */
  .header:not(.is-redesigned) .nav {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }

  .header:not(.is-redesigned) .logo {
    flex: 0 1 auto !important;
    min-width: 0 !important;
  }

  .header:not(.is-redesigned) .nav-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 6px !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
  }

  .header:not(.is-redesigned) .nav-actions .btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 40px !important;
    padding: 8px 9px !important;
    font-size: 0.76rem !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  .header:not(.is-redesigned) .mobile-toggle {
    display: flex !important;
    position: relative !important;
    flex: 0 0 44px !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    cursor: pointer !important;
    touch-action: manipulation;
  }

  .header:not(.is-redesigned) .mobile-toggle span {
    left: 9px !important;
    width: 26px !important;
    height: 2px !important;
  }

  .header:not(.is-redesigned) .mobile-toggle span:nth-child(1) {
    top: 14px !important;
  }

  .header:not(.is-redesigned) .mobile-toggle span:nth-child(2) {
    top: 21px !important;
  }

  .header:not(.is-redesigned) .mobile-toggle span:nth-child(3) {
    bottom: 14px !important;
  }

  .header:not(.is-redesigned) .nav-menu {
    display: none !important;
    position: fixed !important;
    top: 117px !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: min(88vw, 380px) !important;
    max-width: 380px !important;
    height: calc(100vh - 117px) !important;
    height: calc(100dvh - 117px) !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 14px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 4px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    transform: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1002 !important;
    background: #fff !important;
    border: 1px solid rgba(18, 43, 77, 0.12) !important;
    box-shadow: 0 16px 40px rgba(12, 25, 47, 0.22) !important;
  }

  html[dir="ltr"] .header:not(.is-redesigned) .nav-menu {
    right: auto !important;
    left: 0 !important;
  }

  .header:not(.is-redesigned) .nav-menu.active {
    display: flex !important;
  }

  .header:not(.is-redesigned) .nav-menu > li {
    display: block !important;
    width: 100% !important;
    flex: 0 0 auto !important;
  }

  .header:not(.is-redesigned) .nav-menu .nav-link {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    font-size: 0.94rem !important;
    line-height: 1.4 !important;
    white-space: normal !important;
    text-align: start !important;
  }

  .header:not(.is-redesigned) .mobile-toggle:focus-visible,
  .header:not(.is-redesigned) .nav-menu a:focus-visible {
    outline: 3px solid #b38b43 !important;
    outline-offset: 2px !important;
  }

  /* The home header has a compact, measured top bar on tablets. */
  .top-bar {
    min-height: 44px !important;
    padding: 4px 0 !important;
  }

  .top-bar-content {
    display: flex !important;
    min-height: 36px !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
  }

  .top-bar-right {
    display: flex !important;
    flex: 0 1 auto !important;
    align-items: center !important;
    gap: 12px !important;
    min-width: 0 !important;
  }

  .top-bar-right > span {
    display: none !important;
  }

  .top-bar-left {
    display: flex !important;
    flex: 0 0 auto !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  #header.is-redesigned {
    top: 44px !important;
  }

  #header.is-redesigned .mobile-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    border-radius: 10px !important;
    touch-action: manipulation;
  }

  #header.is-redesigned .mobile-toggle span {
    left: 9px !important;
    width: 26px !important;
    height: 2px !important;
  }

  #header.is-redesigned .mobile-toggle span:nth-child(1) {
    top: 14px !important;
  }

  #header.is-redesigned .mobile-toggle span:nth-child(2) {
    top: 21px !important;
  }

  #header.is-redesigned .mobile-toggle span:nth-child(3) {
    bottom: 14px !important;
  }

  #header.is-redesigned .nav-menu {
    top: 125px !important;
    bottom: 0 !important;
    height: calc(100vh - 125px) !important;
    height: calc(100dvh - 125px) !important;
    max-height: none !important;
  }
}

@media (max-width: 768px) {
  .header:not(.is-redesigned) .nav-menu {
    top: 113px !important;
    height: calc(100vh - 113px) !important;
    height: calc(100dvh - 113px) !important;
  }

  /* Keep phone, contact, language and quote actions inside a two-row top bar. */
  .top-bar {
    height: 76px !important;
    min-height: 76px !important;
    padding: 4px 0 !important;
  }

  .top-bar-content {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    grid-template-rows: 36px 28px !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px 8px !important;
    width: 100% !important;
    height: 68px !important;
    min-height: 68px !important;
  }

  .top-bar-right {
    display: flex !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: 36px !important;
    min-width: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
  }

  .top-bar-right a[href^="mailto:"],
  .top-bar-right > span {
    display: none !important;
  }

  .top-bar-right a[href^="tel:"] {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 32px !important;
    padding: 4px 6px !important;
    white-space: nowrap !important;
    font-size: 0.74rem !important;
  }

  .top-bar-left {
    display: grid !important;
    grid-column: 2 !important;
    grid-row: 1 / span 2 !important;
    grid-template-columns: auto auto !important;
    grid-template-rows: 36px 28px !important;
    align-content: center !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 4px 8px !important;
    width: auto !important;
    height: 68px !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  .topbar-contact-link {
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: center !important;
    min-height: 32px !important;
    padding: 5px 8px !important;
    font-size: 0.72rem !important;
    white-space: nowrap !important;
  }

  .lang-dropdown {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: center !important;
    min-width: 0 !important;
  }

  .lang-dropdown-btn {
    min-height: 32px !important;
    padding: 4px 8px !important;
  }

  .topbar-quote-link {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    justify-self: center !important;
    align-self: center !important;
    min-height: 28px !important;
    padding: 4px 10px !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
  }

  #header.is-redesigned {
    top: 76px !important;
  }

  #header.is-redesigned .nav-menu {
    top: 157px !important;
    bottom: 0 !important;
    height: calc(100vh - 157px) !important;
    height: calc(100dvh - 157px) !important;
    max-height: none !important;
  }

  .header:not(.is-redesigned) .logo {
    max-width: calc(100% - 142px) !important;
    gap: 8px !important;
    font-size: 0.84rem !important;
    line-height: 1.1 !important;
  }

  .header:not(.is-redesigned) .nav-actions .btn {
    padding: 7px 8px !important;
    font-size: 0.72rem !important;
  }
}

@media (max-width: 359px) {
  .top-bar-right {
    display: none !important;
  }

  .top-bar-left {
    grid-column: 1 / -1 !important;
  }
}
