/*
 * components/popovers.css — Tooltip + popover components (Session 5: UI Lab).
 *
 * Paired with templates/components/popovers.html and
 * static/js/components/popovers.js (popover open/close only; tooltip is
 * CSS-only hover/focus). Token-driven (D5).
 */

/* Tooltip: CSS-only hover/focus bubble with short text */
.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-fg-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  cursor: help;
  margin-left: var(--space-1);
  vertical-align: middle;
}

.tooltip__bubble {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%) translateY(var(--space-1));
  width: 14rem;
  background: var(--color-fg);
  color: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-normal);
  line-height: var(--lh-base);
  text-align: left;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-fast) var(--ease-standard),
    transform var(--dur-fast) var(--ease-standard);
  z-index: var(--z-popover);
  pointer-events: none;
}

.tooltip:hover .tooltip__bubble,
.tooltip:focus .tooltip__bubble,
.tooltip:focus-within .tooltip__bubble {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Popover: click-triggered richer content */
.popover-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--color-accent);
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--color-accent);
  cursor: pointer;
  padding: 0;
}

.popover-trigger:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.popover {
  position: absolute;
  z-index: var(--z-popover);
  background: var(--color-surface);
  border: var(--border-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: var(--space-4);
  max-width: 20rem;
  display: none;
  font-size: var(--fs-md);
  line-height: var(--lh-base);
}

.popover.is-open { display: block; }

.popover__body { margin: 0; }

.popover__close {
  appearance: none;
  border: none;
  background: transparent;
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--color-fg-muted);
  cursor: pointer;
  float: right;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}

.popover__close:hover {
  color: var(--color-fg);
}

.popover__close:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .tooltip__bubble { transition: none; }
}
