/* Phone menu (#m-menu): a smooth open and close.
   The site script shows and hides the panel by switching display (no animation), so the motion is CSS transitions on
   display (allow-discrete keeps the panel on screen until the exit has played) with the closed look keyed on the inline
   display:none the script sets. Opening: the sheet unrolls down from the top, then the header, each link and the buttons
   rise in one after another. Closing: the sheet rolls back up while the content fades out together.
   Only transform, opacity and clip-path move (compositor friendly). Browsers without allow-discrete just switch as before. */
@media (max-width: 760px) {
  #m-menu {
    --menu-ease-out: cubic-bezier(0.32, 0.72, 0, 1);
    --menu-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    clip-path: inset(0% 0% 0% 0%);
    will-change: clip-path;
    transition:
      clip-path 700ms var(--menu-ease-out),
      display 700ms allow-discrete;
  }
  #m-menu > :nth-child(1),
  #m-menu li,
  #m-menu > :nth-child(3) > * {
    transition:
      opacity 480ms ease-out var(--menu-delay, 0ms),
      transform 680ms var(--menu-ease-out) var(--menu-delay, 0ms);
  }
  #m-menu > :nth-child(1) { --menu-delay: 120ms; }
  #m-menu li:nth-child(1) { --menu-delay: 170ms; }
  #m-menu li:nth-child(2) { --menu-delay: 215ms; }
  #m-menu li:nth-child(3) { --menu-delay: 260ms; }
  #m-menu li:nth-child(4) { --menu-delay: 305ms; }
  #m-menu li:nth-child(5) { --menu-delay: 350ms; }
  #m-menu li:nth-child(n + 6) { --menu-delay: 395ms; }
  #m-menu > :nth-child(3) > :nth-child(1) { --menu-delay: 430ms; }
  #m-menu > :nth-child(3) > :nth-child(2) { --menu-delay: 490ms; }
  #m-menu > :nth-child(1) button img {
    transition: transform 640ms var(--menu-ease-out) 220ms;
  }

  /* Where the panel and its content start when it opens. */
  @starting-style {
    #m-menu { clip-path: inset(0% 0% 100% 0%); }
    #m-menu > :nth-child(1) { opacity: 0; transform: translateY(-10px); }
    #m-menu li { opacity: 0; transform: translateY(22px); }
    #m-menu > :nth-child(3) > * { opacity: 0; transform: translateY(22px); }
    #m-menu > :nth-child(1) button img { transform: rotate(-90deg) scale(0.6); }
  }

  /* Closed: the look the exit plays towards (the script sets display:none inline when it hides the panel). */
  #m-menu[style*="display: none"],
  #m-menu[style*="display:none"] {
    clip-path: inset(0% 0% 100% 0%);
    pointer-events: none;
    transition:
      clip-path 440ms var(--menu-ease-in-out),
      display 440ms allow-discrete;
  }
  #m-menu[style*="display: none"] > :nth-child(1),
  #m-menu[style*="display: none"] li,
  #m-menu[style*="display: none"] > :nth-child(3) > *,
  #m-menu[style*="display:none"] > :nth-child(1),
  #m-menu[style*="display:none"] li,
  #m-menu[style*="display:none"] > :nth-child(3) > * {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 240ms ease-in, transform 320ms ease-in;
  }

  @media (prefers-reduced-motion: reduce) {
    #m-menu,
    #m-menu > :nth-child(1),
    #m-menu li,
    #m-menu > :nth-child(3) > *,
    #m-menu > :nth-child(1) button img,
    #m-menu[style*="display: none"],
    #m-menu[style*="display: none"] > :nth-child(1),
    #m-menu[style*="display: none"] li,
    #m-menu[style*="display: none"] > :nth-child(3) > * {
      transition: none;
    }
  }
}
