/* ------------------------------------------------------------------
   PetESALetter — navigation restore
   The static mirror captured Elementor Pro's CSS, jQuery and SmartMenus,
   but not the lazy-loaded webpack chunk that initialises the Nav Menu
   widget. Without it `.elementor-nav-menu ul { display:none }` was never
   undone, so the desktop "ESA By States" dropdown and the mobile
   hamburger were both dead. This restores both with plain CSS + a small
   script, keeping Elementor's own class names and styling.
   ------------------------------------------------------------------ */

/* ---------- Desktop (>=1025px): hover / keyboard dropdown ---------- */
/* The panel markup is a second copy of the menu that stays in the DOM at all
   widths, so hide its injected arrow when the desktop bar is what's showing. */
@media (min-width: 1025px) {
  .pesa-caret--panel { display: none !important; }

  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children {
    position: relative;
  }
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children > ul.sub-menu {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 9999;
    /* Elementor hard-codes width:12em on submenus, which is narrower than the
       longest item ("ESA Letter California") -- the label then runs flush into
       the right edge. Let the box size to its content instead. */
    width: auto !important;
    min-width: 100%;
    max-width: min(22em, calc(100vw - 32px));
    padding: 8px 0;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .14);
    background-color: #fff;
    /* hidden but focusable-safe: no display:none, so transitions work */
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
    pointer-events: none;
  }
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children:hover > ul.sub-menu,
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children:focus-within > ul.sub-menu,
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children.pesa-open > ul.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children > ul.sub-menu > li {
    width: 100%;
  }
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children > ul.sub-menu > li > a {
    display: block;
    /* symmetrical breathing room on both sides */
    padding: 10px 24px !important;
    white-space: nowrap;
  }
  /* clear hover feedback on dropdown rows */
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children > ul.sub-menu > li > a:hover,
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children > ul.sub-menu > li > a:focus-visible {
    background-color: rgba(0, 0, 0, .045);
  }

  /* Bridge the gap between the menu bar and the panel so moving the mouse down
     into the dropdown doesn't cross dead space and close it. */
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children > ul.sub-menu::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -14px;
    height: 14px;
  }
  /* Caret on the parent item.
     Elementor already uses ::before/::after on .elementor-item for its hover
     "pointer" effects, so we cannot use a pseudo-element here without a
     specificity fight. The script injects a real <span> instead. */
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children > a .pesa-caret {
    display: inline-block;
    width: .42em;
    height: .42em;
    margin-left: .5em;
    vertical-align: middle;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform .18s ease;
    pointer-events: none;
  }
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children:hover > a .pesa-caret,
  .elementor-nav-menu--main .elementor-nav-menu > li.menu-item-has-children.pesa-open > a .pesa-caret {
    transform: translateY(1px) rotate(-135deg);
  }
}

/* ---------- Tablet / mobile (<=1024px): accordion inside the panel ---------- */
@media (max-width: 1024px) {
  .elementor-nav-menu--dropdown .menu-item-has-children > ul.sub-menu {
    display: none;
    padding-left: 0;
  }
  .elementor-nav-menu--dropdown .menu-item-has-children.pesa-open > ul.sub-menu {
    display: block;
  }
  .elementor-nav-menu--dropdown .menu-item-has-children > a {
    position: relative;
    padding-right: 44px !important;
  }
  /* Arrow for the accordion parent. A real element, not ::after -- Elementor's
     .e--pointer-* rules already claim ::after on .elementor-item. */
  .elementor-nav-menu--dropdown .menu-item-has-children > a .pesa-caret {
    display: block;
    position: absolute;
    right: 20px;
    top: 50%;
    width: .45em;
    height: .45em;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-70%) rotate(45deg);
    transition: transform .2s ease;
    pointer-events: none;
    margin: 0;
  }
  .elementor-nav-menu--dropdown .menu-item-has-children.pesa-open > a .pesa-caret {
    transform: translateY(-20%) rotate(-135deg);
  }

  /* The panel is revealed by Elementor's own rule, which needs --menu-height.
     Provide a sane fallback in case the script has not measured it yet. */
  .elementor-nav-menu--toggle .elementor-menu-toggle.elementor-active + .elementor-nav-menu__container {
    max-height: var(--menu-height, 80vh);
  }
  /* let a long menu scroll rather than overflow the screen */
  .elementor-nav-menu--dropdown.elementor-nav-menu__container {
    -webkit-overflow-scrolling: touch;
  }
}

/* Make the hamburger an obvious tap target regardless of viewport. */
.elementor-menu-toggle {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.elementor-menu-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
