/* ==========================================================================
   CHIP (.verser-chip): a filter, sort, when or pick control. CSS only.

   Default look = the app's ui-kit .chip (shared today by .tasks-chip and .hub-chip): a glass pill, 44px on a phone
   and 36px in the desktop layout with a mouse (720px and wider, workspace.js DESK_MEDIA, and a fine pointer: a touch
   tablet keeps the 44px target), 13.5px/600.
   Picked = the focus-ring rim on the pressed fill, never the bone of the primary button.

     selected      aria-pressed="true" | aria-selected="true" | aria-current="page" | data-selected | a <label> chip
                   whose own radio or checkbox is checked (chips acting as radios: <label class="verser-chip"><input …>)
     data-variant  mono                 JetBrains Mono 12.5/500, for counts and short codes (.chip.mono, .hub-chip)
                   menu                 a chip that opens a menu (the Tasks urgency, days and department chips): a 13px
                                        down chevron 8px from the inline end, room for it (10px start, 26px end) on
                                        every width; the chevron turns over while aria-expanded="true". It points down,
                                        so it does not mirror in right-to-left. Wrap the label in .verser-chip-label to end a long
                                        one in an ellipsis inside --verser-chip-menu-max-inline-size (default none).
                   ghost                no fill and a dashed rim: something still to do (Sales' "No next step")
     data-size     sm (32, the agent's source chips) | md (default: 44 phone / 36 desktop)
     data-tone     accent | agent | success | warn | danger   a coloured rim and text (a quiet tag-like chip)
   Removable: put a <button class="verser-chip-x" aria-label="Remove …"> inside a non-button chip (span/div).
   ========================================================================== */

.verser-chip{
  --_verser-chip-fill:var(--verser-chip-fill,var(--surface-fill-1));
  --_verser-chip-border:var(--verser-chip-border,var(--vx-hair));
  --_verser-chip-text:var(--verser-chip-text,var(--text));
  position:relative;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;
  gap:var(--verser-chip-gap,calc(var(--space-1) + 2px));
  min-block-size:var(--verser-chip-height,max(var(--tap-min),var(--control-height)));margin:0;
  padding-block:0;padding-inline:var(--verser-chip-padding-inline,calc(var(--space-3) + 2px));
  border:1px solid var(--_verser-chip-border);border-radius:var(--verser-chip-radius,var(--radius-pill));
  background:var(--verser-chip-gloss,var(--surface-gloss)),var(--_verser-chip-fill);background-origin:border-box;
  color:var(--_verser-chip-text);font-family:var(--verser-chip-font,var(--font-ui));
  font-size:var(--verser-chip-font-size,13.5px);font-weight:var(--verser-chip-font-weight,600);line-height:1.2;
  white-space:nowrap;text-decoration:none;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation;
  transition:background-color 140ms ease,border-color 140ms ease,color 140ms ease,transform 160ms var(--ease-out)
}
.verser-chip>svg,.verser-chip .icon{flex:none;inline-size:var(--verser-chip-icon-size,16px);block-size:var(--verser-chip-icon-size,16px)}
.verser-chip[data-variant="mono"]{font-family:var(--verser-chip-mono-font,var(--font-mono));font-size:var(--verser-chip-mono-font-size,12.5px);font-weight:500}

.verser-chip[data-variant="mono"]:is(:lang(ar),:dir(rtl)){font-family:var(--font-mono-rtl);letter-spacing:0}   /* JetBrains Mono has no Arabic: Plex Arabic first */

.verser-chip:is([aria-pressed="true"],[aria-selected="true"],[aria-current="page"],[data-selected]:not([data-selected="false"]),:has(>input:checked)){
  --_verser-chip-fill:var(--verser-chip-on-fill,var(--surface-pressed));
  --_verser-chip-border:var(--verser-chip-on-border,var(--selected-edge));
  --_verser-chip-text:var(--verser-chip-on-text,var(--text))
}

