/*
 * The price chart's indicator menu (frames/companies/_chart_tools, the
 * `chart-tools` controller; tasks/growth/milestones/37): a popover
 * disclosure whose summary reads as the chart's other caps options
 * (`.company-chart__menu`). Inside,
 * what is drawn now — each a line as the key names it, with Settings, which
 * opens its settings as compact fields, and × — then a search that narrows the
 * catalogue, and the catalogue, on the price and below it, two columns of
 * buttons that add one; a button the chart has no room for is disabled.
 */
@layer components {
  .indicator-menu {
    & > .disclosure__body {
      inline-size: min(28rem, calc(100vw - 2 * var(--gutter)));
      max-block-size: min(36rem, 75vh);
      overflow-y: auto;
    }
  }

  /* The search (a `search-field`) stays at the top of the menu as its lists
     scroll under it. */
  .indicator-menu .indicator-menu__find {
    position: sticky;
    inset-block-start: calc(-1 * var(--space-sm));
    z-index: 1;
    margin-block: var(--space-sm) 0;
    padding-block: var(--space-2xs);
    background-color: var(--color-field);
  }

  .indicator-menu__count {
    color: var(--color-ink);
  }

  .indicator-menu__heading {
    margin-block: var(--space-sm) var(--space-2xs);
  }

  .indicator-menu__active,
  .indicator-menu__kinds {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .indicator-menu__kinds {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr));
    gap: 0 var(--space-md);
  }

  /* A row reads as the key names the indicator — its colour, its short
     name, its settings' values in the data face — with Settings and × at the
     end; its settings open below it, as compact fields in three columns. */
  .indicator-menu__row {
    display: grid;
    grid-template-columns: 0.75rem minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-xs);
    padding-block: var(--space-2xs);
    border-block-end: var(--rule-hairline);
    color: var(--color-ink);

    &::before {
      content: "";
      block-size: 2px;
      background-color: var(--swatch);
    }

    & > .icon-button {
      grid-column: 4;
    }
  }

  .indicator-menu__name {
    font-weight: var(--weight-semibold);
  }

  .indicator-menu__values {
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums;
  }

  .indicator-menu__edit {
    color: var(--color-link);
    font-size: var(--text-ui-sm);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;

    &:hover {
      color: var(--color-link-hover);
    }

    @media (pointer: coarse) {
      min-block-size: var(--target-min);
    }
  }

  .indicator-menu__settings {
    display: grid;
    grid-column: 2 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-xs) var(--space-sm);
    padding-block: var(--space-3xs) var(--space-2xs);

    &[hidden] {
      display: none;
    }
  }

  .indicator-menu__add {
    padding-block: var(--space-3xs);
    color: var(--color-link);
    text-align: start;
    cursor: pointer;

    &:hover {
      color: var(--color-link-hover);
    }

    &:disabled {
      color: var(--color-ink-subtle);
      cursor: default;
    }

    @media (pointer: coarse) {
      min-block-size: var(--target-min);
    }
  }

  .indicator-menu__note {
    margin-block: var(--space-xs) 0;
    color: var(--color-ink-muted);
    font-size: var(--text-meta-xs);
    line-height: var(--leading-meta-xs);
  }
}
