/* hover-click-toolbar.css — IDE-style floating toolbar + dom-select rings
 * Spec: docs/specs/a-hover-click-dom-interaction.md §3
 *
 * Mobile: bottom-sheet variant (slides up from bottom edge, ~50% viewport).
 * Desktop: dropdown popover anchored under the selected element (max 480px).
 * Reduced motion respected on both.
 */

/* ----- DOM-select rings (consumed by dom-select.js) -----
 * v1.2a state machine (Hank feedback 2026-06-03):
 *   IDLE        — no ring
 *   PREVIEW     — pointer is over a selectable element (dashed indigo)
 *   LOCKED      — clicked + toolbar open (solid indigo + soft halo)
 *   ARMED_*     — toolbar action staged, awaiting drag (amber pulsing outline)
 *   ACTIVE      — drag in flight (amber solid + heavier shadow)
 * The state transitions are explicit in JS; the user clicks a chip BEFORE
 * any drag fires, instead of immediate-grab.
 */
.eclaw-dom-select__ring-preview {
  outline: 2px dashed rgba(99, 102, 241, 0.7) !important;
  outline-offset: 2px !important;
  cursor: crosshair !important;
  transition: outline-color 0.15s ease-out, box-shadow 0.15s ease-out;
}

.eclaw-dom-select__ring-selected {
  outline: 2px solid rgba(99, 102, 241, 0.95) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15) !important;
  transition: outline-color 0.15s ease-out, box-shadow 0.15s ease-out;
}

/* v1.2a: ARMED state — toolbar action staged. Amber to distinguish
   from the indigo LOCKED state. cursor hints at the upcoming interaction. */
.eclaw-dom-select__ring-armed-move {
  outline: 3px solid rgba(245, 158, 11, 0.95) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.18) !important;
  cursor: move !important;
  animation: eclaw-armed-pulse 0.9s ease-in-out infinite;
}

.eclaw-dom-select__ring-armed-resize {
  outline: 3px solid rgba(245, 158, 11, 0.95) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.18) !important;
  cursor: nwse-resize !important;
  animation: eclaw-armed-pulse 0.9s ease-in-out infinite;
}

.eclaw-dom-select__ring-active {
  outline: 3px solid rgba(245, 158, 11, 1) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.25), 0 6px 20px rgba(0,0,0,0.25) !important;
}

@keyframes eclaw-armed-pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.18); }
  50% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0.32); }
}

@media (prefers-reduced-motion: reduce) {
  .eclaw-dom-select__ring-armed-move,
  .eclaw-dom-select__ring-armed-resize {
    animation: none !important;
  }
}

/* v1.2a: ARMED-state hint in the toolbar — the active chip glows amber
   while waiting for the user to drag. */
.eclaw-hover-click-toolbar__chip[data-armed="true"] {
  background: rgba(245, 158, 11, 0.15) !important;
  outline: 2px solid rgba(245, 158, 11, 0.6) !important;
  outline-offset: 1px !important;
}

/* ----- Toolbar shell ----- */
/* v1.1 (Hank feedback): dock at top-right of the viewport instead of
   anchoring under the picked element, so it never blocks the visible
   target. Mobile keeps the bottom-sheet variant (handled in @media). */
.eclaw-hover-click-toolbar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  background: var(--bg, #ffffff);
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.12));
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 8px;
  max-width: min(620px, calc(100vw - 32px));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text, #18181b);
  user-select: none;
}

.eclaw-hover-click-toolbar__row {
  flex-wrap: wrap;
}

/* v1.3: drag handle. Renders as a vertical-dots glyph at the left of the row.
   Cursor switches to grabbing while dragging. Mobile hides it — the bottom
   sheet is fixed full-width. */
.eclaw-hover-click-toolbar__drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 28px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary, #71717a);
  cursor: grab;
  user-select: none;
  border-radius: 6px;
  margin-right: 2px;
  touch-action: none;
}
.eclaw-hover-click-toolbar__drag-handle:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text, #18181b);
}
.eclaw-hover-click-toolbar[data-dragging="true"] {
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  transition: none !important;
}
.eclaw-hover-click-toolbar[data-dragging="true"] .eclaw-hover-click-toolbar__drag-handle {
  cursor: grabbing;
}
/* v1.3: when user has dragged, override default top-right dock. Inline styles
   on the shell carry left/top/right=auto so this rule mainly documents the
   contract — the shell switches to absolute-positioned mode. */
.eclaw-hover-click-toolbar[data-user-positioned="true"] {
  /* inline left/top win over right:16px in the base rule */
}

.eclaw-hover-click-toolbar__divider {
  width: 1px;
  height: 20px;
  background: var(--card-border, rgba(0, 0, 0, 0.12));
  margin: 0 4px;
  align-self: center;
}

