/* ═══════════════════════════════════════════════════════════════
   Popover Tooltips
   Uses interestfor + popover="hint" + CSS Anchor Positioning.
   Chrome/Edge 142+. Polyfill needed for Firefox/Safari.
   ═══════════════════════════════════════════════════════════════ */

/* Show and hide instantly by default */
[interestfor] {
  interest-delay: 0s 0s;
}

/* Add --hoverable on the trigger when users need to hover into the popover */
[interestfor].--hoverable {
  interest-delay: 0s 0.5s;
}

.ui-popover-tooltip {
  /* Reset popover defaults */
  margin: 0;
  padding: 0;
  border: none;

  /* Anchor to the trigger automatically */
  position: fixed;
  position-anchor: auto;
  position-area: top;
  margin-bottom: 6px;

  /* Auto-flip if no room */
  position-try-fallbacks: flip-block, flip-inline;

  /* Match existing .ui-tooltip style */
  background: var(--ui-tooltip-background-color, #1a1a2e);
  color: var(--ui-tooltip-text-color, #fff);
  padding: var(--ui-tooltip-padding, 8px);
  font-size: var(--ui-tooltip-font-size, 0.85rem);
  line-height: var(--ui-tooltip-line-height, 1rem);
  white-space: nowrap;
  border-radius: var(--ui-tooltip-border-radius, 6px);
  box-shadow: var(--ui-tooltip-box-shadow, 0 0 0.5rem rgba(0, 0, 0, 0.1));

  /* Entry/exit animation */
  opacity: 1;
  transition:
    opacity 0.15s ease,
    overlay 0.15s allow-discrete,
    display 0.15s allow-discrete;
}

@starting-style {
  .ui-popover-tooltip {
    opacity: 0;
  }
}

/* ── Position variants ── */

.ui-popover-tooltip.--bottom {
  position-area: bottom;
  margin-bottom: 0;
  margin-top: 6px;
}

.ui-popover-tooltip.--left {
  position-area: left;
  margin-bottom: 0;
  margin-right: 6px;
}

.ui-popover-tooltip.--right {
  position-area: right;
  margin-bottom: 0;
  margin-left: 6px;
}

/* ── Size variants (multi-line) ── */

.ui-popover-tooltip.--small {
  white-space: normal;
  width: 80px;
  line-height: 1.4em;
}

.ui-popover-tooltip.--medium {
  white-space: normal;
  width: 150px;
  line-height: 1.4em;
}

.ui-popover-tooltip.--large {
  white-space: normal;
  width: 300px;
  line-height: 1.4em;
}

/* ── Color variants ── */

.ui-popover-tooltip.--error {
  background-color: var(--ui-color-red-600, #dc2626);
}

.ui-popover-tooltip.--warning {
  background-color: var(--ui-color-amber-600, #d97706);
}

.ui-popover-tooltip.--info {
  background-color: var(--ui-color-blue-600, #2563eb);
}

.ui-popover-tooltip.--success {
  background-color: var(--ui-color-green-600, #16a34a);
}
