/* ─────────────────────────────────────────────────────────────────────────
   LIST TOOLBAR — one labelled toolbar on every list page (METIS-pub#821).

   Every list's toolbar was a different row of unlabelled icons in a different
   order. Now each control says what it is, in one order:

     View (List | Board) · Only mine · Journey … Search   ·   Columns · ⋮ More · + Add

   The page's own `.filters` row wears `.list-toolbar`; its controls are the
   existing partials (view_mode_toggle, filter_toggle, journey_filter_chip,
   _col_prefs_menu, _actions_menu, _create_button), unchanged in ids, HTMX and
   JS. This file only lays them out and gives them their words:

     .list-toolbar             the row
     .list-toolbar__switch     a <label> around the Only-mine switch, so its
                               word toggles it too
     .list-toolbar__field      a pill holding a key ("Journey") and a filter chip
                               or a select (crm/partials/filter_chip_select.html)
     .list-toolbar__field--needs-value  the same, ringed red until it is set
     .list-toolbar__key        that key, muted
     .list-toolbar__select     a plain <select> as a field's value ("Kind"),
                               followed by .list-toolbar__chevron
     .list-toolbar--joined     the toolbar as the top of its list, edge to edge
     .list-toolbar__group      a key and a segmented control ("Stage" and
                               its stages), kept together when the row wraps
     .list-toolbar__spacer     pushes Columns · More · Add to the right
     .list-toolbar__add        the "+ Add …" primary button, last

   The big page icon, the Locations/Spheres icons (now in ⋮ More) and the
   extension dot (a notice in the strip, METIS-pub#813) are gone from it. The
   search box is the shared one, last before the spacer
   (crm/css/components/list-search.css, METIS-pub#869).

   Platform tier: the People, holon, board, Outreach and calendar pages and
   Audax's Quests use it. Tokens only.
   ───────────────────────────────────────────────────────────────────────── */

@layer components {
  .list-toolbar {
    gap: var(--space-2) var(--space-3);
    padding-block: var(--space-3);
  }

  .list-toolbar__spacer { flex: 1; }

  /* View: the segmented List | Board switch, with words beside its icons —
     in a toolbar, and wherever an option carries its word (the view switch
     always does, METIS-pub#867, on pages not yet on this toolbar too). */
  .list-toolbar .view-toggle__opt,
  .view-toggle__opt:has(> span) {
    width: auto;
    gap: var(--space-1);
    padding-inline: var(--space-3);
    font-size: var(--text-sm);
    text-decoration: none;
  }

  /* Only mine: the switch and its word, one pill. */
  .list-toolbar__switch {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: var(--toolbar-h);
    padding-inline: 0 var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--text-sm);
    cursor: pointer;
    white-space: nowrap;
  }

  .list-toolbar__switch .toggle-switch { height: calc(var(--toolbar-h) - 2px); }

  /* Journey: the key, then the existing chip without its own icon and border. */
  .list-toolbar__field {
    display: inline-flex;
    align-items: center;
    height: var(--toolbar-h);
    padding-inline-start: var(--space-3);
    padding-inline-end: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
  }

  .list-toolbar__key {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    white-space: nowrap;
  }

  /* A field's own select (Outreach's Kind): no box of its own,
     the pill is the box. */
  /* One dropdown style (METIS-pub#845): no browser arrow, sized to its value
     (field-sizing; Firefox keeps the longest option's width), and the
     journey picker's small grey chevron drawn after it. */
  .list-toolbar__select {
    appearance: none;
    field-sizing: content;
    height: calc(var(--toolbar-h) - 2px);
    padding: 0 var(--space-3) 0 var(--space-1);
    padding-inline-end: var(--space-6);
    border: 0;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
  }

  .list-toolbar__chevron {
    margin-inline-start: calc(-1 * var(--space-4));
    opacity: 0.4;
    pointer-events: none;
  }

  /* The toolbar as the top of its list: on the surface, a hairline under it,
     meeting the tabs and running edge to edge (METIS-pub#845). */
  .list-toolbar--joined {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    margin-inline: calc(-1 * var(--space-md));
    padding-inline: var(--space-md);
  }

  /* The pull up to the tabs applies only while no page header is drawn in the
     list header, at any depth (a filter applied in place swaps the header in
     inside a wrapper): with a header, the header comes first, not the toolbar. */
  .list-header:has(> .list-toolbar--joined):not(:has(.page-header)) { margin-top: calc(-1 * var(--space-md)); }

  .list-toolbar__group {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    max-width: 100%;
  }

  .list-toolbar__group .view-toggle { overflow-x: auto; }

  .list-toolbar__field .filter-chip {
    height: calc(var(--toolbar-h) - 2px);
    border: 0;
    box-shadow: none;
    background: transparent;
    padding-inline-start: var(--space-1);
  }

  .list-toolbar__field .filter-chip__icon,
  .list-toolbar__field .filter-chip__icon + .filter-chip-sep { display: none; }

  /* A chosen journey colours the chip (markJourneyChipSet); let the pill
     carry it instead, so the key and the value read as one control. A set
     filter select (crm/partials/filter_chip_select.html) marks the field
     itself. */
  .list-toolbar__field:has(.filter-chip.has-value),
  .list-toolbar__field.has-value { border-color: var(--color-accent); }

  /* A field that must be set before the page can show anything — a board
     with no journey chosen (METIS-pub#867): the whole pill, key and value,
     ringed in red until it is set. */
  .list-toolbar__field--needs-value,
  .list-toolbar__field--needs-value:has(.filter-chip.has-value) {
    border-color: var(--color-danger);
    box-shadow: var(--list-field-needs-value-ring);
  }

  .list-toolbar__field--needs-value .journey-picker__btn { color: var(--color-danger); }

  /* A clearable filter select's ×, shown while it holds a value. */
  .list-toolbar__field .filter-chip-clear { display: none; }
  .list-toolbar__field.has-value .filter-chip-clear { display: flex; }

  /* Columns and ⋮ More: quiet buttons; Columns (a board's Card fields) says
     its word, in a toolbar and wherever it is given one. */
  .list-toolbar .actions-menu-wrap { margin-left: 0; gap: var(--space-1); }

  .list-toolbar .col-prefs-btn,
  .col-prefs-btn:has(> span) {
    gap: var(--space-1);
    padding-inline: var(--space-3);
    font-size: var(--text-sm);
    white-space: nowrap;
  }

  .list-toolbar .actions-menu-btn { gap: var(--space-1); white-space: nowrap; }
  .list-toolbar .actions-menu-btn__text { font-size: var(--text-sm); }

  /* A list's Info note (METIS-pub#827): two lines at most, the whole note in
     the cell's title. On a list page, so it lives with the list's toolbar. */
  .info-note--clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }

  /* + Add …: the page's primary action, last. */
  .list-toolbar__add {
    height: var(--toolbar-h);
    padding-block: 0;
    padding-inline: var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
  }

  /* A phone: the row wraps; the spacer no longer pushes a lone control to the
     far edge of its own line, and ⋮ More keeps only its mark. */
  @media (max-width: 767.98px) {
    .list-toolbar__spacer { flex-basis: 0; }
    .list-toolbar .actions-menu-btn__text { display: none; }
  }
}