.verser-chip[data-tone="accent"]{--_verser-chip-tone:var(--verser-chip-tone-accent,color-mix(in srgb,var(--accent) 55%,var(--text)))}
.verser-chip[data-tone="agent"]{--_verser-chip-tone:var(--verser-chip-tone-agent,var(--vx-agent))}
.verser-chip[data-tone="success"]{--_verser-chip-tone:var(--verser-chip-tone-success,var(--success))}
.verser-chip[data-tone="warn"]{--_verser-chip-tone:var(--verser-chip-tone-warn,var(--warn))}
.verser-chip[data-tone="danger"]{--_verser-chip-tone:var(--verser-chip-tone-danger,var(--danger))}
.verser-chip[data-tone]:not([data-tone="neutral"]){
  --_verser-chip-border:color-mix(in srgb,var(--_verser-chip-tone) 45%,transparent);--_verser-chip-text:var(--_verser-chip-tone)
}

/* Ghost (data-variant="ghost"): something still to do, not a state (Sales P9's "No next step"): no fill, a dashed rim,
   the secondary text; a tone still colours it. */
.verser-chip[data-variant="ghost"]{
  --_verser-chip-fill:transparent;--verser-chip-gloss:none;border-style:dashed;
  --_verser-chip-text:var(--verser-chip-ghost-text,var(--text-secondary))
}
.verser-chip[data-variant="ghost"]:hover:not(:disabled){--_verser-chip-fill:var(--surface-fill-1)}

.verser-chip[data-size="sm"]{
  min-block-size:var(--verser-chip-height-sm,calc(32px * var(--density)));padding-inline:var(--space-3);
  font-size:var(--font-size-meta);font-weight:500
}

/* The remove button inside a chip: a 24px round target that grows to 44px of hit area on touch. */
.verser-chip-x{
  position:relative;box-sizing:border-box;display:inline-grid;place-items:center;flex:none;
  inline-size:24px;block-size:24px;margin-block:0;margin-inline:calc(var(--space-1) * -1) calc(var(--space-2) * -1);padding:0;
  border:0;border-radius:var(--radius-pill);background:transparent;color:var(--text-secondary);font:inherit;line-height:1;cursor:pointer
}
.verser-chip-x>svg,.verser-chip-x .icon{inline-size:14px;block-size:14px}
.verser-chip-x::after{content:"";position:absolute;inset:-10px}
.verser-chip-x:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring);outline-offset:0}

.verser-chip:active:not(:disabled):not([aria-disabled="true"]):not(:has(.verser-chip-x:active)){transform:scale(.97)}
.verser-chip:is(:focus-visible,:has(>input:focus-visible)){outline:var(--focus-ring-width) solid var(--focus-ring);outline-offset:var(--focus-ring-offset)}
.verser-chip:is(:disabled,[aria-disabled="true"]){opacity:.4;cursor:default}
/* Chips acting as radios or checkboxes: the input stays in the label (it takes the focus and the keys) but is not drawn;
   the chip shows its state. A group of them: <fieldset class="verser-chip-group"><legend class="verser-label">…</legend>
   <label class="verser-chip"><input type="radio" name="…"> Price</label> …</fieldset> (P14's Lost reasons). */
.verser-chip>input:is([type="radio"],[type="checkbox"]){position:absolute;inline-size:1px;block-size:1px;margin:0;opacity:0;pointer-events:none}
.verser-chip-group{display:flex;flex-wrap:wrap;gap:var(--space-2);min-inline-size:0;margin:0;padding:0;border:0}
.verser-chip-group>legend{inline-size:100%;margin-block-end:var(--space-2);padding:0}

