@layer components {
  /* Suggestions float over what follows the field instead of pushing it down. */
  .suggestions {
    position: relative;
  }

  /* A turbo-frame is display: contents by default, which would leave nothing to position. */
  .suggestions__list {
    --rows-border-size: 0;

    display: block;
    position: absolute;
    inset-block-start: 100%;
    inset-inline: 0;
    z-index: var(--z-popup);
    max-block-size: 60vh;
    overflow-y: auto;
    background-color: var(--color-canvas);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);

    &:not(:has(:is(.row, .popup__item):not([hidden]))) {
      display: none;
    }

    [data-filtering] &:has(.suggestions__skeleton) {
      display: block;
    }
  }

  /* Under a search on the page or in the sidebar the list is a small menu, as wide as its longest line, each row a
     line with no rule over it, edge to edge on a soft shadow with no ring. Without the ring, the dark theme lifts it
     off the sheet on the chip's fill. The gate's list keeps its lines and its field's width. */
  :is(.sheet #main, .messages-sidebar) :is(.hire, .site-chips__add, .roster__prompt) .suggestions__list {
    background-color: light-dark(var(--color-canvas), var(--color-chip-fill));
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-note);
    inline-size: fit-content;
    inset-inline-end: auto;
    margin-block-start: 0.25rem;
    max-inline-size: 100%;
    min-inline-size: min(100%, 14rem);
    padding: 0;

    .rows .row {
      --row-padding-block: 0.2em;
      --row-padding-inline: 0.5em;

      border: 0;
      border-radius: 0;
      margin-inline: 0;
      min-block-size: 1.9em;                            /* 30px */
    }
  }

  .suggestions__skeleton {
    padding: var(--block-space-half) var(--inline-space-double);

    > * + * {
      margin-block-start: var(--block-space-half);
    }

    /* The hairline's ink is too faint on the white list in light mode. */
    .skeleton {
      background-color: light-dark(var(--tint-ink-20), var(--color-ink-light));
    }
  }

  /* What to do with the text when nothing suggested matches it, offered once something is typed. Flush with the
     search above it. */
  .suggestions__fallback {
    display: none;

    [data-filtering]:not([data-has-match]) &,
    &[open] {
      display: block;
    }

    > .btn {
      inline-size: fit-content;
      list-style: none;
    }
  }

  .suggestions__typed {
    display: none;

    [data-filtering] & {
      display: inline;
    }
  }

  [data-filtering] .suggestions__untyped {
    display: none;
  }

  /* A firm hired in place: a search over the register, or a new firm's fields. */
  .hire {
    display: flex;
    flex-direction: column;
    gap: var(--block-space-half);
    padding-block: var(--block-space-half);
  }

  .hire__search {
    align-items: center;
    display: flex;
    gap: var(--inline-space-half);

    > .suggestions {
      flex: 1 1 auto;
      min-inline-size: 0;
    }
  }

  .hire__form {
    display: flex;
    flex-direction: column;
    gap: var(--block-space);
    margin-block-start: var(--block-space);
  }

  /* Country, CUIT and name on one row, stacked on a phone. */
  .hire__fields {
    display: flex;
    flex-direction: column;
    gap: var(--block-space-half) var(--inline-space);

    .input {
      inline-size: 100%;
    }

    @media (width >= 640px) {
      flex-direction: row;

      > :nth-child(1) {
        flex: 0 0 9rem;
      }

      > :nth-child(2) {
        flex: 0 1 14rem;
      }

      > :nth-child(3) {
        flex: 1 1 0;
        min-inline-size: 0;
      }
    }
  }
}
