/* Tag — square-ish label, XS only. Confirmed from Figma (node 124:12718):
   radius 3px, padding 3px/8px, text n200 at body-m (13px) — NOT body-xs;
   this was wrong in an earlier draft of this file. Neutral confirmed n10.

   Note: the only Tag instance built in Figma is literally named
   "Tint=Green, Size=XS" but its actual fill is n10, same as Neutral —
   looks like an unfinished placeholder in the file rather than a real
   spec. Using greenTint10 (matching Chip's pattern) instead of copying
   that apparent bug; flagging here in case Figma intended n10 for real. */

@layer components {

  .tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-2) var(--space-6); /* was 4/8 (inspector, 2026-10-03); 3px in Figma — update Figma */
    /* Real Figma value (3px) doesn't land on the radius.css scale
       (2/4/6/8/12/16/24) — it's exactly equidistant between 2 and 4.
       Left hardcoded rather than silently snapped either direction; see
       /kit/corners for the flagged discrepancy. */
    border-radius: 3px;
    color: var(--n200);
    font: var(--body-m);
    letter-spacing: var(--body-m-ls);
    white-space: nowrap;
  }

  /* Long labels (WCAG 2.1 reflow, Santiago's pick A, 2026-11-14): a Tag is never wider than its box,
     a long label ends in …. Ellipsis needs a block box, so the Tag flows inline (not flex) and its
     parts space themselves with margins equal to the old gap (8, S 4). */
  .tag { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
  .tag > :is(.tag-dot, .icon-wrap, svg) { display: inline-block; vertical-align: middle; margin-right: var(--space-8); }
  .tag > .tag-dot { vertical-align: top; margin-top: calc((1lh - 5px) / 2); } /* centered on the line, as flex did */
  .tag > .rpl-tag-icon { display: inline-flex; vertical-align: top; margin-top: calc((1lh - 12px) / 2); margin-right: var(--space-4); } /* the change list's 12px tag icons */
  .tag > .icon-wrap > svg { display: block; }
  .tag > .tag-remove { vertical-align: -1px; margin-left: var(--space-8); } /* -1px = where flex centering put it */
  .tag--s > :is(.tag-dot, .icon-wrap, svg) { margin-right: var(--space-4); }
  .tag--s > .tag-remove { margin-left: var(--space-4); }

  /* Color rule (color.css): --color-tint fills the tag, --color is there
     for its dot or anything else inside that should match. */
  .tag { background-color: var(--color-tint); }
  .tag--neutral { --color: var(--n90);       --color-tint: var(--n10); }
  .tag--green   { --color: var(--green100);  --color-tint: var(--greenTint10); }
  .tag--red     { --color: var(--red100);    --color-tint: var(--redTint10); }
  .tag--yellow  { --color: var(--yellow100); --color-tint: var(--yellowTint10); }
  .tag--blue    { --color: var(--blue100);   --color-tint: var(--blueTint10); }

  /* S — the word chip in drawer lists (Figma 599:17878): Body XS, 2px / 6px,
     an optional 5px dot before the text and a Title XS n90 count after it.
     Quiet = n5, for tags sitting on n0. */
  .tag--s { gap: var(--space-4); padding: var(--space-2) var(--space-6); font: var(--body-s); letter-spacing: var(--body-s-ls); } /* was Body XS (inspector, 2026-10-06) */
  .tag--quiet { background-color: var(--n5); }
  .tag-dot { flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--dot, var(--color, var(--n90))); }
  /* Removable (2026-10-07, for TagInput): an icon-only × at the end, 12,
     n90 → n150 on hover; its name is "Remove <tag>". */
  .tag-remove { display: inline-flex; flex: none; margin: 0 calc(-1 * var(--space-2)) 0 0; padding: 0; border: 0; border-radius: var(--radius-2); background: none; color: var(--n90); cursor: pointer; transition: color var(--dur-120) var(--ease-fade), background-color var(--dur-120) var(--ease-fade); }
  @media (hover: hover) { .tag-remove:hover { color: var(--n150); background: rgb(from var(--n150) r g b / 8%); } }
  .tag-remove:focus-visible { outline: 2px solid var(--blue100); outline-offset: 1px; }
  .tag-remove:disabled { display: none; }
  /* End padding rule (Spacing rules, 2026-10-18): measured to the ×'s
     button (its 12 hover box, not the glyph): as far from the end as from
     the top and bottom, i.e. the padding plus half of what the line has
     over 12. Tag S 4.4, Tag 5.1, inside a TagInput 7 (Santiago, attention). */
  .tag:has(> .tag-remove:last-child) { padding-right: calc(var(--space-2) + (1lh - 12px) / 2); }
  .field-box--tags > .tag:has(> .tag-remove:last-child) { padding-right: calc(var(--space-4) + (1lh - 12px) / 2); }
  .tag > .tag-remove:last-child { margin-right: 0; }
  .tag-count { margin-left: var(--space-6); } /* the old gap minus 2 */
  .tag--s > .tag-count { margin-left: var(--space-2); }
  .tag-count { font: var(--title-xs); letter-spacing: var(--title-xs-ls); color: var(--n90); }
}
