/* Desktop mega menus: one clean fade (see the menu controller in assets/js/header-sticky.js).
   The theme opens and closes a panel by animating max-height between 0 and 1500px while fading it, with no
   overflow clip while closing: the panel sits at full size for most of the close, then its white background
   shrinks upward while the links spill out over the page, and the arrow under the menu item vanishes at the
   start. Here the whole panel (and its arrow) fades as one piece; the coloured line and the arrow stay put, only the
   panel's contents drift 6px. Keep the durations in step with OPEN_MS and CLOSE_MS in header-sticky.js. */
@media (min-width: 76rem) {
  #site-header :is(.cm__mega, .cm__drop)[data-cm-status] :is(.cm__mega__wrapper, .cm__list__drop) { max-height: none; overflow: hidden; }
  #site-header [data-cm-status=opening] :is(.cm__mega__wrapper, .cm__list__drop) { animation: etg-menu-fade-in 200ms cubic-bezier(.22, 1, .36, 1) both; }
  #site-header [data-cm-status=closing] :is(.cm__mega__wrapper, .cm__list__drop) { animation: etg-menu-fade-out 160ms cubic-bezier(.4, 0, 1, 1) both; }
  #site-header [data-cm-status=opening] :is(.cm__mega__wrapper, .cm__list__drop) > * { animation: etg-menu-drift-in 200ms cubic-bezier(.22, 1, .36, 1) both; }
  #site-header [data-cm-status=closing] :is(.cm__mega__wrapper, .cm__list__drop) > * { animation: etg-menu-drift-out 160ms cubic-bezier(.4, 0, 1, 1) both; }
  #site-header .cm__mega[data-cm-status=closing] .cm__mega__wrapper { display: grid; }
  /* the arrow under the item goes with its panel */
  #site-header [data-cm-status=closing] > a { --arrw-size: 0.7rem; position: relative; z-index: calc(var(--level-5) + 1); }
  #site-header [data-cm-status=closing] > a::before {
    content: ""; width: 1.2rem; height: var(--arrw-size); position: absolute; top: calc(100% - var(--arrw-size)); left: 50%;
    transform: translateX(-50%); background: var(--g-rad-pr); clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    animation: etg-menu-fade-out 160ms cubic-bezier(.4, 0, 1, 1) both;
  }
  #site-header [data-cm-status=opening] > a::before { animation: etg-menu-fade-in 200ms cubic-bezier(.22, 1, .36, 1) both; }

  /* Panels hang from the header's bottom edge (the theme starts them 1.5rem above it, over the header). Each item's
     link reaches down to that edge (padding, with a matching negative margin so nothing moves), so the cursor stays
     on the item on its way into the panel, and the arrow (pinned to the link's bottom) sits on the panel's top line. */
  #site-header .cm__mega__wrapper { inset-block-start: 100%; }
  /* the header's grey, flat (the theme's stuck-header rule paints the top 1rem grey and the rest white) */
  #site-header .cm__mega__wrapper, body[data-sticky] #site-header .cm__mega__wrapper { background: hsl(var(--clr-grey-l)); }
  /* The arrow is cut from the line itself: the line's gradient, sized to the line and shifted to the arrow's place
     (--etg-arrow-x, --etg-line-w: set by header-sticky.js), so it is the line's colour where it stands. It overlaps
     the line's 2px so the two read as one shape. */
  #site-header :is([data-cm-status=open], [data-cm-status=opening], [data-cm-status=closing]) > a::before {
    top: calc(100% - var(--arrw-size) + 2px);
    background: var(--g-line-pr) no-repeat calc(-1 * var(--etg-arrow-x, 0px)) 0 / var(--etg-line-w, 100vw) 100%;
  }
  #site-header .combo-menu > .cm__mega > a { padding-block-end: var(--sp-1); margin-block-end: calc(-1 * var(--sp-1)); }
}
@keyframes etg-menu-drift-in { from { translate: 0 -6px; } }
@keyframes etg-menu-drift-out { to { translate: 0 -6px; } }
@keyframes etg-menu-fade-in { from { opacity: 0; } }
@keyframes etg-menu-fade-out { from { opacity: 1; } to { opacity: 0; } }   /* explicit start: a closing panel's base opacity is 0 */
