/* ----------------------------------------------------------------
 Header overrides
-----------------------------------------------------------------*/

/* ---- Hamburger menu button (replaces icon-reorder font icon) ---- */
#primary-menu-trigger {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #333;
}

#primary-menu-trigger:focus {
  outline: none;
}

#primary-menu-trigger .hamburger {
  position: relative;
  display: inline-block;
  width: 26px;
  height: 18px;
}

#primary-menu-trigger .hamburger > span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transform-origin: center center;
  transition:
    transform 0.3s ease,
    top 0.3s ease,
    opacity 0.2s ease;
}

#primary-menu-trigger .hamburger > span:nth-child(1) {
  top: 0;
}
#primary-menu-trigger .hamburger > span:nth-child(2) {
  top: 8px;
}
#primary-menu-trigger .hamburger > span:nth-child(3) {
  top: 16px;
}

/* Open state: morph into an X */
#primary-menu-trigger.is-active .hamburger > span:nth-child(1) {
  top: 8px;
  transform: rotate(45deg);
}

#primary-menu-trigger.is-active .hamburger > span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0.3);
}

#primary-menu-trigger.is-active .hamburger > span:nth-child(3) {
  top: 8px;
  transform: rotate(-45deg);
}

/* Hide the original font-icon (no-op if absent, kept as safety) */
#primary-menu-trigger i.icon-reorder {
  display: none;
}

/* ---- Mobile / Tablet: logo left, menu trigger right ---- */
@media (max-width: 991px) {
  #header #header-wrap > .container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    /* Bootstrap caps .container width at 540/720px above 576/768px viewports
       and centers it with `margin: auto`, leaving a big gap on the sides
       of mobile screens. Force full width here. */
    max-width: 100% !important;
    width: 100%;
    margin: 0 !important;
    padding: 12px 20px 12px 0;
    gap: 0;
  }

  /* Logo: align to the left, no longer centered.
     display: flex so whitespace between the two <a> children (standard / retina)
     doesn't render as an inline gap before the visible logo. */
  #header #logo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    float: none;
    margin: 0 !important;
    margin-right: auto !important;
    padding: 0 !important;
    text-align: left;
    height: auto;
    line-height: 1;
    order: 1;
    flex: 0 0 auto;
  }

  #header #logo > a {
    display: none;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
  }

  #header #logo > a.standard-logo {
    display: block;
  }

  #header #logo img {
    max-height: 68px;
    width: auto;
    display: block;
  }

  /* Hamburger trigger: pulled out of absolute positioning, placed on the right */
  #header #primary-menu-trigger,
  #header #primary-menu .container #primary-menu-trigger {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    margin: 0;
    margin-left: 16px;
    order: 2;
    flex: 0 0 auto;
    z-index: auto;
  }

  /* Dropdown menu: overlay below the header, doesn't push content */
  #header {
    position: relative;
    z-index: 100;
  }

  #header #primary-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    z-index: 200;
    background: transparent;
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition:
      opacity 0.25s ease,
      transform 0.25s ease,
      visibility 0.25s ease;
  }

  #primary-menu-trigger.is-active ~ #primary-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  /* Force menu list to always be in flow, control visibility via max-height */
  #header #primary-menu > ul,
  #header #primary-menu > div > ul {
    display: block !important;
    max-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0 20px !important;
    box-sizing: border-box;
    background: #fff;
    border-top: 1px solid #eee;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
    transition: max-height 0.35s ease;
  }

  /* Open state — sibling combinator from the trigger to the menu */
  #primary-menu-trigger.is-active ~ #primary-menu > ul,
  #primary-menu-trigger.is-active ~ #primary-menu > div > ul {
    max-height: 80vh;
    overflow-y: auto;
  }
}

@media only screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 991px),
  only screen and (min--moz-device-pixel-ratio: 2) and (max-width: 991px),
  only screen and (-o-min-device-pixel-ratio: 2/1) and (max-width: 991px),
  only screen and (min-device-pixel-ratio: 2) and (max-width: 991px),
  only screen and (min-resolution: 192dpi) and (max-width: 991px),
  only screen and (min-resolution: 2dppx) and (max-width: 991px) {
  #header #logo > a.standard-logo {
    display: none;
  }

  #header #logo > a.retina-logo {
    display: block;
  }
}
