/* The in-page menu, the design board Kit's (gap H18): an icon or text
   button opening a menu of commands over the page - a sheet from the
   bottom on a phone, as PhoneListingActions draws it. One primitive,
   the stylesheet 'menu' of every page that draws one: the listing's
   More listing actions, the practice frame's "..." (N1), a console
   practice row's actions, a pre-qualification row's and the Kit's.
   Named .lp-more for the listing page, which drew it first.

   Markup: details.lp-more > summary.btn, then div.lp-menu holding an
   optional .lp-menu-h (the sheet's title and its Close,
   [data-lp-close]) and one ul.lp-menu-g per group of .lp-mi items -
   links, buttons, or a details whose summary is the item and whose
   form asks once more in place (.lp-confirm) */

/* The menu: a <details> whose summary is the button; open, the summary's
   own backdrop covers the page, so a click anywhere else closes it */
.lp-more {
  position: relative;
}

/* A table's box scrolls sideways, which would clip a row's open menu */
.app .tbl-box:has(.lp-more[open]) {
  overflow: visible;
}

.lp-more > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--po-sp-2);
}

.lp-more summary {
  list-style: none;
  cursor: pointer;
}

.lp-more summary::-webkit-details-marker {
  display: none;
}

.lp-menu form {
  margin: 0;
}

.lp-more[open] > summary {
  background: var(--po-brand-tint);
  color: var(--po-brand);
}

.lp-more[open] > summary::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 40;
  cursor: default;
}

.lp-more[open] .lp-more-c {
  transform: rotate(180deg);
}

.lp-menu {
  position: absolute;
  z-index: 41;
  top: calc(100% + 6px);
  right: 0;
  width: 300px;
  padding: 6px;
  border: 1px solid var(--po-line-2);
  border-radius: 8px;
  background: var(--po-surface);
  box-shadow: var(--po-sh-3);
}

/* A menu opened from a row's first column opens to the right */
.lp-more.is-left > .lp-menu {
  right: auto;
  left: 0;
}

/* A menu with no room below it opens upward (_menu_script.php sets
   .is-up when it would run past the foot of the window); never the
   phone's sheet, which keeps to the bottom */
@media (min-width: 641px) {
  .lp-more.is-up > .lp-menu {
    top: auto;
    bottom: calc(100% + 6px);
  }
}

/* The sheet's title and Close, on a phone only */
.lp-menu-h {
  display: none;
}

.lp-menu-g {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lp-menu-g + .lp-menu-g {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--po-line);
}

.lp-mi {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--po-ink-soft);
  font-family: var(--po-font-ui);
  font-size: var(--po-fs-base);
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.lp-mi:hover,
details[open] > .lp-mi {
  background: var(--po-bg-3);
  color: var(--po-ink-soft);
  text-decoration: none;
}

.lp-mi svg.i {
  flex: none;
  color: var(--po-brand-2);
}

.lp-mi.is-warn,
.lp-mi.is-warn svg.i {
  color: var(--po-warn);
}

/* A command that asks again opens its question in place, in the menu */
.lp-menu-g details form {
  padding: var(--po-sp-2) 12px var(--po-sp-3);
}

/* A command's dialog opened from the menu keeps the dialog's own frame,
   not the menu's in-place form padding (D6) */
.lp-menu-g .nda-pop form.nda-dlg__panel {
  padding: 0;
}

@media (max-width: 640px) {
  /* PhoneListingActions: the menu is a sheet from the bottom over a
     scrim, its title and Close above the commands */
  .lp-more[open] > summary::before {
    z-index: 1100;
    background: rgba(32, 44, 54, 0.45);
  }

  .lp-menu {
    position: fixed;
    z-index: 1101;
    inset: auto 0 0;
    width: auto;
    max-height: 85vh;
    overflow-y: auto;
    padding: 8px 8px 24px;
    border: 0;
    border-radius: 16px 16px 0 0;
  }

  .lp-menu-h {
    display: flex;
    align-items: center;
    padding: 12px 8px 12px 16px;
    border-bottom: 1px solid var(--po-line);
    margin: 0 -8px 8px;
  }

  .lp-menu-h::before {
    content: "";
    position: absolute;
    top: 8px;
    left: calc(50% - 20px);
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #d3d9de;
  }

  .lp-menu-h h3 {
    margin: 0;
    color: var(--po-ink-soft);
    font-family: var(--po-font-ui);
    font-size: 18px;
  }

  .lp-menu-x {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-left: auto;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--po-brand-2);
    cursor: pointer;
  }

  .lp-mi {
    min-height: 48px;
  }
}

/* A command's question, asked in place before it posts */
.lp-menu .lp-confirm {
  margin: 0 0 var(--po-sp-3);
  color: var(--po-ink-soft);
  font-weight: 600;
}

/* A menu with nothing in it says so */
.lp-menu .lp-fine {
  margin: var(--po-sp-2) 12px;
}
