/*
 * mw-view-scope.css — MwViewScopeWidget (PeoplePage toolbar) + MwEventScopeChip.
 *
 * The widget is ONE rectangular segmented field that mirrors the toolbar search input's
 * geometry: count segment | hairline divider | team segment | divider | event segment
 * (variant A of docs/mockups/people-toolbar-scope-variants.html). It NEVER wraps: the
 * host is a query container (container-type: inline-size), and @container rules below
 * degrade the content as the available width shrinks — drop the count caption, collapse
 * the team list to a count, then icon-only event. The event name truncates continuously
 * via flex + ellipsis. Hover popovers carry the full breakdown so truncation never loses
 * information.
 *
 * MwEventScopeChip renders the same mw-vs-pill markup STANDALONE elsewhere (e.g. the
 * Teams grid's Events column). The base .mw-vs-chip/.mw-vs-pill rules keep that rounded
 * pill look; the ".mw-vs .mw-vs-pill" overrides flatten pills into full-height segments
 * only inside the widget's field.
 *
 * All colours come from --mud-palette-* so the widget tracks the active theme.
 */

.mw-vs-host {
    container-type: inline-size;
    display: flex;
    align-items: center;
    /* flex-grow shares the toolbar's free space 50/50 with MWDGUtils' trailing spacer,
       which centers the action-button group between the widget and the manage menu.
       basis:auto keeps the container query measuring content + earned free space, so the
       widget re-expands when space returns after a degradation step. */
    flex: 1 1 auto;
    min-width: 0;
    /* breathing room between the search field and the widget (the old standalone
       "Showing: N" text used to provide this gap) */
    margin-left: 12px;
}

/* ── the field shell — search-input geometry ── */
.mw-vs {
    display: flex;
    align-items: stretch;
    flex-wrap: nowrap;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
    min-height: 36px;
    font-size: 0.84rem;
    line-height: 1.4;
    color: var(--mud-palette-text-primary);
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    overflow: hidden;
}

/* ── count segment ── */
.mw-vs-count {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 13px;
    flex: none;
}
.mw-vs-count .mw-vs-num {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    color: var(--mud-palette-primary);
}
.mw-vs-cap {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

/* ── hairline dividers between segments ── */
.mw-vs-div {
    width: 1px;
    background: var(--mud-palette-lines-default);
    margin: 6px 0;
    flex: none;
}

/* ── named team list inside the team segment (≤ 3 teams) ── */
.mw-vs-teams-list {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    min-width: 0;
}
.mw-vs-tname {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: none;
    font-weight: 600;
}
.mw-vs-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--mud-palette-surface) 70%, transparent);
}

/* ── hoverable pills — BASE = standalone rounded chip (MwEventScopeChip outside the widget) ── */
.mw-vs-chip { display: inline-flex; align-items: center; min-width: 0; }
.mw-vs-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    border-radius: 999px;
    padding: 3px 10px 3px 7px;
    font-weight: 700;
    cursor: default;
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-background-grey);
    transition: border-color .15s, background .15s;
}
.mw-vs-pill:hover {
    border-color: color-mix(in srgb, var(--mud-palette-primary) 45%, transparent);
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-background-grey));
}
.mw-vs-pill svg { flex: none; opacity: 0.8; }
.mw-vs-caret { opacity: 0.45; flex: none; }
.mw-vs-pill:hover .mw-vs-caret { opacity: 0.8; }

.mw-vs-pill-global {
    color: var(--mud-palette-primary);
    border-color: color-mix(in srgb, var(--mud-palette-primary) 42%, transparent);
    background: color-mix(in srgb, var(--mud-palette-primary) 14%, transparent);
}

/* ── segment overrides — pills flatten to full-height segments INSIDE the field ── */
.mw-vs .mw-vs-chip,
.mw-vs .mw-vs-anchor { align-items: stretch; }
.mw-vs .mw-vs-pill {
    border: none;
    background: transparent;
    border-radius: 0;
    padding: 4px 13px;
    font-weight: 600;
    transition: background .15s;
    /* squeezed segments clip + ellipsize their labels instead of spilling into the neighbour */
    overflow: hidden;
}

/* text labels inside pills (e.g. the global "all people" wording) — shrink with ellipsis
   so a squeezed field truncates continuously between the discrete ladder steps below */
.mw-vs-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mw-vs .mw-vs-pill:hover {
    border-color: transparent;
    background: var(--mud-palette-action-default-hover);
}
.mw-vs .mw-vs-pill-global { color: var(--mud-palette-primary); }
.mw-vs .mw-vs-pill-global:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 10%, transparent);
}

