@layer components {
  .search {
    position: relative;
  }

  .search__field {
    position: relative;
    width: 100%;

    > .icon {
      position: absolute;
      left: 20px;
      top: 50%;
      width: 22px;
      height: 22px;
      translate: 0 -50%;
      stroke-width: 2;
      pointer-events: none;

      @media (max-width: 699px) {
        left: 16px;
      }
    }
  }

  /* Outlined in ink, like the design's other inputs, and in mono like its labels */
  .search__input {
    width: 100%;
    min-height: 60px;
    padding: 0 92px 0 56px;
    border: 2px solid var(--color-line-strong);
    border-radius: 18px;
    background: var(--color-surface);
    color: var(--color-ink);
    font: 400 max(16px, calc(16 * var(--pt))) / 1.25 var(--font-mono);

    /* No shortcut hint on phones or narrow windows, so the placeholder gets that room, and all of the right side
       until there's text to clear */
    @media (any-hover: none), (max-width: 699px) {
      padding-right: 48px;
      padding-left: 50px;

      &:placeholder-shown {
        padding-right: 14px;
      }
    }

    &::placeholder {
      color: var(--color-ink-placeholder);
      opacity: 1;
    }

    &::-webkit-search-cancel-button {
      appearance: none;
    }
  }

  .search__clear {
    position: absolute;
    right: 72px;
    top: 50%;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    translate: 0 -50%;
    color: var(--color-ink-muted);

    @media (any-hover: none), (max-width: 699px) {
      right: 10px;
    }

    .icon {
      width: 18px;
      height: 18px;
    }
  }

  /* The ⌘J shortcut */
  .search__field .search__key {
    position: absolute;
    right: 16px;
    top: 50%;
    translate: 0 -50%;

    @media (max-width: 699px) {
      display: none;
    }
  }

  /* Paste a link into search and it offers to keep it */
  /* Floats under the field, so it doesn't push the header around */
  .paste-offer {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    z-index: 2;
    translate: -50%;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: max-content;
    max-width: 100%;
    min-height: 44px;
    padding: 0 10px 0 14px;
    border: 1px solid var(--color-line);
    border-radius: 14px;
    background: var(--color-surface);
    box-shadow: var(--shadow-popup);
    color: var(--color-ink);
    font-size: var(--text-control);
    font-weight: 600;
    letter-spacing: -0.02em;

    span {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .icon {
      width: 18px;
      height: 18px;
      stroke-width: 2.2;
    }
  }
}
