/* ============================================================================
   Tooltip — shared system component (canonical: notes/decisions.md "Tooltip").

   One floating .tip node per document, driven by _tooltip.js on hover/focus
   of any [data-tip] element. Theme-awareness is free: the chip inverts through
   --color-fg-default / --color-bg-surface so it flips with the theme tokens.
   Only the navy drop-shadow is re-pinned for dark (in _dark.css).

   Extracted from _card.css so BOTH the preview cards (_card.css @imports this)
   AND the full prototype (ui_kits/cos-library/index.html links it directly)
   share ONE copy — no mirror to keep in sync.
   ============================================================================ */

/* Token-classifier home: --tip-origin is a transform-origin keyword set per
   placement on .tip; declare a plain-:root default so the DS classifier can
   read its @kind (annotations attach in a plain :root). */
:root { --tip-origin: bottom center; /* @kind other */ }
.tip {
  position: fixed;
  /* Top of the stack — must clear the Tweaks/Inspector panel (2147483646) so
     tooltips on panel controls aren't occluded by the panel itself. */
  z-index: 2147483647;
  max-width: 240px;
  padding: 5px 9px;
  border-radius: 5px;
  font: 500 12px/1.45 var(--font-sans);
  letter-spacing: 0.005em;
  white-space: normal;
  /* `--tip-bg` drives BOTH the chip fill and the caret colour (below) so a
     variant only has to re-point this one var. Default: the theme-flipping ink. */
  --tip-bg: var(--color-fg-default);
  background: var(--tip-bg);
  color: var(--color-bg-surface);
  box-shadow: 0 4px 14px rgba(12,24,56,0.22), 0 1px 3px rgba(12,24,56,0.18);
  pointer-events: none;
  /* Hide/show is binary via visibility + opacity, and BOTH are rule-driven
     (instant) — opacity is never transitioned, so it can't park at 0 in
     throttled/capture environments (see notes/pitfalls.md "CSS specificity").
     The entrance motion is a TRANSFORM-ONLY animation: if its clock is frozen
     the worst case is a ~4px offset, never opacity:0, so the tip stays
     readable everywhere; real browsers play the rise. */
  visibility: hidden;
  opacity: 0;
  transform: none;
  transform-origin: var(--tip-origin, bottom center);
  /* Entrance slide offset — direction depends on placement (the tip rises
     toward / slides out from the trigger). Overridden per data-placement. */
  --tip-in-x: 0px;
  --tip-in-y: 4px;
}
.tip[data-show="1"] {
  visibility: visible;
  opacity: 1;
  animation: tipIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes tipIn {
  from { transform: translate(var(--tip-in-x), var(--tip-in-y)) scale(0.98); }
  to   { transform: none; }
}
/* Per-placement transform-origin + entrance direction. top keeps the .tip
   defaults (origin bottom-center, rise up from +4y). */
.tip[data-placement="top"]    { --tip-origin: bottom center; /* @kind other */ }
.tip[data-placement="bottom"] { --tip-origin: top center; /* @kind other */ --tip-in-y: -4px; }
.tip[data-placement="left"]   { --tip-origin: center right; /* @kind other */ --tip-in-x: 4px; --tip-in-y: 0px; }
.tip[data-placement="right"]  { --tip-origin: center left; /* @kind other */ --tip-in-x: -4px; --tip-in-y: 0px; }

/* Optional keyboard-shortcut line (built by _tooltip.js from data-tip-key).
   Keycaps tint off the tip's own ink (currentColor) so they read in BOTH the
   light tip (dark page) and the inverted dark tip (light ink). */
.tip__label { display: block; }
.tip__shortcut {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  margin-top: 5px;
}
.tip__sk {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.07em;
  opacity: 0.55;
}
.tip__or { font-size: 10px; opacity: 0.5; padding: 0 1px; }
/* One alternative shortcut set — never splits mid-chord; the row wraps BETWEEN
   groups (so "or" stays at the end of line 1 and the next set drops to line 2). */
.tip__altgrp { display: inline-flex; align-items: center; gap: 4px; flex-wrap: nowrap; }
.tip__plus { font: 700 9px var(--font-sans); opacity: 0.5; padding: 0 0.5px; }
.tip__actsep { font-size: 11px; opacity: 0.45; padding: 0 2px; }
.tip kbd {
  font: 600 10px/1 var(--font-mono);
  min-width: 9px; text-align: center;
  padding: 2px 5px; border-radius: 4px;
  color: inherit;
  background: color-mix(in srgb, currentColor 16%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
  border-bottom-width: 2px;
}
/* Caret — one ::after, repositioned per placement. top/bottom aim along the
   horizontal axis (--tip-arrow-x), left/right along the vertical (--tip-arrow-y);
   the JS sets whichever axis applies. */
.tip::after {
  content: "";
  position: absolute;
  width: 0; height: 0;
  border: 5px solid transparent;
}
.tip[data-placement="top"]::after    { top: 100%;    left: var(--tip-arrow-x, 50%); margin-left: -5px; border-top-color: var(--tip-bg); }
.tip[data-placement="bottom"]::after { bottom: 100%; left: var(--tip-arrow-x, 50%); margin-left: -5px; border-bottom-color: var(--tip-bg); }
.tip[data-placement="left"]::after   { left: 100%;   top: var(--tip-arrow-y, 50%); margin-top: -5px; border-left-color: var(--tip-bg); }
.tip[data-placement="right"]::after  { right: 100%;  top: var(--tip-arrow-y, 50%); margin-top: -5px; border-right-color: var(--tip-bg); }

/* ── Danger variant ──────────────────────────────────────────────────────
   For tips on destructive actions (delete / clear / irreversible) or to surface
   an error on hover/focus. Set data-tip-variant="danger" on the trigger;
   _tooltip.js mirrors it onto the shared .tip node. A solid error-red fill with
   white ink in BOTH themes (it's a semantic alarm, not a theme-inverted chip),
   so the caret + keycaps follow via --tip-bg / currentColor. The drop-shadow
   gains a faint red cast so the chip reads as "hot" even over busy content. */
.tip[data-tip-variant="danger"] {
  --tip-bg: var(--gov-color-error-600, #c0341d);
  color: #fff;
  box-shadow: 0 4px 14px rgba(176,32,18,0.30), 0 1px 3px rgba(12,24,56,0.18);
}
/* Reduced motion handled system-wide in colors_and_type.css (the tip's one-shot
   entrance animation collapses to ~instant there). */
