/* Copyright (c) 2020, the Dart project authors.  Please see the AUTHORS file
   for details. All rights reserved. Use of this source code is governed by a
   BSD-style license that can be found in the LICENSE file. */

/******************************************************
  searchbar
******************************************************/

@use 'variables';

.search-bar {
  display: flex;
  align-items: center;
  border-radius: 3px;
  max-width: 710px;
  background: transparent;
  position: relative;
  margin: 0 auto;
  padding: 13px 0;

  .home-banner & {
    max-width: 880px;
  }

  >.input {
    font-size: 16px;
    padding: 15px 24px 14px 48px;
    border: none;
    border-radius: 24px;
    width: 150px;
    flex-grow: 1;
    background: var(--pub-searchbar_input-background-color);
    color: var(--pub-searchbar_input-text-color);

    &::placeholder {
      color: var(--pub-input-placeholder-color);
    }

    .home-banner & {
      @media (min-width: variables.$device-desktop-min-width) {
        font-size: 24px;
        padding: 20px 35px 20px 65px;
        border-radius: 35px;
      }
    }

    &:focus {
      outline: none;
    }

    // This is a non-standard feature, supported only by webkit browsers
    // https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-search-cancel-button
    &::-webkit-search-cancel-button {
      display: none;
    }
  }

  >.icon {
    width: 45px;
    height: 45px;
    background-color: var(--pub-link-text-color);
    background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAABGdBTUEAALGPC/xhBQAAARdJREFUOBHNkz1uwkAQhTGkhCuELlQUiAtwilzHtU8BVLkHF4iokbJJkS41EiTS5nvL2FrQGMsdIz3N7ntvZn+8HgyyiDEuwBv4BifLmi8yW/sQ4xMowRl4Ib4Eo/YuKGYixT9QgSUYW9ZcvKJsbYSo42hFmVeeUbzp8vnHRNAdKCqvSc1JTy78NXeVEXWxiuWVcDORnlz4b6TLFFFfRzF2DUaiT5IrxqPnG0L+mDDzDBn3YuNDxjVDNdrZ7LVh/UGtv7sy2+3z1X7xz91GIhFLoOh6R+vWJtao62VrgW1aKsZP8rSrYf6vHSnYgw1IxyEHoAjgfrN7K6kYBKAI4DGbfbCzZ72j3lEUxRdFKxB6F3sF2okg7R/6f6gee6OuegAAAABJRU5ErkJggg==");
    background-repeat: no-repeat;
    background-position: 50% 50%;

    background-color: transparent;
    opacity: 0.4;
    position: absolute;
    left: 10px;
    transform: scale(0.72);

    .home-banner & {
      @media (min-width: variables.$device-desktop-min-width) {
        left: 20px;
        transform: scale(1.0);
      }
    }
  }
}

.search-filters-btn-wrapper {
  display: none;

  @media (max-width: variables.$device-mobile-max-width) {
    display: block;
  }

  .search-filters-btn {
    cursor: pointer;
    display: block;
    width: 40px;
    height: 40px;
    margin-left: 8px;
  }

  .search-filters-btn-inactive {
    display: block;
  }

  .search-filters-btn-active {
    display: none;
  }

  &.-active {
    .search-filters-btn-inactive {
      display: none;
    }

    .search-filters-btn-active {
      display: block;
    }
  }
}

.search-completion.completion-dropdown {
  overflow-y: auto;
  overflow-x: hidden;
  appearance: none;
  width: 25ex;
  border: 1px solid #000;
  border-radius: 0 0 5px 5px;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.33);
  max-height: 20em;
  background: var(--pub-searchbar_suggest-background-color);
  color: var(--pub-searchbar_suggest-text-color);
  font-size: 16px;
  margin-left: 48px; // counter padding-left on .search-bar>.input
  margin-top: -14px; // counter padding-top on .search-bar>.input

  >.completion-option {
    cursor: pointer;
    white-space: nowrap;
    padding: 4px 8px;

    &:hover {
      background-color: var(--pub-searchbar_suggest_hover-background-color);
    }

    .completion-overlap {
      color: var(--pub-searchbar_input-text-color);
      font-weight: 500; // slightly bolder
    }
  }

  >.completion-option-selected {
    background-color: var(--pub-searchbar_suggest_hover-background-color);
  }
}