@media (pointer:coarse){
  .verser-chip[data-size="sm"]::after{content:"";position:absolute;inset-block:min(0px,calc((100% - var(--tap-min)) / 2));inset-inline:0}
}
/* Desktop with a mouse: 36px chips, 12px sides (the app's body.desk width, 720px as in workspace.js DESK_MEDIA, with a fine pointer). */
@media (min-width:720px) and (hover:hover) and (pointer:fine){
  .verser-chip:not([data-size="sm"]){min-block-size:var(--verser-chip-height-desk,var(--control-height-sm));padding-inline:var(--space-3)}
}
/* Menu chip. After the desktop rule so its room for the chevron holds there too (as the Tasks chips do today). */
.verser-chip[data-variant="menu"]{
  max-inline-size:var(--verser-chip-menu-max-inline-size,none);overflow:hidden;
  padding-inline:var(--verser-chip-menu-padding-inline-start,10px) var(--verser-chip-menu-padding-inline-end,26px)
}
.verser-chip[data-variant="menu"]>.verser-chip-label{min-inline-size:0;overflow:hidden;text-overflow:ellipsis}
.verser-chip[data-variant="menu"]::before{
  content:"";position:absolute;inset-block:0;inset-inline-end:var(--verser-chip-menu-chevron-inset,8px);
  inline-size:var(--verser-chip-menu-chevron-size,13px);margin-block:auto;block-size:var(--verser-chip-menu-chevron-size,13px);
  background:var(--verser-chip-menu-chevron-color,var(--text-secondary));
  -webkit-mask:var(--verser-chip-menu-chevron,var(--vx-chevron)) center/100% 100% no-repeat;
  mask:var(--verser-chip-menu-chevron,var(--vx-chevron)) center/100% 100% no-repeat;
  transition:transform 160ms var(--ease-out);pointer-events:none
}
.verser-chip[data-variant="menu"][aria-expanded="true"]::before{transform:rotate(180deg)}

@media (hover:hover) and (pointer:fine){
  .verser-chip:not([aria-pressed="true"]):not([aria-selected="true"]):not([aria-current="page"]):not([data-selected]):not(:has(>input:checked)):not(:disabled):not([aria-disabled="true"]):hover{
    --_verser-chip-fill:var(--verser-chip-fill-hover,var(--surface-fill-2))
  }
  .verser-chip-x:hover{background:var(--surface-fill-2);color:var(--text)}
}
@media (prefers-reduced-motion:reduce){
  .verser-chip,.verser-chip[data-variant="menu"]::before{transition:none}
  .verser-chip:active{transform:none!important}
}

/* COUNT CHIP (.verser-chip[data-variant="count"], Projects kit addition #4, 2026-10-30): a figure and its kind
   ("2 join requests", "3 to verify") inside the Pending strip. Not a control: a <span>, no press, no pointer of its
   own (a tap goes to the strip). Mono, 28px. Wrap the figure in <bdi>. Hook: --verser-chip-count-height. */
.verser-chip[data-variant="count"]{
  min-block-size:var(--verser-chip-count-height,28px);padding-inline:10px;
  font-family:var(--font-mono);font-size:var(--font-size-meta);font-weight:500;cursor:inherit;pointer-events:none
}
.verser-chip[data-variant="count"]:is(:lang(ar),:dir(rtl)){font-family:var(--font-mono-rtl);letter-spacing:0}

/* A count inside a filter chip (.verser-chip-count, 2 Nov 2026: Projects' status chips, "In progress 3"): the figure
   in mono, a step quieter than the word; a status glyph (.verser-lifecycle-glyph, the pill kit) may lead the word. */
.verser-chip-count{font-family:var(--font-mono);font-size:var(--font-size-meta);color:var(--text-muted);font-variant-numeric:tabular-nums}
.verser-chip:is([aria-pressed="true"],[aria-selected="true"]) .verser-chip-count{color:inherit}
.verser-chip-count:is(:lang(ar),:dir(rtl)){font-family:var(--font-mono-rtl);letter-spacing:0}
.verser-chip>.verser-lifecycle-glyph{inline-size:14px;block-size:14px}
