/* tooltip.css — The .info button and its tip popover.
   Cascade position 14 of 18. Order is load-bearing and is asserted by
   verify-fixtures.mjs; index.html links these explicitly (never @import) because Caddy's
   try_files turns a missing file into a 200 text/html SPA shell.
   Owner after Step 1: section (i). Items 77, 62.

   The `.info::after` tooltip this file used to hold is DELETED, not restyled. It was
   generated content with `pointer-events: none` (so a tap showed nothing at all) and
   `z-index: 40` (which cannot escape `.sheet__scroll { overflow-y: auto }` at any value).
   The tip is a real popover in the top layer now — see js/tooltip.js. */

/* ══ The trigger (item 77, defect 1) ══════════════════════════════════════════════════
   MEASURED BEFORE: 18 x 18, below WCAG 2.2 AA 2.5.8's 24 x 24 floor and well below the
   32 x 32 this app's own button base sets (css/base.css).
   The negative vertical margin is what lets the target be 32 px WITHOUT the settings
   column growing: `.field__head` (css/rail.css) is `min-height: 20px`, so a 32 px flex
   item with -8 px top and bottom margins has a 16 px outer size and the label row keeps
   the height it had. `getBoundingClientRect()` still reports 32 x 32, which is the number
   the pointer and the WCAG rule both care about. `margin-left: -4px` spends the same
   trick horizontally so the circle does not push the label's row out.

   `cursor: pointer`, never `cursor: help`: this is a <button> that opens something on
   click, and `help` announced it as inert decoration (DESIGN-SPEC §4.10). */
.info {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 32px; height: 32px;
  margin: -8px 0 -8px -4px;
  padding: 0;
  border: 1px solid var(--sn-line); border-radius: 50%;
  background: var(--sn-surface-2); color: var(--sn-ink-mute);
  font: inherit; line-height: 1; cursor: pointer;
  transition: background-color var(--sn-dur-fast) var(--sn-ease-out),
              border-color var(--sn-dur-fast) var(--sn-ease-out),
              color var(--sn-dur-fast) var(--sn-ease-out);
}
/* Hover changes FILL and border colour and nothing else — no transform, no shadow growth
   (REFERENCE-STUDY §18). The old rule tinted it accent-green, which read as a selected
   state on a control that selects nothing. */
.info:hover, .info:focus-visible {
  border-color: var(--sn-line-strong);
  background: var(--sn-surface-2-alt);
  color: var(--sn-ink);
}
.info svg { width: 11px; height: 11px; display: block; }

/* ══ The tip (item 77, defects 2, 3 and 4) ════════════════════════════════════════════
   A `popover="manual"` element created by js/tooltip.js inside `#tips`, the last child of
   <body>. Being in the top layer is the entire fix for the clipping: a popover is not
   clipped by an ancestor's overflow at any z-index, so the tip on the lowest setting in
   the rail is fully visible for the first time.

   The UA stylesheet for [popover] sets `position: fixed; inset: 0; margin: auto;
   border: solid; padding: .25em` — every one of those is undone here or the tip centres
   itself on the screen inside a default border.

   Elevation is ONE property (COMPONENT-PLAN §0.1 rule 11): the hairline is stop 1 of the
   box-shadow and there is NO `border`, the same grammar as the account menu (b) and the
   dock menu (c), so no floating surface in this app can show a doubled edge. This is a
   deliberate departure from DESIGN-SPEC §4.10's `border: 1px solid var(--sn-line-raised)`
   plus `--sn-shadow-raised`, which would be both at once.

   DARK, not inverted. REFERENCE-STUDY §9's measured target is a light chip because both
   references are LABEL tooltips of two or three words. Ours are explanations up to 280 px
   wide and several lines long, and a light card that size on a near-black page reads as a
   modal rather than a hint. §9's geometry, delays and 4 px offset are taken; its fill is
   not. If section (n) ever ships true 2-3 word label tooltips, the inverted chip is right
   there and the two variants should be NAMED, not blended.

   Width: `max-content` capped at §4.10's `min(280px, 80vw)`, rather than a flat width.
   Both §9 references specify a MAX width, and a fixed 280 px box under a one-line
   explanation is a card with a hole in it. */
.tip {
  position: fixed; inset: auto; margin: 0;
  width: max-content; max-width: min(280px, 80vw);
  padding: var(--sn-space-3);
  border: 0;
  border-radius: var(--sn-radius-sm);
  background: var(--sn-surface-3);
  color: var(--sn-ink-dim);
  font: inherit;
  font-size: var(--sn-text-xs); line-height: var(--sn-lh-xs);
  text-align: left;
  overflow: visible;
  box-shadow: 0 0 0 1px var(--sn-line-raised), var(--sn-shadow-raised);
}

/* The 4 px offset (REFERENCE-STUDY §9) leaves 4 px of dead ground between the trigger and
   the tip, and the pointer has to cross it to reach a tip it is allowed to hover. This is
   the invisible bridge the work order asks for instead of "a timeout that guesses": it
   extends the tip's hit area 6 px past its top and bottom edges, which covers the gap in
   whichever direction the tip flipped, and adds nothing on the sides. */
.tip::before {
  content: ''; position: absolute; inset: -6px 0;
}

/* Anchored 4 px below the trigger with their inline-start edges flush, flipping above
   when there is no room below. js/tooltip.js does the same arithmetic once, at open time,
   only where `anchor-name` is unsupported. `position-anchor` is set per instance from JS:
   two anchors sharing a dashed-ident would resolve to whichever came last in tree order,
   so the name cannot live here. */
@supports (anchor-name: --sn-probe) {
  .tip {
    position-area: block-end span-inline-end;
    margin-top: 4px; margin-bottom: 4px;
    position-try-fallbacks: flip-block;
  }
}

/* Opacity only, 120 ms, one easing. REFERENCE-STUDY §9 measured 150 ms on shadcn; this
   uses --sn-dur-fast instead because tokens.css is Step 1's file and a hand-typed 150 ms
   would be a new magic number in the one place the token system is the point. Both are
   inside the 33-160 ms house rule. `allow-discrete` is what lets the popover's own
   `display` participate, so there is no JS animation bookkeeping. */
.tip {
  opacity: 1;
  transition: opacity var(--sn-dur-fast) var(--sn-ease-out),
              overlay var(--sn-dur-fast) allow-discrete,
              display var(--sn-dur-fast) allow-discrete;
}
.tip:not(:popover-open) { opacity: 0; }
@starting-style { .tip:popover-open { opacity: 0; } }
