/* The item menu (submenus, the phone sheet), the tiles' menu button, drag select, the selection bar and
   "Select" (picking) mode. Owner: actions. Tokens from style.css only (overlays on pictures mix --sunk). */

/* ---------- menus: shell/menu.js (style.css has the base .pmenu / .pm-item) ---------- */
.pmenu { max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.pmenu:focus { outline: none; }
.pm-item { position: relative; }
.pm-item.on, .pm-item.open { background: var(--raised); color: var(--text); }
.pm-item:disabled.on { background: none; }
.pm-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pm-hint { flex: none; font-variant-numeric: tabular-nums; }
.pm-check .ic { color: var(--faint); }
.pm-item.on .pm-check .ic, .pm-item.open .pm-check .ic { color: var(--text-2); }
.pm-item[aria-checked=true] .pm-check .ic { color: var(--accent-text); }
.pm-dot.rate-dot { width: 10px; height: 10px; }
.pm-chev { flex: none; color: var(--faint); margin-right: -4px; }
.pm-sub .pm-hint { margin-right: 2px; }
.pm-danger .pm-label { color: var(--danger); }
.am-menu { min-width: 228px; max-width: min(340px, calc(100vw - 16px)); }
.am-menu .pm-item, .pm-subm .pm-item { min-height: 32px; }
.pm-subm { min-width: 180px; max-width: min(320px, calc(100vw - 16px)); }

/* the phone sheet: 48 px rows, a head, submenus drill down (a back row) */
.pm-scrim { position: fixed; inset: 0; z-index: 79; background: color-mix(in srgb, var(--sunk) 62%, transparent); touch-action: none;
  animation: am-fade .18s ease-out; }
.pmenu.pm-sheet { left: 0; right: 0; bottom: 0; top: auto; min-width: 0; max-width: none; max-height: min(82vh, 720px); padding: 0 10px calc(12px + env(safe-area-inset-bottom));
  border: 0; border-top: 1px solid var(--line-3); border-radius: 22px 22px 0 0; background: var(--sheet); gap: 0; animation: am-up .24s cubic-bezier(.2, .8, .2, 1); }
.pm-grip { position: sticky; top: 0; z-index: 1; flex: none; align-self: stretch; height: 26px; border: 0; padding: 0; background: var(--sheet); cursor: pointer; }
.pm-grip::before { content: ""; position: absolute; left: 50%; top: 9px; width: 38px; height: 5px; margin-left: -19px; border-radius: 999px; background: var(--line-3); }
.pm-list { display: flex; flex-direction: column; gap: 1px; }
.pm-sheet .pm-item { min-height: 48px; padding: 0 12px 0 8px; border-radius: 12px; font-size: 14.5px; }
.pm-sheet .pm-check { width: 22px; }
.pm-sheet .pm-check .ic { width: 17px; height: 17px; }
.pm-sheet .pm-hint { display: none; }
.pm-sheet .pm-sub .pm-chev { width: 14px; height: 14px; }
.pm-sheet .pm-back { color: var(--text); font-weight: 600; }
.pm-sheet .pm-sep { margin: 4px 8px; }
.pm-sheet .pm-text { padding: 8px 12px 4px; }
.am-head { display: flex; align-items: center; gap: 12px; padding: 2px 8px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line-2); min-width: 0; }
.am-head-th { width: 44px; height: 44px; flex: none; border-radius: 10px; overflow: hidden; background: var(--ph); display: grid; place-items: center; color: var(--faint); }
.am-head-th img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .2s; }
.am-head-th img.ld { opacity: 1; }
.am-head-t { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.am-head-n { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-head-m { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes am-up { from { transform: translateY(100%); } }
@keyframes am-fade { from { opacity: 0; } }

/* ---------- the tiles' menu button: top-right of the picture, on hover and keyboard focus ---------- */
.am-more { position: absolute; top: 8px; right: 8px; z-index: 2; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: var(--text); background: color-mix(in srgb, var(--sunk) 76%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 2px 8px color-mix(in srgb, var(--sunk) 50%, transparent);
  visibility: hidden; opacity: 0; transition: opacity .14s ease, background-color .12s, visibility 0s .14s; }
.am-more .ic { width: 16px; height: 16px; }
.am-more:hover, .am-more[aria-expanded=true] { background: var(--accent-strong); }
.am-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) {
  .vcell:hover .am-more, .vcell:focus-within .am-more, .am-more[aria-expanded=true] { visibility: visible; opacity: 1; transition: opacity .14s ease, background-color .12s; }
  /* the rating badge steps aside while the button shows */
  .am-has-more:is(:hover, :focus-within) > .rate-badge, .am-has-more:has(.am-more[aria-expanded=true]) > .rate-badge { right: 40px; }
}
body.drag-selecting .am-more { visibility: hidden !important; }
/* folder cards: the corner of the cover */
.fcard > .am-more { top: 8px; right: 8px; }
/* search results: the check of a multi-selection or "Select" is top-right there (and the "your image" pill can be
   long), so the button moves to the free bottom-right corner */
.s-grid.multi .s-res.sel .am-more, .s-grid.picking .am-more { top: auto; bottom: 8px; }
/* list rows: at the row's end */
.am-more.in-list { top: 50%; right: 10px; margin-top: -14px; width: 28px; height: 28px; border-radius: 8px; background: var(--raised); box-shadow: none;
  backdrop-filter: none; -webkit-backdrop-filter: none; color: var(--text-2); }
.am-more.in-list:hover, .am-more.in-list[aria-expanded=true] { background: var(--raised-2); color: var(--text); }

/* touch screens: a long-press on a tile, a folder-tree row or a crumb opens its menu sheet (shell/gridinput.js,
   features/itemmenu.js), not the browser's link callout
   or a text selection */
@media (hover: none) {
  .vgrid .vcell, #sidebar .trow, #sidebar [data-hover-folder], #crumbs [data-hover-folder] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}

/* ---------- drag select ---------- */
.am-band { position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none; border: 1px solid var(--accent); border-radius: 4px;
  background: var(--accent-soft); will-change: transform, width, height; }
body.drag-selecting { user-select: none; -webkit-user-select: none; cursor: default; }
body.drag-selecting .tile:hover { translate: none; box-shadow: none; }
body.drag-selecting .fcard:hover { translate: none; }
body.drag-selecting .tile .cap { opacity: 0; }

/* ---------- "Select" (picking) mode: an empty check on every file tile ---------- */
body.am-picking .vgrid .tile:not(.sel)::after { content: ""; position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 50%; pointer-events: none;
  box-sizing: border-box; border: 2px solid var(--text); background: color-mix(in srgb, var(--sunk) 30%, transparent); box-shadow: 0 2px 8px color-mix(in srgb, var(--sunk) 45%, transparent); }
body.am-picking .vgrid .lrow:not(.sel) .lthumb { outline: 2px dashed var(--line-3); outline-offset: 2px; }

/* ---------- the selection bar ---------- */
.am-bar { position: fixed; z-index: 46; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; max-width: calc(100vw - 32px); padding: 6px 6px 6px 14px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line-3); box-shadow: 0 18px 50px color-mix(in srgb, var(--sunk) 70%, transparent);
  white-space: nowrap; overflow: hidden; animation: am-bar-in .2s cubic-bezier(.2, .8, .2, 1); }
@keyframes am-bar-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.am-bar-t { display: flex; align-items: baseline; gap: 8px; margin-right: 6px; flex: none; }
.am-bar-n { font-weight: 600; font-variant-numeric: tabular-nums; }
.am-bar-m { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.am-bar-sep { width: 1px; height: 20px; margin: 0 4px; flex: none; background: var(--line-2); }
.am-bb { height: 34px; min-width: 34px; flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 9px;
  border: 0; border-radius: 9px; background: none; color: var(--text-2); font-weight: 500; cursor: pointer; }
.am-bb:hover, .am-bb[aria-expanded=true] { background: var(--raised); color: var(--text); }
.am-bb:disabled { opacity: .45; cursor: default; }
.am-bb.primary { background: var(--accent-strong); color: var(--accent-ink); padding: 0 12px; }
.am-bb.primary:hover, .am-bb.primary[aria-expanded=true] { background: var(--accent); color: var(--accent-ink); }
.am-bb .am-caret { margin-left: -2px; opacity: .8; }
.am-bar.compact .am-bb .am-bl, .am-bar.compact .am-bb .am-caret { display: none; }
.am-bar.compact .am-bar-m { display: none; }
body.am-bar-on main { padding-bottom: 76px; }
/* toasts rise above the bar while it shows */
body.am-bar-on .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }

/* ---------- the multi-selection inspector's actions (js/inspector.js): the primary, then a calm list ---------- */
.am-list { display: flex; flex-direction: column; gap: 2px; }
.am-list .ins-btn { height: 34px; justify-content: flex-start; gap: 10px; padding: 0 10px; border-color: transparent; background: none; color: var(--text-2); font-weight: 500; }
.am-list .ins-btn:hover, .am-list .ins-btn[aria-expanded=true] { background: var(--raised); border-color: transparent; }
.am-list .ins-btn .ic { color: var(--faint); }
.am-list .ins-btn:hover .ic { color: var(--text-2); }
.am-list .ins-btn .am-bl { overflow: hidden; text-overflow: ellipsis; }
.ins-btn .am-caret { margin-left: auto; color: var(--faint); }
.ins-btn.primary .am-caret { color: var(--accent-ink); }

@media (max-width: 767px) {
  .am-bar { left: 12px; right: 12px; transform: none; max-width: none; bottom: calc(108px + env(safe-area-inset-bottom)); padding: 6px 6px 6px 14px;
    border-radius: 16px; animation-name: am-bar-up; }
  @keyframes am-bar-up { from { opacity: 0; transform: translateY(12px); } }
  .am-bar-t { flex: 1 0 auto; }
  .am-bar-n { overflow: hidden; text-overflow: ellipsis; }
  body.am-bar-on .toast { bottom: calc(172px + env(safe-area-inset-bottom)); }
  .am-bb { height: 44px; min-width: 44px; border-radius: 12px; }
  .am-bb.primary { padding: 0 12px; }
  body.am-bar-on main { padding-bottom: calc(196px + env(safe-area-inset-bottom)); }
  .am-list .ins-btn { height: 46px; }
}
