/* ═══════════════════════════════════════════════════════════════════════════
   Editor UI — selection highlight, native toolbar menu, selection handles
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Selection highlight ─────────────────────────────────────────────────── */
/* Background only: text keeps its own colour (syntax colours, bold, links) instead of turning white.
   Dark = grey, light = soft tint of the accent. #dexVSel is our own painted selection (Design / Read). */
.CodeMirror-selected,
.CodeMirror-focused .CodeMirror-selected,
.CodeMirror .CodeMirror-selectedtext,
.CodeMirror-line ::selection,
.CodeMirror-line > span ::selection,
.CodeMirror-line > span > span ::selection,
::selection {
  background: #707070 !important;
  color: inherit !important;
}
#dexVSel > div { background: rgba(112,112,112,.55); }
html[data-theme="light"] .CodeMirror-selected,
html[data-theme="light"] .CodeMirror-focused .CodeMirror-selected,
html[data-theme="light"] .CodeMirror .CodeMirror-selectedtext,
html[data-theme="light"] .CodeMirror-line ::selection,
html[data-theme="light"] .CodeMirror-line > span ::selection,
html[data-theme="light"] .CodeMirror-line > span > span ::selection,
html[data-theme="light"] ::selection {
  background: color-mix(in srgb, var(--c-accent) 22%, transparent) !important;
  color: inherit !important;
}
html[data-theme="light"] #dexVSel > div { background: color-mix(in srgb, var(--c-accent) 22%, transparent); }
/* Read view: no browser callout / lens chip on long-press */
#mdexecPane .mdx-body { -webkit-touch-callout: none; }

/* ── Native toolbar menu — icon-only horizontal pill ─────────────────────── */
#dexNativeMenu {
  position: fixed;
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 1px;
  padding: 4px 8px;
  max-width: calc(100vw - 16px);
  overflow-x: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  background: var(--c-panel-2);
  border: 1px solid color-mix(in srgb, var(--c-white) 10%, transparent);
  border-radius: 100px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.55),
    0 2px 6px  rgba(0, 0, 0, 0.30),
    inset 0 1px 0 color-mix(in srgb, var(--c-white) 6%, transparent);
  z-index: 10050;
  font-family: 'classy', sans-serif;
  -webkit-touch-callout: none;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

#dexNativeMenu.open {
  display: flex;
  animation: dexNmIn 0.16s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes dexNmIn {
  from { opacity: 0; transform: scale(0.92) translateY(-4px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

.dex-nm-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;               /* >= 44px touch target (WCAG 2.5.5 / Apple HIG) */
  height: 44px;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--c-white);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, color 0.12s ease, transform 0.10s ease;
}
#dexNativeMenu::-webkit-scrollbar { display: none; }

.dex-nm-item delluna-icon svg,
.dex-nm-item delluna-icon svg * {
  fill: var(--c-white);
  stroke: var(--c-white);
}

.dex-nm-item delluna-icon {
  width: 22px;
  height: 22px;
  pointer-events: none;
  user-select: none;
}

.dex-nm-item:hover,
.dex-nm-item:focus-visible {
  background: color-mix(in srgb, var(--c-white) 10%, transparent);
  color: var(--c-blue);
  outline: none;
}
.dex-nm-item:hover delluna-icon svg,
.dex-nm-item:hover delluna-icon svg *,
.dex-nm-item:focus-visible delluna-icon svg,
.dex-nm-item:focus-visible delluna-icon svg * {
  fill: var(--c-blue);
  stroke: var(--c-blue);
}

.dex-nm-item:focus-visible {
  background: color-mix(in srgb, var(--c-blue) 18%, transparent);
}

.dex-nm-item:active {
  transform: scale(0.88);
  background: color-mix(in srgb, var(--c-white) 14%, transparent);
}

.dex-nm-item.dex-nm-danger {
  color: var(--c-text-faint);
}
.dex-nm-item.dex-nm-danger delluna-icon svg,
.dex-nm-item.dex-nm-danger delluna-icon svg * {
  fill: var(--c-text-faint);
  stroke: var(--c-text-faint);
}
.dex-nm-item.dex-nm-danger:hover,
.dex-nm-item.dex-nm-danger:active {
  color: var(--c-danger);
  background: color-mix(in srgb, var(--c-danger) 10%, transparent);
}
.dex-nm-item.dex-nm-danger:hover delluna-icon svg,
.dex-nm-item.dex-nm-danger:hover delluna-icon svg *,
.dex-nm-item.dex-nm-danger:active delluna-icon svg,
.dex-nm-item.dex-nm-danger:active delluna-icon svg * {
  fill: var(--c-danger);
  stroke: var(--c-danger);
}

.dex-nm-sep {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  flex-shrink: 0;
  border-radius: 1px;
  background: color-mix(in srgb, var(--c-white) 10%, transparent);
}

/* ── Selection handles — Caps: line through the selected line with a dot cap (black/white theme colours) ────────────── */
.dex-sel-handle {
  position: fixed;
  display: none;
  width: 44px;
  z-index: 9990;
  pointer-events: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transform: translateX(-50%);
  --hc: var(--color);
  --hr: var(--c-panel);
}

.dex-sel-handle .dex-sh-l {
  position: absolute;
  left: 50%;
  top: 18px;
  height: var(--lh, 22px);
  width: 2px;
  margin-left: -1px;
  background: var(--hc);
  box-shadow: 0 0 0 1px var(--hr);
  border-radius: 1px;
}

.dex-sel-handle .dex-sh-d {
  position: absolute;
  left: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: var(--hc);
  box-shadow: 0 0 0 1.5px var(--hr);
  pointer-events: auto;
  cursor: grab;
  transition: transform 0.10s ease;
}

.dex-sel-handle-start .dex-sh-d { top: 8px; }
.dex-sel-handle-end   .dex-sh-d { top: calc(18px + var(--lh, 22px)); }

.dex-sel-handle .dex-sh-d::before {
  content: '';
  position: absolute;
  inset: -17px;
  border-radius: 50%;
}

.dex-sel-handle:active .dex-sh-d { transform: scale(1.25); }
