/*
 Theme Name: Astra Child
 Theme URI: https://example.com/
 Description: Child theme for Astra. Safely add custom CSS, PHP, and templates.
 Author: Your Name
 Template: astra
 Version: 1.0.0
 Text Domain: astra-child
*/

/* Your custom CSS goes below. Avoid @import; parent CSS is enqueued in functions.php */


/* 1) Make the wrap the positioning context but NOT full-width */
#mega-menu-wrap-primary {
  position: relative;
  display: inline-block !important;  /* shrink to toggle */
  width: auto !important;
  flex: 0 0 auto !important;         /* Astra header uses flex */
}

/* 2) Let the panel size to its content and snap its RIGHT edge to the toggle */
#mega-menu-wrap-primary .mega-menu-toggle + .mega-menu {
  position: absolute !important;
  right: 0 !important;               /* align to toggle’s right edge */
  left: auto !important;

  /* Make width follow longest item (no wrapping) */
  display: inline-block;             /* shrink-to-fit contents */
  white-space: nowrap;
  width: auto !important;            /* override any width:100% */
  max-width: none !important;        /* ignore theme caps */
  box-sizing: content-box;

  /* Extra compatibility across browsers */
  width: max-content;                /* modern */
  width: -moz-fit-content;           /* Firefox */
  width: fit-content;                /* spec */
  z-index: 9999;
}

/* 3) Ensure links don’t wrap (so panel grows to longest label) */
#mega-menu-wrap-primary .mega-menu li.mega-menu-item > a.mega-menu-link {
  white-space: nowrap;
}

/* Prevent the immediate header cell around the menu from expanding */
#mega-menu-wrap-primary:not(.ast-header-html) {
  align-self: flex-start;
}

@media (min-width: 1025px) {
  #mega-menu-wrap-primary .mega-menu-toggle + .mega-menu {
    max-width: calc(100vw - 24px);  /* avoid off-screen overflow */
    overflow-x: auto;                /* enable horizontal scroll if ever needed */
  }
}

#mega-menu-wrap-primary .mega-menu {
  transition: transform .18s ease, opacity .18s ease;
  transform: translateY(6px);
  opacity: 0;
  pointer-events: none;
}
#mega-menu-wrap-primary .mega-menu.mega-menu-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.site-header, .ast-header-break-point header {
  position: relative;
  z-index: 1000;
}
