@use "../../../styles/mixins";

.root {
  --color-reaction: var(--color-background-secondary);
  --hover-color-reaction: var(--color-background-secondary-accent);
  --text-color-reaction: var(--color-text-secondary);
  --color-reaction-chosen: var(--color-primary);
  --text-color-reaction-chosen: #FFFFFF;
  --hover-color-reaction-chosen: var(--color-primary-shade);

  pointer-events: none;

  position: absolute;
  z-index: var(--z-local-search);
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;

  @media (min-width: 1276px) {
    :global(#Main.right-column-open) & {
      width: calc(100% - var(--right-column-width));
    }
  }
}

.header {
  pointer-events: auto;

  position: absolute;
  top: 0;
  left: 0;

  display: flex;
  align-items: center;

  width: 100%;
  height: 3.5rem;
  padding-right: max(0.875rem, env(safe-area-inset-right));
  padding-left: max(1.5rem, env(safe-area-inset-left));

  opacity: 0;
  background-color: var(--color-background);

  transition: opacity 200ms ease-in-out;

  .active & {
    opacity: 1;
  }

  :global(body.is-tauri.is-macos) & {
    padding-left: var(--window-controls-width);
  }

  @media (max-width: 600px) {
    padding-right: max(0.5rem, env(safe-area-inset-right));
    padding-left: max(0.5rem, env(safe-area-inset-left));
  }
}

// Same as in MiddleHeader.scss
.avatar {
  width: 2.5rem !important;
  height: 2.5rem !important;
  margin-right: 0.625rem;
}

.input {
  flex: 1;

  margin-right: 0.75rem;
  margin-left: 0.25rem;
  border: none;

  transition-timing-function: ease-in-out;
  transition-duration: 200ms;
  transition-property: background-color, box-shadow, border-radius;

  .mobile & {
    margin: 0;
  }
}

.focused .input {
  box-shadow: 0 0 0.625rem 0 var(--color-default-shadow);
}

.withDropdown {
  background-color: var(--color-background);
  box-shadow: 0 0 0.625rem 0 var(--color-default-shadow);
}

.adaptSearchBorders {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.dropdown {
  pointer-events: all;

  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateY(100%);

  overflow: hidden;
  display: flex;
  flex-direction: column;

  max-height: min(24rem, 80vh);
  border-bottom-right-radius: 1.375rem;
  border-bottom-left-radius: 1.375rem;

  background-color: var(--color-background);
  clip-path: inset(0 -0.625rem -0.625rem -0.625rem); // Hide top shadow
  box-shadow: 0 0 0.625rem 0 var(--color-default-shadow);

  transition-duration: 200ms;
  /* stylelint-disable-next-line plugin/no-low-performance-animation-properties */
  transition-property: display, opacity;

  transition-behavior: allow-discrete;

  .mobile & {
    position: absolute;
    top: 3.375rem; // Subpixel rendering can leave 1px gap otherwise
    right: 0;
    bottom: 3.375rem;
    left: 0;
    transform: none;

    max-height: none;
    padding: 0;
    border-radius: 0;
  }

  @starting-style {
    opacity: 0;
  }
}

.dropdownHidden {
  display: none;
  opacity: 0;
}

.results {
  overflow-y: scroll;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;

  @include mixins.adapt-padding-to-scrollbar(0.5rem);
}

.placeholder {
  margin: 0.5rem;
  color: var(--color-text-secondary);
  text-align: center;
}

.separator {
  margin-inline: 1rem;
  border-top: 1px solid var(--color-borders);
}

.savedTags {
  overflow-x: scroll;
  display: flex;
  flex-shrink: 0;
  gap: 0.375rem;
  align-items: center;

  margin-inline: 1rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--color-borders);
}

.wrap {
  flex-wrap: wrap;
}

.searchTags {
  display: flex;
  gap: 0.125rem;
  align-items: center;
}

.savedSearchTag {
  margin-inline: 0.5rem;
}

.hash {
  display: grid;
  place-items: center;

  margin-inline-start: 0.5rem;
  margin-inline-end: -0.5rem;

  font-size: 1.5rem;
  color: var(--color-text-secondary);
}

.searchTypes {
  overflow-x: scroll;
  display: flex;
  flex-shrink: 0;

  margin-inline: 1rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--color-borders);
}

.searchType {
  --accent-color: var(--color-primary);

  flex-grow: 0 !important;
  flex-shrink: 0;

  margin-bottom: 0;

  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);

  background-color: var(--color-item-active);
}

.selectedType {
  color: var(--color-white) !important;
  background-color: var(--color-primary);

  &:hover {
    background-color: var(--color-primary-shade);
  }
}

.footer {
  pointer-events: auto;

  position: absolute;
  bottom: 0;
  left: 0;
  transform: translateY(100%);

  display: flex;
  align-items: center;

  width: 100%;
  height: 3.5rem;
  padding-right: max(0.5rem, env(safe-area-inset-right));
  padding-left: max(1rem, env(safe-area-inset-left));

  background-color: var(--color-background);
  box-shadow: 0 -2px 2px var(--color-light-shadow);

  transition: transform 200ms ease-in-out;

  .active & {
    transform: translateY(0);
  }

  :global {
    body:not(.keyboard-visible) & {
      height: 3.5rem;
      padding-bottom: 0;
    }

    @media (max-width: 600px) {
      body:not(.keyboard-visible) & {
        height: calc(3.5rem + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
      }
    }
  }
}

.counter {
  flex: 1;
  color: var(--color-text-secondary);
}

.mobileNavigation {
  position: absolute;
  right: 0.5rem;
  bottom: 4rem;

  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.navigationButton {
  transition-property: background-color, color, filter;
}

.navigationDisabled {
  filter: brightness(0.9);
}

@keyframes jumpIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
