/* <vn-hint> tooltip and <vn-hover-card> preview. Both float in the top layer (popover) and are
   placed with CSS anchor positioning; .vn-float--js marks script placement where that is missing. */

vn-hint,
vn-hover-card {
  display: contents;
}

.vn-float {
  position: fixed;
  inset: auto;
  margin: 0;
  box-sizing: border-box;
  overflow: visible;
  opacity: 1;
  transform: none;
  transition:
    opacity var(--vn-duration-quick) var(--vn-ease-out),
    transform var(--vn-duration-quick) var(--vn-ease-out),
    overlay var(--vn-duration-quick) allow-discrete,
    display var(--vn-duration-quick) allow-discrete;
}
.vn-float:not(:popover-open):not([data-open]) {
  opacity: 0;
}
@starting-style {
  .vn-float:popover-open,
  .vn-float[data-open] { opacity: 0; }
}
/* A small slide from the trigger, by side. */
.vn-float[data-side="top"]:not(:popover-open) { transform: translateY(3px); }
.vn-float[data-side="bottom"]:not(:popover-open) { transform: translateY(-3px); }
.vn-float[data-side="left"]:not(:popover-open) { transform: translateX(3px); }
.vn-float[data-side="right"]:not(:popover-open) { transform: translateX(-3px); }
@starting-style {
  .vn-float[data-side="top"]:popover-open { transform: translateY(3px); }
  .vn-float[data-side="bottom"]:popover-open { transform: translateY(-3px); }
  .vn-float[data-side="left"]:popover-open { transform: translateX(3px); }
  .vn-float[data-side="right"]:popover-open { transform: translateX(-3px); }
}

@supports (anchor-name: --vn-a) and (position-area: top) {
  .vn-float:not(.vn-float--js) {
    margin: 6px;
    position-try-order: normal;
  }
  .vn-float:not(.vn-float--js)[data-side="top"] {
    position-area: top;
    position-try-fallbacks: flip-block, top span-right, top span-left, bottom span-right, bottom span-left;
  }
  .vn-float:not(.vn-float--js)[data-side="bottom"] {
    position-area: bottom;
    position-try-fallbacks: flip-block, bottom span-right, bottom span-left, top span-right, top span-left;
  }
  .vn-float:not(.vn-float--js)[data-side="left"] {
    position-area: left;
    position-try-fallbacks: flip-inline, top, bottom;
  }
  .vn-float:not(.vn-float--js)[data-side="right"] {
    position-area: right;
    position-try-fallbacks: flip-inline, top, bottom;
  }
  .vn-float:not(.vn-float--js)[data-side="bottom"][data-align="start"] {
    position-area: bottom span-right;
    position-try-fallbacks: flip-block, bottom span-left, top span-left;
  }
  .vn-float:not(.vn-float--js)[data-side="bottom"][data-align="end"] {
    position-area: bottom span-left;
    position-try-fallbacks: flip-block, bottom span-right, top span-right;
  }
  .vn-float:not(.vn-float--js)[data-side="top"][data-align="start"] {
    position-area: top span-right;
    position-try-fallbacks: flip-block, top span-left, bottom span-left;
  }
  .vn-float:not(.vn-float--js)[data-side="top"][data-align="end"] {
    position-area: top span-left;
    position-try-fallbacks: flip-block, top span-right, bottom span-right;
  }
}

/* Tooltip: dark on light, light on dark. Plain text only. */
.vn-hint-pop {
  z-index: var(--vn-z-toast, 70);
  max-width: min(240px, calc(100vw - 16px));
  padding: 5px 9px;
  border: 0;
  border-radius: var(--vn-radius-6, 6px);
  background: var(--vn-color-ink);
  color: var(--vn-color-bg);
  font: inherit;
  font-family: var(--vn-font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: auto;
}

/* Hover card: a field-colored panel with a soft shadow. */
.vn-hcard-pop {
  z-index: var(--vn-z-menu, 40);
  width: max-content;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 14px;
  border: 1px solid var(--vn-color-line);
  border-radius: var(--vn-radius-menu, 12px);
  background: var(--vn-color-field);
  color: var(--vn-color-ink);
  box-shadow: var(--vn-shadow-md);
  font-family: var(--vn-font-sans);
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  transition-duration: var(--vn-duration-ui);
}
.vn-hcard-pop > :first-child { margin-top: 0; }
.vn-hcard-pop > :last-child { margin-bottom: 0; }

/* Profile preview recipe used inside a hover card. */
.vn-hcard-profile { display: flex; align-items: center; gap: 12px; min-width: 0; }
.vn-hcard-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vn-hcard-name { font-size: 15px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vn-hcard-id { font-family: var(--vn-font-mono); font-size: 12px; color: var(--vn-color-muted); white-space: nowrap; }
.vn-hcard-note { margin: 10px 0 0; font-size: 13px; color: var(--vn-color-muted); }
.vn-hcard-actions { display: flex; gap: 8px; margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  .vn-float,
  .vn-float[data-side]:not(:popover-open) { transform: none; }
  .vn-float { transition-duration: 1ms; }
}