/* stacked dots inside the count form */
.mw-vs-stack { display: inline-flex; align-items: center; flex: none; }
.mw-vs-stack .mw-vs-dot {
    width: 11px;
    height: 11px;
    margin-left: -5px;
    box-shadow: 0 0 0 2px var(--mud-palette-background-grey);
}
.mw-vs-stack .mw-vs-dot:first-child { margin-left: 0; }
.mw-vs .mw-vs-stack .mw-vs-dot { box-shadow: 0 0 0 2px var(--mud-palette-surface); }

.mw-vs-num { font-variant-numeric: tabular-nums; }
.mw-vs-unit { /* the " teams" word — dropped at the tightest width */ }

/* event name — truncates continuously */
.mw-vs-evname {
    display: inline-block;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 22ch;
}
.mw-vs-chip-event { flex: 0 1 auto; }

/* The count form lives inside the same hover trigger as the named list: hidden while the
   list is shown, swapped in by the 290px @container breakpoint below. When teams > 3 the
   component adds .mw-vs-teams-count--always, which keeps it visible at every width. These
   base rules MUST precede the @container blocks so the breakpoint (equal specificity,
   later in source) wins at narrow widths. */
.mw-vs-teams-count { display: none; align-items: center; gap: 6px; min-width: 0; }
.mw-vs-teams-count.mw-vs-teams-count--always { display: inline-flex; }

/* ── popover ──
   Rendered through MudPopover (portals to MudPopoverProvider at the document root) so
   the card escapes the data-grid toolbar's overflow clipping while keeping full custom
   styling. The anchor is position:relative so MudPopover positions under the pill. */
.mw-vs-anchor {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

/* Strip MudPopover's own surface so .mw-vs-pop-inner is the only card chrome. */
.mw-vs-popover {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
}

.mw-vs-pop-inner {
    min-width: 220px;
    max-width: 340px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    box-shadow: 0 16px 42px -12px rgba(0,0,0,.55), 0 4px 12px -6px rgba(0,0,0,.4);
    overflow: hidden;
}
.mw-vs-pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}
.mw-vs-pop-head .t {
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
    font-weight: 700;
}
.mw-vs-pop-head .n {
    font-variant-numeric: tabular-nums;
    font-size: 0.76rem;
    color: var(--mud-palette-primary);
}
.mw-vs-pop-body { padding: 5px; max-height: 240px; overflow-y: auto; }
.mw-vs-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 8px;
    border-radius: 7px;
}
.mw-vs-row:hover { background: var(--mud-palette-action-default-hover); }
.mw-vs-row .name {
    font-weight: 600;
    font-size: 0.8rem;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mw-vs-row .name .sub {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--mud-palette-text-disabled);
}
.mw-vs-row .count {
    font-variant-numeric: tabular-nums;
    font-size: 0.74rem;
    color: var(--mud-palette-text-secondary);
}
.mw-vs-pop-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-top: 1px solid var(--mud-palette-lines-default);
    font-size: 0.74rem;
    color: var(--mud-palette-text-secondary);
}
.mw-vs-pop-foot .v {
    font-variant-numeric: tabular-nums;
    color: var(--mud-palette-text-primary);
}
.mw-vs-pop-note {
    padding: 11px 12px;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--mud-palette-text-secondary);
}
.mw-vs-pop-note b { color: var(--mud-palette-text-primary); }

/* ════════════ responsive concession ladder ════════════
   Breakpoints read the host (available toolbar space). The event name
   ellipsis covers slack between these discrete steps. */

/* drop the count caption — the number alone still reads */
@container (max-width: 360px) {
    .mw-vs-cap { display: none; }
    .mw-vs-count { padding: 4px 11px; }
}

/* collapse a listed team set to its count form */
@container (max-width: 290px) {
    .mw-vs-teams-list { display: none; }
    .mw-vs-teams-count { display: inline-flex; }
}

/* drop pill text labels (globe icon carries the global segment) — the event name,
   which is the more specific information, keeps its remaining space */
@container (max-width: 250px) {
    .mw-vs-label { display: none; }
}

/* minimal: drop the " teams" word and the event name (icon-only) */
@container (max-width: 210px) {
    .mw-vs-unit { display: none; }
    .mw-vs-evname { display: none; }
    .mw-vs .mw-vs-pill { padding: 4px 10px; }
}