.eclaw-hover-click-toolbar__target-label {
  font-size: 12px;
  color: var(--text-secondary, #71717a);
  padding: 0 6px;
  margin-right: 4px;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eclaw-hover-click-toolbar[hidden] { display: none !important; }

.eclaw-hover-click-toolbar__row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.eclaw-hover-click-toolbar__chip {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  min-height: 32px;
  white-space: nowrap;
}

.eclaw-hover-click-toolbar__chip:hover,
.eclaw-hover-click-toolbar__chip:focus-visible {
  background: rgba(99, 102, 241, 0.12);
  outline: 2px solid rgba(99, 102, 241, 0.5);
  outline-offset: 1px;
}

.eclaw-hover-click-toolbar__chip[data-chip="delete"]:hover,
.eclaw-hover-click-toolbar__chip[data-chip="delete"]:focus-visible {
  background: rgba(244, 63, 94, 0.12);
  outline-color: rgba(244, 63, 94, 0.5);
}

.eclaw-hover-click-toolbar__chip-icon { font-size: 16px; line-height: 1; }
.eclaw-hover-click-toolbar__chip-label { font-size: 13px; }

/* Tight pack so the docked top-right toolbar fits 10 chips on one row
   at typical desktop widths without wrap. Falls back to wrap below 620px. */
@media (min-width: 721px) {
  .eclaw-hover-click-toolbar__chip { padding: 4px 8px; gap: 3px; }
  .eclaw-hover-click-toolbar__chip-label { font-size: 12px; }
}

.eclaw-hover-click-toolbar__close {
  margin-left: 4px;
  padding: 6px;
  background: transparent;
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.12));
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

/* ----- v1.2b Style picker subpanel ----- */
.eclaw-hover-click-toolbar__subpanel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg, #ffffff);
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.12));
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 12px;
  min-width: 280px;
  max-width: min(420px, calc(100vw - 32px));
  font-size: 13px;
  color: var(--text, #18181b);
  user-select: none;
}

.eclaw-style-picker__section {
  margin-bottom: 10px;
}

.eclaw-style-picker__section + .eclaw-style-picker__section {
  border-top: 1px solid var(--card-border, rgba(0, 0, 0, 0.08));
  padding-top: 10px;
}

.eclaw-style-picker__section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-secondary, #71717a);
  margin-bottom: 6px;
}

.eclaw-style-picker__row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 28px;
}

.eclaw-style-picker__label {
  flex: 0 0 64px;
  font-size: 12px;
  color: var(--text-secondary, #71717a);
}

.eclaw-style-picker__row input[type="color"] {
  width: 32px; height: 28px;
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.12));
  border-radius: 6px;
  padding: 0; cursor: pointer;
}

.eclaw-style-picker__row input[type="number"],
.eclaw-style-picker__row select {
  flex: 1;
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.12));
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  color: inherit;
  background: var(--bg, #ffffff);
}

.eclaw-style-picker__inline-quartet {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
  flex: 1;
}

.eclaw-style-picker__inline-quartet input {
  width: 100%;
}

.eclaw-style-picker__quartet-hint {
  font-size: 10px;
  color: var(--text-secondary, #71717a);
  display: flex;
  gap: 4px;
  margin-top: 2px;
}
.eclaw-style-picker__quartet-hint span { flex: 1; text-align: center; }

@media (max-width: 720px) {
  .eclaw-hover-click-toolbar__subpanel {
    position: fixed;
    bottom: 0; left: 0; right: 0; top: auto;
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    max-height: 60vh;
    overflow-y: auto;
  }
}

/* ----- Delete inline-Undo ghost (per #6 review §10 Q5) ----- */
.eclaw-hover-click-toolbar__ghost-delete {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(244, 63, 94, 0.08);
  border-radius: 8px;
  font-size: 13px;
}

.eclaw-hover-click-toolbar__ghost-undo {
  border: none;
  background: rgba(244, 63, 94, 0.15);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

/* ----- Mobile: bottom sheet ----- */
@media (max-width: 720px) {
  .eclaw-hover-click-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 12px 12px 24px;
    transform: translateY(100%);
    transition: transform 0.18s ease-out;
  }
  .eclaw-hover-click-toolbar[data-visible="true"] {
    transform: translateY(0);
  }
  .eclaw-hover-click-toolbar__row {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }
  .eclaw-hover-click-toolbar__chip {
    justify-content: flex-start;
    min-height: 44px;
    padding: 10px 14px;
  }
  .eclaw-hover-click-toolbar__close {
    margin-top: 8px;
    margin-left: 0;
    align-self: center;
    width: 50%;
  }
  .eclaw-hover-click-toolbar__drag-handle {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .eclaw-hover-click-toolbar {
    transition: none !important;
  }
}
