/*
 * Provenance you can recognise before you read it: each chip leads with its
 * kind's glyph on that kind's own tint, so a document, a table and a record are
 * telling apart at a glance. The hue is the MEANING, so it is a palette family
 * and moves with no theme (theming.md §2.2).
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-sources {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    /* A `View` shrinks at 0 and a CSS box at 1. */
    flex-shrink: 0;
    min-width: 0;
    gap: var(--lotics-space-8);
  }

  .lotics-sources__row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    flex-wrap: wrap;
    flex-shrink: 0;
    min-width: 0;
    gap: var(--lotics-space-8);
  }

  .lotics-sources__chip {
    display: flex;
    flex-direction: row;
    align-items: center;
    /* Never wider than its row: the chip is capped and the label gives way. */
    max-width: 100%;
    gap: var(--lotics-space-8);
    margin: 0;
    padding-block: var(--lotics-space-4);
    padding-inline-start: var(--lotics-space-4);
    padding-inline-end: var(--lotics-space-10);
    border: 1px solid var(--border);
    border-radius: var(--lotics-radius-control);
    background-color: var(--card);
    background-image: none;
    font-family: var(--font-sans);
    font-size: var(--lotics-text-xs);
    line-height: var(--lotics-leading-xs);
    letter-spacing: var(--lotics-tracking-xs);
    color: var(--lotics-ink-default);
    text-align: start;
    appearance: none;
    transition: background-color var(--lotics-duration-fast) var(--lotics-ease-standard);
  }

  /*
   * A chip that OPENS something is a control standing on the page, so it takes
   * the neutral ladder's selection rung for hover (§2.3). It has to be stated on
   * the chip's OWN rule: a wash a surface underneath paints is covered by the
   * chip's `--card` ground, and the affordance then exists only in the cursor.
   */
  .lotics-sources__chip[data-openable] {
    cursor: pointer;
    touch-action: manipulation;
  }

  /* The wash is an alpha OVERLAY, so it goes on as a layer over the chip's own
     ground rather than replacing it — the same shape `Button` uses. */
  .lotics-sources__chip[data-openable]:hover {
    background-image: linear-gradient(
      0deg,
      var(--lotics-wash-selected),
      var(--lotics-wash-selected)
    );
  }

  .lotics-sources__chip[data-openable]:active {
    background-image: linear-gradient(0deg, var(--lotics-wash-press), var(--lotics-wash-press));
  }

  .lotics-sources__chip[data-openable]:focus-visible {
    outline: var(--lotics-ring-width) solid var(--ring);
    outline-offset: 0;
  }

  .lotics-sources__mark {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: calc(var(--lotics-radius-control) - var(--lotics-space-2));
    background-color: color-mix(in srgb, var(--lotics-sources-kind) 14%, transparent);
    --lotics-icon-color: var(--lotics-sources-kind);
  }

  .lotics-sources__label {
    flex-shrink: 1;
    min-width: 0;
  }

  .lotics-sources__detail {
    flex-shrink: 0;
  }

  .lotics-sources__open {
    --lotics-icon-color: var(--lotics-ink-inactive);
  }
}
