/* {{{ Search modal */
.search-modal__backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5001;

  justify-content: center;

  visibility: hidden;

  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;

  transition: opacity 0.1s ease-out;
}

.search-modal__backdrop.showing,
.search-modal__backdrop.show {
  visibility: visible;
  opacity: 1;
}

.search-modal__backdrop.hiding {
  visibility: visible;
  opacity: 0;
}

.search-modal,
.search-modal * {
  box-sizing: border-box;
}

.search-modal {
  display: flex;

  flex-direction: column;

  width: 100%;
  height: 100%;
  margin: 0;

  line-height: 1.5rem;
  color: var(--background-text-color, #CCC);

  background-color: var(--dark-grey-color, #333);
}

.search-modal *:focus-visible {
  outline: 2px solid var(--light-magenta-color, #CF82B1);
  outline-offset: 2px;
}

.search-modal__header {
  display: flex;
  align-items: center;
  padding: 10px 16px;
}

.search-modal__form {
  display: flex;

  flex-grow: 1;

  align-items: center;

  min-width: 0;
  padding-left: 12px;

  background-color: hsl(0, 0%, 25%);
  border-radius: 8px;
}

.search-modal__input-icon {
  display: block;
  flex-shrink: 0;
  width: 24px;
}

.search-modal__input-icon svg {
  display: block;
  color: hsl(0, 0%, 54%);
}

.search-modal__input {
  flex-grow: 1;

  min-width: 0;
  height: 44px;
  padding-left: 12px;

  color: white;

  background-color: transparent;
  border: none;
  appearance: textfield;
}

.search-modal__input::-webkit-search-decoration,
.search-modal__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-modal__input:focus {
  border-width: 1px;
  outline: none;
}

.search-modal__input::placeholder {
  color: rgba(255, 255, 255, 0.56);
  opacity: 1;
}

/* TODO: The icon button styles were copied from the navbar. */
/* We should refactor this into a shared component when possible. */
.search-modal__close {
  padding: 8px;
  margin-right: -8px; /* Compensate for button padding */
  margin-left: 8px;

  color: #e8e8e8;

  cursor: pointer;

  background-color: transparent;
  border: 0;
  outline: 0;
  opacity: 0.65;

  transition: opacity 0.15s ease-out;
}

.search-modal__close svg {
  display: block;
  width: 24px;
  fill: currentColor;
}

.search-modal__close:hover,
.search-modal__close:focus {
  color: white;
  opacity: 1;
}

.search-modal__results {
  height: 100%;
  padding: 0 16px;
  overflow-y: scroll;

  scrollbar-color: hsl(0, 0%, 67%) transparent;
  scrollbar-width: thin;
}

.search-modal__result {
  display: flex;

  align-items: center;

  padding: 10px;
  padding-left: 14px;

  line-height: 1.2;

  border: none;
  border-radius: 0.5rem;
}

.search-modal__result:hover {
  /* Simulates 33% opacity by blending --dark-blue-color with --dark-grey-color.
   * TODO: Use rgb(var(--dark-blue-color) / 33%) once widely supported.
   * More info: https://caniuse.com/mdn-css_types_color_rgb_relative_syntax */
  background-color: #3c4053;
}

.search-modal__result[aria-selected="true"] {
  background-color: var(--dark-blue-color, #4F5B93);
}

.search-modal__result-content {
  flex-grow: 1;
  min-width: 0; /* Allow text truncation */
}

.search-modal__result-name {
  margin-bottom: 6px;
  overflow: hidden;

  color: #e6e6e6;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-modal__result:hover .search-modal__result-name {
  color: white;
}

.search-modal__result-description {
  overflow: hidden;

  font-size: 14px;
  color: var(--background-text-color, #CCC);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-modal__result:hover .search-modal__result-description {
  color: white;
  opacity: 0.6;
}

.search-modal__result-icon {
  margin-right: 12px;
}

.search-modal__result-icon svg {
  display: block;
  width: 24px;
  fill: hsla(0, 0%, 100%, 0.3);
}

.search-modal__helper-text {
  display: none;
  padding: 10px 16px;
  font-size: 14px;
}

@media (min-width: 992px) {
  .search-modal {
    max-width: 560px;
    height: calc(100% - 1rem * 2);
    margin: 1rem auto;
    border-radius: 16px;
  }

  .search-modal__header {
    padding: 18px 20px;
  }

  .search-modal__input {
    height: 52px;
    font-size: 18px;
  }

  .search-modal__close {
    margin-right: -10px; /* Compensate for button padding */
  }

  .search-modal__results {
    padding: 0 20px;
  }

  .search-modal__helper-text {
    display: block;
    padding: 18px 20px;
  }

  .search-modal__helper-text kbd {
    display: inline-block;

    padding: 0px 4px;

    font-family: inherit;

    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
  }
}
/* }}} */
